From 581016faeb3ad5e1eaffdfec2d56fb3e8dd026b5 Mon Sep 17 00:00:00 2001 From: azv Date: Mon, 27 Jun 2022 09:57:42 +0300 Subject: [PATCH] 0033028: Standard_ConstructionError while using ShapeUpgrade_UnifySameDomain Additional check if the sequence of circular edges is a closed chain. --- .../ShapeUpgrade_UnifySameDomain.cxx | 16 ++++++++- tests/bugs/heal/bug33028 | 36 +++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 tests/bugs/heal/bug33028 diff --git a/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx b/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx index 38bf20fbce..9a722f77e0 100644 --- a/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx +++ b/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx @@ -2058,8 +2058,22 @@ Standard_Boolean ShapeUpgrade_UnifySameDomain::MergeSubSeq(const TopTools_Sequen TopoDS_Vertex V[2]; V[0] = sae.FirstVertex(FE); V[1] = sae.LastVertex(TopoDS::Edge(theChain.Last())); + Standard_Boolean isClosed = V[0].IsSame(V[1]); + if (!isClosed) + { + // additionally check the points for equality to make a final decision about closedness of the result curve + gp_Pnt aP0 = BRep_Tool::Pnt(V[0]); + gp_Pnt aP1 = BRep_Tool::Pnt(V[1]); + Standard_Real aTol = Max(BRep_Tool::Tolerance(V[0]), BRep_Tool::Tolerance(V[1])); + if (aP0.SquareDistance(aP1) < aTol * aTol) + { + isClosed = Standard_True; + V[1] = V[0]; + V[1].Reverse(); + } + } TopoDS_Edge E; - if (V[0].IsSame(V[1])) { + if (isClosed) { // closed chain BRepAdaptor_Curve adef(FE); Handle(Geom_Circle) Cir1; diff --git a/tests/bugs/heal/bug33028 b/tests/bugs/heal/bug33028 new file mode 100644 index 0000000000..4650b331ae --- /dev/null +++ b/tests/bugs/heal/bug33028 @@ -0,0 +1,36 @@ +puts "========================" +puts " OCC33028: Standard_ConstructionError while using ShapeUpgrade_UnifySameDomain" +puts "========================" +puts "" + +stepread [locate_data_file bug33028_kalip.stp] s * + +set nbsBefore " +Number of shapes in shape + VERTEX : 543 + EDGE : 819 + WIRE : 359 + FACE : 289 + SHELL : 2 + SOLID : 2 + COMPSOLID : 0 + COMPOUND : 1 + SHAPE : 2015 +" +checknbshapes s_1 -ref ${nbsBefore} -t -m "result before attempt to simplify the model" + +unifysamedom result s_1 + +set nbsAfter " +Number of shapes in shape + VERTEX : 515 + EDGE : 805 + WIRE : 359 + FACE : 289 + SHELL : 2 + SOLID : 2 + COMPSOLID : 0 + COMPOUND : 1 + SHAPE : 1973 +" +checknbshapes result -ref ${nbsAfter} -t -m "result after attempt to simplify the model"