]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #20513: Filling problem
authorazv <azv@opencascade.com>
Thu, 1 Jul 2021 13:36:13 +0000 (16:36 +0300)
committerazv <azv@opencascade.com>
Thu, 1 Jul 2021 13:36:13 +0000 (16:36 +0300)
Implement the edge reparametrization when convert wire to an edge.

src/BuildPlugin/Test/Test20513_2.py
src/BuildPlugin/Test/Test2398.py
src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp

index 45196abc9144634b79712544bcb59156a69c34b1..5a9679cf60078b403ddaeac9a6b096ad8a99b479 100644 (file)
@@ -1129,7 +1129,7 @@ model.testNbSubShapes(Filling_2, GeomAPI_Shape.SOLID, [0])
 model.testNbSubShapes(Filling_2, GeomAPI_Shape.FACE, [1])
 model.testNbSubShapes(Filling_2, GeomAPI_Shape.EDGE, [4])
 model.testNbSubShapes(Filling_2, GeomAPI_Shape.VERTEX, [8])
-model.testResultsAreas(Filling_2, [29.198793093])
+model.testResultsAreas(Filling_2, [29.10364506])
 
 model.testNbResults(Filling_3, 1)
 model.testNbSubResults(Filling_3, [0])
@@ -1137,6 +1137,6 @@ model.testNbSubShapes(Filling_3, GeomAPI_Shape.SOLID, [0])
 model.testNbSubShapes(Filling_3, GeomAPI_Shape.FACE, [1])
 model.testNbSubShapes(Filling_3, GeomAPI_Shape.EDGE, [4])
 model.testNbSubShapes(Filling_3, GeomAPI_Shape.VERTEX, [8])
-model.testResultsAreas(Filling_3, [30.74501422428])
+model.testResultsAreas(Filling_3, [30.744277238])
 
 assert(model.checkPythonDump())
index 7b6889437de20e73632b3cbc0c5a101ff0f25421..46d6ada01eb998bd4bff78530ae79886e86514d8 100755 (executable)
@@ -92,9 +92,9 @@ from GeomAPI import *
 
 # check fillings
 REF_DATA = [(Filling_1, 719.149788883378505488508380949),
-            (Filling_2, 910.894530912501409147807862610),
+            (Filling_2, 911.056740330659408755309414119),
             (Filling_3, 719.149788883378505488508380949),
-            (Filling_4, 910.894530912501409147807862610)]
+            (Filling_4, 911.056740330659408755309414119)]
 for ref in REF_DATA:
     model.testNbResults(ref[0], 1)
     model.testNbSubResults(ref[0], [0])
index c4cdde252a42e8a4b9dd457415058c75cc1359de..037bacbc41e191ab46b8a8c97a9d8e5b029db265 100644 (file)
@@ -29,6 +29,8 @@
 #include <GeomAPI_Pnt.h>
 #include <GeomAPI_Wire.h>
 
+#include <Approx_CurvilinearParameter.hxx>
+
 #include <Bnd_Box.hxx>
 
 #include <BRep_Tool.hxx>
 #include <Geom2d_Curve.hxx>
 #include <Geom2d_Curve.hxx>
 
+#include <Geom_BSplineCurve.hxx>
 #include <Geom_CylindricalSurface.hxx>
 #include <Geom_Line.hxx>
 #include <Geom_Plane.hxx>
 #include <Geom_RectangularTrimmedSurface.hxx>
 
+#include <GeomAdaptor_HCurve.hxx>
+
 #include <GeomAPI_ProjectPointOnCurve.hxx>
 #include <GeomAPI_ShapeIterator.h>
 
@@ -1190,6 +1195,22 @@ std::shared_ptr<GeomAPI_Edge> GeomAlgoAPI_ShapeTools::wireToEdge(
       aWire = fixParametricGaps(aWire);
       aWire = BRepAlgo::ConcatenateWire(aWire, GeomAbs_G1); // join smooth parts of wire
       aNewEdge = BRepAlgo::ConcatenateWireC0(aWire); // join C0 parts of wire
+
+      // Reapproximate the result edge to have the parameter equal to curvilinear abscissa.
+      static const int THE_MAX_DEGREE = 14;
+      static const int THE_MAX_INTERVALS = 32;
+      double aFirst, aLast;
+      Handle(Geom_Curve) aCurve = BRep_Tool::Curve(aNewEdge, aFirst, aLast);
+      Handle(GeomAdaptor_HCurve) aHCurve = new GeomAdaptor_HCurve(aCurve);
+      Approx_CurvilinearParameter anApprox(aHCurve, Precision::Confusion(), aCurve->Continuity(),
+                                           THE_MAX_DEGREE, THE_MAX_INTERVALS);
+      if (anApprox.HasResult()) {
+        Handle(Geom_BSplineCurve) aNewCurve = anApprox.Curve3d();
+        TColStd_Array1OfReal aKnots = aNewCurve->Knots();
+        BSplCLib::Reparametrize(aFirst, aLast, aKnots);
+        aNewCurve->SetKnots(aKnots);
+        BRep_Builder().UpdateEdge(aNewEdge, aNewCurve, BRep_Tool::Tolerance(aNewEdge));
+      }
     }
     anEdge = GeomEdgePtr(new GeomAPI_Edge);
     anEdge->setImpl(new TopoDS_Edge(aNewEdge));