-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 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
//
// 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
+// 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>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "FeaturesPlugin_CompositeBoolean.h"
#include <GeomAlgoAPI_PaveFiller.h>
#include <GeomAlgoAPI_ShapeTools.h>
-#include <GeomAPI_ShapeExplorer.h>
+#include <GeomAPI_ShapeIterator.h>
#include <map>
for(; aBoolObjIt != aBooleanObjects.cend() && aBoolMSIt != aBooleanMakeShapes.cend();
++aBoolObjIt, ++aBoolMSIt) {
- int aTag = 1;
-
ResultBodyPtr aResultBody = myFeature->document()->createBody(myFeature->data(), aResultIndex);
if((*aBoolObjIt)->isEqual((*aBoolMSIt)->shape())) {
{
aResultBody->storeModified(*aBoolObjIt, (*aBoolMSIt)->shape());
- aTag += 5000;
-
// Store generation history.
ListOfShape::const_iterator aGenBaseIt = aGenBaseShapes.cbegin();
ListOfMakeShape::const_iterator aGenMSIt = aGenMakeShapes.cbegin();
for(; aGenBaseIt != aGenBaseShapes.cend() && aGenMSIt != aGenMakeShapes.cend();
++aGenBaseIt, ++aGenMSIt) {
- storeGenerationHistory(aResultBody, *aGenBaseIt, *aGenMSIt, aTag);
+ std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMSList(new GeomAlgoAPI_MakeShapeList());
+ aMSList->appendAlgo(*aGenMSIt);
+ aMSList->appendAlgo(*aBoolMSIt);
+ storeGenerationHistory(aResultBody, *aGenBaseIt, aMSList);
}
- int aModTag = aTag;
- storeModificationHistory(aResultBody, *aBoolObjIt, aTools, *aBoolMSIt, aModTag);
+ storeModificationHistory(aResultBody, *aBoolObjIt, aTools, *aBoolMSIt);
ResultBaseAlgo aRBA;
aRBA.resultBody = aResultBody;
aRBA.baseShape = *aBoolObjIt;
aRBA.makeShape = *aBoolMSIt;
- aRBA.delTag = aModTag;
aResultBaseAlgoList.push_back(aRBA);
aResultShapesList.push_back((*aBoolMSIt)->shape());
}
aListWithObject.push_back(anObject);
std::shared_ptr<GeomAlgoAPI_Boolean> aBoolAlgo(new GeomAlgoAPI_Boolean(aListWithObject,
theTools,
- GeomAlgoAPI_Boolean::BOOL_CUT));
+ GeomAlgoAPI_Tools::BOOL_CUT));
// Checking that the algorithm worked properly.
if(!aBoolAlgo->isDone() || aBoolAlgo->shape()->isNull() || !aBoolAlgo->isValid()) {
// Collecting solids from compsolids which will not be modified in boolean operation.
ListOfShape aShapesToAdd;
- for(GeomAPI_ShapeExplorer
- anExp(aCompSolid, GeomAPI_Shape::SOLID); anExp.more(); anExp.next()) {
- GeomShapePtr aSolidInCompSolid = anExp.current();
+ for (GeomAPI_ShapeIterator aCompSolidIt(aCompSolid);
+ aCompSolidIt.more();
+ aCompSolidIt.next())
+ {
+ GeomShapePtr aSolidInCompSolid = aCompSolidIt.current();
ListOfShape::const_iterator aUsedShapesIt = aUsedShapes.cbegin();
for(; aUsedShapesIt != aUsedShapes.cend(); ++aUsedShapesIt) {
if(aSolidInCompSolid->isEqual(*aUsedShapesIt)) {
std::shared_ptr<GeomAlgoAPI_Boolean> aBoolAlgo(new GeomAlgoAPI_Boolean(aUsedShapes,
theTools,
- GeomAlgoAPI_Boolean::BOOL_CUT));
+ GeomAlgoAPI_Tools::BOOL_CUT));
// Checking that the algorithm worked properly.
if(!aBoolAlgo->isDone() || aBoolAlgo->shape()->isNull() || !aBoolAlgo->isValid()) {
aMakeShapeList->appendAlgo(aBoolAlgo);
// Add result to not used solids from compsolid.
- aShapesToAdd.push_back(aBoolAlgo->shape());
- std::shared_ptr<GeomAlgoAPI_PaveFiller> aFillerAlgo(
- new GeomAlgoAPI_PaveFiller(aShapesToAdd, true));
- if(!aFillerAlgo->isDone() || aFillerAlgo->shape()->isNull() || !aFillerAlgo->isValid()) {
- myFeature->setError("Error: PaveFiller algorithm failed.");
- return false;
+ GeomShapePtr aBoolRes = aBoolAlgo->shape();
+ if (!aShapesToAdd.empty()) {
+ aShapesToAdd.push_back(aBoolRes);
+ std::shared_ptr<GeomAlgoAPI_PaveFiller> aFillerAlgo(
+ new GeomAlgoAPI_PaveFiller(aShapesToAdd, true));
+ if(!aFillerAlgo->isDone() || aFillerAlgo->shape()->isNull() || !aFillerAlgo->isValid()) {
+ myFeature->setError("Error: PaveFiller algorithm failed.");
+ return false;
+ }
+ aBoolRes = aFillerAlgo->shape();
+ aMakeShapeList->appendAlgo(aFillerAlgo);
}
- aMakeShapeList->appendAlgo(aFillerAlgo);
-
- if(GeomAlgoAPI_ShapeTools::volume(aFillerAlgo->shape()) > 1.e-27) {
+ if(GeomAlgoAPI_ShapeTools::volume(aBoolRes) > 1.e-27) {
theObjects.push_back(aCompSolid);
theMakeShapes.push_back(aMakeShapeList);
}
aSolidsToFuse.insert(aSolidsToFuse.end(), aUsedShapes.begin(), aUsedShapes.end());
// Collect solids from compsolid which will not be modified in boolean operation.
- for(GeomAPI_ShapeExplorer
- anExp(aCompSolid, GeomAPI_Shape::SOLID); anExp.more(); anExp.next()) {
- GeomShapePtr aSolidInCompSolid = anExp.current();
+ for (GeomAPI_ShapeIterator aCompSolidIt(aCompSolid);
+ aCompSolidIt.more();
+ aCompSolidIt.next())
+ {
+ GeomShapePtr aSolidInCompSolid = aCompSolidIt.current();
ListOfShape::iterator anIt = aUsedShapes.begin();
for(; anIt != aUsedShapes.end(); anIt++) {
if(aSolidInCompSolid->isEqual(*anIt)) {
if(!anEdgesAndFaces.empty() && !aCutTools.empty()) {
std::shared_ptr<GeomAlgoAPI_Boolean> aCutAlgo(new GeomAlgoAPI_Boolean(anEdgesAndFaces,
aCutTools,
- GeomAlgoAPI_Boolean::BOOL_CUT));
+ GeomAlgoAPI_Tools::BOOL_CUT));
if(aCutAlgo->isDone() && !aCutAlgo->shape()->isNull() && aCutAlgo->isValid()) {
anEdgesAndFaces.clear();
anEdgesAndFaces.push_back(aCutAlgo->shape());
if(!aShapesToAdd.empty()) {
std::shared_ptr<GeomAlgoAPI_Boolean> aCutAlgo(new GeomAlgoAPI_Boolean(aSolidsToFuse,
aShapesToAdd,
- GeomAlgoAPI_Boolean::BOOL_CUT));
+ GeomAlgoAPI_Tools::BOOL_CUT));
if(aCutAlgo->isDone() && GeomAlgoAPI_ShapeTools::volume(aCutAlgo->shape()) > 1.e-27) {
aSolidsToFuse.clear();
aSolidsToFuse.push_back(aCutAlgo->shape());
std::shared_ptr<GeomAlgoAPI_Boolean> aFuseAlgo(new GeomAlgoAPI_Boolean(anObjects,
aTools,
- GeomAlgoAPI_Boolean::BOOL_FUSE));
+ GeomAlgoAPI_Tools::BOOL_FUSE));
// Checking that the algorithm worked properly.
if(!aFuseAlgo->isDone() || aFuseAlgo->shape()->isNull() || !aFuseAlgo->isValid()) {
void FeaturesPlugin_CompositeBoolean::storeModificationHistory(ResultBodyPtr theResultBody,
const GeomShapePtr theObject,
const ListOfShape& theTools,
- const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
- int& theTag)
+ const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape)
{
- int aModTag = theTag;
- int anEdgesAndFacesTag = ++aModTag;
- int aDelTag = ++anEdgesAndFacesTag;
- theTag = aDelTag;
-
- const std::string aModName = "Modfied";
-
ListOfShape aTools = theTools;
aTools.push_back(theObject);
- std::string aName;
for(ListOfShape::const_iterator anIt = aTools.begin(); anIt != aTools.end(); anIt++) {
- if((*anIt)->shapeType() == GeomAPI_Shape::EDGE) {
- aName = aModName + "_Edge";
- }
- else if((*anIt)->shapeType() == GeomAPI_Shape::FACE) {
- aName = aModName + "_Face";
- } else {
- aName = aModName;
- }
theResultBody->loadModifiedShapes(theMakeShape, *anIt,
(*anIt)->shapeType() == GeomAPI_Shape::EDGE ?
GeomAPI_Shape::EDGE :
- GeomAPI_Shape::FACE,
- aName);
+ GeomAPI_Shape::FACE);
}
}