Skip to content

Commit

Permalink
Fixed the import of the step file "AVE_041_V9_ASRE.stp".
Browse files Browse the repository at this point in the history
This step file has nurbs faces with 2d edges, when the surface will be normalized, the edges must be also modified.
  • Loading branch information
davidebazzi committed Oct 15, 2024
1 parent 0ff903a commit 38d0870
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion CADability/ImportStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ public class ImportStep
private List<Item> notImportedFaces;
private Dictionary<string, ColorDef> definedColors;
private System.Collections.Concurrent.ConcurrentDictionary<string, IGeoObject> namedGeoObjects = new System.Collections.Concurrent.ConcurrentDictionary<string, IGeoObject>();
private System.Collections.Concurrent.ConcurrentDictionary<NurbsSurface, ModOp2D> nurbsSurfacesWithModifiedKnots; // when in construction the nurbs surface get a different 2d space, the modification is saved here
class Tokenizer : IDisposable
{
StreamReader sr;
Expand Down Expand Up @@ -1231,6 +1232,7 @@ public ImportStep()
definitions = new List<Item>();
importProblems = new Dictionary<int, string>();
notImportedFaces = new List<Item>();
nurbsSurfacesWithModifiedKnots = new System.Collections.Concurrent.ConcurrentDictionary<NurbsSurface, ModOp2D>();
#if DEBUG
allNames = new SortedDictionary<string, int>();
entityPattern = new Dictionary<string, HashSet<string>>();
Expand Down Expand Up @@ -2387,7 +2389,7 @@ private object CreateEntity(Item item)
pnt.Symbol = PointSymbol.Cross;
pnt.Name = subItem.parameter["name"].sval;
val.Add(pnt);
subItem.val = pnt; //For this CartesianPoint a Cadability Point is generated. I set it to the item instead of GeoPoint to make it work layer assignment.
subItem.val = pnt; //For this CartesianPoint a Cadability Point is generated. I set it to the item instead of GeoPoint to make it work layer assignment.
}
else if (o is IGeoObject) val.Add(o as IGeoObject);
else if (o is GeoObjectList) val.AddRange(o as GeoObjectList);
Expand Down Expand Up @@ -4236,6 +4238,11 @@ private object CreateEntity(Item item)
}
}
}
if (nurbsSurfacesWithModifiedKnots.TryGetValue(srf as NurbsSurface, out ModOp2D modify2DCurve))
{
// this nurbs surface doesn't have the original 2d space. Move the 2d curve to the modified 2d space here.
c2d = c2d.GetModified(modify2DCurve);
}
if (item.val != null) item.val = srf.Make3dCurve(c2d);
}
else if (o is ICurve c3d)
Expand Down Expand Up @@ -4943,6 +4950,7 @@ private ISurface MakeNurbsSurface(GeoPoint[,] poles, double[,] weights, double[]
// some NURBS surfaces come with extreme small uKnots or vKnots span. For better numerical behavior we normalize it here
// this doesn't change the surface but only the 2d parameter space of the surface
// an other case were we need to modify the knots span is with periodic surfaces that do not start with 0 as the first knot.
ModOp2D knotModification = ModOp2D.Identity;
if (uKnots[uKnots.Length - 1] - uKnots[0] < 0.5 || (uClosed && uKnots[0] != 0.0))
{
double f = 1.0 / (uKnots[uKnots.Length - 1] - uKnots[0]);
Expand All @@ -4951,6 +4959,8 @@ private ISurface MakeNurbsSurface(GeoPoint[,] poles, double[,] weights, double[]
{
uKnots[i] = (uKnots[i] - u0) * f;
}
knotModification[0, 0] = f;
knotModification[0, 2] = -u0;
}
if (vKnots[vKnots.Length - 1] - vKnots[0] < 0.5 || (vClosed && vKnots[0] != 0.0))
{
Expand All @@ -4960,8 +4970,14 @@ private ISurface MakeNurbsSurface(GeoPoint[,] poles, double[,] weights, double[]
{
vKnots[i] = (vKnots[i] - v0) * f;
}
knotModification[1, 1] = f;
knotModification[1, 2] = -v0;
}
NurbsSurface res = new NurbsSurface(poles, weights, uKnots, vKnots, uMults, vMults, uDegree, vDegree, false, false);
if (!knotModification.IsIdentity)
{
nurbsSurfacesWithModifiedKnots[res] = knotModification; // remember the modification for later use
}
// we should not make canonical surfaces here, because a nurbs surface in a "GEOMETRIC_SET" used in a "GEOMETRICALLY_BOUNDED_SURFACE_SHAPE_REPRESENTATION"
// uses nurbs surfaces as faces with natural bounds
switch (form)
Expand Down

0 comments on commit 38d0870

Please sign in to comment.