From b93f6a44447398f38d365bd632c48cab5235319b Mon Sep 17 00:00:00 2001 From: dbv Date: Fri, 26 Feb 2016 16:36:40 +0300 Subject: [PATCH] Changed "From" and "To" face naming in Extrusion and Revolution --- .../FeaturesPlugin_CompositeBoolean.cpp | 12 +++++++-- .../FeaturesPlugin_CompositeSketch.cpp | 10 +++++-- .../FeaturesPlugin_Extrusion.cpp | 12 +++++++-- .../FeaturesPlugin_Revolution.cpp | 12 +++++++-- src/FeaturesPlugin/Test/TestGroup.py | 26 +++++++++---------- src/FeaturesPlugin/Test/TestPlacement.py | 16 ++++++------ src/PythonAPI/examples/MakeBrick1.py | 2 +- src/PythonAPI/examples/MakeBrick2.py | 2 +- src/PythonAPI/examples/Platine.py | 2 +- 9 files changed, 62 insertions(+), 32 deletions(-) diff --git a/src/FeaturesPlugin/FeaturesPlugin_CompositeBoolean.cpp b/src/FeaturesPlugin/FeaturesPlugin_CompositeBoolean.cpp index b47952c5d..48c4f08d0 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_CompositeBoolean.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_CompositeBoolean.cpp @@ -23,6 +23,8 @@ #include #include +#include + //================================================================================================= void FeaturesPlugin_CompositeBoolean::initAttributes() { @@ -417,16 +419,20 @@ void FeaturesPlugin_CompositeBoolean::loadNamingDS(std::shared_ptr aSweepAlgo = std::dynamic_pointer_cast(aSolidAlgo); if(aSweepAlgo.get()) { //Insert to faces + int aToFaceIndex = 1; const ListOfShape& aToFaces = aSweepAlgo->toFaces(); for(ListOfShape::const_iterator anIt = aToFaces.cbegin(); anIt != aToFaces.cend(); anIt++) { std::shared_ptr aToFace = *anIt; if(aSubShapes->isBound(aToFace)) { aToFace = aSubShapes->find(aToFace); } - theResultBody->generated(aToFace, aToName, aToTag++); + std::ostringstream aStr; + aStr << aToName << "_" << aToFaceIndex++; + theResultBody->generated(aToFace, aStr.str(), aToTag++); } //Insert from faces + int aFromFaceIndex = 1; const ListOfShape& aFromFaces = aSweepAlgo->fromFaces(); if (aFromTag < aToTag) aFromTag = aToTag; for(ListOfShape::const_iterator anIt = aFromFaces.cbegin(); anIt != aFromFaces.cend(); anIt++) { @@ -434,7 +440,9 @@ void FeaturesPlugin_CompositeBoolean::loadNamingDS(std::shared_ptrisBound(aFromFace)) { aFromFace = aSubShapes->find(aFromFace); } - theResultBody->generated(aFromFace, aFromName, aFromTag++); + std::ostringstream aStr; + aStr << aFromName << "_" << aFromFaceIndex++; + theResultBody->generated(aFromFace, aStr.str(), aFromTag++); } } } diff --git a/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp b/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp index 3f95c49e8..901433c99 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp @@ -182,6 +182,7 @@ void FeaturesPlugin_CompositeSketch::loadNamingDS(std::shared_ptr aSweepAlgo = std::dynamic_pointer_cast(theMakeShape); if(aSweepAlgo.get()) { //Insert to faces + int aToFaceIndex = 1; const std::string aToName = "ToFace"; int aToTag = 2; const ListOfShape& aToFaces = aSweepAlgo->toFaces(); @@ -190,10 +191,13 @@ void FeaturesPlugin_CompositeSketch::loadNamingDS(std::shared_ptrisBound(aToFace)) { aToFace = aDataMap->find(aToFace); } - theResultBody->generated(aToFace, aToName, aToTag++); + std::ostringstream aStr; + aStr << aToName << "_" << aToFaceIndex++; + theResultBody->generated(aToFace, aStr.str(), aToTag++); } //Insert from faces + int aFromFaceIndex = 1; const std::string aFromName = "FromFace"; int aFromTag = aToTag > 10000 ? aToTag : 10000; const ListOfShape& aFromFaces = aSweepAlgo->fromFaces(); @@ -202,7 +206,9 @@ void FeaturesPlugin_CompositeSketch::loadNamingDS(std::shared_ptrisBound(aFromFace)) { aFromFace = aDataMap->find(aFromFace); } - theResultBody->generated(aFromFace, aFromName, aFromTag++); + std::ostringstream aStr; + aStr << aFromName << "_" << aFromFaceIndex++; + theResultBody->generated(aFromFace, aStr.str(), aFromTag++); } } } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp index c0bcd77f3..535eb2fdd 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp @@ -19,6 +19,8 @@ #include #include +#include + //================================================================================================= FeaturesPlugin_Extrusion::FeaturesPlugin_Extrusion() { @@ -173,6 +175,7 @@ void FeaturesPlugin_Extrusion::loadNamingDS(GeomAlgoAPI_Prism& thePrismAlgo, theResultBody->loadAndOrientGeneratedShapes(&thePrismAlgo, theBasis, GeomAPI_Shape::EDGE, aLatTag, aLatName, *aSubShapes); //Insert to faces + int aToFaceIndex = 1; const std::string aToName = "ToFace"; int aToTag = 2; const ListOfShape& aToFaces = thePrismAlgo.toFaces(); @@ -181,10 +184,13 @@ void FeaturesPlugin_Extrusion::loadNamingDS(GeomAlgoAPI_Prism& thePrismAlgo, if(aSubShapes->isBound(aToFace)) { aToFace = aSubShapes->find(aToFace); } - theResultBody->generated(aToFace, aToName, aToTag++); + std::ostringstream aStr; + aStr << aToName << "_" << aToFaceIndex++; + theResultBody->generated(aToFace, aStr.str(), aToTag++); } //Insert from faces + int aFromFaceIndex = 1; const std::string aFromName = "FromFace"; int aFromTag = aToTag > 10000 ? aToTag : 10000; const ListOfShape& aFromFaces = thePrismAlgo.fromFaces(); @@ -193,6 +199,8 @@ void FeaturesPlugin_Extrusion::loadNamingDS(GeomAlgoAPI_Prism& thePrismAlgo, if(aSubShapes->isBound(aFromFace)) { aFromFace = aSubShapes->find(aFromFace); } - theResultBody->generated(aFromFace, aFromName, aFromTag++); + std::ostringstream aStr; + aStr << aFromName << "_" << aFromFaceIndex++; + theResultBody->generated(aFromFace, aStr.str(), aFromTag++); } } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp b/src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp index 6d2c233d6..c6fc2ed5c 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp @@ -20,6 +20,8 @@ #include #include +#include + //================================================================================================= FeaturesPlugin_Revolution::FeaturesPlugin_Revolution() { @@ -189,6 +191,7 @@ void FeaturesPlugin_Revolution::loadNamingDS(GeomAlgoAPI_Revolution& theRevolAlg theResultBody->loadAndOrientGeneratedShapes(&theRevolAlgo, theBasis, GeomAPI_Shape::EDGE, aLatTag, aLatName, *aSubShapes); //Insert to faces + int aToFaceIndex = 1; const std::string aToName = "ToFace"; int aToTag = 2; const ListOfShape& aToFaces = theRevolAlgo.toFaces(); @@ -197,10 +200,13 @@ void FeaturesPlugin_Revolution::loadNamingDS(GeomAlgoAPI_Revolution& theRevolAlg if(aSubShapes->isBound(aToFace)) { aToFace = aSubShapes->find(aToFace); } - theResultBody->generated(aToFace, aToName, aToTag++); + std::ostringstream aStr; + aStr << aToName << "_" << aToFaceIndex++; + theResultBody->generated(aToFace, aStr.str(), aToTag++); } //Insert from faces + int aFromFaceIndex = 1; const std::string aFromName = "FromFace"; int aFromTag = aToTag > 10000 ? aToTag : 10000; const ListOfShape& aFromFaces = theRevolAlgo.fromFaces(); @@ -209,6 +215,8 @@ void FeaturesPlugin_Revolution::loadNamingDS(GeomAlgoAPI_Revolution& theRevolAlg if(aSubShapes->isBound(aFromFace)) { aFromFace = aSubShapes->find(aFromFace); } - theResultBody->generated(aFromFace, aFromName, aFromTag++); + std::ostringstream aStr; + aStr << aFromName << "_" << aFromFaceIndex++; + theResultBody->generated(aFromFace, aStr.str(), aFromTag++); } } diff --git a/src/FeaturesPlugin/Test/TestGroup.py b/src/FeaturesPlugin/Test/TestGroup.py index e57ed3bce..34adc5240 100644 --- a/src/FeaturesPlugin/Test/TestGroup.py +++ b/src/FeaturesPlugin/Test/TestGroup.py @@ -78,12 +78,12 @@ aSession.startOperation() aGroupFeature = aSession.activeDocument().addFeature("Group") aSelectionListAttr = aGroupFeature.selectionList("group_list") aSelectionListAttr.setSelectionType("vertex") -aSelectionListAttr.append("Extrusion_1_1/LateralFace_3&Extrusion_1_1/LateralFace_1&Extrusion_1_1/ToFace_1") -aSelectionListAttr.append("Extrusion_1_1/LateralFace_3&Extrusion_1_1/LateralFace_2&Extrusion_1_1/ToFace_1") -aSelectionListAttr.append("Extrusion_1_1/LateralFace_2&Extrusion_1_1/LateralFace_1&Extrusion_1_1/ToFace_1") -aSelectionListAttr.append("Extrusion_1_1/LateralFace_3&Extrusion_1_1/LateralFace_1&Extrusion_1_1/FromFace_1") -aSelectionListAttr.append("Extrusion_1_1/LateralFace_3&Extrusion_1_1/LateralFace_2&Extrusion_1_1/FromFace_1") -aSelectionListAttr.append("Extrusion_1_1/LateralFace_2&Extrusion_1_1/LateralFace_1&Extrusion_1_1/FromFace_1") +aSelectionListAttr.append("Extrusion_1_1/LateralFace_3&Extrusion_1_1/LateralFace_1&Extrusion_1_1/ToFace_1_1") +aSelectionListAttr.append("Extrusion_1_1/LateralFace_3&Extrusion_1_1/LateralFace_2&Extrusion_1_1/ToFace_1_1") +aSelectionListAttr.append("Extrusion_1_1/LateralFace_2&Extrusion_1_1/LateralFace_1&Extrusion_1_1/ToFace_1_1") +aSelectionListAttr.append("Extrusion_1_1/LateralFace_3&Extrusion_1_1/LateralFace_1&Extrusion_1_1/FromFace_1_1") +aSelectionListAttr.append("Extrusion_1_1/LateralFace_3&Extrusion_1_1/LateralFace_2&Extrusion_1_1/FromFace_1_1") +aSelectionListAttr.append("Extrusion_1_1/LateralFace_2&Extrusion_1_1/LateralFace_1&Extrusion_1_1/FromFace_1_1") aSession.finishOperation() #========================================================================= # Check results @@ -101,12 +101,12 @@ aSelectionListAttr.setSelectionType("edge") aSelectionListAttr.append("Extrusion_1_1/LateralFace_2&Extrusion_1_1/LateralFace_1") aSelectionListAttr.append("Extrusion_1_1/LateralFace_3&Extrusion_1_1/LateralFace_2") aSelectionListAttr.append("Extrusion_1_1/LateralFace_3&Extrusion_1_1/LateralFace_1") -aSelectionListAttr.append("Extrusion_1_1/LateralFace_3&Extrusion_1_1/FromFace_1") -aSelectionListAttr.append("Extrusion_1_1/LateralFace_1&Extrusion_1_1/ToFace_1") -aSelectionListAttr.append("Extrusion_1_1/LateralFace_1&Extrusion_1_1/FromFace_1") -aSelectionListAttr.append("Extrusion_1_1/LateralFace_2&Extrusion_1_1/ToFace_1") -aSelectionListAttr.append("Extrusion_1_1/LateralFace_2&Extrusion_1_1/FromFace_1") -aSelectionListAttr.append("Extrusion_1_1/LateralFace_3&Extrusion_1_1/ToFace_1") +aSelectionListAttr.append("Extrusion_1_1/LateralFace_3&Extrusion_1_1/FromFace_1_1") +aSelectionListAttr.append("Extrusion_1_1/LateralFace_1&Extrusion_1_1/ToFace_1_1") +aSelectionListAttr.append("Extrusion_1_1/LateralFace_1&Extrusion_1_1/FromFace_1_1") +aSelectionListAttr.append("Extrusion_1_1/LateralFace_2&Extrusion_1_1/ToFace_1_1") +aSelectionListAttr.append("Extrusion_1_1/LateralFace_2&Extrusion_1_1/FromFace_1_1") +aSelectionListAttr.append("Extrusion_1_1/LateralFace_3&Extrusion_1_1/ToFace_1_1") aSession.finishOperation() #========================================================================= # Check results @@ -155,7 +155,7 @@ aSession.startOperation() aGroupFeature = aSession.activeDocument().addFeature("Group") aSelectionListAttr = aGroupFeature.selectionList("group_list") aSelectionListAttr.setSelectionType("face") -aSelectionListAttr.append("Extrusion_1_1/ToFace_1") +aSelectionListAttr.append("Extrusion_1_1/ToFace_1_1") aSession.finishOperation() #========================================================================= # Check results diff --git a/src/FeaturesPlugin/Test/TestPlacement.py b/src/FeaturesPlugin/Test/TestPlacement.py index 4b85903a4..47790a2cb 100644 --- a/src/FeaturesPlugin/Test/TestPlacement.py +++ b/src/FeaturesPlugin/Test/TestPlacement.py @@ -131,7 +131,7 @@ aSession.startOperation() aPlacementFt = aPart.addFeature("Placement") aPlacementFt.selectionList("placement_objects_list").append(anExtrusionResult, anExtrusionResult.shape()) aPlacementFt.selection("placement_start_shape").selectSubShape("face", "Extrusion_1_1/LateralFace_1") -aPlacementFt.selection("placement_end_shape").selectSubShape("edge", "Extrusion_1_2/ToFace_1&Extrusion_1_2/LateralFace_3") +aPlacementFt.selection("placement_end_shape").selectSubShape("edge", "Extrusion_1_2/ToFace_1_1&Extrusion_1_2/LateralFace_3") aPlacementFt.boolean("placement_reverse_direction").setValue(False) aPlacementFt.boolean("placement_centering").setValue(True) aPlacementFt.execute() @@ -150,7 +150,7 @@ aSession.startOperation() aPlacementFt = aPart.addFeature("Placement") aPlacementFt.selectionList("placement_objects_list").append(anExtrusionResult, anExtrusionResult.shape()) aPlacementFt.selection("placement_start_shape").selectSubShape("face", "Extrusion_1_1/LateralFace_1") -aPlacementFt.selection("placement_end_shape").selectSubShape("vertex", "Extrusion_1_2/ToFace_1&Extrusion_1_2/LateralFace_3&Extrusion_1_2/LateralFace_2") +aPlacementFt.selection("placement_end_shape").selectSubShape("vertex", "Extrusion_1_2/ToFace_1_1&Extrusion_1_2/LateralFace_3&Extrusion_1_2/LateralFace_2") aPlacementFt.boolean("placement_reverse_direction").setValue(False) aPlacementFt.boolean("placement_centering").setValue(True) aPlacementFt.execute() @@ -168,8 +168,8 @@ aSession.undo() aSession.startOperation() aPlacementFt = aPart.addFeature("Placement") aPlacementFt.selectionList("placement_objects_list").append(anExtrusionResult, anExtrusionResult.shape()) -aPlacementFt.selection("placement_start_shape").selectSubShape("edge", "Extrusion_1_1/ToFace_1&Extrusion_1_1/LateralFace_1") -aPlacementFt.selection("placement_end_shape").selectSubShape("edge", "Extrusion_1_2/ToFace_1&Extrusion_1_2/LateralFace_3") +aPlacementFt.selection("placement_start_shape").selectSubShape("edge", "Extrusion_1_1/ToFace_1_1&Extrusion_1_1/LateralFace_1") +aPlacementFt.selection("placement_end_shape").selectSubShape("edge", "Extrusion_1_2/ToFace_1_1&Extrusion_1_2/LateralFace_3") aPlacementFt.boolean("placement_reverse_direction").setValue(False) aPlacementFt.boolean("placement_centering").setValue(True) aPlacementFt.execute() @@ -187,8 +187,8 @@ aSession.undo() aSession.startOperation() aPlacementFt = aPart.addFeature("Placement") aPlacementFt.selectionList("placement_objects_list").append(anExtrusionResult, anExtrusionResult.shape()) -aPlacementFt.selection("placement_start_shape").selectSubShape("edge", "Extrusion_1_1/ToFace_1&Extrusion_1_1/LateralFace_1") -aPlacementFt.selection("placement_end_shape").selectSubShape("vertex", "Extrusion_1_2/ToFace_1&Extrusion_1_2/LateralFace_3&Extrusion_1_2/LateralFace_2") +aPlacementFt.selection("placement_start_shape").selectSubShape("edge", "Extrusion_1_1/ToFace_1_1&Extrusion_1_1/LateralFace_1") +aPlacementFt.selection("placement_end_shape").selectSubShape("vertex", "Extrusion_1_2/ToFace_1_1&Extrusion_1_2/LateralFace_3&Extrusion_1_2/LateralFace_2") aPlacementFt.boolean("placement_reverse_direction").setValue(False) aPlacementFt.boolean("placement_centering").setValue(True) aPlacementFt.execute() @@ -206,8 +206,8 @@ aSession.undo() aSession.startOperation() aPlacementFt = aPart.addFeature("Placement") aPlacementFt.selectionList("placement_objects_list").append(anExtrusionResult, anExtrusionResult.shape()) -aPlacementFt.selection("placement_start_shape").selectSubShape("vertex", "Extrusion_1_1/LateralFace_4&Extrusion_1_1/FromFace_1&Extrusion_1_1/LateralFace_1") -aPlacementFt.selection("placement_end_shape").selectSubShape("vertex", "Extrusion_1_2/ToFace_1&Extrusion_1_2/LateralFace_3&Extrusion_1_2/LateralFace_2") +aPlacementFt.selection("placement_start_shape").selectSubShape("vertex", "Extrusion_1_1/LateralFace_4&Extrusion_1_1/FromFace_1_1&Extrusion_1_1/LateralFace_1") +aPlacementFt.selection("placement_end_shape").selectSubShape("vertex", "Extrusion_1_2/ToFace_1_1&Extrusion_1_2/LateralFace_3&Extrusion_1_2/LateralFace_2") aPlacementFt.boolean("placement_reverse_direction").setValue(False) aPlacementFt.boolean("placement_centering").setValue(True) aPlacementFt.execute() diff --git a/src/PythonAPI/examples/MakeBrick1.py b/src/PythonAPI/examples/MakeBrick1.py index 3f7d6fbbc..b698f0a50 100644 --- a/src/PythonAPI/examples/MakeBrick1.py +++ b/src/PythonAPI/examples/MakeBrick1.py @@ -48,7 +48,7 @@ thisface = "Extrusion_1_1/LateralFace_2" thisxmin = "Extrusion_1_1/LateralFace_3&Extrusion_1_1/LateralFace_2" thisxmax = "Extrusion_1_1/LateralFace_2&Extrusion_1_1/LateralFace_1" thiszmin = "Sketch_1/Edge5_1" -thiszmax = "Extrusion_1_1/LateralFace_2&Extrusion_1_1/ToFace_1" +thiszmax = "Extrusion_1_1/LateralFace_2&Extrusion_1_1/ToFace_1_1" mystand = model.addSketch(mypart, thisface) diff --git a/src/PythonAPI/examples/MakeBrick2.py b/src/PythonAPI/examples/MakeBrick2.py index 55cc29bbc..03c07c4ee 100644 --- a/src/PythonAPI/examples/MakeBrick2.py +++ b/src/PythonAPI/examples/MakeBrick2.py @@ -45,7 +45,7 @@ mybox = model.addExtrusion(mypart, mybase.selectFace(), 50) thisface = "Extrusion_1_1/LateralFace_2" thisxmin = "Extrusion_1_1/LateralFace_3&Extrusion_1_1/LateralFace_2" -thiszmax = "Extrusion_1_1/LateralFace_2&Extrusion_1_1/ToFace_1" +thiszmax = "Extrusion_1_1/LateralFace_2&Extrusion_1_1/ToFace_1_1" mystand = model.addSketch(mypart, thisface) circle = mystand.addCircle(0, 25, 5) diff --git a/src/PythonAPI/examples/Platine.py b/src/PythonAPI/examples/Platine.py index 4d136f952..47d7bf30d 100644 --- a/src/PythonAPI/examples/Platine.py +++ b/src/PythonAPI/examples/Platine.py @@ -87,7 +87,7 @@ def bottom_body(): sketch.setCoincident(arc.endPoint(), h1.startPoint()) # Binding - left_e = sketch.addLine("Extrusion_1_1/LateralFace_4&Extrusion_1_1/ToFace_1") + left_e = sketch.addLine("Extrusion_1_1/LateralFace_4&Extrusion_1_1/ToFace_1_1") sketch.setCoincident(left_e.startPoint(), left.endPoint()) sketch.setCoincident(left_e.endPoint(), left.startPoint()) -- 2.39.2