From a1253b004d66406ecc457c46cedd1adf0b86fca7 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Tue, 5 Nov 2019 15:13:34 +0100 Subject: [PATCH] Fixes for closed/non-periodic nurbs curve edges #586 --- src/ifcgeom/IfcGeomCurves.cpp | 4 +++- src/ifcgeom/IfcGeomWires.cpp | 18 ++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/ifcgeom/IfcGeomCurves.cpp b/src/ifcgeom/IfcGeomCurves.cpp index ea6ec0b051..0623c28588 100644 --- a/src/ifcgeom/IfcGeomCurves.cpp +++ b/src/ifcgeom/IfcGeomCurves.cpp @@ -157,7 +157,9 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcBSplineCurveWithKnots* l, Hand TColStd_Array1OfReal Knots(0, (int)knots.size() - 1); TColStd_Array1OfInteger Mults(0, (int)mults.size() - 1); Standard_Integer Degree = l->Degree(); - Standard_Boolean Periodic = l->ClosedCurve(); + Standard_Boolean Periodic = false; + // @tfk: it appears to be wrong to expect a period curve when the curve is closed, see #586 + // Standard_Boolean Periodic = l->ClosedCurve(); int i; diff --git a/src/ifcgeom/IfcGeomWires.cpp b/src/ifcgeom/IfcGeomWires.cpp index 5f929d55ba..d63791e93e 100644 --- a/src/ifcgeom/IfcGeomWires.cpp +++ b/src/ifcgeom/IfcGeomWires.cpp @@ -764,13 +764,19 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcEdgeCurve* l, TopoDS_Wire& res continue; } - BRep_Builder builder; - TopoDS_Vertex v1, v2; - /// @todo project first and emit warnings accordingly - builder.MakeVertex(v1, a, getValue(GV_PRECISION)); - builder.MakeVertex(v2, b, getValue(GV_PRECISION)); + if (ecrv->IsClosed() && a.Distance(b) < getValue(GV_PRECISION)) { + // When vertices are close enough and the curve is closed, + // use the entire curve. + mw.Add(BRepBuilderAPI_MakeEdge(ecrv)); + } else { + BRep_Builder builder; + TopoDS_Vertex v1, v2; + /// @todo project first and emit warnings accordingly + builder.MakeVertex(v1, a, getValue(GV_PRECISION)); + builder.MakeVertex(v2, b, getValue(GV_PRECISION)); - mw.Add(BRepBuilderAPI_MakeEdge(ecrv, v1, v2)); + mw.Add(BRepBuilderAPI_MakeEdge(ecrv, v1, v2)); + } first = false; }