#include <GeomAPI_ShapeExplorer.h>
#include <GeomAPI_ShapeIterator.h>
+//==================================================================================================
+const int ModifyVTag = 1;
+const int ModifyETag = 2;
+const int ModifyFTag = 3;
+const int DeletedTag = 4;
+/// sub solids will be placed at labels 5, 6, etc. if result is compound of solids
+const int SubsolidsTag = 5;
+
+
//==================================================================================================
FeaturesPlugin_BooleanCut::FeaturesPlugin_BooleanCut()
: FeaturesPlugin_Boolean(FeaturesPlugin_Boolean::BOOL_CUT)
return;
}
+ std::vector<ResultBaseAlgo> aResultBaseAlgoList;
+ ListOfShape aResultShapesList;
+
// For solids cut each object with all tools.
for(ListOfShape::iterator anObjectsIt = anObjects.begin();
anObjectsIt != anObjects.end();
++anObjectsIt) {
std::shared_ptr<GeomAPI_Shape> anObject = *anObjectsIt;
- GeomAlgoAPI_MakeShapeList aMakeShapeList;
+ std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
std::shared_ptr<GeomAlgoAPI_Boolean> aCutAlgo(
new GeomAlgoAPI_Boolean(anObject,
aTools,
return;
}
- aMakeShapeList.appendAlgo(aCutAlgo);
+ aMakeShapeList->appendAlgo(aCutAlgo);
GeomAPI_ShapeIterator aShapeIt(aResShape);
if (aShapeIt.more() || aResShape->shapeType() == GeomAPI_Shape::VERTEX)
document()->createBody(data(), aResultIndex);
loadNamingDS(aResultBody, anObject, aTools, aResShape,
- aMakeShapeList, *(aCutAlgo->mapOfSubShapes()),
+ *aMakeShapeList, *(aCutAlgo->mapOfSubShapes()),
false);
setResult(aResultBody, aResultIndex);
aResultIndex++;
+
+ ResultBaseAlgo aRBA;
+ aRBA.resultBody = aResultBody;
+ aRBA.baseShape = anObject;
+ aRBA.makeShape = aMakeShapeList;
+ aResultBaseAlgoList.push_back(aRBA);
+ aResultShapesList.push_back(aResShape);
}
}
}
}
- GeomAlgoAPI_MakeShapeList aMakeShapeList;
+ std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
std::shared_ptr<GeomAlgoAPI_Boolean> aCutAlgo(
new GeomAlgoAPI_Boolean(aUsedInOperationSolids,
aTools,
return;
}
- aMakeShapeList.appendAlgo(aCutAlgo);
+ aMakeShapeList->appendAlgo(aCutAlgo);
GeomAPI_DataMapOfShapeShape aMapOfShapes;
aMapOfShapes.merge(aCutAlgo->mapOfSubShapes());
GeomShapePtr aResultShape = aCutAlgo->shape();
return;
}
- aMakeShapeList.appendAlgo(aFillerAlgo);
+ aMakeShapeList->appendAlgo(aFillerAlgo);
aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes());
aResultShape = aFillerAlgo->shape();
}
aCompSolid,
aTools,
aResultShape,
- aMakeShapeList,
+ *aMakeShapeList,
aMapOfShapes,
false);
setResult(aResultBody, aResultIndex);
aResultIndex++;
+
+ ResultBaseAlgo aRBA;
+ aRBA.resultBody = aResultBody;
+ aRBA.baseShape = aCompSolid;
+ aRBA.makeShape = aMakeShapeList;
+ aResultBaseAlgoList.push_back(aRBA);
+ aResultShapesList.push_back(aResultShape);
}
}
}
}
- GeomAlgoAPI_MakeShapeList aMakeShapeList;
+ std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
std::shared_ptr<GeomAlgoAPI_Boolean> aCutAlgo(
new GeomAlgoAPI_Boolean(aUsedInOperationShapes,
aTools,
return;
}
- aMakeShapeList.appendAlgo(aCutAlgo);
+ aMakeShapeList->appendAlgo(aCutAlgo);
GeomAPI_DataMapOfShapeShape aMapOfShapes;
aMapOfShapes.merge(aCutAlgo->mapOfSubShapes());
GeomShapePtr aResultShape = aCutAlgo->shape();
aCompound,
aTools,
aResultShape,
- aMakeShapeList,
+ *aMakeShapeList,
aMapOfShapes,
false);
setResult(aResultBody, aResultIndex);
aResultIndex++;
+
+ ResultBaseAlgo aRBA;
+ aRBA.resultBody = aResultBody;
+ aRBA.baseShape = aCompound;
+ aRBA.makeShape = aMakeShapeList;
+ aResultBaseAlgoList.push_back(aRBA);
+ aResultShapesList.push_back(aResultShape);
}
}
+ // Store deleted shapes after all results has been proceeded. This is to avoid issue when in one
+ // result shape has been deleted, but in another it was modified or stayed.
+ GeomShapePtr aResultShapesCompound = GeomAlgoAPI_CompoundBuilder::compound(aResultShapesList);
+ storeDeletedShapes(aResultBaseAlgoList, aTools, aResultShapesCompound);
+
// remove the rest results if there were produced in the previous pass
removeResults(aResultIndex);
}
if(theBaseShape->isEqual(theResultShape)) {
theResultBody->store(theResultShape, false);
} else {
- const int aModifyVTag = 1;
- const int aModifyETag = 2;
- const int aModifyFTag = 3;
- const int aDeletedTag = 4;
- /// sub solids will be placed at labels 5, 6, etc. if result is compound of solids
- const int aSubsolidsTag = 5;
-
- theResultBody->storeModified(theBaseShape, theResultShape, aSubsolidsTag);
+ theResultBody->storeModified(theBaseShape, theResultShape, SubsolidsTag);
const std::string aModVName = "Modified_Vertex";
const std::string aModEName = "Modified_Edge";
const std::string aModFName = "Modified_Face";
theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::VERTEX,
- aModifyVTag, aModVName, theMapOfShapes, false,
+ ModifyVTag, aModVName, theMapOfShapes, false,
theIsStoreAsGenerated, true);
theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::EDGE,
- aModifyETag, aModEName, theMapOfShapes, false,
+ ModifyETag, aModEName, theMapOfShapes, false,
theIsStoreAsGenerated, true);
theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::FACE,
- aModifyFTag, aModFName, theMapOfShapes, false,
+ ModifyFTag, aModFName, theMapOfShapes, false,
theIsStoreAsGenerated, true);
- theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape,
- GeomAPI_Shape::VERTEX, aDeletedTag);
- theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape,
- GeomAPI_Shape::EDGE, aDeletedTag);
- theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape,
- GeomAPI_Shape::FACE, aDeletedTag);
-
for (ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++)
{
theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::VERTEX,
- aModifyVTag, aModVName, theMapOfShapes, false,
+ ModifyVTag, aModVName, theMapOfShapes, false,
theIsStoreAsGenerated, true);
theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::EDGE,
- aModifyETag, aModEName, theMapOfShapes, false,
+ ModifyETag, aModEName, theMapOfShapes, false,
theIsStoreAsGenerated, true);
theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE,
- aModifyFTag, aModFName, theMapOfShapes, false,
+ ModifyFTag, aModFName, theMapOfShapes, false,
theIsStoreAsGenerated, true);
+ }
+ }
+}
+
+//==================================================================================================
+void FeaturesPlugin_BooleanCut::storeDeletedShapes(
+ std::vector<ResultBaseAlgo>& theResultBaseAlgoList,
+ const ListOfShape& theTools,
+ const GeomShapePtr theResultShapesCompound)
+{
+ for (std::vector<ResultBaseAlgo>::iterator anIt = theResultBaseAlgoList.begin();
+ anIt != theResultBaseAlgoList.end();
+ ++anIt)
+ {
+ ResultBaseAlgo& aRCA = *anIt;
+ aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(),
+ aRCA.baseShape,
+ GeomAPI_Shape::VERTEX,
+ DeletedTag,
+ theResultShapesCompound);
+ aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(),
+ aRCA.baseShape,
+ GeomAPI_Shape::EDGE,
+ DeletedTag,
+ theResultShapesCompound);
+ aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(),
+ aRCA.baseShape,
+ GeomAPI_Shape::FACE,
+ DeletedTag,
+ theResultShapesCompound);
- theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::VERTEX, aDeletedTag);
- theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::EDGE, aDeletedTag);
- theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE, aDeletedTag);
+ for (ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++)
+ {
+ aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(),
+ *anIter,
+ GeomAPI_Shape::VERTEX,
+ DeletedTag,
+ theResultShapesCompound);
+ aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(),
+ *anIter,
+ GeomAPI_Shape::EDGE,
+ DeletedTag,
+ theResultShapesCompound);
+ aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(),
+ *anIter,
+ GeomAPI_Shape::FACE,
+ DeletedTag,
+ theResultShapesCompound);
}
}
}
--- /dev/null
+## 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<mailto: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()
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchLine_1 = Sketch_1.addLine(-53.93497380447579, 58.11303515552675, 60.01215395145899, 58.11303515552675)
+SketchLine_2 = Sketch_1.addLine(60.01215395145899, 58.11303515552675, 60.01215395145899, 11.01488901640705)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+model.do()
+Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchLine_3 = Sketch_2.addLine(31.90519577166173, 58.11303515552675, 60.012153951459, 58.11303515552675)
+SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), False)
+SketchLine_4 = SketchProjection_1.createdFeature()
+SketchConstraintCoincidence_2 = Sketch_2.setCoincident(SketchLine_3.startPoint(), SketchLine_4.result())
+SketchConstraintCoincidence_3 = Sketch_2.setCoincident(SketchAPI_Line(SketchLine_4).endPoint(), SketchLine_3.endPoint())
+SketchLine_5 = Sketch_2.addLine(60.012153951459, 58.11303515552675, 60.012153951459, 33.0446670492211)
+SketchConstraintCoincidence_4 = Sketch_2.setCoincident(SketchLine_3.endPoint(), SketchLine_5.startPoint())
+SketchProjection_2 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_2"), False)
+SketchLine_6 = SketchProjection_2.createdFeature()
+SketchConstraintCoincidence_5 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_6.result())
+model.do()
+Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_2")])
+Edge_2 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchLine_3"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_5")])
+Cut_1 = model.addCut(Part_1_doc, [model.selection("EDGE", "Edge_1_1"), model.selection("EDGE", "Edge_1_2")], [model.selection("EDGE", "Edge_2_1"), model.selection("EDGE", "Edge_2_2")])
+model.testHaveNamingSubshapes(Cut_1, model, Part_1_doc)
+model.do()
+model.end()
+
+from GeomAPI import GeomAPI_Shape
+
+model.testNbResults(Cut_1, 2)
+model.testNbSubResults(Cut_1, [0, 0])
+model.testNbSubShapes(Cut_1, GeomAPI_Shape.SOLID, [0, 0])
+model.testNbSubShapes(Cut_1, GeomAPI_Shape.FACE, [0, 0])
+model.testNbSubShapes(Cut_1, GeomAPI_Shape.EDGE, [1, 1])
+model.testNbSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [2, 2])
+
+assert(model.checkPythonDump())