#include <ModelAPI_ResultBody.h>
#include <ModelAPI_ResultConstruction.h>
+#include <GeomAlgoAPI_CompoundBuilder.h>
#include <GeomAlgoAPI_Prism.h>
#include <GeomAlgoAPI_Revolution.h>
#include <GeomAlgoAPI_ShapeTools.h>
}
int aSketchFacesNum = aConstruction->facesNum();
if(aSketchFacesNum == 0) {
- return; //TODO: set error message
+ return;
}
- ListOfShape aSketchFacesList;
+ ListOfShape aFacesList;
for(int aFaceIndex = 0; aFaceIndex < aSketchFacesNum; aFaceIndex++) {
std::shared_ptr<GeomAPI_Shape> aFace = std::dynamic_pointer_cast<GeomAPI_Shape>(aConstruction->face(aFaceIndex));
- aSketchFacesList.push_back(aFace);
+ aFacesList.push_back(aFace);
+ }
+
+ // Searching faces with common edges.
+ ListOfShape aShells;
+ ListOfShape aFreeFaces;
+ std::shared_ptr<GeomAPI_Shape> aFacesCompound = GeomAlgoAPI_CompoundBuilder::compound(aFacesList);
+ GeomAlgoAPI_ShapeTools::combineShapes(aFacesCompound, GeomAPI_Shape::SHELL, aShells, aFreeFaces);
+ if(aShells.empty()) {
+ aShells = aFreeFaces;
+ } else {
+ aShells.merge(aFreeFaces);
}
- // Pass faces to soldis creation function.
+ // Pass shells/faces to soldis creation function.
ListOfShape aBooleanTools;
- std::list<std::shared_ptr<GeomAPI_Interface>> theSolidsAlgos;
- makeSolids(aSketchFacesList, aBooleanTools, theSolidsAlgos);
+ std::list<std::shared_ptr<GeomAPI_Interface>> aSolidsAlgos;
+ makeSolids(aShells, aBooleanTools, aSolidsAlgos);
if(aBooleanTools.empty()) {
return;
}
if(GeomAlgoAPI_ShapeTools::volume(aBoolAlgo.shape()) > 1.e-7) {
std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data(), aResultIndex);
- loadNamingDS(aResultBody, anObject, aSketchFacesList, theSolidsAlgos, aBooleanTools, aBoolAlgo);
+ loadNamingDS(aResultBody, anObject, aShells, aSolidsAlgos, aBooleanTools, aBoolAlgo);
setResult(aResultBody, aResultIndex);
aResultIndex++;
}
}
std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data(), aResultIndex);
- loadNamingDS(aResultBody, aBooleanObjects.front(), aSketchFacesList, theSolidsAlgos, aBooleanTools, aBoolAlgo);
+ loadNamingDS(aResultBody, aBooleanObjects.front(), aShells, aSolidsAlgos, aBooleanTools, aBoolAlgo);
setResult(aResultBody, aResultIndex);
aResultIndex++;
break;
//=================================================================================================
void FeaturesPlugin_CompositeBoolean::loadNamingDS(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
const std::shared_ptr<GeomAPI_Shape>& theBaseShape,
- const ListOfShape& theFaces,
+ const ListOfShape& theShells,
const std::list<std::shared_ptr<GeomAPI_Interface>>& theSolidsAlgos,
const ListOfShape& theTools,
const GeomAlgoAPI_Boolean& theAlgo)
theResultBody->store(theAlgo.shape());
} else {
const int aGenTag = 1;
- const int aFrTag = 2;
+ const int aFromTag = 2;
const int aToTag = 3;
const int aModTag = 4;
const int aDelTag = 5;
const std::string aGenName = "Generated";
const std::string aModName = "Modified";
const std::string aLatName = "LateralFace";
- const std::string aFrName = "FromFace";
+ const std::string aFromName = "FromFace";
const std::string aToName = "ToFace";
theResultBody->storeModified(theBaseShape, theAlgo.shape(), aSubsolidsTag);
- ListOfShape::const_iterator aFaceIter = theFaces.begin();
+ ListOfShape::const_iterator aShellsIter = theShells.begin();
std::list<std::shared_ptr<GeomAPI_Interface>>::const_iterator aSolidsAlgosIter = theSolidsAlgos.begin();
- for(; aFaceIter != theFaces.end() && aSolidsAlgosIter != theSolidsAlgos.end(); aFaceIter++, aSolidsAlgosIter++) {
- std::shared_ptr<GeomAPI_Shape> aFromFace;
- std::shared_ptr<GeomAPI_Shape> aToFace;
+ for(; aShellsIter != theShells.end() && aSolidsAlgosIter != theSolidsAlgos.end(); aShellsIter++, aSolidsAlgosIter++) {
+ ListOfShape aFromFaces;
+ ListOfShape aToFaces;
std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes;
//Insert lateral face : Face from Edge
if(std::dynamic_pointer_cast<GeomAlgoAPI_Prism>(*aSolidsAlgosIter)) {
std::shared_ptr<GeomAlgoAPI_Prism> aPrismAlgo = std::dynamic_pointer_cast<GeomAlgoAPI_Prism>(*aSolidsAlgosIter);
aSubShapes = aPrismAlgo->mapOfShapes();
- theResultBody->loadAndOrientGeneratedShapes(aPrismAlgo->makeShape().get(), *aFaceIter, GeomAPI_Shape::EDGE, aGenTag,
+ theResultBody->loadAndOrientGeneratedShapes(aPrismAlgo->makeShape().get(), *aShellsIter, GeomAPI_Shape::EDGE, aGenTag,
aLatName, *aSubShapes.get());
- //TODO: fix
- //aFromFace = aPrismAlgo->firstShape();
- //aToFace = aPrismAlgo->lastShape();
+
+ aFromFaces = aPrismAlgo->fromFaces();
+ aToFaces = aPrismAlgo->toFaces();
} else if(std::dynamic_pointer_cast<GeomAlgoAPI_Revolution>(*aSolidsAlgosIter)) {
std::shared_ptr<GeomAlgoAPI_Revolution> aRevolAlgo = std::dynamic_pointer_cast<GeomAlgoAPI_Revolution>(*aSolidsAlgosIter);
aSubShapes = aRevolAlgo->mapOfShapes();
- theResultBody->loadAndOrientGeneratedShapes(aRevolAlgo->makeShape().get(), *aFaceIter, GeomAPI_Shape::EDGE, aGenTag,
+ theResultBody->loadAndOrientGeneratedShapes(aRevolAlgo->makeShape().get(), *aShellsIter, GeomAPI_Shape::EDGE, aGenTag,
aLatName, *aSubShapes.get());
- //TODO: fix
- //aFromFace = aRevolAlgo->firstShape();
- //aToFace = aRevolAlgo->lastShape();
+ aFromFaces = aRevolAlgo->fromFaces();
+ aToFaces = aRevolAlgo->toFaces();
}
- /*
- //Insert bottom face
- if(!aFromFace->isNull()) {
- if(aSubShapes->isBound(aFromFace)) {
- aFromFace = aSubShapes->find(aFromFace);
+ //Insert to faces
+ for(ListOfShape::const_iterator anIt = aToFaces.cbegin(); anIt != aToFaces.cend(); anIt++) {
+ std::shared_ptr<GeomAPI_Shape> aToFace = *anIt;
+ if(aSubShapes->isBound(aToFace)) {
+ aToFace = aSubShapes->find(aToFace);
}
- theResultBody->generated(aFromFace, aFrName, aFrTag);
+ theResultBody->generated(aToFace, aToName, aToTag);
}
- //Insert top face
- if (!aToFace->isNull()) {
- if (aSubShapes->isBound(aToFace)) {
- aToFace = aSubShapes->find(aToFace);
+ //Insert from faces
+ for(ListOfShape::const_iterator anIt = aFromFaces.cbegin(); anIt != aFromFaces.cend(); anIt++) {
+ std::shared_ptr<GeomAPI_Shape> aFromFace = *anIt;
+ if(aSubShapes->isBound(aFromFace)) {
+ aFromFace = aSubShapes->find(aFromFace);
}
- theResultBody->generated(aToFace, aToName, aToTag);
+ theResultBody->generated(aFromFace, aFromName, aFromTag);
}
- */
}
theResultBody->loadAndOrientModifiedShapes(theAlgo.makeShape().get(), theBaseShape, GeomAPI_Shape::FACE,