// Keep only the shapes with minimal shape type
static void keepTopLevelShapes(ListOfShape& theShapes, const TopoDS_Shape& theRoot,
- const GeomShapePtr& theResultShape)
+ const GeomShapePtr& theResultShape = GeomShapePtr())
{
GeomAPI_Shape::ShapeType aKeepShapeType = GeomAPI_Shape::SHAPE;
ListOfShape::iterator anIt = theShapes.begin();
while (anIt != theShapes.end()) {
TopoDS_Shape aNewShape = (*anIt)->impl<TopoDS_Shape>();
- GeomShapePtr aGeomNewShape(new GeomAPI_Shape());
- aGeomNewShape->setImpl(new TopoDS_Shape(aNewShape));
- if (theRoot.IsSame(aNewShape) || !theResultShape->isSubShape(aGeomNewShape, false) ||
- theResultShape->isSame(*anIt))
- {
+ if (theRoot.IsSame(aNewShape) || (theResultShape &&
+ (!theResultShape->isSubShape(*anIt, false) || theResultShape->isSame(*anIt)))) {
ListOfShape::iterator aRemoveIt = anIt++;
theShapes.erase(aRemoveIt);
} else {
int aBuilderTag = aTag;
if (!theIsStoreSeparate)
aSameParentShapes++;
+
+ static const int THE_ANCHOR_TAG = 100000;
+ int aCurShapeType = (int)((*anIt)->shapeType());
+ bool needSuffix = false; // suffix for the name based on the shape type
if (aSameParentShapes > 0) { // store in other label
- aBuilderTag = 100000 - aSameParentShapes * 10 - aTag;
+ aBuilderTag = THE_ANCHOR_TAG - aSameParentShapes * 10 - aCurShapeType;
+ needSuffix = true;
+ } else if (aCurShapeType != theKindOfShape) {
+ // modified shape has different type => set another tag
+ // to avoid shapes of different types on the same label
+ aBuilderTag = THE_ANCHOR_TAG - aCurShapeType;
+ needSuffix = true;
+ }
+ std::string aSuffix;
+ if (needSuffix) {
+ switch (aCurShapeType) {
+ case GeomAPI_Shape::VERTEX: aSuffix = "_v"; break;
+ case GeomAPI_Shape::EDGE: aSuffix = "_e"; break;
+ case GeomAPI_Shape::FACE: aSuffix = "_f"; break;
+ default: break;
+ }
}
+
if(theIsStoreAsGenerated) {
// Here we store shapes as generated, to avoid problem when one parent shape produce
// several child shapes. In this case naming could not determine which shape to select.
builder(aBuilderTag)->Modify(aRoot, aNewShape);
}
if(isBuilt) {
- if(theIsStoreSeparate) {
- aStream.str(std::string());
- aStream.clear();
- aStream << theName << "_" << anIndex++;
- aName = aStream.str();
- }
+ aStream.str(std::string());
+ aStream.clear();
+ aStream << theName;
+ if(theIsStoreSeparate)
+ aStream << "_" << anIndex++;
+
if (aSameParentShapes > 0) {
aStream.str(std::string());
aStream.clear();
aStream << aName << "_" << aSameParentShapes << "divided";
- std::string aNameDiv = aStream.str();
- buildName(aBuilderTag, aNameDiv);
- } else {
- buildName(aBuilderTag, aName);
}
+
+ aStream << aSuffix;
+ buildName(aBuilderTag, aStream.str());
}
if(theIsStoreSeparate) {
aTag++;
TopTools_MapOfShape aView;
bool isBuilt = !theName.empty();
TopExp_Explorer aShapeExplorer (aShapeIn, (TopAbs_ShapeEnum)theKindOfShape);
- GeomShapePtr aResultShape = shape();
for (; aShapeExplorer.More(); aShapeExplorer.Next ()) {
const TopoDS_Shape& aRoot = aShapeExplorer.Current ();
if (!aView.Add(aRoot)) continue;
std::shared_ptr<GeomAPI_Shape> aRShape(new GeomAPI_Shape());
aRShape->setImpl((new TopoDS_Shape(aRoot)));
theMS->generated(aRShape, aList);
- keepTopLevelShapes(aList, aRoot, aResultShape);
+ keepTopLevelShapes(aList, aRoot);
std::list<std::shared_ptr<GeomAPI_Shape> >::const_iterator
anIt = aList.begin(), aLast = aList.end();
for (; anIt != aLast; anIt++) {
assert(ModelAPI.ModelAPI_Session.get().validators().validate(Sketch_4.feature()))
assert(ModelAPI.ModelAPI_Session.get().validators().validate(ExtrusionCut_2.feature()))
-assert(Sketch_3.feature().selection("External").namingName() == "ExtrusionCut_3_1/Modfied_3")
+assert(Sketch_3.feature().selection("External").namingName() == "ExtrusionCut_3_1/Modfied_5")
assert(model.checkPythonDump())
SketchLine_77 = Sketch_10.addLine(64, 20, 89, 20)
SketchLine_77.setName("SketchLine_76")
SketchLine_77.result().setName("SketchLine_76")
-SketchPoint_4 = Sketch_10.addPoint(model.selection("VERTEX", "RevolutionFuse_2_1/Modfied_9&RevolutionFuse_2_1/Modfied_12&RevolutionFuse_3_1/Modfied_12&RevolutionFuse_3_1/Modfied_1divided_1"))
+SketchPoint_4 = Sketch_10.addPoint(model.selection("VERTEX", "RevolutionFuse_2_1/Modfied_9&RevolutionFuse_2_1/Modfied_12&RevolutionFuse_3_1/Modfied_12&RevolutionFuse_3_1/Modfied_1divided_f_1"))
SketchConstraintCoincidence_122 = Sketch_10.setCoincident(SketchLine_77.startPoint(), SketchPoint_4.result())
SketchConstraintCoincidence_122.setName("SketchConstraintCoincidence_120")
SketchPoint_5 = Sketch_10.addPoint(model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1s-SketchLine_8e-SketchLine_4e"))
SketchLine_78 = Sketch_10.addLine(64, -20, 89, -20)
SketchLine_78.setName("SketchLine_77")
SketchLine_78.result().setName("SketchLine_77")
-SketchPoint_6 = Sketch_10.addPoint(model.selection("VERTEX", "RevolutionFuse_1_1/Modfied_4&RevolutionFuse_1_1/Modfied_10&RevolutionFuse_3_1/Modfied_13&RevolutionFuse_3_1/Modfied_1divided_2"))
+SketchPoint_6 = Sketch_10.addPoint(model.selection("VERTEX", "RevolutionFuse_1_1/Modfied_4&RevolutionFuse_1_1/Modfied_10&RevolutionFuse_3_1/Modfied_13&RevolutionFuse_3_1/Modfied_1divided_f_2"))
SketchConstraintCoincidence_124 = Sketch_10.setCoincident(SketchLine_78.startPoint(), SketchPoint_6.result())
SketchConstraintCoincidence_124.setName("SketchConstraintCoincidence_122")
SketchPoint_7 = Sketch_10.addPoint(model.selection("VERTEX", "ExtrusionFuse_2_1/Modfied_3&RevolutionFuse_1_1/Modfied_4&ExtrusionFuse_2_1/Modfied_4&RevolutionFuse_3_1/Modfied_13"))
SketchConstraintCoincidence_129.setName("SketchConstraintCoincidence_127")
SketchConstraintTangent_19 = Sketch_10.setTangent(SketchArc_11.results()[1], SketchLine_78.result())
SketchConstraintTangent_19.setName("SketchConstraintTangent_24")
-SketchPoint_8 = Sketch_10.addPoint(model.selection("VERTEX", "RevolutionFuse_3_1/Modfied_7&RevolutionFuse_3_1/Modfied_1divided_2&ExtrusionCut_2_1/Modfied_4&RevolutionFuse_3_1/Modfied_3divided_1&RevolutionFuse_3_1/Modfied_15"))
+SketchPoint_8 = Sketch_10.addPoint(model.selection("VERTEX", "RevolutionFuse_1_1/Modfied_10&RevolutionFuse_3_1/Modfied_7&RevolutionFuse_3_1/Modfied_1divided_f_2"))
SketchConstraintCoincidence_130 = Sketch_10.setCoincident(SketchArc_11.endPoint(), SketchPoint_8.result())
SketchConstraintCoincidence_130.setName("SketchConstraintCoincidence_128")
SketchArc_12 = Sketch_10.addArc(64.00001789135865, 23.01137360115889, 64, 20, 61.15622559702543, 22.02080994708722, True)
SketchConstraintCoincidence_131.setName("SketchConstraintCoincidence_129")
SketchConstraintTangent_20 = Sketch_10.setTangent(SketchArc_12.results()[1], SketchLine_77.result())
SketchConstraintTangent_20.setName("SketchConstraintTangent_25")
-SketchPoint_9 = Sketch_10.addPoint(model.selection("VERTEX", "RevolutionFuse_3_1/Modfied_4&RevolutionFuse_3_1/Modfied_1divided_1&ExtrusionCut_2_1/Modfied_4&RevolutionFuse_3_1/Modfied_1divided_5&RevolutionFuse_3_1/Modfied_15"))
+SketchPoint_9 = Sketch_10.addPoint(model.selection("VERTEX", "RevolutionFuse_2_1/Modfied_12&RevolutionFuse_3_1/Modfied_4&RevolutionFuse_3_1/Modfied_1divided_f_1"))
SketchConstraintCoincidence_132 = Sketch_10.setCoincident(SketchArc_12.endPoint(), SketchPoint_9.result())
SketchConstraintCoincidence_132.setName("SketchConstraintCoincidence_130")
SketchLine_79 = Sketch_10.addLine(61.15622559702543, 22.02080994708722, 59.81204392543111, 22.0208099470871)
# Test reexecution after parameter change
Parameter_R.setValue(5)
model.do()
-model.testResultsVolumes(ExtrusionCut_4, [502615.944655187719035893678665161])
+model.testResultsVolumes(ExtrusionCut_4, [502616.749082866765093058347702026])
Parameter_R.setValue(3)
model.end()
model.testNbSubResults(ExtrusionCut_4, [0])
model.testNbSubShapes(ExtrusionCut_4, GeomAPI_Shape.SOLID, [1])
model.testNbSubShapes(ExtrusionCut_4, GeomAPI_Shape.FACE, [81])
-model.testNbSubShapes(ExtrusionCut_4, GeomAPI_Shape.EDGE, [406])
-model.testNbSubShapes(ExtrusionCut_4, GeomAPI_Shape.VERTEX, [812])
-model.testResultsVolumes(ExtrusionCut_4, [502902.431481667619664222002029419])
+model.testNbSubShapes(ExtrusionCut_4, GeomAPI_Shape.EDGE, [410])
+model.testNbSubShapes(ExtrusionCut_4, GeomAPI_Shape.VERTEX, [820])
+model.testResultsVolumes(ExtrusionCut_4, [502903.236060981987975537776947021])
assert(model.checkPythonDump())
SketchLine_56.result().setName("SketchLine_58")
model.do()
ExtrusionFuse_1 = model.addExtrusionFuse(Part_1_doc, [model.selection("COMPOUND", "Sketch_6")], model.selection(), model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_7f-SketchArc_1_2f-SketchLine_8f-SketchLine_9f-SketchLine_10r-SketchLine_11r-SketchLine_12r-SketchLine_14r-SketchArc_2_2r"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_5_1")])
-Sketch_7 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_2_1/Modfied_1divided_3"))
+Sketch_7 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_2_1/Modfied_9"))
SketchLine_64 = Sketch_7.addLine(50.25000000000001, -4.5, 31.24999999998802, -4.499999999999997)
SketchLine_64.setName("SketchLine_76")
SketchLine_64.result().setName("SketchLine_76")
SketchLine_162.result().setName("SketchLine_58")
model.do()
ExtrusionFuse_2 = model.addExtrusionFuse(Part_2_doc, [model.selection("COMPOUND", "Sketch_6")], model.selection(), model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_7f-SketchArc_1_2f-SketchLine_8f-SketchLine_9f-SketchLine_10r-SketchLine_11r-SketchLine_12r-SketchLine_14r-SketchArc_2_2r"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_5_1")])
-Sketch_17 = model.addSketch(Part_2_doc, model.selection("FACE", "ExtrusionCut_2_1/Modfied_1divided_3"))
+Sketch_17 = model.addSketch(Part_2_doc, model.selection("FACE", "ExtrusionCut_2_1/Modfied_9"))
SketchLine_170 = Sketch_17.addLine(50.25000000000001, -4.5, 31.24999999998802, -4.499999999999997)
SketchLine_170.setName("SketchLine_76")
SketchLine_170.result().setName("SketchLine_76")