Group_2 = model.addGroup(Part_1_doc, Group_2_objects)
Group_3_objects = [model.selection("EDGE", "[Box_1_1/Back][Box_1_1/Bottom]"), model.selection("EDGE", "[Box_1_1/Back][Box_1_1/Right]"), model.selection("EDGE", "[Box_1_1/Back][Box_1_1/Left]"), model.selection("EDGE", "[Box_1_1/Back][Box_1_1/Top]"), model.selection("EDGE", "[Box_1_1/Right][Box_1_1/Bottom]"), model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Top]"), model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Bottom]"), model.selection("EDGE", "[Box_1_1/Right][Box_1_1/Top]"), model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Bottom]"), model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Left]"), model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Right]"), model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Top]")]
Group_3 = model.addGroup(Part_1_doc, Group_3_objects)
-Axis_4 = model.addAxis(Part_1_doc, model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Left][Box_1_1/Bottom]"), model.selection("VERTEX", "[Box_1_1/Front][Box_1_1/Right][Box_1_1/Top]"))
-LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "Axis_1"), 10, 2)
+LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "PartSet/OX"), 15, 2)
model.do()
# move groups to the end
Part_1_doc.moveFeature(Group_1.feature(), LinearCopy_1.feature())
from ModelAPI import *
aFactory = ModelAPI_Session.get().validators()
-# check group 1: full compound should be selected
+# check group 1: all solids in compound should be selected
selectionList = Group_1.feature().selectionList("group_list")
-assert(selectionList.size() == 1)
+assert(selectionList.size() == 2)
assert(aFactory.validate(Group_1.feature()))
# check group 2: number of faces is multiplied twice than original
selectionList = Group_2.feature().selectionList("group_list")
assert(selectionList.size() == 24)
assert(aFactory.validate(Group_3.feature()))
+model.begin()
+LinearCopy_2 = model.addMultiTranslation(Part_1_doc, [model.selection("COMPOUND", "LinearCopy_1_1")], model.selection("EDGE", "PartSet/OY"), 15, 2, model.selection("EDGE", "PartSet/OZ"), 15, 2)
+# move groups to the end
+Part_1_doc.moveFeature(Group_1.feature(), LinearCopy_2.feature())
+Part_1_doc.moveFeature(Group_2.feature(), Group_1.feature())
+Part_1_doc.moveFeature(Group_3.feature(), Group_2.feature())
+model.end()
+
+# check group 1: all solids in compound should be selected
+selectionList = Group_1.feature().selectionList("group_list")
+assert(selectionList.size() == 8)
+assert(aFactory.validate(Group_1.feature()))
+# check group 2: number of faces is multiplied twice than original
+selectionList = Group_2.feature().selectionList("group_list")
+assert(selectionList.size() == 48)
+assert(aFactory.validate(Group_2.feature()))
+# check group 3: number of edges is multiplied twice than original
+selectionList = Group_3.feature().selectionList("group_list")
+assert(selectionList.size() == 96)
+assert(aFactory.validate(Group_3.feature()))
+
+model.begin()
+AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "LinearCopy_2_1_1_1"), model.selection("SOLID", "LinearCopy_2_1_1_2")], model.selection("EDGE", "PartSet/OZ"), 2)
+# move groups to the end
+Part_1_doc.moveFeature(Group_1.feature(), AngularCopy_1.feature())
+Part_1_doc.moveFeature(Group_2.feature(), Group_1.feature())
+Part_1_doc.moveFeature(Group_3.feature(), Group_2.feature())
+model.end()
+
+# check group 1: all solids in compound should be selected
+selectionList = Group_1.feature().selectionList("group_list")
+assert(selectionList.size() == 4)
+assert(aFactory.validate(Group_1.feature()))
+# check group 2: number of faces is multiplied twice than original
+selectionList = Group_2.feature().selectionList("group_list")
+assert(selectionList.size() == 24)
+assert(aFactory.validate(Group_2.feature()))
+# check group 3: number of edges is multiplied twice than original
+selectionList = Group_3.feature().selectionList("group_list")
+assert(selectionList.size() == 48)
+assert(aFactory.validate(Group_3.feature()))
+
assert(model.checkPythonDump())
// Author: Clarisse Genrault (CEA)
#include <FeaturesPlugin_MultiRotation.h>
+#include <FeaturesPlugin_Tools.h>
#include <GeomAlgoAPI_CompoundBuilder.h>
+#include <GeomAlgoAPI_MakeShapeList.h>
#include <GeomAlgoAPI_ShapeTools.h>
#include <GeomAlgoAPI_Tools.h>
#include <GeomAlgoAPI_Translation.h>
} else {
std::string anError;
ListOfShape aListOfShape;
- std::list<std::shared_ptr<GeomAlgoAPI_Rotation> > aListOfRotationAlgo;
+ std::shared_ptr<GeomAlgoAPI_MakeShapeList>
+ aListOfRotationAlgo(new GeomAlgoAPI_MakeShapeList);
for (int i=0; i<nbCopies; i++) {
std::shared_ptr<GeomAlgoAPI_Rotation> aRotationnAlgo(
break;
}
aListOfShape.push_back(aRotationnAlgo->shape());
- aListOfRotationAlgo.push_back(aRotationnAlgo);
+ aListOfRotationAlgo->appendAlgo(aRotationnAlgo);
}
std::shared_ptr<GeomAPI_Shape> aCompound =
GeomAlgoAPI_CompoundBuilder::compound(aListOfShape);
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
- aResultBody->storeModified(aBaseShape, aCompound);
- loadNamingDS(aListOfRotationAlgo, aResultBody, aBaseShape);
+
+ ListOfShape aBaseShapes;
+ aBaseShapes.push_back(aBaseShape);
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShapes, ListOfShape(),
+ aListOfRotationAlgo, aCompound, "Rotated");
setResult(aResultBody, aResultIndex);
}
//
#include <FeaturesPlugin_MultiTranslation.h>
+#include <FeaturesPlugin_Tools.h>
#include <GeomAlgoAPI_CompoundBuilder.h>
+#include <GeomAlgoAPI_MakeShapeList.h>
#include <GeomAlgoAPI_Tools.h>
#include <GeomAPI_Ax1.h>
} else {
std::string anError;
ListOfShape aListOfShape;
- std::list<std::shared_ptr<GeomAlgoAPI_Translation> > aListOfTranslationAlgo;
+ std::shared_ptr<GeomAlgoAPI_MakeShapeList>
+ aListOfTranslationAlgo(new GeomAlgoAPI_MakeShapeList);
for (int i=0; i<nbCopies; i++) {
std::shared_ptr<GeomAlgoAPI_Translation> aTranslationAlgo(
break;
}
aListOfShape.push_back(aTranslationAlgo->shape());
- aListOfTranslationAlgo.push_back(aTranslationAlgo);
+ aListOfTranslationAlgo->appendAlgo(aTranslationAlgo);
}
std::shared_ptr<GeomAPI_Shape> aCompound =
GeomAlgoAPI_CompoundBuilder::compound(aListOfShape);
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
- aResultBody->storeModified(aBaseShape, aCompound);
- loadNamingDS(aListOfTranslationAlgo, aResultBody, aBaseShape);
+
+ ListOfShape aBaseShapes;
+ aBaseShapes.push_back(aBaseShape);
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShapes, ListOfShape(),
+ aListOfTranslationAlgo, aCompound, "Translated");
setResult(aResultBody, aResultIndex);
}
} else {
std::string anError;
ListOfShape aListOfShape;
- std::list<std::shared_ptr<GeomAlgoAPI_Translation> > aListOfTranslationAlgo;
+ std::shared_ptr<GeomAlgoAPI_MakeShapeList>
+ aListOfTranslationAlgo(new GeomAlgoAPI_MakeShapeList);
for (int j=0; j<aSecondNbCopies; j++) {
for (int i=0; i<aFirstNbCopies; i++) {
break;
}
aListOfShape.push_back(aTranslationAlgo->shape());
- aListOfTranslationAlgo.push_back(aTranslationAlgo);
+ aListOfTranslationAlgo->appendAlgo(aTranslationAlgo);
}
}
std::shared_ptr<GeomAPI_Shape> aCompound =
GeomAlgoAPI_CompoundBuilder::compound(aListOfShape);
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
- aResultBody->storeModified(aBaseShape, aCompound);
- loadNamingDS(aListOfTranslationAlgo, aResultBody, aBaseShape);
+
+ ListOfShape aBaseShapes;
+ aBaseShapes.push_back(aBaseShape);
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShapes, ListOfShape(),
+ aListOfTranslationAlgo, aCompound, "Translated");
+
setResult(aResultBody, aResultIndex);
}
aResultIndex++;
// Remove the rest results if there were produced in the previous pass.
removeResults(aResultIndex);
}
-
-//=================================================================================================
-void FeaturesPlugin_MultiTranslation::loadNamingDS(
- std::list<std::shared_ptr<GeomAlgoAPI_Translation> > theListOfTranslationAlgo,
- std::shared_ptr<ModelAPI_ResultBody> theResultBody,
- std::shared_ptr<GeomAPI_Shape> theBaseShape)
-{
- for (std::list<std::shared_ptr<GeomAlgoAPI_Translation> >::const_iterator anIt =
- theListOfTranslationAlgo.begin(); anIt != theListOfTranslationAlgo.cend(); ++anIt) {
- // naming of faces
- theResultBody->loadModifiedShapes(*anIt,
- theBaseShape,
- GeomAPI_Shape::FACE,
- "Translated_Face");
-
- // naming of edges
- theResultBody->loadModifiedShapes(*anIt,
- theBaseShape,
- GeomAPI_Shape::EDGE,
- "Translated_Edge");
-
- // naming of vertex
- theResultBody->loadModifiedShapes(*anIt,
- theBaseShape,
- GeomAPI_Shape::VERTEX,
- "Translated_Vertex");
- }
-}
/// Perform the multi translation in two directions.
void performTwoDirection();
-
- void loadNamingDS(std::list<std::shared_ptr<GeomAlgoAPI_Translation> > theListOfTranslationAlgo,
- std::shared_ptr<ModelAPI_ResultBody> theResultBody,
- std::shared_ptr<GeomAPI_Shape> theBaseShape);
};
#endif // FEATURESPLUGIN_MULTITRANSLATION_H_
\ No newline at end of file
const ListOfShape& theBaseShapes,
const ListOfShape& theTools,
const GeomMakeShapePtr& theMakeShape,
- const GeomShapePtr theResultShape)
+ const GeomShapePtr theResultShape,
+ const std::string& theNamePrefix)
{
theResultBody->storeModified(theBaseShapes, theResultShape, theMakeShape);
for(; aToolIter != theTools.cend(); aToolIter++)
aShapes.push_back(*aToolIter);
+ std::string aVertexName, anEdgeName, aFaceName;
+ if (!theNamePrefix.empty()) {
+ aVertexName = theNamePrefix + "_Vertex";
+ anEdgeName = theNamePrefix + "_Edge";
+ aFaceName = theNamePrefix + "_Face";
+ }
+
for (ListOfShape::const_iterator anIter = aShapes.begin(); anIter != aShapes.end(); ++anIter)
{
- theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::VERTEX);
- theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::EDGE);
- theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::FACE);
+ theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::VERTEX, aVertexName);
+ theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::EDGE, anEdgeName);
+ theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::FACE, aFaceName);
}
}
const ListOfShape& theBaseShapes,
const ListOfShape& theTools,
const GeomMakeShapePtr& theMakeShape,
- const GeomShapePtr theResultShape);
+ const GeomShapePtr theResultShape,
+ const std::string& theNamePrefix = "");
static void loadModifiedShapes(ResultBodyPtr theResultBody,
const GeomShapePtr& theBaseShape,