From 3cb0f0c093faddfc03aadb9091164f3d1555034d Mon Sep 17 00:00:00 2001 From: dbv Date: Tue, 7 Feb 2017 14:21:29 +0300 Subject: [PATCH] Issue #2023: Crash during a rotation after an intersection Fixed infinite loop in namig for Translation, Rotation, Placement --- src/FeaturesPlugin/CMakeLists.txt | 1 + .../FeaturesPlugin_Placement.cpp | 3 +- .../FeaturesPlugin_Rotation.cpp | 3 +- src/FeaturesPlugin/FeaturesPlugin_Tools.cpp | 22 ++++++---- src/FeaturesPlugin/FeaturesPlugin_Tools.h | 4 +- .../FeaturesPlugin_Translation.cpp | 3 +- src/FeaturesPlugin/Test/Test2023.py | 41 +++++++++++++++++++ 7 files changed, 62 insertions(+), 15 deletions(-) create mode 100644 src/FeaturesPlugin/Test/Test2023.py diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt index cf821fd9e..d63df3b66 100644 --- a/src/FeaturesPlugin/CMakeLists.txt +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -143,4 +143,5 @@ ADD_UNIT_TESTS(TestExtrusion.py Test1922.py Test1942.py Test1915.py + Test2023.py ) diff --git a/src/FeaturesPlugin/FeaturesPlugin_Placement.cpp b/src/FeaturesPlugin/FeaturesPlugin_Placement.cpp index c28d769d0..0039d750d 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Placement.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Placement.cpp @@ -193,11 +193,10 @@ void FeaturesPlugin_Placement::loadNamingDS(GeomAlgoAPI_Transform& theTransformA //load result theResultBody->storeModified(theBaseShape, theTransformAlgo.shape()); - int aPlacedTag = 1; std::string aPlacedName = "Placed"; std::shared_ptr aSubShapes = theTransformAlgo.mapOfSubShapes(); FeaturesPlugin_Tools::storeModifiedShapes(theTransformAlgo, theResultBody, - theBaseShape, aPlacedTag, aPlacedName, + theBaseShape, 1, 2, 3, aPlacedName, *aSubShapes.get()); } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp b/src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp index 9ba830b83..16028546c 100755 --- a/src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp @@ -128,11 +128,10 @@ void FeaturesPlugin_Rotation::loadNamingDS(GeomAlgoAPI_Rotation& theRotaionAlgo, // Store result. theResultBody->storeModified(theBaseShape, theRotaionAlgo.shape()); - int aRotatedTag = 1; std::string aRotatedName = "Rotated"; std::shared_ptr aSubShapes = theRotaionAlgo.mapOfSubShapes(); FeaturesPlugin_Tools::storeModifiedShapes(theRotaionAlgo, theResultBody, - theBaseShape, aRotatedTag, aRotatedName, + theBaseShape, 1, 2, 3, aRotatedName, *aSubShapes.get()); } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Tools.cpp b/src/FeaturesPlugin/FeaturesPlugin_Tools.cpp index 847a8916f..89f5870b2 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Tools.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Tools.cpp @@ -13,7 +13,9 @@ void FeaturesPlugin_Tools::storeModifiedShapes(GeomAlgoAPI_MakeShape& theAlgo, std::shared_ptr theResultBody, std::shared_ptr theBaseShape, - int& theTag, + const int theFaceTag, + const int theEdgeTag, + const int theVertexTag, const std::string theName, GeomAPI_DataMapOfShapeShape& theSubShapes) { @@ -21,7 +23,14 @@ void FeaturesPlugin_Tools::storeModifiedShapes(GeomAlgoAPI_MakeShape& theAlgo, case GeomAPI_Shape::COMPOUND: { for(GeomAPI_ShapeIterator anIt(theBaseShape); anIt.more(); anIt.next()) { - storeModifiedShapes(theAlgo, theResultBody, theBaseShape, theTag, theName, theSubShapes); + storeModifiedShapes(theAlgo, + theResultBody, + anIt.current(), + theFaceTag, + theEdgeTag, + theVertexTag, + theName, + theSubShapes); } break; } @@ -30,25 +39,22 @@ void FeaturesPlugin_Tools::storeModifiedShapes(GeomAlgoAPI_MakeShape& theAlgo, case GeomAPI_Shape::SHELL: { theResultBody->loadAndOrientModifiedShapes(&theAlgo, theBaseShape, GeomAPI_Shape::FACE, - theTag, theName + "_Face", theSubShapes); + theFaceTag, theName + "_Face", theSubShapes); if (theBaseShape->shapeType() == GeomAPI_Shape::COMPSOLID || theBaseShape->shapeType() == GeomAPI_Shape::SOLID) { break; } - ++theTag; } case GeomAPI_Shape::FACE: case GeomAPI_Shape::WIRE: { theResultBody->loadAndOrientModifiedShapes(&theAlgo, theBaseShape, GeomAPI_Shape::EDGE, - theTag, theName + "_Edge", theSubShapes); - ++theTag; + theEdgeTag, theName + "_Edge", theSubShapes); } case GeomAPI_Shape::EDGE: { theResultBody->loadAndOrientModifiedShapes(&theAlgo, theBaseShape, GeomAPI_Shape::VERTEX, - theTag, theName + "_Vertex", theSubShapes); - ++theTag; + theVertexTag, theName + "_Vertex", theSubShapes); } } } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Tools.h b/src/FeaturesPlugin/FeaturesPlugin_Tools.h index c6cd120db..3ba38561e 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Tools.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Tools.h @@ -16,7 +16,9 @@ public: static void storeModifiedShapes(GeomAlgoAPI_MakeShape& theAlgo, std::shared_ptr theResultBody, std::shared_ptr theBaseShape, - int& theTag, + const int theFaceTag, + const int theEdgeTag, + const int theVertexTag, const std::string theName, GeomAPI_DataMapOfShapeShape& theSubShapes); }; diff --git a/src/FeaturesPlugin/FeaturesPlugin_Translation.cpp b/src/FeaturesPlugin/FeaturesPlugin_Translation.cpp index 4e7dcef66..34e5bd112 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Translation.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Translation.cpp @@ -356,11 +356,10 @@ void FeaturesPlugin_Translation::loadNamingDS(GeomAlgoAPI_Translation& theTransl // Store result. theResultBody->storeModified(theBaseShape, theTranslationAlgo.shape()); - int aTranslatedTag = 1; std::string aTranslatedName = "Translated"; std::shared_ptr aSubShapes = theTranslationAlgo.mapOfSubShapes(); FeaturesPlugin_Tools::storeModifiedShapes(theTranslationAlgo, theResultBody, - theBaseShape, aTranslatedTag, aTranslatedName, + theBaseShape, 1, 2, 3, aTranslatedName, *aSubShapes.get()); } diff --git a/src/FeaturesPlugin/Test/Test2023.py b/src/FeaturesPlugin/Test/Test2023.py new file mode 100644 index 000000000..953a4e590 --- /dev/null +++ b/src/FeaturesPlugin/Test/Test2023.py @@ -0,0 +1,41 @@ +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(178.3876500857632, 167.2384219554031, -133.7907375643225, 167.2384219554031) +SketchLine_2 = Sketch_1.addLine(-133.7907375643225, 167.2384219554031, -133.7907375643225, -134.6483704974271) +SketchLine_3 = Sketch_1.addLine(-133.7907375643225, -134.6483704974271, 178.3876500857632, -134.6483704974271) +SketchLine_4 = Sketch_1.addLine(178.3876500857632, -134.6483704974271, 178.3876500857632, 167.2384219554031) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint()) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result()) +SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result()) +SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result()) +SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result()) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f-SketchLine_4f")], model.selection(), 100, 0) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face_1")) +SketchLine_5 = Sketch_2.addLine(99.48542024013722, 69.46826758147516, -34.30531732418524, 69.46826758147516) +SketchLine_6 = Sketch_2.addLine(-34.30531732418524, 69.46826758147516, -34.30531732418524, -62.60720411663805) +SketchLine_7 = Sketch_2.addLine(-34.30531732418524, -62.60720411663805, 99.48542024013722, -62.60720411663805) +SketchLine_8 = Sketch_2.addLine(99.48542024013722, -62.60720411663805, 99.48542024013722, 69.46826758147516) +SketchConstraintCoincidence_5 = Sketch_2.setCoincident(SketchLine_8.endPoint(), SketchLine_5.startPoint()) +SketchConstraintCoincidence_6 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint()) +SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint()) +SketchConstraintCoincidence_8 = Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint()) +SketchConstraintHorizontal_3 = Sketch_2.setHorizontal(SketchLine_5.result()) +SketchConstraintVertical_3 = Sketch_2.setVertical(SketchLine_6.result()) +SketchConstraintHorizontal_4 = Sketch_2.setHorizontal(SketchLine_7.result()) +SketchConstraintVertical_4 = Sketch_2.setVertical(SketchLine_8.result()) +model.do() +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_8f")], model.selection(), 10, 110) +Intersection_1 = model.addIntersection(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], [model.selection("SOLID", "Extrusion_2_1")]) +Rotation_1 = model.addRotation(Part_1_doc, [model.selection("COMPOUND", "Intersection_1_1")], model.selection("EDGE", "PartSet/OZ"), 45) +model.end() + +assert(model.checkPythonDump()) -- 2.39.2