diff --git a/CADability/ImportStep.cs b/CADability/ImportStep.cs index 9ef63459..cb3483d0 100644 --- a/CADability/ImportStep.cs +++ b/CADability/ImportStep.cs @@ -411,6 +411,7 @@ public class ImportStep private List notImportedFaces; private Dictionary definedColors; private System.Collections.Concurrent.ConcurrentDictionary namedGeoObjects = new System.Collections.Concurrent.ConcurrentDictionary(); + private System.Collections.Concurrent.ConcurrentDictionary nurbsSurfacesWithModifiedKnots; // when in construction the nurbs surface get a different 2d space, the modification is saved here class Tokenizer : IDisposable { StreamReader sr; @@ -1231,6 +1232,7 @@ public ImportStep() definitions = new List(); importProblems = new Dictionary(); notImportedFaces = new List(); + nurbsSurfacesWithModifiedKnots = new System.Collections.Concurrent.ConcurrentDictionary(); #if DEBUG allNames = new SortedDictionary(); entityPattern = new Dictionary>(); @@ -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); @@ -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) @@ -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]); @@ -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)) { @@ -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)