From: mpv Date: Tue, 23 Jan 2018 08:52:59 +0000 (+0300) Subject: Partial fix for the issue #2375 : the cut by many circular extrusions produces differ... X-Git-Tag: V_3.0.0RC1~16 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0fb364615cb02c9aed5ff040f7ed2595a0f4979d;p=modules%2Fshaper.git Partial fix for the issue #2375 : the cut by many circular extrusions produces different lateral sub-shape names. --- diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt index c83a60b01..023ee0ffe 100644 --- a/src/FeaturesPlugin/CMakeLists.txt +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -243,6 +243,7 @@ ADD_UNIT_TESTS(TestExtrusion.py Test2289.py Test2304.py Test2304_2.py + Test2375.py Test2377.py Test2394.py Test2395.py diff --git a/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp b/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp index a3018be53..9724f6d4b 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp @@ -358,7 +358,7 @@ void FeaturesPlugin_CompositeSketch::storeGenerationHistory(ResultBodyPtr theRes bool isClosed = false; // lateral edges are closed (in full revolution) GeomAPI_DataMapOfShapeShape anEdgesFromVertices; GeomAPI_ShapeExplorer aVertExp(theBaseShape, GeomAPI_Shape::VERTEX); - for(int anIndex = 1; aVertExp.more(); aVertExp.next()) { + for(; aVertExp.more(); aVertExp.next()) { ListOfShape aGenerated; theMakeShape->generated(aVertExp.current(), aGenerated); ListOfShape::iterator aGenIter = aGenerated.begin(); @@ -367,7 +367,7 @@ void FeaturesPlugin_CompositeSketch::storeGenerationHistory(ResultBodyPtr theRes if (anEdgesFromVertices.isBound(aGenerated)) // already here continue; std::ostringstream aStream; - aStream<<"Lateral_Edge_"<generated(aGenerated, aStream.str(), theTag++); anEdgesFromVertices.bind(aGenerated, aVertExp.current()); @@ -377,11 +377,11 @@ void FeaturesPlugin_CompositeSketch::storeGenerationHistory(ResultBodyPtr theRes } if (isClosed) { GeomAPI_ShapeExplorer anEdgesExp(theMakeShape->shape(), GeomAPI_Shape::EDGE); - for(int anIndex = 1; anEdgesExp.more(); anEdgesExp.next()) { + for(; anEdgesExp.more(); anEdgesExp.next()) { if (!anEdgesFromVertices.isBound(anEdgesExp.current())) { // found a base edge std::ostringstream aStream; - aStream<<"Base_Edge_"<generated(anEdgesExp.current(), aStream.str(), theTag++); // only one orientation is needed anEdgesFromVertices.bind(anEdgesExp.current(), anEdgesExp.current()); @@ -395,7 +395,7 @@ void FeaturesPlugin_CompositeSketch::storeGenerationHistory(ResultBodyPtr theRes if (!aVertices.isBound(aVertExp.current())) { // found a base edge std::ostringstream aStream; - aStream<<"Vertex_"<generated(aVertExp.current(), aStream.str(), theTag++); // only one orientation is needed aVertices.bind(aVertExp.current(), aVertExp.current()); @@ -405,7 +405,7 @@ void FeaturesPlugin_CompositeSketch::storeGenerationHistory(ResultBodyPtr theRes } else { // issue #2197, test case 4 : edges that produce fully-revolved face, // but contain only 2 edges (on apex of revolution) GeomAPI_ShapeExplorer anEdgeExp(theBaseShape, GeomAPI_Shape::EDGE); - for(int anIndex = 1; anEdgeExp.more(); anEdgeExp.next()) { + for(; anEdgeExp.more(); anEdgeExp.next()) { ListOfShape aGenerated; theMakeShape->generated(anEdgeExp.current(), aGenerated); ListOfShape::iterator aGenIter = aGenerated.begin(); @@ -431,7 +431,7 @@ void FeaturesPlugin_CompositeSketch::storeGenerationHistory(ResultBodyPtr theRes } if (aNumEdges == 2 && aNumClosed == 1) { std::ostringstream aStream; - aStream<<"Base_Edge_"<generated(aNotClosedEdge, aStream.str(), theTag++); } } diff --git a/src/FeaturesPlugin/Test/Test2375.py b/src/FeaturesPlugin/Test/Test2375.py new file mode 100644 index 000000000..fb13fde51 --- /dev/null +++ b/src/FeaturesPlugin/Test/Test2375.py @@ -0,0 +1,221 @@ +## Copyright (C) 2014-2017 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, "angle", "27.5") +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ")) +SketchLine_1 = Sketch_1.addLine(0, 4, 6.2, 4) +SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OZ"), False) +SketchLine_2 = SketchProjection_1.createdFeature() +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_2.result()) +SketchLine_3 = Sketch_1.addLine(6.2, 4, 6.2, 2.5) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_3.startPoint()) +SketchLine_4 = Sketch_1.addLine(6.2, 2.5, 3.5, 2) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +SketchLine_5 = Sketch_1.addLine(3.5, 2, 3.5, 0) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint()) +SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False) +SketchLine_6 = SketchProjection_2.createdFeature() +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.result()) +SketchLine_7 = Sketch_1.addLine(3.5, 0, 0, 0) +SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_7.startPoint()) +SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchAPI_Line(SketchLine_2).startPoint(), SketchLine_7.endPoint()) +SketchLine_8 = Sketch_1.addLine(0, 4, 0, 0) +SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_8.startPoint()) +SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchAPI_Line(SketchLine_2).startPoint(), SketchLine_8.endPoint()) +SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_5.result()) +SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_3.result()) +SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result()) +SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 6.2) +SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_7.result(), 3.5) +SketchConstraintLength_3 = Sketch_1.setLength(SketchLine_5.result(), 2) +SketchConstraintLength_4 = Sketch_1.setLength(SketchLine_3.result(), 1.5) +SketchConstraintLength_5 = Sketch_1.setLength(SketchLine_8.result(), 4) +model.do() +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_3r-SketchLine_4r-SketchLine_5r-SketchLine_7r-SketchLine_8f")], model.selection("EDGE", "PartSet/OZ"), 360, 0) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Revolution_1_1/Generated_Face_1")) +SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "Revolution_1_1/Generated_Face_2&Revolution_1_1/Generated_Face_1__cc"), False) +SketchPoint_1 = SketchProjection_3.createdFeature() +SketchCircle_1 = Sketch_2.addCircle(0, 0, 4.75) +SketchCircle_1.setAuxiliary(True) +SketchConstraintCoincidence_10 = Sketch_2.setCoincident(SketchPoint_1.result(), SketchCircle_1.center()) +SketchCircle_2 = Sketch_2.addCircle(4.113620667976081, 2.375000000000003, 1.1) +SketchConstraintCoincidence_11 = Sketch_2.setCoincident(SketchCircle_1.results()[1], SketchCircle_2.center()) +SketchCircle_3 = Sketch_2.addCircle(-4.113620667974014, 2.375000000003604, 1.1) +SketchConstraintCoincidence_12 = Sketch_2.setCoincident(SketchCircle_1.results()[1], SketchCircle_3.center()) +SketchCircle_4 = Sketch_2.addCircle(4.163806340121522e-012, -4.75000000000001, 1.1) +SketchConstraintCoincidence_13 = Sketch_2.setCoincident(SketchCircle_1.results()[1], SketchCircle_4.center()) +SketchConstraintEqual_1 = Sketch_2.setEqual(SketchCircle_2.results()[1], SketchCircle_3.results()[1]) +SketchConstraintEqual_2 = Sketch_2.setEqual(SketchCircle_3.results()[1], SketchCircle_4.results()[1]) +SketchLine_9 = Sketch_2.addLine(0, 0, 4.113620667976081, 2.375000000000003) +SketchLine_9.setAuxiliary(True) +SketchConstraintCoincidence_14 = Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_9.startPoint()) +SketchConstraintCoincidence_15 = Sketch_2.setCoincident(SketchCircle_2.center(), SketchLine_9.endPoint()) +SketchLine_10 = Sketch_2.addLine(-4.113620667974014, 2.375000000003604, 0, 0) +SketchLine_10.setAuxiliary(True) +SketchConstraintCoincidence_16 = Sketch_2.setCoincident(SketchCircle_3.center(), SketchLine_10.startPoint()) +SketchConstraintCoincidence_17 = Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_10.endPoint()) +SketchLine_11 = Sketch_2.addLine(4.163806340121522e-012, -4.75000000000001, 0, 0) +SketchLine_11.setAuxiliary(True) +SketchConstraintCoincidence_18 = Sketch_2.setCoincident(SketchCircle_4.center(), SketchLine_11.startPoint()) +SketchConstraintCoincidence_19 = Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_11.endPoint()) +SketchConstraintRadius_1 = Sketch_2.setRadius(SketchCircle_2.results()[1], 1.1) +SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), False) +SketchLine_12 = SketchProjection_4.createdFeature() +SketchConstraintAngle_1 = Sketch_2.setAngleBackward(SketchLine_9.result(), SketchLine_12.result(), 30.00000000000006) +SketchConstraintAngle_2 = Sketch_2.setAngle(SketchLine_9.result(), SketchLine_10.result(), 119.9999999999498) +SketchConstraintAngle_3 = Sketch_2.setAngle(SketchLine_10.result(), SketchLine_11.result(), 120.0000000001004) +SketchConstraintLength_6 = Sketch_2.setLength(SketchLine_9.result(), 4.75) +SketchCircle_5 = Sketch_2.addCircle(2.552173139647412, 4.006109367611208, 0.65) +SketchConstraintCoincidence_20 = Sketch_2.setCoincident(SketchCircle_1.results()[1], SketchCircle_5.center()) +SketchCircle_6 = Sketch_2.addCircle(2.552173139647412, 4.006109367611208, 0.8) +SketchConstraintCoincidence_21 = Sketch_2.setCoincident(SketchCircle_1.results()[1], SketchCircle_6.center()) +SketchConstraintCoincidence_22 = Sketch_2.setCoincident(SketchCircle_5.center(), SketchCircle_6.center()) +SketchCircle_7 = Sketch_2.addCircle(4.745479052513824, 0.20719208998535, 0.65) +SketchConstraintCoincidence_23 = Sketch_2.setCoincident(SketchCircle_1.results()[1], SketchCircle_7.center()) +SketchCircle_8 = Sketch_2.addCircle(4.745479052513824, 0.20719208998535, 0.8) +SketchConstraintCoincidence_24 = Sketch_2.setCoincident(SketchCircle_1.results()[1], SketchCircle_8.center()) +SketchConstraintCoincidence_25 = Sketch_2.setCoincident(SketchCircle_7.center(), SketchCircle_8.center()) +SketchLine_13 = Sketch_2.addLine(0, 0, 2.552173139647412, 4.006109367611208) +SketchLine_13.setAuxiliary(True) +SketchConstraintCoincidence_26 = Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_13.startPoint()) +SketchConstraintCoincidence_27 = Sketch_2.setCoincident(SketchCircle_5.center(), SketchLine_13.endPoint()) +SketchLine_14 = Sketch_2.addLine(0, 0, 4.745479052513824, 0.20719208998535) +SketchLine_14.setAuxiliary(True) +SketchConstraintCoincidence_28 = Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_14.startPoint()) +SketchConstraintCoincidence_29 = Sketch_2.setCoincident(SketchCircle_7.center(), SketchLine_14.endPoint()) +SketchConstraintEqual_3 = Sketch_2.setEqual(SketchCircle_7.results()[1], SketchCircle_5.results()[1]) +SketchConstraintEqual_4 = Sketch_2.setEqual(SketchCircle_8.results()[1], SketchCircle_6.results()[1]) +SketchConstraintRadius_2 = Sketch_2.setRadius(SketchCircle_7.results()[1], 0.65) +SketchConstraintRadius_3 = Sketch_2.setRadius(SketchCircle_8.results()[1], 0.8) +SketchCircle_9 = Sketch_2.addCircle(-2.552173139482203, 4.006109367717388, 0.65) +SketchConstraintCoincidence_30 = Sketch_2.setCoincident(SketchCircle_1.results()[1], SketchCircle_9.center()) +SketchCircle_10 = Sketch_2.addCircle(-4.745479052513825, 0.2071920899853395, 0.65) +SketchConstraintCoincidence_31 = Sketch_2.setCoincident(SketchCircle_1.results()[1], SketchCircle_10.center()) +SketchCircle_11 = Sketch_2.addCircle(-2.552173139482203, 4.006109367717388, 0.8) +SketchConstraintCoincidence_32 = Sketch_2.setCoincident(SketchCircle_1.results()[1], SketchCircle_11.center()) +SketchCircle_12 = Sketch_2.addCircle(-4.745479052513825, 0.2071920899853395, 0.8) +SketchConstraintCoincidence_33 = Sketch_2.setCoincident(SketchCircle_10.center(), SketchCircle_12.center()) +SketchConstraintCoincidence_34 = Sketch_2.setCoincident(SketchCircle_9.center(), SketchCircle_11.center()) +SketchConstraintEqual_5 = Sketch_2.setEqual(SketchCircle_6.results()[1], SketchCircle_11.results()[1]) +SketchConstraintEqual_6 = Sketch_2.setEqual(SketchCircle_5.results()[1], SketchCircle_9.results()[1]) +SketchConstraintEqual_7 = Sketch_2.setEqual(SketchCircle_9.results()[1], SketchCircle_10.results()[1]) +SketchConstraintEqual_8 = Sketch_2.setEqual(SketchCircle_11.results()[1], SketchCircle_12.results()[1]) +SketchLine_15 = Sketch_2.addLine(-2.552173139482203, 4.006109367717388, 0, 0) +SketchLine_15.setAuxiliary(True) +SketchConstraintCoincidence_35 = Sketch_2.setCoincident(SketchCircle_9.center(), SketchLine_15.startPoint()) +SketchConstraintCoincidence_36 = Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_15.endPoint()) +SketchLine_16 = Sketch_2.addLine(-4.745479052513825, 0.2071920899853395, 0, 0) +SketchLine_16.setAuxiliary(True) +SketchConstraintCoincidence_37 = Sketch_2.setCoincident(SketchCircle_10.center(), SketchLine_16.startPoint()) +SketchConstraintCoincidence_38 = Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_16.endPoint()) +SketchCircle_13 = Sketch_2.addCircle(-2.193305912870557, -4.213301457594897, 0.8) +SketchConstraintCoincidence_39 = Sketch_2.setCoincident(SketchCircle_1.results()[1], SketchCircle_13.center()) +SketchCircle_14 = Sketch_2.addCircle(2.193305912973027, -4.213301457541542, 0.8) +SketchConstraintCoincidence_40 = Sketch_2.setCoincident(SketchCircle_1.results()[1], SketchCircle_14.center()) +SketchConstraintEqual_9 = Sketch_2.setEqual(SketchCircle_14.results()[1], SketchCircle_13.results()[1]) +SketchConstraintEqual_10 = Sketch_2.setEqual(SketchCircle_12.results()[1], SketchCircle_13.results()[1]) +SketchLine_17 = Sketch_2.addLine(0, 0, -2.193305912870557, -4.213301457594897) +SketchLine_17.setAuxiliary(True) +SketchConstraintCoincidence_41 = Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_17.startPoint()) +SketchConstraintCoincidence_42 = Sketch_2.setCoincident(SketchCircle_13.center(), SketchLine_17.endPoint()) +SketchLine_18 = Sketch_2.addLine(0, 0, 2.193305912973027, -4.213301457541542) +SketchLine_18.setAuxiliary(True) +SketchConstraintCoincidence_43 = Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_18.startPoint()) +SketchConstraintCoincidence_44 = Sketch_2.setCoincident(SketchCircle_14.center(), SketchLine_18.endPoint()) +SketchConstraintAngle_4 = Sketch_2.setAngleBackward(SketchLine_9.result(), SketchLine_14.result(), "angle") +SketchConstraintAngle_5 = Sketch_2.setAngle(SketchLine_9.result(), SketchLine_13.result(), "angle") +SketchConstraintAngle_6 = Sketch_2.setAngleBackward(SketchLine_10.result(), SketchLine_15.result(), "angle") +SketchConstraintAngle_7 = Sketch_2.setAngleBackward(SketchLine_16.result(), SketchLine_10.result(), "angle") +SketchConstraintAngle_8 = Sketch_2.setAngle(SketchLine_17.result(), SketchLine_11.result(), "angle") +SketchConstraintAngle_9 = Sketch_2.setAngle(SketchLine_11.result(), SketchLine_18.result(), "angle") +SketchProjection_5 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OY"), False) +SketchLine_19 = SketchProjection_5.createdFeature() +SketchCircle_15 = Sketch_2.addCircle(0, 5, 0.45) +SketchConstraintCoincidence_45 = Sketch_2.setCoincident(SketchLine_19.result(), SketchCircle_15.center()) +SketchConstraintRadius_4 = Sketch_2.setRadius(SketchCircle_15.results()[1], 0.45) +SketchLine_20 = Sketch_2.addLine(0, 0, 4.385635518227006, -2.793957963403483) +SketchLine_20.setAuxiliary(True) +SketchConstraintCoincidence_46 = Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_20.startPoint()) +SketchCircle_16 = Sketch_2.addCircle(3.373565783251674, -2.149198433387089, 0.3) +SketchConstraintCoincidence_47 = Sketch_2.setCoincident(SketchLine_20.result(), SketchCircle_16.center()) +SketchCircle_17 = Sketch_2.addCircle(4.385635518227006, -2.793957963403483, 0.5) +SketchConstraintCoincidence_48 = Sketch_2.setCoincident(SketchLine_20.endPoint(), SketchCircle_17.center()) +SketchConstraintRadius_5 = Sketch_2.setRadius(SketchCircle_16.results()[1], 0.3) +SketchConstraintRadius_6 = Sketch_2.setRadius(SketchCircle_17.results()[1], 0.5) +SketchConstraintAngle_10 = Sketch_2.setAngleBackward(SketchLine_14.result(), SketchLine_20.result(), 35.00000000000006) +SketchConstraintDistance_1 = Sketch_2.setDistance(SketchCircle_15.center(), SketchLine_12.result(), 5, True) +SketchConstraintDistance_2 = Sketch_2.setDistance(SketchCircle_16.center(), SketchAPI_Line(SketchLine_19).startPoint(), 4, True) +SketchConstraintDistance_3 = Sketch_2.setDistance(SketchAPI_Line(SketchLine_19).startPoint(), SketchCircle_17.center(), 5.2, True) +model.do() +ExtrusionCut_1_objects_1 = [model.selection("FACE", "Sketch_2/Face-SketchCircle_9_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_10_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_5_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_2_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_7_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_17_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_16_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_4_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_3_2f")] +ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, ExtrusionCut_1_objects_1, model.selection(), model.selection("FACE", "Revolution_1_1/Generated_Face_5"), 0, model.selection(), 0, [model.selection("SOLID", "Revolution_1_1")]) +ExtrusionCut_2_objects_1 = [model.selection("WIRE", "Sketch_2/Wire-SketchCircle_11_2f"), model.selection("WIRE", "Sketch_2/Wire-SketchCircle_12_2f"), model.selection("WIRE", "Sketch_2/Wire-SketchCircle_6_2f"), model.selection("WIRE", "Sketch_2/Wire-SketchCircle_8_2f")] +ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, ExtrusionCut_2_objects_1, model.selection(), 0, 0.75, [model.selection("SOLID", "ExtrusionCut_1_1")]) +Axis_4 = model.addAxis(Part_1_doc, 0, -1, -10) +ExtrusionCut_3 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_15_2f")], model.selection("EDGE", "Axis_1"), model.selection("FACE", "Revolution_1_1/Generated_Face_5"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_2_1")]) +ExtrusionCut_3.result().setDeflection(1e-005) +Sketch_3 = model.addSketch(Part_1_doc, model.standardPlane("XOZ")) +SketchLine_21 = Sketch_3.addLine(3.5, 2.508501119175777, 3.5, 4.934853156880259) +SketchLine_22 = Sketch_3.addLine(3.5, 4.934853156880259, 6.2, 4.934853156880259) +SketchConstraintCoincidence_49 = Sketch_3.setCoincident(SketchLine_21.endPoint(), SketchLine_22.startPoint()) +SketchLine_23 = Sketch_3.addLine(6.2, 4.934853156880259, 6.2, 3.008501119175777) +SketchConstraintCoincidence_50 = Sketch_3.setCoincident(SketchLine_22.endPoint(), SketchLine_23.startPoint()) +SketchProjection_6 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_3"), False) +SketchLine_24 = SketchProjection_6.createdFeature() +SketchConstraintCoincidence_51 = Sketch_3.setCoincident(SketchLine_23.endPoint(), SketchLine_24.result()) +SketchLine_25 = Sketch_3.addLine(6.2, 3.008501119175777, 3.5, 2.508501119175777) +SketchConstraintCoincidence_52 = Sketch_3.setCoincident(SketchLine_23.endPoint(), SketchLine_25.startPoint()) +SketchConstraintCoincidence_53 = Sketch_3.setCoincident(SketchLine_21.startPoint(), SketchLine_25.endPoint()) +SketchProjection_7 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_5"), False) +SketchLine_26 = SketchProjection_7.createdFeature() +SketchConstraintCoincidence_54 = Sketch_3.setCoincident(SketchLine_21.startPoint(), SketchLine_26.result()) +SketchConstraintCoincidence_55 = Sketch_3.setCoincident(SketchLine_21.endPoint(), SketchLine_26.result()) +SketchConstraintHorizontal_2 = Sketch_3.setHorizontal(SketchLine_22.result()) +SketchConstraintCoincidence_56 = Sketch_3.setCoincident(SketchLine_22.endPoint(), SketchLine_24.result()) +SketchProjection_8 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_4"), False) +SketchLine_27 = SketchProjection_8.createdFeature() +SketchConstraintParallel_1 = Sketch_3.setParallel(SketchLine_25.result(), SketchLine_27.result()) +SketchProjection_9 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_4"), False) +SketchLine_28 = SketchProjection_9.createdFeature() +SketchConstraintDistance_4 = Sketch_3.setDistance(SketchLine_21.startPoint(), SketchLine_28.result(), 0.5, True) +model.do() +Revolution_2 = model.addRevolution(Part_1_doc, [model.selection("COMPOUND", "Sketch_3")], model.selection("EDGE", "PartSet/OZ"), 360, 0) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_13_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_14_2f")], model.selection(), model.selection("FACE", "Revolution_1_1/Generated_Face_5"), 0, model.selection(), 0) +Boolean_1 = model.addCommon(Part_1_doc, [model.selection("SOLID", "Extrusion_1_2"), model.selection("SOLID", "Extrusion_1_1")], [model.selection("SOLID", "Revolution_2_1")]) +Boolean_2 = model.addCut(Part_1_doc, [model.selection("SOLID", "ExtrusionCut_3_1")], [model.selection("SOLID", "Boolean_1_1"), model.selection("SOLID", "Boolean_1_2")]) +# skip 3 vertices, limitation +Group_1_objects = [model.selection("VERTEX", "Revolution_1_1/Generated_Face_2&Boolean_2_1/Modified_Face_3"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&Revolution_1_1/Generated_Face_2"), model.selection("VERTEX", "ExtrusionCut_2_1/Vertex_5033"), model.selection("VERTEX", "ExtrusionCut_2_1/Vertex_5031"), model.selection("VERTEX", "ExtrusionCut_1_1/Lateral_5043"), model.selection("VERTEX", "ExtrusionCut_2_1/Modfied_5&ExtrusionCut_2_1/Modfied_6"), model.selection("VERTEX", "ExtrusionCut_1_1/Lateral_5069"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_8"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_6"), model.selection("VERTEX", "ExtrusionCut_1_1/Lateral_5082"), model.selection("VERTEX", "ExtrusionCut_2_1/Vertex_5024"), model.selection("VERTEX", "ExtrusionCut_2_1/Vertex_5022"), model.selection("VERTEX", "ExtrusionCut_2_1/Modfied_2&ExtrusionCut_2_1/Modfied_8"), model.selection("VERTEX", "Extrusion_1_2/Lateral_4"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_5"), model.selection("VERTEX", "Revolution_1_1/Generated_Face_4&ExtrusionCut_3_1/Modfied_2"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_2_1/Modfied_2"), model.selection("VERTEX", "Boolean_2_1/Modified_Face_2&Boolean_1_1/Modified_Face_1"), model.selection("VERTEX", "Revolution_1_1/Generated_Face_5&Revolution_1_1/Generated_Face_4"), model.selection("VERTEX", "ExtrusionCut_1_1/Lateral_5095"), model.selection("VERTEX", "ExtrusionCut_3_1/Lateral_5004"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_4"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_3_1/Modfied_3"), model.selection("VERTEX", "Extrusion_1_1/Lateral_4"), model.selection("VERTEX", "ExtrusionCut_2_1/Vertex_5006"), model.selection("VERTEX", "Boolean_2_1/Modified_Face_1&Boolean_1_2/Modified_Face_1"), model.selection("VERTEX", "ExtrusionCut_2_1/Vertex_5004"), model.selection("VERTEX", "ExtrusionCut_2_1/Modfied_4&ExtrusionCut_2_1/Modfied_12"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_2_1/Modfied_4"), model.selection("VERTEX", "ExtrusionCut_1_1/Lateral_5108"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_3"), model.selection("VERTEX", "ExtrusionCut_2_1/Vertex_5015"), model.selection("VERTEX", "ExtrusionCut_2_1/Vertex_5013"), model.selection("VERTEX", "ExtrusionCut_2_1/Modfied_3&ExtrusionCut_2_1/Modfied_10"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_2_1/Modfied_3")] +Group_1 = model.addGroup(Part_1_doc, Group_1_objects) +# skip 3 edges, limitation +Group_2_objects = [model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_2_1/Modfied_3"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_3"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_10&ExtrusionCut_2_1/Modfied_11"), model.selection("EDGE", "Boolean_2_1/Modified_Face_3&ExtrusionCut_2_1/Modfied_11"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_3&ExtrusionCut_2_1/Modfied_10"), model.selection("EDGE", "ExtrusionCut_2_1/Lateral_5011"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_3"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_3&Boolean_2_1/Modified_Face_3"), model.selection("EDGE", "Boolean_2_1/Modified_Face_1&Boolean_1_2/Modified_Face_1"), model.selection("EDGE", "Boolean_2_1/Modified_Face_3&Boolean_2_1/Modified_Face_1"), model.selection("EDGE", "Boolean_1_2/Modified_Edge_1"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_4"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_3"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_4"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_2_1/Modfied_4"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_4&ExtrusionCut_2_1/Modfied_12"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_12&ExtrusionCut_2_1/Modfied_13"), model.selection("EDGE", "Boolean_2_1/Modified_Face_3&ExtrusionCut_2_1/Modfied_13"), model.selection("EDGE", "ExtrusionCut_2_1/Lateral_5002"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_3_1/Modfied_3"), model.selection("EDGE", "Boolean_1_1/Modified_Edge_1"), model.selection("EDGE", "Boolean_2_1/Modified_Face_2&Boolean_1_1/Modified_Face_1"), model.selection("EDGE", "Boolean_2_1/Modified_Face_3&ExtrusionCut_2_1/Modfied_9"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&Revolution_1_1/Generated_Face_2"), model.selection("EDGE", "Boolean_2_1/Modified_Face_3&Boolean_2_1/Modified_Face_2"), model.selection("EDGE", "Revolution_1_1/Generated_Face_4&ExtrusionCut_3_1/Modfied_2"), model.selection("EDGE", "Revolution_1_1/Generated_Face_5&Revolution_1_1/Generated_Face_4"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_2_1/Modfied_2"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_8&ExtrusionCut_2_1/Modfied_9"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_2&ExtrusionCut_2_1/Modfied_8"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_4&Boolean_2_1/Modified_Face_3"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_4"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_3"), model.selection("EDGE", "Revolution_1_1/Generated_Face_2&Boolean_2_1/Modified_Face_3"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_3&Boolean_2_1/Modified_Face_3"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_5"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_6"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_6"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_5"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_5&Boolean_2_1/Modified_Face_3"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_6&Boolean_2_1/Modified_Face_3"), model.selection("EDGE", "Revolution_1_1/Generated_Face_4"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_6&ExtrusionCut_2_1/Modfied_7"), model.selection("EDGE", "Boolean_2_1/Modified_Face_3&ExtrusionCut_2_1/Modfied_7"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_5&ExtrusionCut_2_1/Modfied_6"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_5"), model.selection("EDGE", "Revolution_1_1/Generated_Face_2"), model.selection("EDGE", "ExtrusionCut_2_1/Lateral_5029"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_8"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_8"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_8&Boolean_2_1/Modified_Face_3"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_2"), model.selection("EDGE", "ExtrusionCut_2_1/Lateral_5020")] +Group_2 = model.addGroup(Part_1_doc, Group_2_objects) +Group_3_objects = [model.selection("FACE", "ExtrusionCut_2_1/Modfied_3"), model.selection("FACE", "ExtrusionCut_2_1/Modfied_11"), model.selection("FACE", "ExtrusionCut_2_1/Modfied_10"), model.selection("FACE", "ExtrusionCut_1_1/Modfied_3"), model.selection("FACE", "Boolean_1_2/Modified_Face_1"), model.selection("FACE", "ExtrusionCut_1_1/Modfied_4"), model.selection("FACE", "ExtrusionCut_2_1/Modfied_4"), model.selection("FACE", "ExtrusionCut_2_1/Modfied_12"), model.selection("FACE", "Boolean_1_1/Modified_Face_1"), model.selection("FACE", "Revolution_1_1/Generated_Face_5"), model.selection("FACE", "ExtrusionCut_2_1/Modfied_9"), model.selection("FACE", "Boolean_2_1/Modified_Face_3"), model.selection("FACE", "ExtrusionCut_2_1/Modfied_2"), model.selection("FACE", "ExtrusionCut_2_1/Modfied_8"), model.selection("FACE", "Boolean_2_1/Modified_Face_2"), model.selection("FACE", "ExtrusionCut_3_1/Modfied_2"), model.selection("FACE", "Revolution_1_1/Generated_Face_4"), model.selection("FACE", "ExtrusionCut_2_1/Modfied_13"), model.selection("FACE", "Boolean_2_1/Modified_Face_1"), model.selection("FACE", "Revolution_1_1/Generated_Face_2"), model.selection("FACE", "ExtrusionCut_3_1/Modfied_3"), model.selection("FACE", "ExtrusionCut_1_1/Modfied_5"), model.selection("FACE", "ExtrusionCut_1_1/Modfied_6"), model.selection("FACE", "ExtrusionCut_2_1/Modfied_5"), model.selection("FACE", "ExtrusionCut_2_1/Modfied_7"), model.selection("FACE", "ExtrusionCut_2_1/Modfied_6"), model.selection("FACE", "ExtrusionCut_1_1/Modfied_8")] +Group_3 = model.addGroup(Part_1_doc, Group_3_objects) +model.end() + +assert(model.checkPythonDump()) diff --git a/src/Model/Model_SelectionNaming.cpp b/src/Model/Model_SelectionNaming.cpp index fd7b72f13..be25462d9 100644 --- a/src/Model/Model_SelectionNaming.cpp +++ b/src/Model/Model_SelectionNaming.cpp @@ -256,6 +256,46 @@ const TopoDS_Shape findCommonShape( return aSharedShape; } +// searches theType shape that contains theConnectionType sub-shapes in each shape from the List, +// so, implements the neighbours searching +/* +const TopoDS_Shape findCommonShapeByNB(const TopAbs_ShapeEnum theType, + const TopAbs_ShapeEnum theConnectionType, const TopTools_ListOfShape& theList) +{ +TopTools_MapOfShape aCheckedShapes; // already checked shapes of type theType + TopoDS_Shape aResult; // theType result shape + for(TopTools_ListIteratorOfListOfShape anIt(theList); anIt.More(); anIt.Next()) { // iterate all + for(TopExp_Explorer anExp(anIt.ChangeValue(), theType); anExp.More(); anExp.Next()) { + if (aCheckedShapes.Contains(anExp.Current())) + continue; // already checked + aCheckedShapes.Add(anExp.Current()); + TopTools_MapOfShape aConnectors; // all connectors of the checked theType shape + for(TopExp_Explorer aCExp(anExp.Current(), theConnectionType); aCExp.More(); aCExp.Next()) { + aConnectors.Add(aCExp.Current()); + } + // check that all shapes from the List contain the connector sub-shapes + bool aFound = true; + for(TopTools_ListIteratorOfListOfShape anIt2(theList); anIt2.More() && aFound; anIt2.Next()) { + if (anIt2.Value().IsSame(anIt.Value())) + continue; + aFound = false; + for(TopExp_Explorer anE(anIt2.ChangeValue(), theConnectionType); anE.More(); anE.Next()) { + if (aConnectors.Contains(anE.Current())) { + aFound = true; + break; + } + } + } + if (aFound) { + if (!aResult.IsNull()) // more than one result + return TopoDS_Shape(); + aResult = anExp.Current(); + } + } + } + return aResult; +}*/ + std::string Model_SelectionNaming::vertexNameByEdges(TopoDS_Shape theContext, TopoDS_Shape theSub, std::shared_ptr theDoc, ResultPtr& theContextRes, const bool theAnotherDoc) { @@ -357,7 +397,7 @@ std::string Model_SelectionNaming::namingName(ResultPtr& theContext, } } else break; - TopTools_ListOfShape aListOfNbs; + TopTools_MapOfShape aNbs; if(!isTrivialCase) { // find Neighbors TNaming_Localizer aLocalizer; TopTools_MapOfShape aMap3; @@ -371,25 +411,25 @@ std::string Model_SelectionNaming::namingName(ResultPtr& theContext, TopTools_ListIteratorOfListOfShape it2(aList); for(;it2.More();it2.Next()) { if(aSMap.Contains(it2.Value())) continue; // skip this Face - aListOfNbs.Append(it2.Value()); + aNbs.Add(it2.Value()); } } } // else a trivial case // build name of the sub-shape Edge - for(int i=1; i <= aSMap.Extent(); i++) { - const TopoDS_Shape& aFace = aSMap.FindKey(i); + // iterate faces of the context to get stable order, not map-order + TopTools_MapOfShape aStoredFaces; // to avoid duplicates + for(TopExp_Explorer aContExp(aContext, TopAbs_FACE); aContExp.More(); aContExp.Next()) { + const TopoDS_Shape& aFace = aContExp.Current(); + if (aStoredFaces.Contains(aFace) || !(aSMap.Contains(aFace) || aNbs.Contains(aFace))) + continue; + aStoredFaces.Add(aFace); std::string aFaceName = getShapeName(aDoc, aFace, theContext, theAnotherDoc, false); - if(i == 1) + if(aName.empty()) aName = aFaceName; else aName += "&" + aFaceName; } - TopTools_ListIteratorOfListOfShape itl(aListOfNbs); - for (;itl.More();itl.Next()) { - std::string aFaceName = getShapeName(aDoc, itl.Value(), theContext, theAnotherDoc, false); - aName += "&" + aFaceName; - } } break; @@ -914,6 +954,9 @@ bool Model_SelectionNaming::selectSubShape(const std::string& theType, aList.Append(aFace); } aSelection = findCommonShape(aType, aList); + //if (aSelection.IsNull() && aType == TopAbs_EDGE) { // try to find selection by neighbours + // aSelection = findCommonShapeByNB(aType, TopAbs_VERTEX, aList); + //} } } // in case of construction, there is no registered names for all sub-elements,