Boolean Fuse operation now allow to fuse edges and faces with solids.
return;
GeomAlgoAPI_Boolean::OperationType aType = (GeomAlgoAPI_Boolean::OperationType)aTypeAttr->value();
- ListOfShape anObjects, aTools;
+ ListOfShape anObjects, aTools, anEdgesAndFaces;
std::map<std::shared_ptr<GeomAPI_Shape>, ListOfShape> aCompSolidsObjects;
// Getting objects.
aCompSolidsObjects[aContextShape].push_back(anObject);
}
} else {
- anObjects.push_back(anObject);
+ if(anObject->shapeType() == GeomAPI_Shape::EDGE ||
+ anObject->shapeType() == GeomAPI_Shape::FACE) {
+ anEdgesAndFaces.push_back(anObject);
+ } else {
+ anObjects.push_back(anObject);
+ }
}
}
if(!aTool.get()) {
return;
}
- aTools.push_back(aTool);
+ if(aTool->shapeType() == GeomAPI_Shape::EDGE ||
+ aTool->shapeType() == GeomAPI_Shape::FACE) {
+ anEdgesAndFaces.push_back(aTool);
+ } else {
+ aTools.push_back(aTool);
+ }
}
int aResultIndex = 0;
break;
}
case GeomAlgoAPI_Boolean::BOOL_FUSE: {
- if((anObjects.size() + aTools.size() + aCompSolidsObjects.size()) < 2) {
+ if((anObjects.size() + aTools.size() + aCompSolidsObjects.size() + anEdgesAndFaces.size()) < 2) {
std::string aFeatureError = "Not enough objects for boolean operation";
setError(aFeatureError);
return;
aSolidsToFuse.insert(aSolidsToFuse.end(), anObjects.begin(), anObjects.end());
aSolidsToFuse.insert(aSolidsToFuse.end(), aTools.begin(), aTools.end());
- // Collecting solids from compsolids which will not be modified in boolean operation.
- ListOfShape aNotUsedSolids;
+ // Collecting solids from compsolids which will not be modified in boolean operation and will be added to result.
+ ListOfShape aShapesToAdd;
for(std::map<std::shared_ptr<GeomAPI_Shape>, ListOfShape>::iterator anIt = aCompSolidsObjects.begin();
anIt != aCompSolidsObjects.end(); anIt++) {
std::shared_ptr<GeomAPI_Shape> aCompSolid = anIt->first;
}
}
if(anIt == aUsedInOperationSolids.end()) {
- aNotUsedSolids.push_back(aSolidInCompSolid);
+ aShapesToAdd.push_back(aSolidInCompSolid);
}
}
}
- ListOfShape anOriginalSolids = aSolidsToFuse;
- anOriginalSolids.insert(anOriginalSolids.end(), aNotUsedSolids.begin(), aNotUsedSolids.end());
+ ListOfShape anOriginalShapes = aSolidsToFuse;
+ anOriginalShapes.insert(anOriginalShapes.end(), aShapesToAdd.begin(), aShapesToAdd.end());
+
+ // Cut edges and faces(if we have any) with solids.
GeomAlgoAPI_MakeShapeList aMakeShapeList;
GeomAPI_DataMapOfShapeShape aMapOfShapes;
+ std::shared_ptr<GeomAPI_Shape> aCuttedEdgesAndFaces;
+ if(!anEdgesAndFaces.empty()) {
+ std::shared_ptr<GeomAlgoAPI_Boolean> aCutAlgo(new GeomAlgoAPI_Boolean(anEdgesAndFaces, anOriginalShapes, GeomAlgoAPI_Boolean::BOOL_CUT));
+ if(aCutAlgo->isDone()) {
+ aCuttedEdgesAndFaces = aCutAlgo->shape();
+ aMakeShapeList.appendAlgo(aCutAlgo);
+ aMapOfShapes.merge(aCutAlgo->mapOfSubShapes());
+ }
+ }
+ anOriginalShapes.insert(anOriginalShapes.end(), anEdgesAndFaces.begin(), anEdgesAndFaces.end());
// If we have compsolids then cut with not used solids all others.
- if(!aNotUsedSolids.empty()) {
+ if(!aShapesToAdd.empty()) {
aSolidsToFuse.clear();
- for(ListOfShape::iterator anIt = anOriginalSolids.begin(); anIt != anOriginalSolids.end(); anIt++) {
+ for(ListOfShape::iterator anIt = anOriginalShapes.begin(); anIt != anOriginalShapes.end(); anIt++) {
ListOfShape aOneObjectList;
aOneObjectList.push_back(*anIt);
- std::shared_ptr<GeomAlgoAPI_Boolean> aCutAlgo(new GeomAlgoAPI_Boolean(aOneObjectList, aNotUsedSolids, GeomAlgoAPI_Boolean::BOOL_CUT));
+ std::shared_ptr<GeomAlgoAPI_Boolean> aCutAlgo(new GeomAlgoAPI_Boolean(aOneObjectList, aShapesToAdd, GeomAlgoAPI_Boolean::BOOL_CUT));
if(GeomAlgoAPI_ShapeTools::volume(aCutAlgo->shape()) > 1.e-7) {
aSolidsToFuse.push_back(aCutAlgo->shape());
}
}
- anObjects.clear();
- anObjects.push_back(aSolidsToFuse.back());
- aSolidsToFuse.pop_back();
- aTools = aSolidsToFuse;
+ if(!aSolidsToFuse.empty()) {
+ anObjects.clear();
+ anObjects.push_back(aSolidsToFuse.back());
+ aSolidsToFuse.pop_back();
+ aTools = aSolidsToFuse;
+ }
// Fuse all objects and all tools.
- std::shared_ptr<GeomAlgoAPI_Boolean> aFuseAlgo(new GeomAlgoAPI_Boolean(anObjects, aTools, aType));
+ std::shared_ptr<GeomAPI_Shape> aShape;
+ if(anObjects.size() == 1 && aTools.empty()) {
+ aShape = anObjects.front();
+ } else if(anObjects.empty() && aTools.size() == 1) {
+ aShape = aTools.front();
+ } else if((anObjects.size() + aTools.size()) > 1){
+ std::shared_ptr<GeomAlgoAPI_Boolean> aFuseAlgo(new GeomAlgoAPI_Boolean(anObjects, aTools, aType));
- // Checking that the algorithm worked properly.
- if(!aFuseAlgo->isDone()) {
- static const std::string aFeatureError = "Boolean algorithm failed";
- setError(aFeatureError);
- return;
- }
- if(aFuseAlgo->shape()->isNull()) {
- static const std::string aShapeError = "Resulting shape is Null";
- setError(aShapeError);
- return;
- }
- if(!aFuseAlgo->isValid()) {
- std::string aFeatureError = "Warning: resulting shape is not valid";
- setError(aFeatureError);
- return;
- }
+ // Checking that the algorithm worked properly.
+ if(!aFuseAlgo->isDone()) {
+ static const std::string aFeatureError = "Boolean algorithm failed";
+ setError(aFeatureError);
+ return;
+ }
+ if(aFuseAlgo->shape()->isNull()) {
+ static const std::string aShapeError = "Resulting shape is Null";
+ setError(aShapeError);
+ return;
+ }
+ if(!aFuseAlgo->isValid()) {
+ std::string aFeatureError = "Warning: resulting shape is not valid";
+ setError(aFeatureError);
+ return;
+ }
- std::shared_ptr<GeomAPI_Shape> aShape = aFuseAlgo->shape();
- aMakeShapeList.appendAlgo(aFuseAlgo);
- aMapOfShapes.merge(aFuseAlgo->mapOfSubShapes());
+ aShape = aFuseAlgo->shape();
+ aMakeShapeList.appendAlgo(aFuseAlgo);
+ aMapOfShapes.merge(aFuseAlgo->mapOfSubShapes());
+ }
- // Add result to not used solids from compsolid (if we have any).
- if(!aNotUsedSolids.empty()) {
- aNotUsedSolids.push_back(aShape);
- std::shared_ptr<GeomAlgoAPI_PaveFiller> aFillerAlgo(new GeomAlgoAPI_PaveFiller(aNotUsedSolids, true));
+ // Combine result with not used solids from compsolid and edges and faces (if we have any).
+ if(aCuttedEdgesAndFaces.get() && !aCuttedEdgesAndFaces->isNull()) {
+ aShapesToAdd.push_back(aCuttedEdgesAndFaces);
+ } else {
+ aShapesToAdd.insert(aShapesToAdd.end(), anEdgesAndFaces.begin(), anEdgesAndFaces.end());
+ }
+ if(!aShapesToAdd.empty()) {
+ if(aShape.get()) {
+ aShapesToAdd.push_back(aShape);
+ }
+ std::shared_ptr<GeomAlgoAPI_PaveFiller> aFillerAlgo(new GeomAlgoAPI_PaveFiller(aShapesToAdd, true));
if(!aFillerAlgo->isDone()) {
std::string aFeatureError = "PaveFiller algorithm failed";
setError(aFeatureError);
aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes());
}
+ std::shared_ptr<GeomAPI_Shape> aBackShape = anOriginalShapes.back();
+ anOriginalShapes.pop_back();
std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data(), aResultIndex);
- loadNamingDS(aResultBody, anOriginalSolids.front(), anOriginalSolids, aShape, aMakeShapeList, aMapOfShapes);
+ loadNamingDS(aResultBody, aBackShape, anOriginalShapes, aShape, aMakeShapeList, aMapOfShapes);
setResult(aResultBody, aResultIndex);
aResultIndex++;
break;
const int aModifyTag = 1;
const int aDeletedTag = 2;
const int aSubsolidsTag = 3; /// sub solids will be placed at labels 3, 4, etc. if result is compound of solids
+ const int anEdgesAndFacesTag = 10000;
theResultBody->storeModified(theBaseShape, theResultShape, aSubsolidsTag);
- std::string aModName = "Modified";
+ const std::string aModName = "Modified";
+ const std::string aModEName = "Modified_Edge";
+ const std::string aModFName = "Modified_Face";
+
theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::FACE,
aModifyTag, aModName, theMapOfShapes);
theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::FACE, aDeletedTag);
+ int aTag;
+ std::string aName;
for(ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++) {
- theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE,
- aModifyTag, aModName, theMapOfShapes);
+ if((*anIter)->shapeType() == GeomAPI_Shape::EDGE) {
+ aTag = anEdgesAndFacesTag;
+ aName = aModEName;
+ }
+ else if((*anIter)->shapeType() == GeomAPI_Shape::FACE) {
+ aTag = anEdgesAndFacesTag;
+ aName = aModFName;
+ } else {
+ aTag = aModifyTag;
+ aName = aModName;
+ }
+ theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, aName == aModEName ? GeomAPI_Shape::EDGE : GeomAPI_Shape::FACE,
+ aTag, aName, theMapOfShapes);
theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE, aDeletedTag);
}
}
label="Main objects"
icon=""
tooltip="Select solid objects"
- type_choice="Solids"
+ type_choice="Solids Objects"
+ use_choice="false"
concealment="true">
<validator id="PartSet_DifferentObjects"/>
- <validator id="GeomValidators_ShapeType" parameters="empty,solid"/>
+ <!--<validator id="GeomValidators_ShapeType" parameters="empty,edge,face,solid"/>-->
+ <validator id="GeomValidators_BooleanSelection"/>
</multi_selector>
- <multi_selector id="tool_objects"
- label="Tool objects"
- icon=""
+ <multi_selector id="tool_objects"
+ label="Tool objects"
+ icon=""
tooltip="Select a tool solid"
- type_choice="Solids"
+ type_choice="Solids Objects"
+ use_choice="false"
concealment="true" >
<validator id="PartSet_DifferentObjects"/>
- <validator id="GeomValidators_ShapeType" parameters="empty,solid"/>
+ <!--<validator id="GeomValidators_ShapeType" parameters="empty,edge,face,solid"/>-->
+ <validator id="GeomValidators_BooleanSelection"/>
</multi_selector>
<validator id="GeomValidators_BooleanArguments" parameters="main_objects,tool_objects,bool_type"/>
</source>
void GeomAPI_DataMapOfShapeShape::merge(const std::shared_ptr<GeomAPI_DataMapOfShapeShape> theDataMap)
{
- merge(*theDataMap.get());
+ if(theDataMap.get()) {
+ merge(*theDataMap.get());
+ }
}
bool GeomAPI_DataMapOfShapeShape::isBound (std::shared_ptr<GeomAPI_Shape> theKey)
#include <GeomAlgoAPI_DFLoader.h>
-#include <BRepAlgoAPI_BooleanOperation.hxx>
-#include <BRepAlgoAPI_Common.hxx>
-#include <BRepAlgoAPI_Cut.hxx>
-#include <BRepAlgoAPI_Fuse.hxx>
+#include <BOPAlgo_BOP.hxx>
#include <TopTools_ListOfShape.hxx>
//=================================================================================================
}
// Creating boolean operation.
- BRepAlgoAPI_BooleanOperation* anOperation;
+ BOPAlgo_BOP* aBuilder = new BOPAlgo_BOP();
switch (theOperationType) {
case BOOL_CUT: {
- anOperation = new BRepAlgoAPI_Cut();
+ aBuilder->SetOperation(BOPAlgo_CUT);
break;
}
case BOOL_FUSE: {
- anOperation = new BRepAlgoAPI_Fuse();
+ aBuilder->SetOperation(BOPAlgo_FUSE);
break;
}
case BOOL_COMMON: {
- anOperation = new BRepAlgoAPI_Common();
+ aBuilder->SetOperation(BOPAlgo_COMMON);
break;
}
default: {
return;
}
}
- this->setImpl(anOperation);
- this->setBuilderType(OCCT_BRepBuilderAPI_MakeShape);
- anOperation->SetArguments(anObjects);
- anOperation->SetTools(aTools);
+ this->setImpl(aBuilder);
+ this->setBuilderType(OCCT_BOPAlgo_Builder);
+ aBuilder->SetArguments(anObjects);
+ aBuilder->SetTools(aTools);
// Building and getting result.
- anOperation->Build();
- if(anOperation->IsDone() != Standard_True) {
+ aBuilder->Perform();
+ if(aBuilder->ErrorStatus() != 0) {
return;
}
- TopoDS_Shape aResult = anOperation->Shape();
+ TopoDS_Shape aResult = aBuilder->Shape();
if(aResult.ShapeType() == TopAbs_COMPOUND) {
aResult = GeomAlgoAPI_DFLoader::refineResult(aResult);
#include <BOPAlgo_Builder.hxx>
#include <BOPAlgo_PaveFiller.hxx>
#include <TopoDS_Builder.hxx>
+#include <TopoDS_Iterator.hxx>
//=================================================================================================
GeomAlgoAPI_PaveFiller::GeomAlgoAPI_PaveFiller(const ListOfShape& theListOfShape, const bool theIsMakeCompSolids)
BOPAlgo_PaveFiller aPaveFiller;
BOPCol_ListOfShape aListOfShape;
for(ListOfShape::const_iterator anIt = theListOfShape.cbegin(); anIt != theListOfShape.cend(); anIt++) {
- aListOfShape.Append((*anIt)->impl<TopoDS_Shape>());
+ const TopoDS_Shape& aShape = (*anIt)->impl<TopoDS_Shape>();
+ if(aShape.ShapeType() == TopAbs_COMPOUND) {
+ for(TopoDS_Iterator anIter(aShape); anIter.More(); anIter.Next()) {
+ aListOfShape.Append(anIter.Value());
+ }
+ } else {
+ aListOfShape.Append(aShape);
+ }
}
aPaveFiller.SetArguments(aListOfShape);
aPaveFiller.Perform();
aTA = TopAbs_SOLID;
}
- // Map subshapes and shapes.
+ // Get free shapes.
const TopoDS_Shape& aShapesComp = theCompound->impl<TopoDS_Shape>();
- BOPCol_IndexedDataMapOfShapeListOfShape aMapEF;
- BOPTools::MapShapesAndAncestors(aShapesComp, aTS, aTA, aMapEF);
- if(aMapEF.IsEmpty()) {
+ for(TopoDS_Iterator anIter(aShapesComp); anIter.More(); anIter.Next() ) {
+ const TopoDS_Shape& aShape = anIter.Value();
+ if(aShape.ShapeType() > aTA) {
+ std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape);
+ aGeomShape->setImpl<TopoDS_Shape>(new TopoDS_Shape(aShape));
+ theFreeShapes.push_back(aGeomShape);
+ }
+ }
+
+ // Map subshapes and shapes.
+ BOPCol_IndexedDataMapOfShapeListOfShape aMapSA;
+ BOPTools::MapShapesAndAncestors(aShapesComp, aTS, aTA, aMapSA);
+ if(aMapSA.IsEmpty()) {
return;
}
// Get all shapes with common subshapes and free shapes.
NCollection_Map<TopoDS_Shape> aFreeShapes;
NCollection_Vector<NCollection_Map<TopoDS_Shape>> aShapesWithCommonSubshapes;
- for(BOPCol_IndexedDataMapOfShapeListOfShape::Iterator anIter(aMapEF); anIter.More(); anIter.Next()) {
+ for(BOPCol_IndexedDataMapOfShapeListOfShape::Iterator anIter(aMapSA); anIter.More(); anIter.Next()) {
const TopoDS_Shape& aShape = anIter.Key();
BOPCol_ListOfShape& aListOfShape = anIter.ChangeValue();
if(aListOfShape.IsEmpty()) {
aListOfShape.Clear();
for(NCollection_List<TopoDS_Shape>::Iterator aTempIter(aTempList); aTempIter.More(); aTempIter.Next()) {
const TopoDS_Shape& aTempShape = aTempIter.Value();
- for(BOPCol_IndexedDataMapOfShapeListOfShape::Iterator anIter(aMapEF); anIter.More(); anIter.Next()) {
+ for(BOPCol_IndexedDataMapOfShapeListOfShape::Iterator anIter(aMapSA); anIter.More(); anIter.Next()) {
BOPCol_ListOfShape& aTempListOfShape = anIter.ChangeValue();
if(aTempListOfShape.IsEmpty()) {
continue;
GeomValidators_Tools.h
GeomValidators_ZeroOffset.h
GeomValidators_Different.h
+ GeomValidators_BooleanSelection.h
)
SET(PROJECT_SOURCES
GeomValidators_Tools.cpp
GeomValidators_ZeroOffset.cpp
GeomValidators_Different.cpp
+ GeomValidators_BooleanSelection.cpp
)
SET(PROJECT_LIBRARIES
)
INSTALL(TARGETS GeomValidators DESTINATION plugins)
-
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomValidators_BooleanSelection.cpp
+// Created: 3 Feb 2016
+// Author: Dmitry Bobylev
+
+#include "GeomValidators_BooleanSelection.h"
+
+#include <ModelAPI_AttributeInteger.h>
+#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_Feature.h>
+
+bool GeomValidators_BooleanSelection::isValid(const AttributePtr& theAttribute,
+ const std::list<std::string>& theArguments,
+ std::string& theError) const
+{
+ if(!theAttribute.get()) {
+ theError = "Error: empty selection.";
+ return false;
+ }
+ FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
+ int anOperationType = aFeature->integer("bool_type")->value();
+ AttributeSelectionListPtr anAttrSelectionList = std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
+ for(int anIndex = 0; anIndex < anAttrSelectionList->size(); ++anIndex) {
+ AttributeSelectionPtr anAttrSelection = anAttrSelectionList->value(anIndex);
+ if(!anAttrSelection.get()) {
+ theError = "Error: empty attribute selection.";
+ return false;
+ }
+ std::shared_ptr<GeomAPI_Shape> aShape = anAttrSelection->value();
+ if(!aShape.get()) {
+ ResultPtr aContext = anAttrSelection->context();
+ if(!aContext.get()) {
+ theError = "Error: empty selection context.";
+ return false;
+ }
+ FeaturePtr aFeature = ModelAPI_Feature::feature(aContext);
+ if(!aFeature.get()) {
+ theError = "Error: empty feature.";
+ return false;
+ }
+ std::string aFeatureKind = aFeature->getKind();
+ if(aFeatureKind == "Sketch") {
+ theError = "Error: sketch shape is selected, but only objects are acceptable.";
+ return false;
+ }
+ aShape = aContext->shape();
+ }
+ if(!aShape.get()) {
+ theError = "Error: empty shape.";
+ return false;
+ }
+ int aShapeType = aShape->shapeType();
+ if(anOperationType == 1) {
+ // Fuse operation. Allow to select edges, faces and solids.
+ if(aShapeType != GeomAPI_Shape::EDGE &&
+ aShapeType != GeomAPI_Shape::FACE &&
+ aShapeType != GeomAPI_Shape::SOLID &&
+ aShapeType != GeomAPI_Shape::COMPSOLID &&
+ aShapeType != GeomAPI_Shape::COMPOUND) {
+ theError = "Error: selected shape has the wrong type.";
+ return false;
+ }
+ } else {
+ if(aShapeType != GeomAPI_Shape::SOLID &&
+ aShapeType != GeomAPI_Shape::COMPSOLID &&
+ aShapeType != GeomAPI_Shape::COMPOUND) {
+ theError = "Error: selected shape has the wrong type.";
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomValidators_BooleanSelection.h
+// Created: 3 Feb 2016
+// Author: Dmitry Bobylev
+
+#ifndef GeomValidators_BooleanSelection_H
+#define GeomValidators_BooleanSelection_H
+
+#include <ModelAPI.h>
+
+#include <ModelAPI_AttributeValidator.h>
+#include <ModelAPI_Attribute.h>
+
+/// \class GeomValidators_ZeroOffset
+/// \ingroup Validators
+/// \brief Validates selection for boolean operation.
+class GeomValidators_BooleanSelection: public ModelAPI_AttributeValidator
+{
+public:
+ /// \return True if the attribute is valid. It checks whether the selection
+ /// is acceptable for boolean operation.
+ /// \param[in] theAttribute an attribute to check.
+ /// \param[in] theArguments a filter parameters.
+ /// \param[out] theError error message.
+ MODELAPI_EXPORT virtual bool isValid(const AttributePtr& theAttribute,
+ const std::list<std::string>& theArguments,
+ std::string& theError) const;
+};
+
+#endif
#include <GeomValidators_BodyShapes.h>
#include <GeomValidators_BooleanArguments.h>
+#include <GeomValidators_BooleanSelection.h>
#include <GeomValidators_ConstructionComposite.h>
#include <GeomValidators_Different.h>
#include <GeomValidators_DifferentShapes.h>
aFactory->registerValidator("GeomValidators_PartitionArguments", new GeomValidators_PartitionArguments);
aFactory->registerValidator("GeomValidators_ShapeType", new GeomValidators_ShapeType);
aFactory->registerValidator("GeomValidators_ZeroOffset", new GeomValidators_ZeroOffset);
+ aFactory->registerValidator("GeomValidators_BooleanSelection", new GeomValidators_BooleanSelection);
// register this plugin
ModelAPI_Session::get()->registerPlugin(this);
TNaming_Builder aSubBuilder(aShapeLab.FindChild(aTag++));
aSubBuilder.Generated(aSubIter.Value());
if(!aName.IsEmpty()) {
+ TCollection_AsciiString aShapeType = aShape.ShapeType() == TopAbs_EDGE ? "_Edge_" :
+ aShape.ShapeType() == TopAbs_FACE ? "_Face_" :
+ aShape.ShapeType() == TopAbs_SOLID ? "_Solid_" : "_Shape_";
std::string aSolidName =
- (aName + "_Solid_" + TCollection_AsciiString(aTag - theDecomposeSolidsTag)).ToCString();
+ (aName + aShapeType + TCollection_AsciiString(aTag - theDecomposeSolidsTag)).ToCString();
std::shared_ptr<Model_Document> aDoc =
std::dynamic_pointer_cast<Model_Document>(document());
aDoc->addNamingName(aSubBuilder.NamedShape()->Label(), aSolidName);
bool aWasEmpty = mySubs.empty();
Model_Objects* anObjects = std::dynamic_pointer_cast<Model_Document>(document())->objects();
unsigned int aSubIndex = 0;
- TopExp_Explorer aSolids(aThisShape, TopAbs_SOLID);
- for(; aSolids.More(); aSolids.Next(), aSubIndex++) {
- std::shared_ptr<GeomAPI_Shape> aSolidShape(new GeomAPI_Shape);
- aSolidShape->setImpl(new TopoDS_Shape(aSolids.Current()));
+ TopoDS_Iterator aShapesIter(aThisShape);
+ for(; aShapesIter.More(); aShapesIter.Next(), aSubIndex++) {
+ std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape);
+ aShape->setImpl(new TopoDS_Shape(aShapesIter.Value()));
ResultBodyPtr aSub;
if (mySubs.size() <= aSubIndex) { // it is needed to create a new sub-result
aSub = anObjects->createBody(this->data(), aSubIndex);
} else { // just update shape of this result
aSub = mySubs[aSubIndex];
}
- if (!aSolidShape->isEqual(aSub->shape())) {
- aSub->store(aSolidShape, false);
+ if (!aShape->isEqual(aSub->shape())) {
+ aSub->store(aShape, false);
aECreator->sendUpdated(aSub, EVENT_DISP);
aECreator->sendUpdated(aSub, EVENT_UPD);
}