From 04a80e2c553cff698cb44206ce2da2cc362de53a Mon Sep 17 00:00:00 2001 From: Artem Zhidkov Date: Fri, 8 May 2020 17:05:38 +0300 Subject: [PATCH] Issue #19058: Error in sketch projection when changing parameter Improve weak naming indexing mechanism for stable enumeration of subshapes. --- src/GeomAPI/GeomAPI_Pnt.cpp | 13 +- src/GeomAPI/GeomAPI_Pnt.h | 3 +- src/ModelAPI/CMakeLists.txt | 1 + src/ModelAPI/Test/Test19058.py | 321 +++++++++++++++++++++++++++++ src/Selector/CMakeLists.txt | 2 + src/Selector/Selector_NExplode.cpp | 23 ++- 6 files changed, 346 insertions(+), 17 deletions(-) create mode 100644 src/ModelAPI/Test/Test19058.py diff --git a/src/GeomAPI/GeomAPI_Pnt.cpp b/src/GeomAPI/GeomAPI_Pnt.cpp index ea04047b2..d2b943df3 100644 --- a/src/GeomAPI/GeomAPI_Pnt.cpp +++ b/src/GeomAPI/GeomAPI_Pnt.cpp @@ -85,15 +85,16 @@ bool GeomAPI_Pnt::isEqual(const std::shared_ptr& theOther) const return distance(theOther) < Precision::Confusion(); } -bool GeomAPI_Pnt::isLess(const std::shared_ptr& theOther) const +bool GeomAPI_Pnt::isLess(const std::shared_ptr& theOther, + const double theTolerance) const { - if (MY_PNT->X() + Precision::Confusion() < theOther->x()) + if (MY_PNT->X() + theTolerance < theOther->x()) return true; - else if (MY_PNT->X() < theOther->x() + Precision::Confusion()) { - if (MY_PNT->Y() + Precision::Confusion() < theOther->y()) + else if (MY_PNT->X() < theOther->x() + theTolerance) { + if (MY_PNT->Y() + theTolerance < theOther->y()) return true; - else if (MY_PNT->Y() < theOther->y() + Precision::Confusion() && - MY_PNT->Z() + Precision::Confusion() < theOther->z()) + else if (MY_PNT->Y() < theOther->y() + theTolerance && + MY_PNT->Z() + theTolerance < theOther->z()) return true; } return false; diff --git a/src/GeomAPI/GeomAPI_Pnt.h b/src/GeomAPI/GeomAPI_Pnt.h index 18d8c4e42..13445889e 100644 --- a/src/GeomAPI/GeomAPI_Pnt.h +++ b/src/GeomAPI/GeomAPI_Pnt.h @@ -81,7 +81,8 @@ class GeomAPI_Pnt : public GeomAPI_Interface /// In case of X's are equal, if Y is less than other. /// If Y's are equal too, compare Z's. GEOMAPI_EXPORT - bool isLess(const std::shared_ptr& theOther) const; + bool isLess(const std::shared_ptr& theOther, + const double theTolerance = 1.e-7) const; /// Projects a point to the plane defined by the origin and 2 axes vectors in this plane GEOMAPI_EXPORT diff --git a/src/ModelAPI/CMakeLists.txt b/src/ModelAPI/CMakeLists.txt index 47f1bd9d8..19ad06cf7 100644 --- a/src/ModelAPI/CMakeLists.txt +++ b/src/ModelAPI/CMakeLists.txt @@ -258,4 +258,5 @@ ADD_UNIT_TESTS(TestConstants.py Test19019_1.py Test19019_2.py Test19031.py + Test19058.py ) diff --git a/src/ModelAPI/Test/Test19058.py b/src/ModelAPI/Test/Test19058.py new file mode 100644 index 000000000..bd0368bbd --- /dev/null +++ b/src/ModelAPI/Test/Test19058.py @@ -0,0 +1,321 @@ +# Copyright (C) 2020 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +from SketchAPI import * + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +model.addParameter(Part_1_doc, "l", "50") +width = model.addParameter(Part_1_doc, "width", "10") +Sketch_1 = model.addSketch(Part_1_doc, model.standardPlane("XOY")) +SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False) +SketchPoint_1 = SketchProjection_1.createdFeature() +SketchCircle_1 = Sketch_1.addCircle(0, 0, 9) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchPoint_1.result(), SketchCircle_1.center()) +SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 9) +SketchArc_1 = Sketch_1.addArc(0, 0, 18.97366669488877, 0.9999860756345847, -18.97366670156818, 0.9999859489016699, False) +SketchConstraintRadius_2 = Sketch_1.setRadius(SketchArc_1.results()[1], 19) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchArc_1.center(), SketchCircle_1.center()) +SketchProjection_2 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False) +SketchPoint_2 = SketchProjection_2.createdFeature() +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchAPI_Point(SketchPoint_2).coordinates(), SketchArc_1.center()) +SketchLine_1 = Sketch_1.addLine(-44, -2.000000000000004, 44, -2) +SketchLine_1.setName("SketchLine_2") +SketchLine_1.result().setName("SketchLine_2") +SketchLine_1.setAuxiliary(True) +SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result()) +SketchArc_2 = Sketch_1.addArc(-21.97366670156818, 1, -18.97366670156818, 0.9999859489016699, -21.97366670156818, -2, True) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchArc_2.startPoint()) +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_1.result(), SketchArc_2.endPoint()) +SketchArc_3 = Sketch_1.addArc(21.97366669488877, 1, 18.97366669488877, 0.9999860756345847, 21.97366670156818, -2, False) +SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchArc_3.startPoint()) +SketchConstraintDistanceHorizontal_1 = Sketch_1.setHorizontalDistance(SketchArc_2.center(), SketchArc_2.startPoint(), 3) +SketchConstraintDistanceHorizontal_2 = Sketch_1.setHorizontalDistance(SketchArc_3.center(), SketchArc_1.startPoint(), 3) +SketchLine_2 = Sketch_1.addLine(-21.97366670156818, -2, -44, -2.000000000000003) +SketchLine_2.setName("SketchLine_3") +SketchLine_2.result().setName("SketchLine_3") +SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchArc_2.endPoint(), SketchLine_2.startPoint()) +SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_1.result()) +SketchLine_3 = Sketch_1.addLine(-44, -2.000000000000003, -44, -15) +SketchLine_3.setName("SketchLine_4") +SketchLine_3.result().setName("SketchLine_4") +SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchLine_4 = Sketch_1.addLine(-44, -15, -18.09005251512554, -15) +SketchLine_4.setName("SketchLine_5") +SketchLine_4.result().setName("SketchLine_5") +SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +SketchLine_5 = Sketch_1.addLine(-18.09005251512554, -15, -18.09005251512554, -18) +SketchLine_5.setName("SketchLine_6") +SketchLine_5.result().setName("SketchLine_6") +SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint()) +SketchLine_6 = Sketch_1.addLine(-18.09005251512554, -18, -4.999999999999997, -18) +SketchLine_6.setName("SketchLine_7") +SketchLine_6.result().setName("SketchLine_7") +SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint()) +SketchLine_7 = Sketch_1.addLine(-4.999999999999997, -18, -4.999999999999997, -24) +SketchLine_7.setName("SketchLine_8") +SketchLine_7.result().setName("SketchLine_8") +SketchConstraintCoincidence_13 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint()) +SketchLine_8 = Sketch_1.addLine(-4.999999999999997, -24, 5.000000000000002, -24) +SketchLine_8.setName("SketchLine_9") +SketchLine_8.result().setName("SketchLine_9") +SketchConstraintCoincidence_14 = Sketch_1.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint()) +SketchLine_9 = Sketch_1.addLine(5.000000000000002, -24, 5.000000000000002, -18) +SketchLine_9.setName("SketchLine_10") +SketchLine_9.result().setName("SketchLine_10") +SketchConstraintCoincidence_15 = Sketch_1.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint()) +SketchLine_10 = Sketch_1.addLine(5.000000000000002, -18, 18.09005251512554, -18) +SketchLine_10.setName("SketchLine_11") +SketchLine_10.result().setName("SketchLine_11") +SketchConstraintCoincidence_16 = Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint()) +SketchLine_11 = Sketch_1.addLine(18.09005251512554, -18, 18.09005251512554, -15) +SketchLine_11.setName("SketchLine_12") +SketchLine_11.result().setName("SketchLine_12") +SketchConstraintCoincidence_17 = Sketch_1.setCoincident(SketchLine_10.endPoint(), SketchLine_11.startPoint()) +SketchLine_12 = Sketch_1.addLine(18.09005251512554, -15, 44, -15) +SketchLine_12.setName("SketchLine_13") +SketchLine_12.result().setName("SketchLine_13") +SketchConstraintCoincidence_18 = Sketch_1.setCoincident(SketchLine_11.endPoint(), SketchLine_12.startPoint()) +SketchLine_13 = Sketch_1.addLine(44, -15, 44, -2.000000000000003) +SketchLine_13.setName("SketchLine_14") +SketchLine_13.result().setName("SketchLine_14") +SketchConstraintCoincidence_19 = Sketch_1.setCoincident(SketchLine_12.endPoint(), SketchLine_13.startPoint()) +SketchConstraintCoincidence_20 = Sketch_1.setCoincident(SketchLine_13.endPoint(), SketchLine_1.result()) +SketchLine_14 = Sketch_1.addLine(44, -2.000000000000003, 21.97366670156818, -2) +SketchLine_14.setName("SketchLine_15") +SketchLine_14.result().setName("SketchLine_15") +SketchConstraintCoincidence_21 = Sketch_1.setCoincident(SketchLine_13.endPoint(), SketchLine_14.startPoint()) +SketchConstraintCoincidence_22 = Sketch_1.setCoincident(SketchArc_3.endPoint(), SketchLine_14.endPoint()) +SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_13.result()) +SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_3.result()) +SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_5.result()) +SketchConstraintVertical_4 = Sketch_1.setVertical(SketchLine_7.result()) +SketchConstraintVertical_5 = Sketch_1.setVertical(SketchLine_9.result()) +SketchConstraintVertical_6 = Sketch_1.setVertical(SketchLine_11.result()) +SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_4.result()) +SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_6.result()) +SketchConstraintHorizontal_4 = Sketch_1.setHorizontal(SketchLine_8.result()) +SketchConstraintHorizontal_5 = Sketch_1.setHorizontal(SketchLine_10.result()) +SketchConstraintHorizontal_6 = Sketch_1.setHorizontal(SketchLine_12.result()) +SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_3.result(), 13) +SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_5.result(), 3) +SketchConstraintLength_3 = Sketch_1.setLength(SketchLine_7.result(), 6) +SketchConstraintLength_4 = Sketch_1.setLength(SketchLine_9.result(), 6) +SketchConstraintLength_5 = Sketch_1.setLength(SketchLine_11.result(), 3) +SketchLine_15 = Sketch_1.addLine(0, 19, 0, -112) +SketchLine_15.setName("SketchLine_16") +SketchLine_15.result().setName("SketchLine_16") +SketchLine_15.setAuxiliary(True) +SketchProjection_3 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False) +SketchLine_16 = SketchProjection_3.createdFeature() +SketchLine_16.setName("SketchLine_17") +SketchLine_16.result().setName("SketchLine_17") +SketchConstraintCoincidence_23 = Sketch_1.setCoincident(SketchLine_15.startPoint(), SketchLine_16.result()) +SketchConstraintVertical_7 = Sketch_1.setVertical(SketchLine_15.result()) +SketchConstraintDistanceHorizontal_3 = Sketch_1.setHorizontalDistance(SketchLine_6.endPoint(), SketchLine_9.endPoint(), "width") +SketchConstraintHorizontal_7 = Sketch_1.setHorizontal(SketchLine_14.result()) +SketchLine_17 = Sketch_1.addLine(-44, -15, -44, -54.03211253603285) +SketchLine_17.setName("SketchLine_18") +SketchLine_17.result().setName("SketchLine_18") +SketchConstraintVertical_8 = Sketch_1.setVertical(SketchLine_17.result()) +SketchConstraintCoincidence_24 = Sketch_1.setCoincident(SketchLine_17.startPoint(), SketchLine_3.endPoint()) +SketchLine_18 = Sketch_1.addLine(-39.73398465789798, -68, -16.15549442140351, -103) +SketchLine_18.setName("SketchLine_19") +SketchLine_18.result().setName("SketchLine_19") +SketchArc_4 = Sketch_1.addArc(0, -93, -16.15549442140351, -103, 16.15549442140351, -103, False) +SketchArc_4.setName("SketchArc_5") +SketchArc_4.result().setName("SketchArc_5") +SketchArc_4.results()[1].setName("SketchArc_5_2") +SketchConstraintCoincidence_25 = Sketch_1.setCoincident(SketchLine_18.endPoint(), SketchArc_4.startPoint()) +SketchLine_19 = Sketch_1.addLine(16.15549442140351, -103, 39.73398472457715, -68) +SketchLine_19.setName("SketchLine_20") +SketchLine_19.result().setName("SketchLine_20") +SketchConstraintCoincidence_26 = Sketch_1.setCoincident(SketchArc_4.endPoint(), SketchLine_19.startPoint()) +SketchLine_20 = Sketch_1.addLine(44, -15, 44, -54.03211263501164) +SketchLine_20.setName("SketchLine_21") +SketchLine_20.result().setName("SketchLine_21") +SketchConstraintCoincidence_27 = Sketch_1.setCoincident(SketchLine_12.endPoint(), SketchLine_20.startPoint()) +SketchConstraintVertical_9 = Sketch_1.setVertical(SketchLine_20.result()) +SketchConstraintRadius_3 = Sketch_1.setRadius(SketchArc_4.results()[1], 19) +SketchLine_21 = Sketch_1.addLine(-44, -46, 44.00000000000001, -46) +SketchLine_21.setName("SketchLine_22") +SketchLine_21.result().setName("SketchLine_22") +SketchLine_21.setAuxiliary(True) +SketchCircle_2 = Sketch_1.addCircle(-24.99999999999994, -46, 5) +SketchConstraintDistance_1 = Sketch_1.setDistance(SketchLine_4.result(), SketchCircle_2.center(), 31, True) +SketchConstraintRadius_4 = Sketch_1.setRadius(SketchCircle_2.results()[1], 5) +SketchPoint_3 = Sketch_1.addPoint(-44, -46) +SketchConstraintCoincidence_28 = Sketch_1.setCoincident(SketchLine_21.startPoint(), SketchPoint_3.coordinates()) +SketchPoint_4 = Sketch_1.addPoint(25, -46) +SketchConstraintCoincidence_29 = Sketch_1.setCoincident(SketchPoint_4.coordinates(), SketchLine_21.result()) +SketchConstraintDistance_2 = Sketch_1.setDistance(SketchLine_12.result(), SketchPoint_4.coordinates(), 31, True) +SketchMultiTranslation_1 = Sketch_1.addTranslation([SketchCircle_2.results()[1]], SketchCircle_2.center(), SketchPoint_4.coordinates(), 2) +[SketchCircle_3] = SketchMultiTranslation_1.translated() +SketchConstraintDistanceHorizontal_4 = Sketch_1.setHorizontalDistance(SketchCircle_2.center(), SketchAPI_Circle(SketchCircle_3).center(), "l") +SketchLine_22 = Sketch_1.addLine(-39.733984657898, -68, 39.73398472457715, -68) +SketchLine_22.setName("SketchLine_23") +SketchLine_22.result().setName("SketchLine_23") +SketchLine_22.setAuxiliary(True) +SketchConstraintHorizontal_8 = Sketch_1.setHorizontal(SketchLine_22.result()) +SketchPoint_5 = Sketch_1.addPoint(0, -112) +SketchConstraintDistance_3 = Sketch_1.setDistance(SketchPoint_5.coordinates(), SketchLine_8.result(), 88, True) +SketchConstraintCoincidence_30 = Sketch_1.setCoincident(SketchPoint_5.coordinates(), SketchArc_4.results()[1]) +SketchConstraintCoincidence_31 = Sketch_1.setCoincident(SketchLine_15.startPoint(), SketchArc_1.results()[1]) +SketchConstraintDistanceVertical_1 = Sketch_1.setVerticalDistance(SketchArc_2.center(), SketchLine_2.startPoint(), 3) +SketchConstraintCoincidence_32 = Sketch_1.setCoincident(SketchArc_3.endPoint(), SketchLine_14.endPoint()) +SketchConstraintCoincidence_33 = Sketch_1.setCoincident(SketchLine_14.result(), SketchArc_3.endPoint()) +SketchConstraintDistanceVertical_2 = Sketch_1.setVerticalDistance(SketchArc_3.center(), SketchArc_3.endPoint(), 3) +SketchLine_23 = Sketch_1.addLine(-16.15549442140351, -103, 16.15549442140351, -103) +SketchLine_23.setName("SketchLine_29") +SketchLine_23.result().setName("SketchLine_29") +SketchLine_23.setAuxiliary(True) +SketchConstraintHorizontal_9 = Sketch_1.setHorizontal(SketchLine_23.result()) +SketchConstraintCoincidence_34 = Sketch_1.setCoincident(SketchLine_18.endPoint(), SketchLine_23.result()) +SketchConstraintCoincidence_35 = Sketch_1.setCoincident(SketchLine_23.result(), SketchLine_19.startPoint()) +SketchConstraintCoincidence_36 = Sketch_1.setCoincident(SketchLine_22.result(), SketchLine_18.startPoint()) +SketchConstraintCoincidence_37 = Sketch_1.setCoincident(SketchLine_22.result(), SketchLine_19.endPoint()) +SketchConstraintDistance_4 = Sketch_1.setDistance(SketchLine_17.endPoint(), SketchLine_20.endPoint(), 88, True) +SketchConstraintDistanceVertical_3 = Sketch_1.setVerticalDistance(SketchLine_21.startPoint(), SketchLine_18.startPoint(), 22) +SketchConstraintDistanceVertical_4 = Sketch_1.setVerticalDistance(SketchLine_18.startPoint(), SketchLine_18.endPoint(), 35) +SketchConstraintDistanceVertical_5 = Sketch_1.setVerticalDistance(SketchLine_20.startPoint(), SketchArc_4.endPoint(), 88) +SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_2.result(), SketchLine_14.result()) +SketchConstraintEqual_2 = Sketch_1.setEqual(SketchLine_4.result(), SketchLine_12.result()) +SketchConstraintEqual_3 = Sketch_1.setEqual(SketchLine_6.result(), SketchLine_10.result()) +SketchConstraintDistance_5 = Sketch_1.setDistance(SketchAPI_Line(SketchLine_16).startPoint(), SketchLine_4.endPoint(), 23.5, True) +SketchConstraintDistance_6 = Sketch_1.setDistance(SketchAPI_Line(SketchLine_16).startPoint(), SketchLine_11.endPoint(), 23.5, True) +SketchConstraintDistance_7 = Sketch_1.setDistance(SketchAPI_Line(SketchLine_16).startPoint(), SketchLine_8.result(), 24, True) +SketchArc_5 = Sketch_1.addArc(-19, -54.03211253603285, -44, -54.03211253603285, -39.733984657898, -68, False) +SketchArc_5.setName("SketchArc_6") +SketchArc_5.result().setName("SketchArc_6") +SketchArc_5.results()[1].setName("SketchArc_6_2") +SketchConstraintCoincidence_38 = Sketch_1.setCoincident(SketchLine_17.endPoint(), SketchArc_5.startPoint()) +SketchConstraintCoincidence_39 = Sketch_1.setCoincident(SketchLine_18.result(), SketchArc_5.endPoint()) +SketchArc_6 = Sketch_1.addArc(19, -54.03211263501164, 44, -54.03211263501164, 39.73398472457715, -68, True) +SketchArc_6.setName("SketchArc_7") +SketchArc_6.result().setName("SketchArc_7") +SketchArc_6.results()[1].setName("SketchArc_7_2") +SketchConstraintCoincidence_40 = Sketch_1.setCoincident(SketchLine_20.endPoint(), SketchArc_6.startPoint()) +SketchConstraintCoincidence_41 = Sketch_1.setCoincident(SketchLine_19.result(), SketchArc_6.endPoint()) +SketchConstraintCoincidence_42 = Sketch_1.setCoincident(SketchLine_19.endPoint(), SketchArc_6.endPoint()) +SketchConstraintRadius_5 = Sketch_1.setRadius(SketchArc_5.results()[1], 25) +SketchConstraintRadius_6 = Sketch_1.setRadius(SketchArc_6.results()[1], 25) +SketchConstraintCoincidence_43 = Sketch_1.setCoincident(SketchPoint_3.coordinates(), SketchLine_17.result()) +SketchConstraintCoincidence_44 = Sketch_1.setCoincident(SketchLine_22.startPoint(), SketchArc_5.endPoint()) +SketchConstraintCoincidence_45 = Sketch_1.setCoincident(SketchLine_22.endPoint(), SketchLine_19.endPoint()) +SketchConstraintCoincidence_46 = Sketch_1.setCoincident(SketchLine_21.endPoint(), SketchLine_20.result()) +SketchConstraintCoincidence_47 = Sketch_1.setCoincident(SketchArc_4.center(), SketchLine_15.result()) +SketchConstraintCoincidence_48 = Sketch_1.setCoincident(SketchLine_23.endPoint(), SketchArc_4.endPoint()) +SketchConstraintCoincidence_49 = Sketch_1.setCoincident(SketchLine_23.startPoint(), SketchLine_18.endPoint()) +SketchConstraintCoincidence_50 = Sketch_1.setCoincident(SketchLine_15.endPoint(), SketchPoint_5.coordinates()) +SketchConstraintTangent_1 = Sketch_1.setTangent(SketchLine_17.result(), SketchArc_5.results()[1]) +SketchConstraintTangent_2 = Sketch_1.setTangent(SketchLine_20.result(), SketchArc_6.results()[1]) +SketchConstraintTangent_3 = Sketch_1.setTangent(SketchArc_5.results()[1], SketchLine_18.result()) +SketchConstraintTangent_4 = Sketch_1.setTangent(SketchArc_6.results()[1], SketchLine_19.result()) +SketchConstraintTangent_5 = Sketch_1.setTangent(SketchLine_2.result(), SketchArc_2.results()[1]) +SketchConstraintCoincidence_51 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_52 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_13.result()) +SketchConstraintCoincidence_53 = Sketch_1.setCoincident(SketchLine_15.startPoint(), SketchArc_1.results()[1]) +SketchConstraintDistance_8 = Sketch_1.setDistance(SketchPoint_4.coordinates(), SketchLine_15.result(), "l/2", True) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchArc_1_2f-SketchArc_2_2r-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_8f-SketchLine_9f-SketchLine_10f-SketchLine_11f-SketchLine_12f-SketchLine_13f-SketchLine_14f-SketchLine_15f-SketchArc_3_2r-SketchCircle_1_2r"), model.selection("FACE", "Sketch_1/Face-SketchLine_18f-SketchArc_6_2f-SketchLine_19f-SketchArc_5_2f-SketchLine_20f-SketchArc_7_2f-SketchLine_21r-SketchLine_13r-SketchLine_12r-SketchLine_11r-SketchLine_10r-SketchLine_9r-SketchLine_8r-SketchLine_7r-SketchLine_6r-SketchLine_5r-SketchCircle_2_2r-SketchCircle_3_2r")], model.selection(), 10, 0) +Wire_1_objects = [model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_1_2][Extrusion_1_1_1/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_3_2][Extrusion_1_1_1/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_15][Extrusion_1_1_1/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_14][Extrusion_1_1_1/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_13][Extrusion_1_1_2/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_12][Extrusion_1_1_2/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_11][Extrusion_1_1_2/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_10][Extrusion_1_1_2/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_9][Extrusion_1_1_2/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_8][Extrusion_1_1_2/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_7][Extrusion_1_1_2/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_6][Extrusion_1_1_2/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_5][Extrusion_1_1_2/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_4][Extrusion_1_1_1/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1_1/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_2_2][Extrusion_1_1_1/To_Face]")] +Wire_1 = model.addWire(Part_1_doc, Wire_1_objects, False) +Recover_1 = model.addRecover(Part_1_doc, Wire_1, [Extrusion_1.result().subResult(0), Extrusion_1.result().subResult(1)]) +Recover_1.result().setName("BaseHorizontale") +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Recover_1_2/Modified_Face&Extrusion_1_1_1/To_Face")], model.selection(), 40, 10) +Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "_weak_name_8_Extrusion_2_1")]) +Recover_2 = model.addRecover(Part_1_doc, Shell_1, [Extrusion_2.result()]) +Recover_2.result().setName("BaseVerticale") +Extrusion_3 = model.addExtrusion(Part_1_doc, [model.selection("SHELL", "Shell_1_1")], model.selection(), 0, 67) +Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("YOZ")) +SketchLine_24 = Sketch_2.addLine(-24, 50, -91, 10) +SketchLine_24.setName("SketchLine_24") +SketchLine_24.result().setName("SketchLine_24") +SketchLine_25 = Sketch_2.addLine(-91, 10, -95.16657804170339, 15.01933103534318) +SketchLine_25.setName("SketchLine_25") +SketchLine_25.result().setName("SketchLine_25") +SketchConstraintCoincidence_54 = Sketch_2.setCoincident(SketchLine_24.endPoint(), SketchLine_25.startPoint()) +SketchLine_26 = Sketch_2.addLine(-95.16657804170339, 15.01933103534318, -95.16657804170339, 56.48490151730473) +SketchLine_26.setName("SketchLine_26") +SketchLine_26.result().setName("SketchLine_26") +SketchConstraintCoincidence_55 = Sketch_2.setCoincident(SketchLine_25.endPoint(), SketchLine_26.startPoint()) +SketchLine_27 = Sketch_2.addLine(-95.16657804170339, 56.48490151730473, -23.26184103325994, 56.92117661842984) +SketchLine_27.setName("SketchLine_27") +SketchLine_27.result().setName("SketchLine_27") +SketchConstraintCoincidence_56 = Sketch_2.setCoincident(SketchLine_26.endPoint(), SketchLine_27.startPoint()) +SketchLine_28 = Sketch_2.addLine(-23.26184103325994, 56.92117661842984, -24, 50) +SketchLine_28.setName("SketchLine_28") +SketchLine_28.result().setName("SketchLine_28") +SketchConstraintCoincidence_57 = Sketch_2.setCoincident(SketchLine_27.endPoint(), SketchLine_28.startPoint()) +SketchConstraintCoincidence_58 = Sketch_2.setCoincident(SketchLine_24.startPoint(), SketchLine_28.endPoint()) +SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "[BaseHorizontale/Modified_Face&Sketch_1/SketchLine_19][BaseHorizontale/Modified_Face&Extrusion_1_1_2/To_Face]"), False) +SketchLine_29 = SketchProjection_4.createdFeature() +SketchLine_29.setName("SketchLine_30") +SketchLine_29.result().setName("SketchLine_30") +SketchConstraintCoincidence_59 = Sketch_2.setCoincident(SketchLine_25.startPoint(), SketchLine_29.result()) +SketchProjection_5 = Sketch_2.addProjection(model.selection("EDGE", "[_weak_name_1_Extrusion_3_1_1][Extrusion_3_1_1/From_Face]"), False) +SketchLine_30 = SketchProjection_5.createdFeature() +SketchLine_30.setName("SketchLine_31") +SketchLine_30.result().setName("SketchLine_31") +SketchConstraintCoincidence_60 = Sketch_2.setCoincident(SketchLine_25.startPoint(), SketchLine_30.result()) +SketchProjection_6 = Sketch_2.addProjection(model.selection("EDGE", "[_weak_name_1_Extrusion_3_1_1][_weak_name_4_Extrusion_3_1_1]"), False) +SketchLine_31 = SketchProjection_6.createdFeature() +SketchLine_31.setName("SketchLine_32") +SketchLine_31.result().setName("SketchLine_32") +SketchConstraintCoincidence_61 = Sketch_2.setCoincident(SketchLine_24.startPoint(), SketchAPI_Line(SketchLine_31).endPoint()) +model.do() +Extrusion_4 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchLine_28r-SketchLine_27r-SketchLine_26r-SketchLine_25r-SketchLine_24r_wire")], model.selection(), 50, 50) +Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Extrusion_3_1_1")], [model.selection("SOLID", "Extrusion_4_1")]) +Cut_1.result().setName("AreteDiagonale") +Fuse_1_objects_1 = [model.selection("SOLID", "BaseHorizontale"), model.selection("SOLID", "BaseVerticale"), model.selection("SOLID", "AreteDiagonale")] +Fuse_1 = model.addFuse(Part_1_doc, Fuse_1_objects_1, removeEdges = True, keepSubResults = True) +RemoveResults_1 = model.addRemoveResults(Part_1_doc, [model.selection("WIRE", "Wire_1_1")]) +Group_1 = model.addGroup(Part_1_doc, "Faces", [model.selection("FACE", "BaseHorizontale/Modified_Face&Extrusion_1_1_2/To_Face")]) +Group_2 = model.addGroup(Part_1_doc, "Faces", [model.selection("FACE", "BaseHorizontale/Modified_Face&Sketch_2/SketchLine_24")]) +Group_3 = model.addGroup(Part_1_doc, "Faces", [model.selection("FACE", "BaseHorizontale/Modified_Face&Extrusion_2_1/To_Face")]) + +model.end() + +from GeomAPI import * + +model.testNbResults(Fuse_1, 1) +model.testNbSubResults(Fuse_1, [0]) +model.testNbSubShapes(Fuse_1, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Fuse_1, GeomAPI_Shape.FACE, [27]) +model.testNbSubShapes(Fuse_1, GeomAPI_Shape.EDGE, [150]) +model.testNbSubShapes(Fuse_1, GeomAPI_Shape.VERTEX, [300]) +model.testResultsVolumes(Fuse_1, [163259.1989]) + +model.begin() +width.setValue(5) +model.end() + +model.testNbResults(Fuse_1, 1) +model.testNbSubResults(Fuse_1, [0]) +model.testNbSubShapes(Fuse_1, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Fuse_1, GeomAPI_Shape.FACE, [27]) +model.testNbSubShapes(Fuse_1, GeomAPI_Shape.EDGE, [150]) +model.testNbSubShapes(Fuse_1, GeomAPI_Shape.VERTEX, [300]) +model.testResultsVolumes(Fuse_1, [155359.198457]) + +assert(model.checkPythonDump()) diff --git a/src/Selector/CMakeLists.txt b/src/Selector/CMakeLists.txt index a0882147f..ec8d88240 100644 --- a/src/Selector/CMakeLists.txt +++ b/src/Selector/CMakeLists.txt @@ -50,9 +50,11 @@ SET(PROJECT_SOURCES SET(PROJECT_LIBRARIES ${OpenCASCADE_ApplicationFramework_LIBRARIES} + GeomAPI ) SET(PROJECT_INCLUDES ${OpenCASCADE_INCLUDE_DIR} + ../GeomAPI ) diff --git a/src/Selector/Selector_NExplode.cpp b/src/Selector/Selector_NExplode.cpp index deb3071cd..93e510e6c 100644 --- a/src/Selector/Selector_NExplode.cpp +++ b/src/Selector/Selector_NExplode.cpp @@ -19,6 +19,8 @@ #include "Selector_NExplode.h" +#include + #include #include #include @@ -34,7 +36,7 @@ #include #include -static std::pair ShapeToDouble (const TopoDS_Shape& S) +static std::pair ShapeToDouble (const TopoDS_Shape& S) { // Computing of CentreOfMass gp_Pnt GPoint; @@ -59,8 +61,7 @@ static std::pair ShapeToDouble (const TopoDS_Shape& S) Len = GPr.Mass(); } - double dMidXYZ = GPoint.X() * 999.0 + GPoint.Y() * 99.0 + GPoint.Z() * 0.9; - return std::make_pair(dMidXYZ, Len); + return std::make_pair(GPoint, Len); } /*! @@ -68,7 +69,7 @@ static std::pair ShapeToDouble (const TopoDS_Shape& S) */ struct CompareShapes : public std::binary_function { - typedef NCollection_DataMap > DataMapOfShapeDouble; + typedef NCollection_DataMap > DataMapOfShapeDouble; CompareShapes(DataMapOfShapeDouble* theCashMap) : myMap(theCashMap) {} @@ -88,17 +89,19 @@ bool CompareShapes::operator() (const TopoDS_Shape& theShape1, myMap->Bind(theShape2, ShapeToDouble(theShape2)); } - std::pair val1 = myMap->Find(theShape1); - std::pair val2 = myMap->Find(theShape2); + const std::pair& val1 = myMap->Find(theShape1); + const std::pair& val2 = myMap->Find(theShape2); - double tol = Precision::Confusion(); + double tol = 10.0 * Precision::Confusion(); bool exchange = Standard_False; - double dMidXYZ = val1.first - val2.first; - if (dMidXYZ >= tol) { + // compare coordinates of center points + GeomPointPtr aPnt1(new GeomAPI_Pnt(val1.first.X(), val1.first.Y(), val1.first.Z())); + GeomPointPtr aPnt2(new GeomAPI_Pnt(val2.first.X(), val2.first.Y(), val2.first.Z())); + if (aPnt2->isLess(aPnt1, tol)) { exchange = Standard_True; } - else if (Abs(dMidXYZ) < tol) { + else if (!aPnt1->isLess(aPnt2, tol)) { double dLength = val1.second - val2.second; if (dLength >= tol) { exchange = Standard_True; -- 2.39.2