From 2a1c29852ea846cb9449de9fcbd9b2eb4aac4ea1 Mon Sep 17 00:00:00 2001 From: azv Date: Thu, 1 Jul 2021 16:36:13 +0300 Subject: [PATCH] Issue #20513: Filling problem Implement the edge reparametrization when convert wire to an edge. --- src/BuildPlugin/Test/Test20513_2.py | 4 ++-- src/BuildPlugin/Test/Test2398.py | 4 ++-- src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp | 21 +++++++++++++++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/BuildPlugin/Test/Test20513_2.py b/src/BuildPlugin/Test/Test20513_2.py index 45196abc9..5a9679cf6 100644 --- a/src/BuildPlugin/Test/Test20513_2.py +++ b/src/BuildPlugin/Test/Test20513_2.py @@ -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()) diff --git a/src/BuildPlugin/Test/Test2398.py b/src/BuildPlugin/Test/Test2398.py index 7b6889437..46d6ada01 100755 --- a/src/BuildPlugin/Test/Test2398.py +++ b/src/BuildPlugin/Test/Test2398.py @@ -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]) diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp index c4cdde252..037bacbc4 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp @@ -29,6 +29,8 @@ #include #include +#include + #include #include @@ -59,11 +61,14 @@ #include #include +#include #include #include #include #include +#include + #include #include @@ -1190,6 +1195,22 @@ std::shared_ptr 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)); -- 2.30.2