Fixed connected topology creation in partition.
#include <GeomAlgoAPI_PaveFiller.h>
#include <GeomAlgoAPI_ShapeTools.h>
#include <GeomAPI_ShapeExplorer.h>
+#include <GeomAPI_ShapeIterator.h>
#include <algorithm>
#include <map>
ListOfShape aListWithObject;
aListWithObject.push_back(anObject);
GeomAlgoAPI_MakeShape aBoolAlgo;
+ GeomShapePtr aResShape;
switch(aType) {
- case BOOL_CUT: aBoolAlgo = GeomAlgoAPI_Boolean(aListWithObject, aTools, GeomAlgoAPI_Boolean::BOOL_CUT); break;
- case BOOL_COMMON: aBoolAlgo = GeomAlgoAPI_Boolean(aListWithObject, aTools, GeomAlgoAPI_Boolean::BOOL_COMMON); break;
- case BOOL_FILL: aBoolAlgo = GeomAlgoAPI_Partition(aListWithObject, aTools); break;
+ case BOOL_CUT: {
+ aBoolAlgo = GeomAlgoAPI_Boolean(aListWithObject, aTools, GeomAlgoAPI_Boolean::BOOL_CUT);
+ aResShape = aBoolAlgo.shape();
+ break;
+ }
+ case BOOL_COMMON: {
+ aBoolAlgo = GeomAlgoAPI_Boolean(aListWithObject, aTools, GeomAlgoAPI_Boolean::BOOL_COMMON);
+ aResShape = aBoolAlgo.shape();
+ break;
+ }
+ case BOOL_FILL: {
+ aBoolAlgo = GeomAlgoAPI_Partition(aListWithObject, aTools);
+ aResShape = aBoolAlgo.shape();
+ if(aResShape->shapeType() == GeomAPI_Shape::COMPOUND) {
+ int aSubResultsNb = 0;
+ GeomAPI_ShapeIterator anIt(aResShape);
+ for(; anIt.more(); anIt.next()) {
+ ++aSubResultsNb;
+ }
+ if(aSubResultsNb == 1) {
+ anIt.init(aResShape);
+ if(anIt.more()) {
+ aResShape = anIt.current();
+ }
+ }
+ }
+ break;
+ }
}
// Checking that the algorithm worked properly.
setError(aFeatureError);
return;
}
- if(aBoolAlgo.shape()->isNull()) {
+ if(aResShape->isNull()) {
static const std::string aShapeError = "Error: Resulting shape is Null.";
setError(aShapeError);
return;
return;
}
- if(GeomAlgoAPI_ShapeTools::volume(aBoolAlgo.shape()) > 1.e-27) {
+ if(GeomAlgoAPI_ShapeTools::volume(aResShape) > 1.e-27) {
std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data(), aResultIndex);
- loadNamingDS(aResultBody, anObject, aTools, aBoolAlgo.shape(), aBoolAlgo, *aBoolAlgo.mapOfSubShapes().get());
+ loadNamingDS(aResultBody, anObject, aTools, aResShape, aBoolAlgo, *aBoolAlgo.mapOfSubShapes().get());
setResult(aResultBody, aResultIndex);
aResultIndex++;
}
aGroups.Append(aGroupedShapes);
}
- if(aGroups.Size() == 1) {
- NCollection_List<TopoDS_Shape> aGroup = aGroups.First();
+ 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());
- 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>());
+ 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>());
+ }
- if(!aCompound.IsNull()) {
- aResult->setImpl(new TopoDS_Shape(aCompound));
- }
+ if(!aCompound.IsNull()) {
+ aResult->setImpl(new TopoDS_Shape(aCompound));
}
return aResult;
updateSubs(std::shared_ptr<GeomAPI_Shape>()); // erase sub-results
}
-void Model_ResultCompSolid::store(const std::shared_ptr<GeomAPI_Shape>& theShape)
+void Model_ResultCompSolid::store(const std::shared_ptr<GeomAPI_Shape>& theShape,
+ const bool theIsStoreSameShapes)
{
- ModelAPI_ResultCompSolid::store(theShape);
+ ModelAPI_ResultCompSolid::store(theShape, theIsStoreSameShapes);
updateSubs(theShape);
}
MODEL_EXPORT virtual ~Model_ResultCompSolid();
/// Stores the shape (called by the execution method). Creates sub-results for compsolid.
- MODEL_EXPORT virtual void store(const std::shared_ptr<GeomAPI_Shape>& theShape);
+ MODEL_EXPORT virtual void store(const std::shared_ptr<GeomAPI_Shape>& theShape,
+ const bool theIsStoreSameShapes = true);
/// Stores the generated shape. Creates sub-results for compsolid.
MODEL_EXPORT virtual void storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,