theMainObjects,
theToolObjects));
}
+
+//==================================================================================================
+BooleanPtr addSmash(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const std::list<ModelHighAPI_Selection>& theMainObjects,
+ const std::list<ModelHighAPI_Selection>& theToolObjects)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID());
+ return BooleanPtr(new FeaturesAPI_Boolean(aFeature,
+ FeaturesPlugin_Boolean::BOOL_SMASH,
+ theMainObjects,
+ theToolObjects));
+}
+
+//==================================================================================================
+BooleanPtr addFill(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const std::list<ModelHighAPI_Selection>& theMainObjects,
+ const std::list<ModelHighAPI_Selection>& theToolObjects)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID());
+ return BooleanPtr(new FeaturesAPI_Boolean(aFeature,
+ FeaturesPlugin_Boolean::BOOL_FILL,
+ theMainObjects,
+ theToolObjects));
+}
const std::list<ModelHighAPI_Selection>& theMainObjects,
const std::list<ModelHighAPI_Selection>& theToolObjects);
+/// \ingroup CPPHighAPI
+/// \brief Create Boolean Smash feature.
+FEATURESAPI_EXPORT
+BooleanPtr addSmash(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const std::list<ModelHighAPI_Selection>& theMainObjects,
+ const std::list<ModelHighAPI_Selection>& theToolObjects);
+
+/// \ingroup CPPHighAPI
+/// \brief Create Boolean Fill feature.
+FEATURESAPI_EXPORT
+BooleanPtr addFill(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const std::list<ModelHighAPI_Selection>& theMainObjects,
+ const std::list<ModelHighAPI_Selection>& theToolObjects);
+
#endif // FeaturesAPI_Boolean_H_
TestBoolean.py
TestBooleanCompSolids.py
TestBooleanSmash.py
+ TestBooleanFill.py
TestMultiBoolean.py
TestSerialBoolean.py
TestGroup.py
--- /dev/null
+"""
+Test case for Boolean Fill feature. Written on High API.
+"""
+from ModelAPI import *
+from GeomAPI import *
+
+import model
+
+# Get session
+aSession = ModelAPI_Session.get()
+
+# Create a part
+aDocument = aSession.activeDocument()
+aSession.startOperation()
+model.addPart(aDocument)
+aDocument = aSession.activeDocument()
+aSession.finishOperation()
+
+# Create a sketch with circle to extrude
+aSession.startOperation()
+anOrigin = GeomAPI_Pnt(0, 0, 0)
+aDirX = GeomAPI_Dir(1, 0, 0)
+aNorm = GeomAPI_Dir(0, 0, 1)
+aCircleSketch = model.addSketch(aDocument, GeomAPI_Ax3(anOrigin, aDirX, aNorm))
+aCircleSketch.addCircle(0, 0, 50)
+aSession.finishOperation()
+
+# Create a sketch with triangle to extrude
+aSession.startOperation()
+aTriangleSketch = model.addSketch(aDocument, GeomAPI_Ax3(anOrigin, aDirX, aNorm))
+aTriangleSketch.addLine(25, 25, 100, 25)
+aTriangleSketch.addLine(100, 25, 60, 75)
+aTriangleSketch.addLine(60, 75, 25, 25)
+aSession.finishOperation()
+
+# Make extrusion on circle (cylinder) and triangle (prism)
+aSession.startOperation()
+anExtrusion = model.addExtrusion(aDocument, aCircleSketch.result() + aTriangleSketch.result(), 100)
+aSession.finishOperation()
+
+# Fill prism with cylinder
+aSession.startOperation()
+aBoolean = model.addFill(aDocument, [anExtrusion.result()[0]], [anExtrusion.result()[1]])
+assert (len(aBoolean.result()) > 0)
+aSession.finishOperation()
buttons_dir="horizontal"
label="Operation type"
tooltip="Type of boolean operation"
- string_list="Cut Fuse Common Smash"
+ string_list="Cut Fuse Common Fill Smash"
use_in_title="true"
- icons_list="icons/Features/bool_cut.png icons/Features/bool_fuse.png icons/Features/bool_common.png icons/Features/bool_smash.png"
+ icons_list="icons/Features/bool_cut.png icons/Features/bool_fuse.png icons/Features/bool_common.png icons/Features/bool_fill.png icons/Features/bool_smash.png"
default="0"
/>
<multi_selector id="main_objects"
if(theCombinedShapes.size() == 1 && theFreeShapes.size() == 0) {
aResult = theCombinedShapes.front();
- } else if (theCombinedShapes.size() > 1 || (theCombinedShapes.size() >= 1 && theFreeShapes.size() >= 1)) {
+ } else if(theCombinedShapes.size() == 0 && theFreeShapes.size() == 1) {
+ aResult = theFreeShapes.front();
+ } else {
TopoDS_Compound aResultComp;
TopoDS_Builder aBuilder;
aBuilder.MakeCompound(aResultComp);
aGroups.Append(aGroupedShapes);
}
- TopoDS_Compound aCompound;
- BRep_Builder aBuilder;
- aBuilder.MakeCompound(aCompound);
- ListOfShape aCompSolids, aFreeSolids;
- for(NCollection_Vector<NCollection_List<TopoDS_Shape>>::Iterator anIt(aGroups); anIt.More(); anIt.Next()) {
- NCollection_List<TopoDS_Shape> aGroup = anIt.Value();
+ if(aGroups.Size() == 1) {
+ NCollection_List<TopoDS_Shape> aGroup = aGroups.First();
GeomShapePtr aGeomShape(new GeomAPI_Shape());
- if(aGroup.Size() == 1) {
- aGeomShape->setImpl(new TopoDS_Shape(aGroup.First()));
- } else {
- aGeomShape->setImpl(new TopoDS_Shape(makeCompound(anIt.Value())));
- aGeomShape = GeomAlgoAPI_ShapeTools::combineShapes(aGeomShape,
- GeomAPI_Shape::COMPSOLID,
- aCompSolids,
- aFreeSolids);
+ aGeomShape->setImpl(new TopoDS_Shape(makeCompound(aGroup)));
+ ListOfShape aCompSolids, aFreeSolids;
+ aGeomShape = GeomAlgoAPI_ShapeTools::combineShapes(aGeomShape,
+ GeomAPI_Shape::COMPSOLID,
+ aCompSolids,
+ aFreeSolids);
+ aResult = aGeomShape;
+ } else {
+ TopoDS_Compound aCompound;
+ BRep_Builder aBuilder;
+ aBuilder.MakeCompound(aCompound);
+ ListOfShape aCompSolids, aFreeSolids;
+ for(NCollection_Vector<NCollection_List<TopoDS_Shape>>::Iterator anIt(aGroups); anIt.More(); anIt.Next()) {
+ NCollection_List<TopoDS_Shape> aGroup = anIt.Value();
+ GeomShapePtr aGeomShape(new GeomAPI_Shape());
+ if(aGroup.Size() == 1) {
+ aGeomShape->setImpl(new TopoDS_Shape(aGroup.First()));
+ } else {
+ aGeomShape->setImpl(new TopoDS_Shape(makeCompound(aGroup)));
+ aGeomShape = GeomAlgoAPI_ShapeTools::combineShapes(aGeomShape,
+ GeomAPI_Shape::COMPSOLID,
+ aCompSolids,
+ aFreeSolids);
+ }
+ aBuilder.Add(aCompound, aGeomShape->impl<TopoDS_Shape>());
}
- aBuilder.Add(aCompound, aGeomShape->impl<TopoDS_Shape>());
- }
- if(!aCompound.IsNull()) {
- aResult->setImpl(new TopoDS_Shape(aCompound));
+ if(!aCompound.IsNull()) {
+ aResult->setImpl(new TopoDS_Shape(aCompound));
+ }
}
return aResult;
from FeaturesAPI import addPlacement, addRotation, addTranslation
-from FeaturesAPI import addFuse, addCut, addCommon
+from FeaturesAPI import addCut, addFuse, addCommon, addSmash, addFill
from FeaturesAPI import addPartition