From a276c3f6288ffcd67f1dab8323d7e4666a1aded7 Mon Sep 17 00:00:00 2001 From: dbv Date: Tue, 16 Oct 2018 12:23:10 +0300 Subject: [PATCH] Updated modified shapes storing. --- src/BuildPlugin/BuildPlugin_Compound.cpp | 18 +- src/BuildPlugin/BuildPlugin_Edge.cpp | 17 +- src/BuildPlugin/BuildPlugin_Interpolation.cpp | 2 +- src/BuildPlugin/BuildPlugin_Polyline.cpp | 4 +- src/BuildPlugin/BuildPlugin_Shell.cpp | 43 +- src/BuildPlugin/BuildPlugin_Solid.cpp | 13 +- src/BuildPlugin/BuildPlugin_SubShapes.cpp | 28 +- src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp | 123 ++-- src/FeaturesPlugin/FeaturesPlugin_Boolean.h | 4 +- .../FeaturesPlugin_BooleanCommon.cpp | 155 ++--- .../FeaturesPlugin_BooleanCommon.h | 11 - .../FeaturesPlugin_BooleanCut.cpp | 152 +---- .../FeaturesPlugin_BooleanCut.h | 24 - .../FeaturesPlugin_BooleanFuse.cpp | 131 ++--- .../FeaturesPlugin_BooleanFuse.h | 9 - .../FeaturesPlugin_BooleanSmash.cpp | 100 +--- .../FeaturesPlugin_BooleanSmash.h | 11 - .../FeaturesPlugin_CompositeBoolean.cpp | 22 +- src/FeaturesPlugin/FeaturesPlugin_Fillet.cpp | 15 +- .../FeaturesPlugin_FusionFaces.cpp | 9 +- .../FeaturesPlugin_Intersection.cpp | 3 +- .../FeaturesPlugin_MultiRotation.cpp | 46 +- .../FeaturesPlugin_MultiTranslation.cpp | 32 +- .../FeaturesPlugin_Partition.cpp | 24 +- src/FeaturesPlugin/FeaturesPlugin_Pipe.cpp | 8 +- .../FeaturesPlugin_Placement.cpp | 31 +- src/FeaturesPlugin/FeaturesPlugin_Placement.h | 5 - .../FeaturesPlugin_RemoveSubShapes.cpp | 36 +- .../FeaturesPlugin_Rotation.cpp | 54 +- src/FeaturesPlugin/FeaturesPlugin_Rotation.h | 4 - src/FeaturesPlugin/FeaturesPlugin_Scale.cpp | 58 +- src/FeaturesPlugin/FeaturesPlugin_Scale.h | 5 - .../FeaturesPlugin_Symmetry.cpp | 21 +- src/FeaturesPlugin/FeaturesPlugin_Symmetry.h | 5 - src/FeaturesPlugin/FeaturesPlugin_Tools.cpp | 117 +++- src/FeaturesPlugin/FeaturesPlugin_Tools.h | 42 +- .../FeaturesPlugin_Translation.cpp | 79 ++- .../FeaturesPlugin_Translation.h | 4 - src/FeaturesPlugin/FeaturesPlugin_Union.cpp | 21 +- src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.cpp | 133 +++-- src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h | 68 ++- .../GeomAlgoAPI_MakeShapeCustom.cpp | 62 +- src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeCustom.h | 22 +- src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeList.cpp | 96 +-- src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeList.h | 12 +- src/Model/Model_BodyBuilder.cpp | 554 +++++++----------- src/Model/Model_BodyBuilder.h | 94 +-- src/Model/Model_ResultBody.cpp | 25 +- src/Model/Model_ResultBody.h | 10 +- src/ModelAPI/ModelAPI_BodyBuilder.h | 87 ++- src/ModelAPI/ModelAPI_ResultBody.cpp | 90 +-- src/ModelAPI/ModelAPI_ResultBody.h | 84 +-- 52 files changed, 1188 insertions(+), 1635 deletions(-) diff --git a/src/BuildPlugin/BuildPlugin_Compound.cpp b/src/BuildPlugin/BuildPlugin_Compound.cpp index 69c8551bb..39c136ade 100644 --- a/src/BuildPlugin/BuildPlugin_Compound.cpp +++ b/src/BuildPlugin/BuildPlugin_Compound.cpp @@ -70,24 +70,16 @@ void BuildPlugin_Compound::execute() // Build compound. GeomShapePtr aCompound = GeomAlgoAPI_CompoundBuilder::compound(anOriginalShapes); // Copy shape. - GeomAlgoAPI_Copy aCopyAlgo(aCompound); - GeomShapePtr aCopyCompound = aCopyAlgo.shape(); + GeomMakeShapePtr aCopyAlgo(new GeomAlgoAPI_Copy(aCompound)); + GeomShapePtr aCopyCompound = aCopyAlgo->shape(); int anIndexToRemove = 0; if (aCopyCompound) { - std::shared_ptr aMapOfShapes = aCopyAlgo.mapOfSubShapes(); - ResultBodyPtr aResultBody = document()->createBody(data(), anIndexToRemove++); aResultBody->store(aCopyCompound); - aResultBody->loadAndOrientModifiedShapes(&aCopyAlgo, aCompound, GeomAPI_Shape::VERTEX, - 1, "Modified_Vertex", *aMapOfShapes.get(), - true, false, true); - aResultBody->loadAndOrientModifiedShapes(&aCopyAlgo, aCompound, GeomAPI_Shape::EDGE, - 100000, "Modified_Edge", *aMapOfShapes.get(), - true, false, true); - aResultBody->loadAndOrientModifiedShapes(&aCopyAlgo, aCompound, GeomAPI_Shape::FACE, - 200000, "Modified_Face", *aMapOfShapes.get(), - true, false, true); + aResultBody->loadModifiedShapes(aCopyAlgo, aCompound, GeomAPI_Shape::VERTEX, "Modified_Vertex"); + aResultBody->loadModifiedShapes(aCopyAlgo, aCompound, GeomAPI_Shape::EDGE, "Modified_Edge"); + aResultBody->loadModifiedShapes(aCopyAlgo, aCompound, GeomAPI_Shape::FACE, "Modified_Face"); setResult(aResultBody); } removeResults(anIndexToRemove); diff --git a/src/BuildPlugin/BuildPlugin_Edge.cpp b/src/BuildPlugin/BuildPlugin_Edge.cpp index 253de35b5..2004281d7 100644 --- a/src/BuildPlugin/BuildPlugin_Edge.cpp +++ b/src/BuildPlugin/BuildPlugin_Edge.cpp @@ -76,35 +76,30 @@ void BuildPlugin_Edge::execute() } // Copy shape. - GeomAlgoAPI_Copy aCopyAlgo(aShape); + GeomMakeShapePtr aCopyAlgo(new GeomAlgoAPI_Copy(aShape)); // Check that algo is done. - if(!aCopyAlgo.isDone()) { + if(!aCopyAlgo->isDone()) { setError("Error: " + getKind() + " algorithm failed."); return; } // Check if shape is not null. - if(!aCopyAlgo.shape().get() || aCopyAlgo.shape()->isNull()) { + if(!aCopyAlgo->shape().get() || aCopyAlgo->shape()->isNull()) { setError("Error: Resulting shape is null."); return; } // Check that resulting shape is valid. - if(!aCopyAlgo.isValid()) { + if(!aCopyAlgo->isValid()) { setError("Error: Resulting shape is not valid."); return; } // Store result. ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex); - aResultBody->storeModified(aShape, aCopyAlgo.shape()); - std::shared_ptr aSubShapes = aCopyAlgo.mapOfSubShapes(); - int aModVertexTag = 1; - std::string aModVertexName = "Modified_Vertex"; - aResultBody->loadAndOrientModifiedShapes(&aCopyAlgo, aShape, GeomAPI_Shape::VERTEX, - aModVertexTag, aModVertexName, *aSubShapes.get(), - true); + aResultBody->storeModified(aShape, aCopyAlgo->shape()); + aResultBody->loadModifiedShapes(aCopyAlgo, aShape, GeomAPI_Shape::VERTEX, "Modified_Vertex"); setResult(aResultBody, aResultIndex); ++aResultIndex; diff --git a/src/BuildPlugin/BuildPlugin_Interpolation.cpp b/src/BuildPlugin/BuildPlugin_Interpolation.cpp index e1ace5e4a..481a51ff1 100644 --- a/src/BuildPlugin/BuildPlugin_Interpolation.cpp +++ b/src/BuildPlugin/BuildPlugin_Interpolation.cpp @@ -128,7 +128,7 @@ void BuildPlugin_Interpolation::execute() ResultBodyPtr aResultBody = document()->createBody(data()); std::set::const_iterator aContextIt = aContexts.begin(); for (; aContextIt != aContexts.end(); aContextIt++) { - aResultBody->storeModified(*aContextIt, anEdge, aContextIt == aContexts.begin() ? 0 : -2); + aResultBody->storeModified(*aContextIt, anEdge, aContextIt == aContexts.begin()); } int aVertexIndex = 1; for (GeomAPI_ShapeExplorer anExp(anEdge, GeomAPI_Shape::VERTEX); anExp.more(); anExp.next()) { diff --git a/src/BuildPlugin/BuildPlugin_Polyline.cpp b/src/BuildPlugin/BuildPlugin_Polyline.cpp index d06f265d1..312f17790 100644 --- a/src/BuildPlugin/BuildPlugin_Polyline.cpp +++ b/src/BuildPlugin/BuildPlugin_Polyline.cpp @@ -107,7 +107,7 @@ void BuildPlugin_Polyline::execute() ResultBodyPtr aResultBody = document()->createBody(data()); std::set::const_iterator aContextIt = aContexts.begin(); for (; aContextIt != aContexts.end(); aContextIt++) { - aResultBody->storeModified(*aContextIt, aWire, aContextIt == aContexts.begin() ? 0 : -2); + aResultBody->storeModified(*aContextIt, aWire, aContextIt == aContexts.begin()); } aPointsIt = aPoints.cbegin(); @@ -115,7 +115,7 @@ void BuildPlugin_Polyline::execute() for (; anExp.more() && aPointsIt != aPoints.cend(); anExp.next(), ++aPointsIt) { GeomShapePtr aPoint = *aPointsIt; GeomShapePtr anEdge = anExp.current(); - aResultBody->generated(aPoint, anEdge, "Edge", 1); + aResultBody->generated(aPoint, anEdge, "Edge"); } if (!isClosed) { diff --git a/src/BuildPlugin/BuildPlugin_Shell.cpp b/src/BuildPlugin/BuildPlugin_Shell.cpp index 725f8d336..9e55284ce 100644 --- a/src/BuildPlugin/BuildPlugin_Shell.cpp +++ b/src/BuildPlugin/BuildPlugin_Shell.cpp @@ -56,29 +56,28 @@ void BuildPlugin_Shell::execute() } // Sew faces. - GeomAlgoAPI_Sewing aSewingAlgo(aShapes); + GeomMakeShapePtr aSewingAlgo(new GeomAlgoAPI_Sewing(aShapes)); // Check that algo is done. - if(!aSewingAlgo.isDone()) { + if(!aSewingAlgo->isDone()) { setError("Error: " + getKind() + " algorithm failed."); return; } // Check if shape is not null. - if(!aSewingAlgo.shape().get() || aSewingAlgo.shape()->isNull()) { + if(!aSewingAlgo->shape().get() || aSewingAlgo->shape()->isNull()) { setError("Error: Resulting shape is null."); return; } // Check that resulting shape is valid. - if(!aSewingAlgo.isValid()) { + if(!aSewingAlgo->isValid()) { setError("Error: Resulting shape is not valid."); return; } // Store result. - GeomShapePtr aResult = aSewingAlgo.shape(); - std::shared_ptr aMapOfShapes = aSewingAlgo.mapOfSubShapes(); + GeomShapePtr aResult = aSewingAlgo->shape(); int anIndex = 0; for(GeomAPI_ShapeExplorer anExp(aResult, GeomAPI_Shape::SHELL); anExp.more(); anExp.next()) { @@ -86,23 +85,27 @@ void BuildPlugin_Shell::execute() ResultBodyPtr aResultBody = document()->createBody(data(), anIndex); aResultBody->store(aShell); for(ListOfShape::const_iterator anIt = aShapes.cbegin(); anIt != aShapes.cend(); ++anIt) { - for(GeomAPI_ShapeExplorer - aFaceExp(*anIt, GeomAPI_Shape::FACE); aFaceExp.more(); aFaceExp.next()) { + for (GeomAPI_ShapeExplorer aFaceExp(*anIt, GeomAPI_Shape::FACE); + aFaceExp.more(); + aFaceExp.next()) + { GeomShapePtr aFace = aFaceExp.current(); ListOfShape aHistory; - aSewingAlgo.modified(aFace, aHistory); - for(ListOfShape::const_iterator aHistoryIt = aHistory.cbegin(); - aHistoryIt != aHistory.cend(); - ++aHistoryIt) { + aSewingAlgo->modified(aFace, aHistory); + for (ListOfShape::const_iterator aHistoryIt = aHistory.cbegin(); + aHistoryIt != aHistory.cend(); + ++aHistoryIt) + { GeomShapePtr aHistoryShape = *aHistoryIt; - if(aMapOfShapes->isBound(aHistoryShape)) { - aHistoryShape = aMapOfShapes->find(aHistoryShape); - } - if(aShell->isSubShape(aHistoryShape)) { - aResultBody->loadAndOrientModifiedShapes(&aSewingAlgo, aFace, GeomAPI_Shape::EDGE, - 1, "Modified_Edge", *aMapOfShapes.get()); - aResultBody->loadAndOrientModifiedShapes(&aSewingAlgo, aFace, GeomAPI_Shape::FACE, - 2, "Modified_Face", *aMapOfShapes.get()); + if (aShell->isSubShape(aHistoryShape, false)) { + aResultBody->loadModifiedShapes(aSewingAlgo, + aFace, + GeomAPI_Shape::EDGE, + "Modified_Edge"); + aResultBody->loadModifiedShapes(aSewingAlgo, + aFace, + GeomAPI_Shape::FACE, + "Modified_Face"); break; } } diff --git a/src/BuildPlugin/BuildPlugin_Solid.cpp b/src/BuildPlugin/BuildPlugin_Solid.cpp index 0f044564e..6e79e3b89 100644 --- a/src/BuildPlugin/BuildPlugin_Solid.cpp +++ b/src/BuildPlugin/BuildPlugin_Solid.cpp @@ -60,19 +60,18 @@ void BuildPlugin_Solid::execute() void BuildPlugin_Solid::storeResult(const ListOfShape& theOriginalShapes, const GeomShapePtr& theResultShape, - const std::shared_ptr& theAlgorithm) + const GeomMakeShapePtr& theAlgorithm) { ResultBodyPtr aResultBody = document()->createBody(data()); aResultBody->store(theResultShape); // Store faces - std::shared_ptr aMapOfSubs = theAlgorithm->mapOfSubShapes(); - int aModifiedTag = 1; - for(ListOfShape::const_iterator anIt = theOriginalShapes.cbegin(); - anIt != theOriginalShapes.cend(); ++anIt) { + for (ListOfShape::const_iterator anIt = theOriginalShapes.cbegin(); + anIt != theOriginalShapes.cend(); + ++anIt) + { GeomShapePtr aShape = *anIt; - aResultBody->loadAndOrientModifiedShapes(theAlgorithm.get(), aShape, GeomAPI_Shape::FACE, - aModifiedTag, "Modified_Face", *aMapOfSubs.get(), false, true, true); + aResultBody->loadModifiedShapes(theAlgorithm, aShape, GeomAPI_Shape::FACE, "Modified_Face"); } setResult(aResultBody); } diff --git a/src/BuildPlugin/BuildPlugin_SubShapes.cpp b/src/BuildPlugin/BuildPlugin_SubShapes.cpp index 35aa48914..bb2fa74c9 100644 --- a/src/BuildPlugin/BuildPlugin_SubShapes.cpp +++ b/src/BuildPlugin/BuildPlugin_SubShapes.cpp @@ -105,9 +105,9 @@ void BuildPlugin_SubShapes::execute() if(!aBaseShape.get()) { return; } - GeomAlgoAPI_ShapeBuilder aBuilder; - aBuilder.removeInternal(aBaseShape); - GeomShapePtr aResultShape = aBuilder.shape(); + std::shared_ptr aBuilder(new GeomAlgoAPI_ShapeBuilder()); + aBuilder->removeInternal(aBaseShape); + GeomShapePtr aResultShape = aBuilder->shape(); // Get list of shapes. ListOfShape aShapesToAdd; @@ -118,8 +118,8 @@ void BuildPlugin_SubShapes::execute() // Copy sub-shapes from list to new shape. if(!aShapesToAdd.empty()) { - aBuilder.addInternal(aResultShape, aShapesToAdd); - aResultShape = aBuilder.shape(); + aBuilder->addInternal(aResultShape, aShapesToAdd); + aResultShape = aBuilder->shape(); } // Store result. @@ -127,15 +127,17 @@ void BuildPlugin_SubShapes::execute() const int aModEdgeTag = 2; ResultBodyPtr aResultBody = document()->createBody(data()); aResultBody->storeModified(aBaseShape, aResultShape); - aResultBody->loadAndOrientModifiedShapes(&aBuilder, aBaseShape, GeomAPI_Shape::EDGE, aModEdgeTag, - "Modified_Edge", *aBuilder.mapOfSubShapes().get()); - for(ListOfShape::const_iterator - anIt = aShapesToAdd.cbegin(); anIt != aShapesToAdd.cend(); ++anIt) { + aResultBody->loadModifiedShapes(aBuilder, aBaseShape, GeomAPI_Shape::EDGE, "Modified_Edge"); + for (ListOfShape::const_iterator anIt = aShapesToAdd.cbegin(); + anIt != aShapesToAdd.cend(); + ++anIt) + { GeomAPI_Shape::ShapeType aShType = (*anIt)->shapeType(); - aResultBody->loadAndOrientModifiedShapes(&aBuilder, *anIt, aShType, - aShType == GeomAPI_Shape::VERTEX ? aModVertexTag : aModEdgeTag, - aShType == GeomAPI_Shape::VERTEX ? "Modified_Vertex" : "Modified_Edge", - *aBuilder.mapOfSubShapes().get()); + aResultBody->loadModifiedShapes(aBuilder, + *anIt, + aShType, + aShType == GeomAPI_Shape::VERTEX ? "Modified_Vertex" + : "Modified_Edge"); } setResult(aResultBody); } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp b/src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp index 99afc6e8d..e12238eaa 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp @@ -167,7 +167,7 @@ void FeaturesPlugin_Boolean::execute() std::shared_ptr anObject = *anObjectsIt; ListOfShape aListWithObject; aListWithObject.push_back(anObject); - GeomAlgoAPI_MakeShapeList aMakeShapeList; + std::shared_ptr aMakeShapeList(new GeomAlgoAPI_MakeShapeList()); std::shared_ptr aBoolAlgo; GeomShapePtr aResShape; @@ -201,7 +201,7 @@ void FeaturesPlugin_Boolean::execute() std::shared_ptr aMkShCustom( new GeomAlgoAPI_MakeShapeCustom); aMkShCustom->addModified(aPlane, aTool); - aMakeShapeList.appendAlgo(aMkShCustom); + aMakeShapeList->appendAlgo(aMkShCustom); aToolsWithPlanes.push_back(aTool); } @@ -241,7 +241,7 @@ void FeaturesPlugin_Boolean::execute() return; } - aMakeShapeList.appendAlgo(aBoolAlgo); + aMakeShapeList->appendAlgo(aBoolAlgo); if(GeomAlgoAPI_ShapeTools::volume(aResShape) > 1.e-27 || (myOperationType != BOOL_CUT && myOperationType != BOOL_COMMON)) @@ -254,9 +254,7 @@ void FeaturesPlugin_Boolean::execute() aUsedTools.insert(aUsedTools.end(), aPlanes.begin(), aPlanes.end()); } - loadNamingDS(aResultBody, anObject, aUsedTools, aResShape, - aMakeShapeList, *(aBoolAlgo->mapOfSubShapes()), - myOperationType == BOOL_FILL); + loadNamingDS(aResultBody, anObject, aUsedTools, aResShape, aMakeShapeList); setResult(aResultBody, aResultIndex); aResultIndex++; } @@ -285,7 +283,7 @@ void FeaturesPlugin_Boolean::execute() } } - GeomAlgoAPI_MakeShapeList aMakeShapeList; + std::shared_ptr aMakeShapeList(new GeomAlgoAPI_MakeShapeList()); std::shared_ptr aBoolAlgo; switch(myOperationType) { @@ -316,7 +314,7 @@ void FeaturesPlugin_Boolean::execute() std::shared_ptr aMkShCustom( new GeomAlgoAPI_MakeShapeCustom); aMkShCustom->addModified(aPlane, aTool); - aMakeShapeList.appendAlgo(aMkShCustom); + aMakeShapeList->appendAlgo(aMkShCustom); aToolsWithPlanes.push_back(aTool); } @@ -342,9 +340,7 @@ void FeaturesPlugin_Boolean::execute() return; } - aMakeShapeList.appendAlgo(aBoolAlgo); - GeomAPI_DataMapOfShapeShape aMapOfShapes; - aMapOfShapes.merge(aBoolAlgo->mapOfSubShapes()); + aMakeShapeList->appendAlgo(aBoolAlgo); GeomShapePtr aResultShape = aBoolAlgo->shape(); // Add result to not used solids from compsolid. @@ -359,8 +355,7 @@ void FeaturesPlugin_Boolean::execute() return; } - aMakeShapeList.appendAlgo(aFillerAlgo); - aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes()); + aMakeShapeList->appendAlgo(aFillerAlgo); aResultShape = aFillerAlgo->shape(); } @@ -379,9 +374,7 @@ void FeaturesPlugin_Boolean::execute() aCompSolid, aUsedTools, aResultShape, - aMakeShapeList, - aMapOfShapes, - myOperationType == BOOL_FILL); + aMakeShapeList); setResult(aResultBody, aResultIndex); aResultIndex++; } @@ -432,16 +425,14 @@ void FeaturesPlugin_Boolean::execute() 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 aMakeShapeList(new GeomAlgoAPI_MakeShapeList()); std::shared_ptr aCuttedEdgesAndFaces; if(!anEdgesAndFaces.empty()) { std::shared_ptr aCutAlgo(new GeomAlgoAPI_Boolean(anEdgesAndFaces, anOriginalShapes, GeomAlgoAPI_Boolean::BOOL_CUT)); if(aCutAlgo->isDone()) { aCuttedEdgesAndFaces = aCutAlgo->shape(); - aMakeShapeList.appendAlgo(aCutAlgo); - aMapOfShapes.merge(aCutAlgo->mapOfSubShapes()); + aMakeShapeList->appendAlgo(aCutAlgo); } } anOriginalShapes.insert(anOriginalShapes.end(), anEdgesAndFaces.begin(), @@ -459,8 +450,7 @@ void FeaturesPlugin_Boolean::execute() if(GeomAlgoAPI_ShapeTools::volume(aCutAlgo->shape()) > 1.e-27) { aSolidsToFuse.push_back(aCutAlgo->shape()); - aMakeShapeList.appendAlgo(aCutAlgo); - aMapOfShapes.merge(aCutAlgo->mapOfSubShapes()); + aMakeShapeList->appendAlgo(aCutAlgo); } } } @@ -501,8 +491,7 @@ void FeaturesPlugin_Boolean::execute() } aShape = aFuseAlgo->shape(); - aMakeShapeList.appendAlgo(aFuseAlgo); - aMapOfShapes.merge(aFuseAlgo->mapOfSubShapes()); + aMakeShapeList->appendAlgo(aFuseAlgo); } // Combine result with not used solids from compsolid and edges and faces (if we have any). @@ -534,8 +523,7 @@ void FeaturesPlugin_Boolean::execute() } aShape = aFillerAlgo->shape(); - aMakeShapeList.appendAlgo(aFillerAlgo); - aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes()); + aMakeShapeList->appendAlgo(aFillerAlgo); } std::shared_ptr aBackShape = anOriginalShapes.back(); @@ -543,7 +531,7 @@ void FeaturesPlugin_Boolean::execute() std::shared_ptr aResultBody = document()->createBody(data(), aResultIndex); loadNamingDS(aResultBody, aBackShape, anOriginalShapes, - aShape, aMakeShapeList, aMapOfShapes); + aShape, aMakeShapeList); setResult(aResultBody, aResultIndex); aResultIndex++; break; @@ -592,7 +580,7 @@ void FeaturesPlugin_Boolean::execute() } } - GeomAlgoAPI_MakeShapeList aMakeShapeList; + std::shared_ptr aMakeShapeList; GeomAPI_DataMapOfShapeShape aMapOfShapes; if(!aShapesToAdd.empty()) { // Cut objects with not used solids. @@ -604,7 +592,7 @@ void FeaturesPlugin_Boolean::execute() if(GeomAlgoAPI_ShapeTools::volume(anObjectsCutAlgo->shape()) > 1.e-27) { aShapesToSmash.clear(); aShapesToSmash.push_back(anObjectsCutAlgo->shape()); - aMakeShapeList.appendAlgo(anObjectsCutAlgo); + aMakeShapeList->appendAlgo(anObjectsCutAlgo); aMapOfShapes.merge(anObjectsCutAlgo->mapOfSubShapes()); } @@ -616,7 +604,7 @@ void FeaturesPlugin_Boolean::execute() if(GeomAlgoAPI_ShapeTools::volume(aToolsCutAlgo->shape()) > 1.e-27) { aTools.clear(); aTools.push_back(aToolsCutAlgo->shape()); - aMakeShapeList.appendAlgo(aToolsCutAlgo); + aMakeShapeList->appendAlgo(aToolsCutAlgo); aMapOfShapes.merge(aToolsCutAlgo->mapOfSubShapes()); } } @@ -642,7 +630,7 @@ void FeaturesPlugin_Boolean::execute() setError(aFeatureError); return; } - aMakeShapeList.appendAlgo(aBoolAlgo); + aMakeShapeList->appendAlgo(aBoolAlgo); aMapOfShapes.merge(aBoolAlgo->mapOfSubShapes()); // Put all (cut result, tools and not used solids) to PaveFiller. @@ -668,15 +656,14 @@ void FeaturesPlugin_Boolean::execute() } std::shared_ptr aShape = aFillerAlgo->shape(); - aMakeShapeList.appendAlgo(aFillerAlgo); + aMakeShapeList->appendAlgo(aFillerAlgo); aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes()); std::shared_ptr aFrontShape = anOriginalShapes.front(); anOriginalShapes.pop_front(); std::shared_ptr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aResultBody, aFrontShape, anOriginalShapes, - aShape, aMakeShapeList, aMapOfShapes); + loadNamingDS(aResultBody, aFrontShape, anOriginalShapes, aShape, aMakeShapeList); setResult(aResultBody, aResultIndex); aResultIndex++; @@ -697,49 +684,37 @@ void FeaturesPlugin_Boolean::loadNamingDS(std::shared_ptr t const std::shared_ptr theBaseShape, const ListOfShape& theTools, const std::shared_ptr theResultShape, - GeomAlgoAPI_MakeShape& theMakeShape, - GeomAPI_DataMapOfShapeShape& theMapOfShapes, - const bool theIsStoreAsGenerated) + const GeomMakeShapePtr& theMakeShape) { //load result if(theBaseShape->isEqual(theResultShape)) { theResultBody->store(theResultShape, false); - } else { - const int aModifyTag = 1; - const int aModifyEdgeTag = 2; - const int aModifyFaceTag = 3; - const int aDeletedTag = 4; - /// sub solids will be placed at labels 5, 6, etc. if result is compound of solids - const int aSubsolidsTag = 5; - - theResultBody->storeModified(theBaseShape, theResultShape, aSubsolidsTag); - - const std::string aModName = "Modified"; - const std::string aModEName = "Modified_Edge"; - const std::string aModFName = "Modified_Face"; - - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::EDGE, - aModifyEdgeTag, aModEName, theMapOfShapes, false, theIsStoreAsGenerated, true); - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::FACE, - aModifyFaceTag, aModFName, theMapOfShapes, false, theIsStoreAsGenerated, true); - theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape, - GeomAPI_Shape::FACE, aDeletedTag); - - int aTag; - std::string aName; - for(ListOfShape::const_iterator - anIter = theTools.begin(); anIter != theTools.end(); anIter++) { - if((*anIter)->shapeType() <= GeomAPI_Shape::FACE) { - aTag = aModifyFaceTag; - aName = aModFName; - } else { - aTag = aModifyEdgeTag; - aName = aModEName; - } - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, - aName == aModEName ? GeomAPI_Shape::EDGE : GeomAPI_Shape::FACE, - aTag, aName, theMapOfShapes, false, theIsStoreAsGenerated, true); - theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE, aDeletedTag); - } + return; + } + + theResultBody->storeModified(theBaseShape, theResultShape); + + const std::string aModEName = "Modified_Edge"; + const std::string aModFName = "Modified_Face"; + + theResultBody->loadModifiedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::EDGE, aModEName); + theResultBody->loadModifiedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::FACE, aModFName); + + theResultBody->loadDeletedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::FACE); + + std::string aName; + for (ListOfShape::const_iterator anIter = theTools.begin(); + anIter != theTools.end(); + ++anIter) + { + aName = (*anIter)->shapeType() <= GeomAPI_Shape::FACE ? aModFName + : aModEName; + theResultBody->loadModifiedShapes(theMakeShape, + *anIter, + aName == aModEName ? GeomAPI_Shape::EDGE + : GeomAPI_Shape::FACE, + aName); + + theResultBody->loadDeletedShapes(theMakeShape, *anIter, GeomAPI_Shape::FACE); } } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Boolean.h b/src/FeaturesPlugin/FeaturesPlugin_Boolean.h index ce70e57bc..95db06460 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Boolean.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Boolean.h @@ -78,9 +78,7 @@ private: const std::shared_ptr theBaseShape, const ListOfShape& theTools, const std::shared_ptr theResultShape, - GeomAlgoAPI_MakeShape& theMakeShape, - GeomAPI_DataMapOfShapeShape& theMapOfShapes, - const bool theIsStoreAsGenerated = false); + const GeomMakeShapePtr& theMakeShape); private: OperationType myOperationType; diff --git a/src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.cpp b/src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.cpp index c8cee6318..d52e23146 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.cpp @@ -20,6 +20,8 @@ #include "FeaturesPlugin_BooleanCommon.h" +#include "FeaturesPlugin_Tools.h" + #include #include #include @@ -125,8 +127,9 @@ void FeaturesPlugin_BooleanCommon::execute() } int aResultIndex = 0; - GeomAlgoAPI_MakeShapeList aMakeShapeList; - GeomAPI_DataMapOfShapeShape aMapOfShapes; + std::shared_ptr aMakeShapeList(new GeomAlgoAPI_MakeShapeList()); + std::vector aResultBaseAlgoList; + ListOfShape aResultShapesList; if (isSimpleMode) { @@ -155,8 +158,7 @@ void FeaturesPlugin_BooleanCommon::execute() } aShape = aCommonAlgo->shape(); - aMakeShapeList.appendAlgo(aCommonAlgo); - aMapOfShapes.merge(aCommonAlgo->mapOfSubShapes()); + aMakeShapeList->appendAlgo(aCommonAlgo); } GeomAPI_ShapeIterator aShapeIt(aShape); @@ -164,9 +166,23 @@ void FeaturesPlugin_BooleanCommon::execute() std::shared_ptr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aResultBody, anObjects.front(), anObjects, aShape, aMakeShapeList, aMapOfShapes); + GeomShapePtr aBaseShape = anObjects.front(); + anObjects.pop_front(); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, + aBaseShape, + anObjects, + aMakeShapeList, + aShape); setResult(aResultBody, aResultIndex); aResultIndex++; + + aTools = anObjects; + FeaturesPlugin_Tools::ResultBaseAlgo aRBA; + aRBA.resultBody = aResultBody; + aRBA.baseShape = aBaseShape; + aRBA.makeShape = aMakeShapeList; + aResultBaseAlgoList.push_back(aRBA); + aResultShapesList.push_back(aShape); } } else { for (ListOfShape::iterator anObjectsIt = anObjects.begin(); @@ -176,7 +192,7 @@ void FeaturesPlugin_BooleanCommon::execute() std::shared_ptr anObject = *anObjectsIt; ListOfShape aListWithObject; aListWithObject.push_back(anObject); - GeomAlgoAPI_MakeShapeList aMakeShapeList; + std::shared_ptr aMakeShapeList(new GeomAlgoAPI_MakeShapeList()); std::shared_ptr aBoolAlgo; GeomShapePtr aResShape; @@ -193,7 +209,7 @@ void FeaturesPlugin_BooleanCommon::execute() std::shared_ptr aMkShCustom( new GeomAlgoAPI_MakeShapeCustom); aMkShCustom->addModified(aPlane, aTool); - aMakeShapeList.appendAlgo(aMkShCustom); + aMakeShapeList->appendAlgo(aMkShCustom); aToolsWithPlanes.push_back(aTool); } @@ -219,17 +235,27 @@ void FeaturesPlugin_BooleanCommon::execute() return; } - aMakeShapeList.appendAlgo(aBoolAlgo); + aMakeShapeList->appendAlgo(aBoolAlgo); GeomAPI_ShapeIterator aShapeIt(aResShape); if (aShapeIt.more() || aResShape->shapeType() == GeomAPI_Shape::VERTEX) { std::shared_ptr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aResultBody, anObject, aTools, aResShape, - aMakeShapeList, *(aBoolAlgo->mapOfSubShapes())); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, + anObject, + aTools, + aMakeShapeList, + aResShape); setResult(aResultBody, aResultIndex); aResultIndex++; + + FeaturesPlugin_Tools::ResultBaseAlgo aRBA; + aRBA.resultBody = aResultBody; + aRBA.baseShape = anObject; + aRBA.makeShape = aMakeShapeList; + aResultBaseAlgoList.push_back(aRBA); + aResultShapesList.push_back(aResShape); } } @@ -284,8 +310,6 @@ void FeaturesPlugin_BooleanCommon::execute() } aMakeShapeList->appendAlgo(aCommonAlgo); - GeomAPI_DataMapOfShapeShape aMapOfShapes; - aMapOfShapes.merge(aCommonAlgo->mapOfSubShapes()); GeomShapePtr aResultShape = aCommonAlgo->shape(); // Add result to not used solids from compsolid. @@ -301,7 +325,6 @@ void FeaturesPlugin_BooleanCommon::execute() } aMakeShapeList->appendAlgo(aFillerAlgo); - aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes()); aResultShape = aFillerAlgo->shape(); } @@ -311,14 +334,20 @@ void FeaturesPlugin_BooleanCommon::execute() std::shared_ptr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aResultBody, - aCompSolid, - aTools, - aResultShape, - *aMakeShapeList, - aMapOfShapes); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, + aCompSolid, + aTools, + aMakeShapeList, + aResultShape); setResult(aResultBody, aResultIndex); aResultIndex++; + + FeaturesPlugin_Tools::ResultBaseAlgo aRBA; + aRBA.resultBody = aResultBody; + aRBA.baseShape = aCompSolid; + aRBA.makeShape = aMakeShapeList; + aResultBaseAlgoList.push_back(aRBA); + aResultShapesList.push_back(aResultShape); } } @@ -373,8 +402,6 @@ void FeaturesPlugin_BooleanCommon::execute() } aMakeShapeList->appendAlgo(aCommonAlgo); - GeomAPI_DataMapOfShapeShape aMapOfShapes; - aMapOfShapes.merge(aCommonAlgo->mapOfSubShapes()); GeomShapePtr aResultShape = aCommonAlgo->shape(); // Add result to not used shape from compound. @@ -402,82 +429,30 @@ void FeaturesPlugin_BooleanCommon::execute() std::shared_ptr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aResultBody, - aCompound, - aTools, - aResultShape, - *aMakeShapeList, - aMapOfShapes); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, + aCompound, + aTools, + aMakeShapeList, + aResultShape); setResult(aResultBody, aResultIndex); aResultIndex++; + + FeaturesPlugin_Tools::ResultBaseAlgo aRBA; + aRBA.resultBody = aResultBody; + aRBA.baseShape = aCompound; + aRBA.makeShape = aMakeShapeList; + aResultBaseAlgoList.push_back(aRBA); + aResultShapesList.push_back(aResultShape); } } } + // Store deleted shapes after all results has been proceeded. This is to avoid issue when in one + // result shape has been deleted, but in another it was modified or stayed. + GeomShapePtr aResultShapesCompound = GeomAlgoAPI_CompoundBuilder::compound(aResultShapesList); + FeaturesPlugin_Tools::loadDeletedShapes(aResultBaseAlgoList, aTools, aResultShapesCompound); + // remove the rest results if there were produced in the previous pass removeResults(aResultIndex); } - -//================================================================================================== -void FeaturesPlugin_BooleanCommon::loadNamingDS(ResultBodyPtr theResultBody, - const GeomShapePtr theBaseShape, - const ListOfShape& theTools, - const GeomShapePtr theResultShape, - GeomAlgoAPI_MakeShape& theMakeShape, - GeomAPI_DataMapOfShapeShape& theMapOfShapes) -{ - //load result - if (theBaseShape->isEqual(theResultShape)) { - theResultBody->store(theResultShape, false); - } else { - const int aModifyVTag = 1; - const int aModifyETag = 2; - const int aModifyFTag = 3; - const int aDeletedTag = 4; - /// sub solids will be placed at labels 5, 6, etc. if result is compound of solids - const int aSubsolidsTag = 5; - - theResultBody->storeModified(theBaseShape, theResultShape, aSubsolidsTag); - - const std::string aModVName = "Modified_Vertex"; - const std::string aModEName = "Modified_Edge"; - const std::string aModFName = "Modified_Face"; - - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::VERTEX, - aModifyVTag, aModVName, theMapOfShapes, false, - false, true); - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::EDGE, - aModifyETag, aModEName, theMapOfShapes, false, - false, true); - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::FACE, - aModifyFTag, aModFName, theMapOfShapes, false, - false, true); - - theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape, - GeomAPI_Shape::VERTEX, aDeletedTag); - theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape, - GeomAPI_Shape::EDGE, aDeletedTag); - theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape, - GeomAPI_Shape::FACE, aDeletedTag); - - for (ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++) - { - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::VERTEX, - aModifyVTag, aModVName, theMapOfShapes, false, - false, true); - - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::EDGE, - aModifyETag, aModEName, theMapOfShapes, false, - false, true); - - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE, - aModifyFTag, aModFName, theMapOfShapes, false, - false, true); - - theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::VERTEX, aDeletedTag); - theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::EDGE, aDeletedTag); - theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE, aDeletedTag); - } - } -} diff --git a/src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.h b/src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.h index caf67d38e..d7dafcd67 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.h +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.h @@ -91,17 +91,6 @@ public: /// Use plugin manager for features creation. FeaturesPlugin_BooleanCommon(); - -private: - - /// Load Naming data structure of the feature to the document - void loadNamingDS(ResultBodyPtr theResultBody, - const GeomShapePtr theBaseShape, - const ListOfShape& theTools, - const GeomShapePtr theResultShape, - GeomAlgoAPI_MakeShape& theMakeShape, - GeomAPI_DataMapOfShapeShape& theMapOfShapes); - }; #endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_BooleanCut.cpp b/src/FeaturesPlugin/FeaturesPlugin_BooleanCut.cpp index 79b959e9b..ae5cac2f5 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_BooleanCut.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanCut.cpp @@ -20,6 +20,8 @@ #include "FeaturesPlugin_BooleanCut.h" +#include "FeaturesPlugin_Tools.h" + #include #include #include @@ -32,15 +34,6 @@ #include #include -//================================================================================================== -const int ModifyVTag = 1; -const int ModifyETag = 2; -const int ModifyFTag = 3; -const int DeletedTag = 4; -/// sub solids will be placed at labels 5, 6, etc. if result is compound of solids -const int SubsolidsTag = 5; - - //================================================================================================== FeaturesPlugin_BooleanCut::FeaturesPlugin_BooleanCut() : FeaturesPlugin_Boolean(FeaturesPlugin_Boolean::BOOL_CUT) @@ -108,7 +101,7 @@ void FeaturesPlugin_BooleanCut::execute() return; } - std::vector aResultBaseAlgoList; + std::vector aResultBaseAlgoList; ListOfShape aResultShapesList; // For solids cut each object with all tools. @@ -148,13 +141,15 @@ void FeaturesPlugin_BooleanCut::execute() std::shared_ptr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aResultBody, anObject, aTools, aResShape, - *aMakeShapeList, *(aCutAlgo->mapOfSubShapes()), - false); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, + anObject, + aTools, + aMakeShapeList, + aResShape); setResult(aResultBody, aResultIndex); aResultIndex++; - ResultBaseAlgo aRBA; + FeaturesPlugin_Tools::ResultBaseAlgo aRBA; aRBA.resultBody = aResultBody; aRBA.baseShape = anObject; aRBA.makeShape = aMakeShapeList; @@ -214,8 +209,6 @@ void FeaturesPlugin_BooleanCut::execute() } aMakeShapeList->appendAlgo(aCutAlgo); - GeomAPI_DataMapOfShapeShape aMapOfShapes; - aMapOfShapes.merge(aCutAlgo->mapOfSubShapes()); GeomShapePtr aResultShape = aCutAlgo->shape(); // Add result to not used solids from compsolid. @@ -231,7 +224,6 @@ void FeaturesPlugin_BooleanCut::execute() } aMakeShapeList->appendAlgo(aFillerAlgo); - aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes()); aResultShape = aFillerAlgo->shape(); } @@ -241,17 +233,15 @@ void FeaturesPlugin_BooleanCut::execute() std::shared_ptr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aResultBody, - aCompSolid, - aTools, - aResultShape, - *aMakeShapeList, - aMapOfShapes, - false); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, + aCompSolid, + aTools, + aMakeShapeList, + aResultShape); setResult(aResultBody, aResultIndex); aResultIndex++; - ResultBaseAlgo aRBA; + FeaturesPlugin_Tools::ResultBaseAlgo aRBA; aRBA.resultBody = aResultBody; aRBA.baseShape = aCompSolid; aRBA.makeShape = aMakeShapeList; @@ -311,8 +301,6 @@ void FeaturesPlugin_BooleanCut::execute() } aMakeShapeList->appendAlgo(aCutAlgo); - GeomAPI_DataMapOfShapeShape aMapOfShapes; - aMapOfShapes.merge(aCutAlgo->mapOfSubShapes()); GeomShapePtr aResultShape = aCutAlgo->shape(); // Add result to not used shape from compound. @@ -338,17 +326,15 @@ void FeaturesPlugin_BooleanCut::execute() std::shared_ptr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aResultBody, - aCompound, - aTools, - aResultShape, - *aMakeShapeList, - aMapOfShapes, - false); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, + aCompound, + aTools, + aMakeShapeList, + aResultShape); setResult(aResultBody, aResultIndex); aResultIndex++; - ResultBaseAlgo aRBA; + FeaturesPlugin_Tools::ResultBaseAlgo aRBA; aRBA.resultBody = aResultBody; aRBA.baseShape = aCompound; aRBA.makeShape = aMakeShapeList; @@ -360,102 +346,8 @@ void FeaturesPlugin_BooleanCut::execute() // Store deleted shapes after all results has been proceeded. This is to avoid issue when in one // result shape has been deleted, but in another it was modified or stayed. GeomShapePtr aResultShapesCompound = GeomAlgoAPI_CompoundBuilder::compound(aResultShapesList); - storeDeletedShapes(aResultBaseAlgoList, aTools, aResultShapesCompound); + FeaturesPlugin_Tools::loadDeletedShapes(aResultBaseAlgoList, aTools, aResultShapesCompound); // remove the rest results if there were produced in the previous pass removeResults(aResultIndex); } - -//================================================================================================== -void FeaturesPlugin_BooleanCut::loadNamingDS(ResultBodyPtr theResultBody, - const GeomShapePtr theBaseShape, - const ListOfShape& theTools, - const GeomShapePtr theResultShape, - GeomAlgoAPI_MakeShape& theMakeShape, - GeomAPI_DataMapOfShapeShape& theMapOfShapes, - const bool theIsStoreAsGenerated) -{ - //load result - if(theBaseShape->isEqual(theResultShape)) { - theResultBody->store(theResultShape, false); - } else { - theResultBody->storeModified(theBaseShape, theResultShape, SubsolidsTag); - - const std::string aModVName = "Modified_Vertex"; - const std::string aModEName = "Modified_Edge"; - const std::string aModFName = "Modified_Face"; - - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::VERTEX, - ModifyVTag, aModVName, theMapOfShapes, false, - theIsStoreAsGenerated, true); - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::EDGE, - ModifyETag, aModEName, theMapOfShapes, false, - theIsStoreAsGenerated, true); - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::FACE, - ModifyFTag, aModFName, theMapOfShapes, false, - theIsStoreAsGenerated, true); - - for (ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++) - { - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::VERTEX, - ModifyVTag, aModVName, theMapOfShapes, false, - theIsStoreAsGenerated, true); - - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::EDGE, - ModifyETag, aModEName, theMapOfShapes, false, - theIsStoreAsGenerated, true); - - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE, - ModifyFTag, aModFName, theMapOfShapes, false, - theIsStoreAsGenerated, true); - } - } -} - -//================================================================================================== -void FeaturesPlugin_BooleanCut::storeDeletedShapes( - std::vector& theResultBaseAlgoList, - const ListOfShape& theTools, - const GeomShapePtr theResultShapesCompound) -{ - for (std::vector::iterator anIt = theResultBaseAlgoList.begin(); - anIt != theResultBaseAlgoList.end(); - ++anIt) - { - ResultBaseAlgo& aRCA = *anIt; - aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(), - aRCA.baseShape, - GeomAPI_Shape::VERTEX, - DeletedTag, - theResultShapesCompound); - aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(), - aRCA.baseShape, - GeomAPI_Shape::EDGE, - DeletedTag, - theResultShapesCompound); - aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(), - aRCA.baseShape, - GeomAPI_Shape::FACE, - DeletedTag, - theResultShapesCompound); - - for (ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++) - { - aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(), - *anIter, - GeomAPI_Shape::VERTEX, - DeletedTag, - theResultShapesCompound); - aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(), - *anIter, - GeomAPI_Shape::EDGE, - DeletedTag, - theResultShapesCompound); - aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(), - *anIter, - GeomAPI_Shape::FACE, - DeletedTag, - theResultShapesCompound); - } - } -} diff --git a/src/FeaturesPlugin/FeaturesPlugin_BooleanCut.h b/src/FeaturesPlugin/FeaturesPlugin_BooleanCut.h index 11c154ced..2cc8048f8 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_BooleanCut.h +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanCut.h @@ -55,30 +55,6 @@ public: /// Use plugin manager for features creation. FeaturesPlugin_BooleanCut(); -private: - - struct ResultBaseAlgo { - ResultBodyPtr resultBody; - GeomShapePtr baseShape; - std::shared_ptr makeShape; - }; - -private: - - /// Load Naming data structure of the feature to the document - void loadNamingDS(ResultBodyPtr theResultBody, - const GeomShapePtr theBaseShape, - const ListOfShape& theTools, - const GeomShapePtr theResultShape, - GeomAlgoAPI_MakeShape& theMakeShape, - GeomAPI_DataMapOfShapeShape& theMapOfShapes, - const bool theIsStoreAsGenerated = false); - - /// Stores deleted shapes. - void storeDeletedShapes(std::vector& theResultBaseAlgoList, - const ListOfShape& theTools, - const GeomShapePtr theResultShapesCompound); - }; #endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.cpp b/src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.cpp index 0f1ac4f72..b09cde2e7 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.cpp @@ -20,6 +20,8 @@ #include "FeaturesPlugin_BooleanFuse.h" +#include "FeaturesPlugin_Tools.h" + #include #include #include @@ -59,13 +61,14 @@ void FeaturesPlugin_BooleanFuse::initAttributes() void FeaturesPlugin_BooleanFuse::execute() { ListOfShape anObjects, aTools, anEdgesAndFaces; - std::map, ListOfShape> aCompSolidsObjects; + std::map aCompSolidsObjects; bool isSimpleCreation = false; AttributeStringPtr aCreationMethodAttr = string(CREATION_METHOD()); if (aCreationMethodAttr.get() - && aCreationMethodAttr->value() == CREATION_METHOD_SIMPLE()) { + && aCreationMethodAttr->value() == CREATION_METHOD_SIMPLE()) + { isSimpleCreation = true; } @@ -74,7 +77,7 @@ void FeaturesPlugin_BooleanFuse::execute() selectionList(FeaturesPlugin_Boolean::OBJECT_LIST_ID()); for (int anObjectsIndex = 0; anObjectsIndex < anObjectsSelList->size(); anObjectsIndex++) { AttributeSelectionPtr anObjectAttr = anObjectsSelList->value(anObjectsIndex); - std::shared_ptr anObject = anObjectAttr->value(); + GeomShapePtr anObject = anObjectAttr->value(); if (!anObject.get()) { return; } @@ -82,9 +85,10 @@ void FeaturesPlugin_BooleanFuse::execute() ResultBodyPtr aResCompSolidPtr = ModelAPI_Tools::bodyOwner(aContext); if (!isSimpleCreation && aResCompSolidPtr.get() - && aResCompSolidPtr->shape()->shapeType() == GeomAPI_Shape::COMPSOLID) { - std::shared_ptr aContextShape = aResCompSolidPtr->shape(); - std::map, ListOfShape>::iterator + && aResCompSolidPtr->shape()->shapeType() == GeomAPI_Shape::COMPSOLID) + { + GeomShapePtr aContextShape = aResCompSolidPtr->shape(); + std::map::iterator anIt = aCompSolidsObjects.begin(); for (; anIt != aCompSolidsObjects.end(); anIt++) { if (anIt->first->isEqual(aContextShape)) { @@ -136,10 +140,11 @@ void FeaturesPlugin_BooleanFuse::execute() // Collecting solids from compsolids which will not be modified // in boolean operation and will be added to result. ListOfShape aShapesToAdd; - for (std::map, ListOfShape>::iterator - anIt = aCompSolidsObjects.begin(); - anIt != aCompSolidsObjects.end(); anIt++) { - std::shared_ptr aCompSolid = anIt->first; + for (std::map::iterator anIt = aCompSolidsObjects.begin(); + anIt != aCompSolidsObjects.end(); + ++anIt) + { + GeomShapePtr aCompSolid = anIt->first; ListOfShape& aUsedInOperationSolids = anIt->second; aSolidsToFuse.insert(aSolidsToFuse.end(), aUsedInOperationSolids.begin(), aUsedInOperationSolids.end()); @@ -147,7 +152,7 @@ void FeaturesPlugin_BooleanFuse::execute() // Collect solids from compsolid which will not be modified in boolean operation. for (GeomAPI_ShapeExplorer anExp(aCompSolid, GeomAPI_Shape::SOLID); anExp.more(); anExp.next()) { - std::shared_ptr aSolidInCompSolid = anExp.current(); + GeomShapePtr aSolidInCompSolid = anExp.current(); ListOfShape::iterator anIt = aUsedInOperationSolids.begin(); for (; anIt != aUsedInOperationSolids.end(); anIt++) { if (aSolidInCompSolid->isEqual(*anIt)) { @@ -164,16 +169,14 @@ void FeaturesPlugin_BooleanFuse::execute() 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 aCuttedEdgesAndFaces; + std::shared_ptr aMakeShapeList(new GeomAlgoAPI_MakeShapeList()); + GeomShapePtr aCuttedEdgesAndFaces; if (!anEdgesAndFaces.empty()) { std::shared_ptr aCutAlgo(new GeomAlgoAPI_Boolean(anEdgesAndFaces, anOriginalShapes, GeomAlgoAPI_Boolean::BOOL_CUT)); if (aCutAlgo->isDone()) { aCuttedEdgesAndFaces = aCutAlgo->shape(); - aMakeShapeList.appendAlgo(aCutAlgo); - aMapOfShapes.merge(aCutAlgo->mapOfSubShapes()); + aMakeShapeList->appendAlgo(aCutAlgo); } } anOriginalShapes.insert(anOriginalShapes.end(), anEdgesAndFaces.begin(), @@ -191,8 +194,7 @@ void FeaturesPlugin_BooleanFuse::execute() if (GeomAlgoAPI_ShapeTools::volume(aCutAlgo->shape()) > 1.e-27) { aSolidsToFuse.push_back(aCutAlgo->shape()); - aMakeShapeList.appendAlgo(aCutAlgo); - aMapOfShapes.merge(aCutAlgo->mapOfSubShapes()); + aMakeShapeList->appendAlgo(aCutAlgo); } } } @@ -205,7 +207,7 @@ void FeaturesPlugin_BooleanFuse::execute() } // Fuse all objects and all tools. - std::shared_ptr aShape; + GeomShapePtr aShape; if (anObjects.size() == 1 && aTools.empty()) { aShape = anObjects.front(); } else if (anObjects.empty() && aTools.size() == 1) { @@ -233,8 +235,7 @@ void FeaturesPlugin_BooleanFuse::execute() } aShape = aFuseAlgo->shape(); - aMakeShapeList.appendAlgo(aFuseAlgo); - aMapOfShapes.merge(aFuseAlgo->mapOfSubShapes()); + aMakeShapeList->appendAlgo(aFuseAlgo); } // Combine result with not used solids from compsolid and edges and faces (if we have any). @@ -266,8 +267,7 @@ void FeaturesPlugin_BooleanFuse::execute() } aShape = aFillerAlgo->shape(); - aMakeShapeList.appendAlgo(aFillerAlgo); - aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes()); + aMakeShapeList->appendAlgo(aFillerAlgo); } bool isRemoveEdges = false; @@ -297,84 +297,29 @@ void FeaturesPlugin_BooleanFuse::execute() } aShape = aUnifyAlgo->shape(); - aMakeShapeList.appendAlgo(aUnifyAlgo); - aMapOfShapes.merge(aUnifyAlgo->mapOfSubShapes()); + aMakeShapeList->appendAlgo(aUnifyAlgo); } int aResultIndex = 0; - std::shared_ptr aBackShape = anOriginalShapes.back(); + GeomShapePtr aBackShape = anOriginalShapes.back(); anOriginalShapes.pop_back(); - std::shared_ptr aResultBody = - document()->createBody(data(), aResultIndex); - loadNamingDS(aResultBody, aBackShape, anOriginalShapes, - aShape, aMakeShapeList, aMapOfShapes); + ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex); + + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, + aBackShape, + anOriginalShapes, + aMakeShapeList, + aShape); setResult(aResultBody, aResultIndex); aResultIndex++; + FeaturesPlugin_Tools::loadDeletedShapes(aResultBody, + aBackShape, + anOriginalShapes, + aMakeShapeList, + aShape); + // remove the rest results if there were produced in the previous pass removeResults(aResultIndex); } - -//================================================================================================== -void FeaturesPlugin_BooleanFuse::loadNamingDS(ResultBodyPtr theResultBody, - const GeomShapePtr theBaseShape, - const ListOfShape& theTools, - const GeomShapePtr theResultShape, - GeomAlgoAPI_MakeShape& theMakeShape, - GeomAPI_DataMapOfShapeShape& theMapOfShapes) -{ - //load result - if (theBaseShape->isEqual(theResultShape)) { - theResultBody->store(theResultShape, false); - } else { - const int aModifyVTag = 1; - const int aModifyETag = 2; - const int aModifyFTag = 3; - const int aDeletedTag = 4; - /// sub solids will be placed at labels 5, 6, etc. if result is compound of solids - const int aSubsolidsTag = 5; - - theResultBody->storeModified(theBaseShape, theResultShape, aSubsolidsTag); - - const std::string aModVName = "Modified_Vertex"; - const std::string aModEName = "Modified_Edge"; - const std::string aModFName = "Modified_Face"; - - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::VERTEX, - aModifyVTag, aModVName, theMapOfShapes, false, - false, true); - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::EDGE, - aModifyETag, aModEName, theMapOfShapes, false, - false, true); - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::FACE, - aModifyFTag, aModFName, theMapOfShapes, false, - false, true); - - theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape, - GeomAPI_Shape::VERTEX, aDeletedTag); - theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape, - GeomAPI_Shape::EDGE, aDeletedTag); - theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape, - GeomAPI_Shape::FACE, aDeletedTag); - - for (ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++) - { - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::VERTEX, - aModifyVTag, aModVName, theMapOfShapes, false, - false, true); - - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::EDGE, - aModifyETag, aModEName, theMapOfShapes, false, - false, true); - - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE, - aModifyFTag, aModFName, theMapOfShapes, false, - false, true); - - theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::VERTEX, aDeletedTag); - theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::EDGE, aDeletedTag); - theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE, aDeletedTag); - } - } -} diff --git a/src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.h b/src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.h index 950b8223f..1010871c4 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.h +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.h @@ -96,15 +96,6 @@ public: /// Use plugin manager for features creation. FeaturesPlugin_BooleanFuse(); - -private: - /// Load Naming data structure of the feature to the document - void loadNamingDS(std::shared_ptr theResultBody, - const std::shared_ptr theBaseShape, - const ListOfShape& theTools, - const std::shared_ptr theResultShape, - GeomAlgoAPI_MakeShape& theMakeShape, - GeomAPI_DataMapOfShapeShape& theMapOfShapes); }; #endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.cpp b/src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.cpp index 0dbe5a348..65f1a77fe 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.cpp @@ -20,6 +20,8 @@ #include "FeaturesPlugin_BooleanSmash.h" +#include "FeaturesPlugin_Tools.h" + #include #include #include @@ -144,8 +146,7 @@ void FeaturesPlugin_BooleanSmash::execute() } } - GeomAlgoAPI_MakeShapeList aMakeShapeList; - GeomAPI_DataMapOfShapeShape aMapOfShapes; + std::shared_ptr aMakeShapeList(new GeomAlgoAPI_MakeShapeList()); if (!aShapesToAdd.empty()) { // Cut objects with not used solids. std::shared_ptr anObjectsCutAlgo( @@ -156,8 +157,7 @@ void FeaturesPlugin_BooleanSmash::execute() if (GeomAlgoAPI_ShapeTools::volume(anObjectsCutAlgo->shape()) > 1.e-27) { aShapesToSmash.clear(); aShapesToSmash.push_back(anObjectsCutAlgo->shape()); - aMakeShapeList.appendAlgo(anObjectsCutAlgo); - aMapOfShapes.merge(anObjectsCutAlgo->mapOfSubShapes()); + aMakeShapeList->appendAlgo(anObjectsCutAlgo); } // Cut tools with not used solids. @@ -169,8 +169,7 @@ void FeaturesPlugin_BooleanSmash::execute() if (GeomAlgoAPI_ShapeTools::volume(aToolsCutAlgo->shape()) > 1.e-27) { aTools.clear(); aTools.push_back(aToolsCutAlgo->shape()); - aMakeShapeList.appendAlgo(aToolsCutAlgo); - aMapOfShapes.merge(aToolsCutAlgo->mapOfSubShapes()); + aMakeShapeList->appendAlgo(aToolsCutAlgo); } } @@ -196,8 +195,7 @@ void FeaturesPlugin_BooleanSmash::execute() setError(aFeatureError); return; } - aMakeShapeList.appendAlgo(aBoolAlgo); - aMapOfShapes.merge(aBoolAlgo->mapOfSubShapes()); + aMakeShapeList->appendAlgo(aBoolAlgo); // Put all (cut result, tools and not used solids) to PaveFiller. GeomShapePtr aShape = aBoolAlgo->shape(); @@ -230,88 +228,28 @@ void FeaturesPlugin_BooleanSmash::execute() } aShape = aFillerAlgo->shape(); - aMakeShapeList.appendAlgo(aFillerAlgo); - aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes()); + aMakeShapeList->appendAlgo(aFillerAlgo); } std::shared_ptr aFrontShape = anOriginalShapes.front(); anOriginalShapes.pop_front(); std::shared_ptr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aResultBody, - aFrontShape, - anOriginalShapes, - aShape, - aMakeShapeList, - aMapOfShapes); + + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, + aFrontShape, + anOriginalShapes, + aMakeShapeList, + aShape); setResult(aResultBody, aResultIndex); aResultIndex++; + FeaturesPlugin_Tools::loadDeletedShapes(aResultBody, + aFrontShape, + anOriginalShapes, + aMakeShapeList, + aShape); + // remove the rest results if there were produced in the previous pass removeResults(aResultIndex); } - -//================================================================================================== -void FeaturesPlugin_BooleanSmash::loadNamingDS(ResultBodyPtr theResultBody, - const GeomShapePtr theBaseShape, - const ListOfShape& theTools, - const GeomShapePtr theResultShape, - GeomAlgoAPI_MakeShape& theMakeShape, - GeomAPI_DataMapOfShapeShape& theMapOfShapes) -{ - //load result - if (theBaseShape->isEqual(theResultShape)) { - theResultBody->store(theResultShape, false); - } else if (theResultShape->isEqual(theTools.front())) { - theResultBody->store(theResultShape, false); - } else { - const int aModifyVTag = 1; - const int aModifyETag = 2; - const int aModifyFTag = 3; - const int aDeletedTag = 4; - /// sub solids will be placed at labels 5, 6, etc. if result is compound of solids - const int aSubsolidsTag = 5; - - theResultBody->storeModified(theBaseShape, theResultShape, aSubsolidsTag); - - const std::string aModVName = "Modified_Vertex"; - const std::string aModEName = "Modified_Edge"; - const std::string aModFName = "Modified_Face"; - - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::VERTEX, - aModifyVTag, aModVName, theMapOfShapes, false, - true, true); - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::EDGE, - aModifyETag, aModEName, theMapOfShapes, false, - true, true); - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::FACE, - aModifyFTag, aModFName, theMapOfShapes, false, - true, true); - - theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape, - GeomAPI_Shape::VERTEX, aDeletedTag); - theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape, - GeomAPI_Shape::EDGE, aDeletedTag); - theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape, - GeomAPI_Shape::FACE, aDeletedTag); - - for (ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++) - { - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::VERTEX, - aModifyVTag, aModVName, theMapOfShapes, false, - true, true); - - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::EDGE, - aModifyETag, aModEName, theMapOfShapes, false, - true, true); - - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE, - aModifyFTag, aModFName, theMapOfShapes, false, - true, true); - - theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::VERTEX, aDeletedTag); - theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::EDGE, aDeletedTag); - theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE, aDeletedTag); - } - } -} diff --git a/src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.h b/src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.h index 0238d2712..8a0057c9b 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.h +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.h @@ -70,17 +70,6 @@ public: /// Use plugin manager for features creation. FeaturesPlugin_BooleanSmash(); - -private: - - /// Load Naming data structure of the feature to the document - void loadNamingDS(ResultBodyPtr theResultBody, - const GeomShapePtr theBaseShape, - const ListOfShape& theTools, - const GeomShapePtr theResultShape, - GeomAlgoAPI_MakeShape& theMakeShape, - GeomAPI_DataMapOfShapeShape& theMapOfShapes); - }; #endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_CompositeBoolean.cpp b/src/FeaturesPlugin/FeaturesPlugin_CompositeBoolean.cpp index 6f0d65f4d..e17304991 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_CompositeBoolean.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_CompositeBoolean.cpp @@ -86,7 +86,7 @@ void FeaturesPlugin_CompositeBoolean::executeCompositeBoolean() } else { - aResultBody->storeModified(*aBoolObjIt, (*aBoolMSIt)->shape(), aTag); + aResultBody->storeModified(*aBoolObjIt, (*aBoolMSIt)->shape()); aTag += 5000; @@ -393,25 +393,21 @@ void FeaturesPlugin_CompositeBoolean::storeModificationHistory(ResultBodyPtr the ListOfShape aTools = theTools; aTools.push_back(theObject); - std::shared_ptr aMap = theMakeShape->mapOfSubShapes(); - - int aTag; std::string aName; for(ListOfShape::const_iterator anIt = aTools.begin(); anIt != aTools.end(); anIt++) { if((*anIt)->shapeType() == GeomAPI_Shape::EDGE) { - aTag = anEdgesAndFacesTag; aName = aModName + "_Edge"; } else if((*anIt)->shapeType() == GeomAPI_Shape::FACE) { - aTag = anEdgesAndFacesTag; aName = aModName + "_Face"; } else { - aTag = aModTag; aName = aModName; } - theResultBody->loadAndOrientModifiedShapes(theMakeShape.get(), *anIt, - (*anIt)->shapeType() == GeomAPI_Shape::EDGE ? - GeomAPI_Shape::EDGE : GeomAPI_Shape::FACE, aTag, aName, *aMap.get(), false, false, true); + theResultBody->loadModifiedShapes(theMakeShape, *anIt, + (*anIt)->shapeType() == GeomAPI_Shape::EDGE ? + GeomAPI_Shape::EDGE : + GeomAPI_Shape::FACE, + aName); } } @@ -426,18 +422,16 @@ void FeaturesPlugin_CompositeBoolean::storeDeletedShapes( ++anIt) { ResultBaseAlgo& aRCA = *anIt; - aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(), + aRCA.resultBody->loadDeletedShapes(aRCA.makeShape, aRCA.baseShape, GeomAPI_Shape::FACE, - aRCA.delTag, theResultShapesCompound); for (ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++) { - aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(), + aRCA.resultBody->loadDeletedShapes(aRCA.makeShape, *anIter, GeomAPI_Shape::FACE, - aRCA.delTag, theResultShapesCompound); } } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Fillet.cpp b/src/FeaturesPlugin/FeaturesPlugin_Fillet.cpp index 8b0fdab81..2ee269e42 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Fillet.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Fillet.cpp @@ -208,20 +208,15 @@ void FeaturesPlugin_Fillet::loadNamingDS( std::shared_ptr aMapOfShapes = theMakeShape->mapOfSubShapes(); - const int aDeletedTag = 1; - const int aModifyTag = 2; const int aGeneratedTag = 3; - /// sub solids will be placed at labels 4, 5, etc. if result is compound of solids - const int aSubsolidsTag = 4; - theResultBody->storeModified(theBaseShape, theResultShape, aSubsolidsTag); + theResultBody->storeModified(theBaseShape, theResultShape); const std::string aModFaceName = "Modified_Face"; const std::string aFilletFaceName = "Fillet_Face"; // Store modified faces - theResultBody->loadAndOrientModifiedShapes(theMakeShape.get(), theBaseShape, - GeomAPI_Shape::FACE, aModifyTag, aModFaceName, *aMapOfShapes); + theResultBody->loadModifiedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::FACE, aModFaceName); // Store new faces generated from edges and vertices theResultBody->loadAndOrientGeneratedShapes(theMakeShape.get(), theBaseShape, @@ -230,8 +225,6 @@ void FeaturesPlugin_Fillet::loadNamingDS( GeomAPI_Shape::VERTEX, aGeneratedTag, aFilletFaceName, *aMapOfShapes); // Deleted shapes - theResultBody->loadDeletedShapes(theMakeShape.get(), theBaseShape, - GeomAPI_Shape::EDGE, aDeletedTag); - theResultBody->loadDeletedShapes(theMakeShape.get(), theBaseShape, - GeomAPI_Shape::FACE, aDeletedTag); + theResultBody->loadDeletedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::EDGE); + theResultBody->loadDeletedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::FACE); } diff --git a/src/FeaturesPlugin/FeaturesPlugin_FusionFaces.cpp b/src/FeaturesPlugin/FeaturesPlugin_FusionFaces.cpp index b3cc312c5..12e0325e0 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_FusionFaces.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_FusionFaces.cpp @@ -81,15 +81,10 @@ void FeaturesPlugin_FusionFaces::execute() } else { aResultBody->storeModified(aBaseShape, aResultShape); - const int aModifyEdgeTag = 1; - const int aModifyFaceTag = 2; const std::string aModEName = "Modified_Edge"; const std::string aModFName = "Modified_Face"; - std::shared_ptr aMapOfShapes = anAlgo->mapOfSubShapes(); - aResultBody->loadAndOrientModifiedShapes(anAlgo.get(), aBaseShape, GeomAPI_Shape::EDGE, - aModifyEdgeTag, aModEName, *aMapOfShapes.get(), true); - aResultBody->loadAndOrientModifiedShapes(anAlgo.get(), aBaseShape, GeomAPI_Shape::FACE, - aModifyFaceTag, aModFName, *aMapOfShapes.get(), true); + aResultBody->loadModifiedShapes(anAlgo, aBaseShape, GeomAPI_Shape::EDGE, aModEName); + aResultBody->loadModifiedShapes(anAlgo, aBaseShape, GeomAPI_Shape::FACE, aModFName); } setResult(aResultBody); } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Intersection.cpp b/src/FeaturesPlugin/FeaturesPlugin_Intersection.cpp index e421c55f4..73dec6b8a 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Intersection.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Intersection.cpp @@ -147,8 +147,7 @@ void FeaturesPlugin_Intersection::loadNamingDS(std::shared_ptrgenerated( aSubShape, diff --git a/src/FeaturesPlugin/FeaturesPlugin_MultiRotation.cpp b/src/FeaturesPlugin/FeaturesPlugin_MultiRotation.cpp index 90c459949..2410ac080 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_MultiRotation.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_MultiRotation.cpp @@ -388,34 +388,16 @@ void FeaturesPlugin_MultiRotation::loadNamingDS2( std::shared_ptr theResultBody, std::shared_ptr theBaseShape) { - int aTag = 1; - int anIndex = 1; - std::string aRotatedName; - for (std::list >::const_iterator anIt = theListOfTranslationAlgo.begin(); anIt != theListOfTranslationAlgo.cend(); ++anIt) { - std::cout << "LOAD" << std::endl; - std::shared_ptr aSubShapes = (*anIt)->mapOfSubShapes(); - // naming of faces - aRotatedName = "Rotated_Face_" + std::to_string((long long) anIndex); - theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::FACE, - aTag++, aRotatedName, *aSubShapes.get(), - false, true); + theResultBody->loadModifiedShapes(*anIt, theBaseShape, GeomAPI_Shape::FACE, "Rotated_Face"); // naming of edges - aRotatedName = "Rotated_Edge_" + std::to_string((long long) anIndex); - theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::EDGE, - aTag++, aRotatedName, *aSubShapes.get(), - false, true); + theResultBody->loadModifiedShapes(*anIt, theBaseShape, GeomAPI_Shape::EDGE, "Rotated_Edge"); // naming of vertex - aRotatedName = "Rotated_Vertex_" + std::to_string((long long) anIndex); - theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::VERTEX, - aTag++, aRotatedName, *aSubShapes.get(), - false, true); - - ++anIndex; + theResultBody->loadModifiedShapes(*anIt, theBaseShape, GeomAPI_Shape::VERTEX, "Rotated_Vertex"); } } @@ -450,31 +432,15 @@ void FeaturesPlugin_MultiRotation::loadNamingDS( std::shared_ptr theResultBody, std::shared_ptr theBaseShape) { - int aTag = 1; - int anIndex = 1; - std::string aRotatedName; - for (std::list >::const_iterator anIt = theListOfRotationAlgo.begin(); anIt != theListOfRotationAlgo.cend(); ++anIt) { - std::shared_ptr aSubShapes = (*anIt)->mapOfSubShapes(); - // naming of faces - aRotatedName = "Rotated_Face_" + std::to_string((long long) anIndex); - theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::FACE, - aTag++, aRotatedName, *aSubShapes.get(), - false, true); + theResultBody->loadModifiedShapes(*anIt, theBaseShape, GeomAPI_Shape::FACE, "Rotated_Face"); // naming of edges - aRotatedName = "Rotated_Edge_" + std::to_string((long long) anIndex); - theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::EDGE, - aTag++, aRotatedName, *aSubShapes.get(), - false, true); + theResultBody->loadModifiedShapes(*anIt, theBaseShape, GeomAPI_Shape::EDGE, "Rotated_Edge"); // naming of vertex - aRotatedName = "Rotated_Vertex_" + std::to_string((long long) anIndex); - theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::VERTEX, - aTag++, aRotatedName, *aSubShapes.get(), - false, true); - ++anIndex; + theResultBody->loadModifiedShapes(*anIt, theBaseShape, GeomAPI_Shape::VERTEX, "Rotated_Vertex"); } } diff --git a/src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.cpp b/src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.cpp index d23742c6d..81d07b5a4 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.cpp @@ -368,32 +368,24 @@ void FeaturesPlugin_MultiTranslation::loadNamingDS( std::shared_ptr theResultBody, std::shared_ptr theBaseShape) { - int aTag = 1; - int anIndex = 1; - std::string aTranslatedName; - for (std::list >::const_iterator anIt = theListOfTranslationAlgo.begin(); anIt != theListOfTranslationAlgo.cend(); ++anIt) { - std::shared_ptr aSubShapes = (*anIt)->mapOfSubShapes(); - // naming of faces - aTranslatedName = "Translated_Face_" + std::to_string((long long) anIndex); - theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::FACE, - aTag++, aTranslatedName, *aSubShapes.get(), - false, true); + theResultBody->loadModifiedShapes(*anIt, + theBaseShape, + GeomAPI_Shape::FACE, + "Translated_Face"); // naming of edges - aTranslatedName = "Translated_Edge_" + std::to_string((long long) anIndex); - theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::EDGE, - aTag++, aTranslatedName, *aSubShapes.get(), - false, true); + theResultBody->loadModifiedShapes(*anIt, + theBaseShape, + GeomAPI_Shape::EDGE, + "Translated_Edge"); // naming of vertex - aTranslatedName = "Translated_Vertex_" + std::to_string((long long) anIndex); - theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::VERTEX, - aTag++, aTranslatedName, *aSubShapes.get(), - false, true); - - ++anIndex; + theResultBody->loadModifiedShapes(*anIt, + theBaseShape, + GeomAPI_Shape::VERTEX, + "Translated_Vertex"); } } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp b/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp index cd4f34cd3..f8b1bfdb2 100755 --- a/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp @@ -204,26 +204,18 @@ void FeaturesPlugin_Partition::storeResult( return; } - const int aDelTag = 1; - /// sub solids will be placed at labels 3, 4, etc. if result is compound of solids - const int aSubTag = 2; - int aModTag = aSubTag + 10000; - const std::string aModName = "Modified"; - - aResultBody->storeModified(aBaseShape, theResultShape, aSubTag); + aResultBody->storeModified(aBaseShape, theResultShape); std::shared_ptr aMapOfSubShapes = theMakeShape->mapOfSubShapes(); theObjects.insert(theObjects.end(), thePlanes.begin(), thePlanes.end()); - int anIndex = 1; - for(ListOfShape::const_iterator anIt = theObjects.cbegin(); anIt != theObjects.cend(); ++anIt) { + for (ListOfShape::const_iterator anIt = theObjects.cbegin(); + anIt != theObjects.cend(); + ++anIt) + { GeomShapePtr aShape = *anIt; - std::string aModEdgeName = aModName + "_Edge_" + std::to_string((long long)anIndex); - aResultBody->loadAndOrientModifiedShapes(theMakeShape.get(), aShape, GeomAPI_Shape::EDGE, - aModTag, aModEdgeName, *aMapOfSubShapes.get(), false, true, true); - std::string aModFaceName = aModName + "_Face_" + std::to_string((long long)anIndex++); - aResultBody->loadAndOrientModifiedShapes(theMakeShape.get(), aShape, GeomAPI_Shape::FACE, - aModTag + 1, aModFaceName, *aMapOfSubShapes.get(), false, true, true); - aResultBody->loadDeletedShapes(theMakeShape.get(), aShape, GeomAPI_Shape::FACE, aDelTag); + aResultBody->loadModifiedShapes(theMakeShape, aShape, GeomAPI_Shape::EDGE, "Modified_Edge"); + aResultBody->loadModifiedShapes(theMakeShape, aShape, GeomAPI_Shape::FACE, "Modified_Face"); + aResultBody->loadDeletedShapes(theMakeShape, aShape, GeomAPI_Shape::FACE); } setResult(aResultBody, theIndex); diff --git a/src/FeaturesPlugin/FeaturesPlugin_Pipe.cpp b/src/FeaturesPlugin/FeaturesPlugin_Pipe.cpp index 3448c72c5..d8d90cd6e 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Pipe.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Pipe.cpp @@ -314,10 +314,10 @@ void FeaturesPlugin_Pipe::storeResult(const std::shared_ptr theBa thePipeAlgo.generated(aV1, aV1History); thePipeAlgo.generated(aV2, aV2History); if(!aV1History.empty()) { - aResultBody->generated(aV1, aV1History.front(), aGenName + "Edge_1", aGenTag++); + aResultBody->generated(aV1, aV1History.front(), aGenName + "Edge_1"); } if(!aV2History.empty()) { - aResultBody->generated(aV2, aV2History.front(), aGenName + "Edge_2", aGenTag++); + aResultBody->generated(aV2, aV2History.front(), aGenName + "Edge_2"); } } case GeomAPI_Shape::FACE: @@ -387,8 +387,8 @@ void FeaturesPlugin_Pipe::storeResult(const ListOfShape& theBaseShapes, ListOfShape aV1History, aV2History; thePipeAlgo.generated(aV1, aV1History); thePipeAlgo.generated(aV2, aV2History); - aResultBody->generated(aV1, aV1History.front(), aGenName + "Edge_1", aGenTag++); - aResultBody->generated(aV2, aV2History.front(), aGenName + "Edge_2", aGenTag++); + aResultBody->generated(aV1, aV1History.front(), aGenName + "Edge_1"); + aResultBody->generated(aV2, aV2History.front(), aGenName + "Edge_2"); } case GeomAPI_Shape::FACE: case GeomAPI_Shape::SHELL: { diff --git a/src/FeaturesPlugin/FeaturesPlugin_Placement.cpp b/src/FeaturesPlugin/FeaturesPlugin_Placement.cpp index ab932f01d..bd1e96efc 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Placement.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Placement.cpp @@ -167,29 +167,30 @@ void FeaturesPlugin_Placement::execute() setResult(aResultPart, aResultIndex); } else { std::shared_ptr aBaseShape = *anObjectsIt; - GeomAlgoAPI_Transform aTransformAlgo(aBaseShape, aTrsf); + std::shared_ptr aTransformAlgo(new GeomAlgoAPI_Transform(aBaseShape, + aTrsf)); // Checking that the algorithm worked properly. - if(!aTransformAlgo.isDone()) { + if(!aTransformAlgo->isDone()) { static const std::string aFeatureError = "Error: Transform algorithm failed."; setError(aFeatureError); break; } - if(aTransformAlgo.shape()->isNull()) { + if(aTransformAlgo->shape()->isNull()) { static const std::string aShapeError = "Error: Resulting shape is Null."; setError(aShapeError); break; } - if(!aTransformAlgo.isValid()) { + if(!aTransformAlgo->isValid()) { std::string aFeatureError = "Error: Resulting shape is not valid."; setError(aFeatureError); break; } //LoadNamingDS - std::shared_ptr aResultBody = - document()->createBody(data(), aResultIndex); - loadNamingDS(aTransformAlgo, aResultBody, aBaseShape); + ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex); + aResultBody->storeModified(aBaseShape, aTransformAlgo->shape()); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShape, aTransformAlgo, "Placed"); setResult(aResultBody, aResultIndex); } aResultIndex++; @@ -198,19 +199,3 @@ void FeaturesPlugin_Placement::execute() // Remove the rest results if there were produced in the previous pass. removeResults(aResultIndex); } - -//============================================================================ -void FeaturesPlugin_Placement::loadNamingDS(GeomAlgoAPI_Transform& theTransformAlgo, - std::shared_ptr theResultBody, - std::shared_ptr theBaseShape) -{ - //load result - theResultBody->storeModified(theBaseShape, theTransformAlgo.shape()); - - std::string aPlacedName = "Placed"; - std::shared_ptr aSubShapes = theTransformAlgo.mapOfSubShapes(); - - FeaturesPlugin_Tools::storeModifiedShapes(theTransformAlgo, theResultBody, - theBaseShape, 1, 2, 3, aPlacedName, - *aSubShapes.get()); -} diff --git a/src/FeaturesPlugin/FeaturesPlugin_Placement.h b/src/FeaturesPlugin/FeaturesPlugin_Placement.h index 1b8a7b6bd..ccc9dba8b 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Placement.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Placement.h @@ -95,11 +95,6 @@ class FeaturesPlugin_Placement : public ModelAPI_Feature /// Use plugin manager for features creation FeaturesPlugin_Placement(); -private: - /// Load Naming data structure of the feature to the document - void loadNamingDS(GeomAlgoAPI_Transform& theTransformAlgo, - std::shared_ptr theResultBody, - std::shared_ptr theBaseShape); }; #endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_RemoveSubShapes.cpp b/src/FeaturesPlugin/FeaturesPlugin_RemoveSubShapes.cpp index e4d61f163..b53eca256 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_RemoveSubShapes.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_RemoveSubShapes.cpp @@ -232,7 +232,7 @@ void FeaturesPlugin_RemoveSubShapes::execute() aResultShape = anAttrSelectionInList->value(); } // deleted and copied must be jointed to one list which keeps all the history - GeomAlgoAPI_MakeShapeList aMakeShapeList; + std::shared_ptr aMakeShapeList(new GeomAlgoAPI_MakeShapeList()); // find all removed shapes std::shared_ptr aDeletedSubs(new GeomAlgoAPI_MakeShapeCustom); @@ -263,11 +263,11 @@ void FeaturesPlugin_RemoveSubShapes::execute() } } } - aMakeShapeList.appendAlgo(aDeletedSubs); + aMakeShapeList->appendAlgo(aDeletedSubs); std::shared_ptr aCopy(new GeomAlgoAPI_Copy(aResultShape)); aResultShape = aCopy->shape(); - aMakeShapeList.appendAlgo(aCopy); + aMakeShapeList->appendAlgo(aCopy); if (aResultShape->shapeType() == GeomAPI_Shape::COMPOUND) { aResultShape = GeomAlgoAPI_ShapeTools::groupSharedTopology(aResultShape); @@ -283,15 +283,25 @@ void FeaturesPlugin_RemoveSubShapes::execute() // Store result. ResultBodyPtr aResultBody = document()->createBody(data()); - aResultBody->storeModified(aBaseShape, aResultShape, 1); - std::set::iterator aTypeIter = aTypes.begin(); - for(; aTypeIter != aTypes.end(); aTypeIter++) - aResultBody->loadDeletedShapes(&aMakeShapeList, aBaseShape, *aTypeIter, 1); - aResultBody->loadAndOrientModifiedShapes(&aMakeShapeList, aBaseShape, GeomAPI_Shape::FACE, - 2, "Modified_Face", *aMakeShapeList.mapOfSubShapes().get(), true, false, true); - aResultBody->loadAndOrientModifiedShapes(&aMakeShapeList, aBaseShape, GeomAPI_Shape::EDGE, - 3, "Modified_Edge", *aMakeShapeList.mapOfSubShapes().get(), false, false, true); - aResultBody->loadAndOrientModifiedShapes(&aMakeShapeList, aBaseShape, GeomAPI_Shape::VERTEX, - 4, "Modified_Vertex", *aMakeShapeList.mapOfSubShapes().get()); + aResultBody->storeModified(aBaseShape, aResultShape); + for (std::set::iterator aTypeIter = aTypes.begin(); + aTypeIter != aTypes.end(); + ++aTypeIter) + { + aResultBody->loadDeletedShapes(aMakeShapeList, aBaseShape, *aTypeIter); + } + + aResultBody->loadModifiedShapes(aMakeShapeList, + aBaseShape, + GeomAPI_Shape::FACE, + "Modified_Face"); + aResultBody->loadModifiedShapes(aMakeShapeList, + aBaseShape, + GeomAPI_Shape::EDGE, + "Modified_Edge"); + aResultBody->loadModifiedShapes(aMakeShapeList, + aBaseShape, + GeomAPI_Shape::VERTEX, + "Modified_Vertex"); setResult(aResultBody); } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp b/src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp index 07d2d575c..d87346d1a 100755 --- a/src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp @@ -134,34 +134,36 @@ void FeaturesPlugin_Rotation::performTranslationByAxisAndAngle() aResultPart->setTrsf(*aContext, aTrsf); setResult(aResultPart, aResultIndex); } else { - GeomAlgoAPI_Rotation aRotationAlgo(aBaseShape, anAxis, anAngle); + std::shared_ptr aRotationAlgo(new GeomAlgoAPI_Rotation(aBaseShape, + anAxis, + anAngle)); - if (!aRotationAlgo.check()) { - setError(aRotationAlgo.getError()); + if (!aRotationAlgo->check()) { + setError(aRotationAlgo->getError()); return; } - aRotationAlgo.build(); + aRotationAlgo->build(); // Checking that the algorithm worked properly. - if(!aRotationAlgo.isDone()) { + if(!aRotationAlgo->isDone()) { static const std::string aFeatureError = "Error: Rotation algorithm failed."; setError(aFeatureError); break; } - if(aRotationAlgo.shape()->isNull()) { + if(aRotationAlgo->shape()->isNull()) { static const std::string aShapeError = "Error: Resulting shape is Null."; setError(aShapeError); break; } - if(!aRotationAlgo.isValid()) { + if(!aRotationAlgo->isValid()) { std::string aFeatureError = "Error: Resulting shape is not valid."; setError(aFeatureError); break; } ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aRotationAlgo, aResultBody, aBaseShape); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShape, aRotationAlgo, "Rotated"); setResult(aResultBody, aResultIndex); } aResultIndex++; @@ -238,52 +240,40 @@ void FeaturesPlugin_Rotation::performTranslationByThreePoints() aResultPart->setTrsf(*aContext, aTrsf); setResult(aResultPart, aResultIndex); } else { - GeomAlgoAPI_Rotation aRotationAlgo(aBaseShape, aCenterPoint, aStartPoint, anEndPoint); + std::shared_ptr aRotationAlgo(new GeomAlgoAPI_Rotation(aBaseShape, + aCenterPoint, + aStartPoint, + anEndPoint)); - if (!aRotationAlgo.check()) { - setError(aRotationAlgo.getError()); + if (!aRotationAlgo->check()) { + setError(aRotationAlgo->getError()); return; } - aRotationAlgo.build(); + aRotationAlgo->build(); // Checking that the algorithm worked properly. - if(!aRotationAlgo.isDone()) { + if(!aRotationAlgo->isDone()) { static const std::string aFeatureError = "Error: Rotation algorithm failed."; setError(aFeatureError); break; } - if(aRotationAlgo.shape()->isNull()) { + if(aRotationAlgo->shape()->isNull()) { static const std::string aShapeError = "Error : Resulting shape is Null."; setError(aShapeError); break; } - if(!aRotationAlgo.isValid()) { + if(!aRotationAlgo->isValid()) { std::string aFeatureError = "Error: Resulting shape is not valid."; setError(aFeatureError); break; } ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aRotationAlgo, aResultBody, aBaseShape); + aResultBody->storeModified(aBaseShape, aRotationAlgo->shape()); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShape, aRotationAlgo, "Rotated"); setResult(aResultBody, aResultIndex); } aResultIndex++; } } - -//================================================================================================= -void FeaturesPlugin_Rotation::loadNamingDS(GeomAlgoAPI_Rotation& theRotaionAlgo, - std::shared_ptr theResultBody, - std::shared_ptr theBaseShape) -{ - // Store result. - theResultBody->storeModified(theBaseShape, theRotaionAlgo.shape()); - - std::string aRotatedName = "Rotated"; - std::shared_ptr aSubShapes = theRotaionAlgo.mapOfSubShapes(); - - FeaturesPlugin_Tools::storeModifiedShapes(theRotaionAlgo, theResultBody, - theBaseShape, 1, 2, 3, aRotatedName, - *aSubShapes.get()); -} diff --git a/src/FeaturesPlugin/FeaturesPlugin_Rotation.h b/src/FeaturesPlugin/FeaturesPlugin_Rotation.h index ce064ca21..0c8a24aee 100755 --- a/src/FeaturesPlugin/FeaturesPlugin_Rotation.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Rotation.h @@ -125,10 +125,6 @@ private: ///Perform the rotation using a center and two points. void performTranslationByThreePoints(); - - void loadNamingDS(GeomAlgoAPI_Rotation& theRotaionAlgo, - std::shared_ptr theResultBody, - std::shared_ptr theBaseShape); }; #endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_Scale.cpp b/src/FeaturesPlugin/FeaturesPlugin_Scale.cpp index 4e854c22a..a60b77984 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Scale.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Scale.cpp @@ -120,34 +120,36 @@ void FeaturesPlugin_Scale::performScaleByFactor() for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end(); anObjectsIt++, aContext++) { std::shared_ptr aBaseShape = *anObjectsIt; - GeomAlgoAPI_Scale aScaleAlgo(aBaseShape, aCenterPoint, aScaleFactor); + std::shared_ptr aScaleAlgo( + new GeomAlgoAPI_Scale(aBaseShape, aCenterPoint, aScaleFactor)); - if (!aScaleAlgo.check()) { - setError(aScaleAlgo.getError()); + if (!aScaleAlgo->check()) { + setError(aScaleAlgo->getError()); return; } - aScaleAlgo.build(); + aScaleAlgo->build(); // Checking that the algorithm worked properly. - if(!aScaleAlgo.isDone()) { + if(!aScaleAlgo->isDone()) { static const std::string aFeatureError = "Error: Symmetry algorithm failed."; setError(aFeatureError); break; } - if(aScaleAlgo.shape()->isNull()) { + if(aScaleAlgo->shape()->isNull()) { static const std::string aShapeError = "Error: Resulting shape is Null."; setError(aShapeError); break; } - if(!aScaleAlgo.isValid()) { + if(!aScaleAlgo->isValid()) { std::string aFeatureError = "Error: Resulting shape is not valid."; setError(aFeatureError); break; } ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aScaleAlgo, aResultBody, aBaseShape); + aResultBody->storeModified(aBaseShape, aScaleAlgo->shape()); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShape, aScaleAlgo, "Scaled"); setResult(aResultBody, aResultIndex); aResultIndex++; } @@ -204,35 +206,39 @@ void FeaturesPlugin_Scale::performScaleByDimensions() for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end(); anObjectsIt++, aContext++) { std::shared_ptr aBaseShape = *anObjectsIt; - GeomAlgoAPI_Scale aScaleAlgo(aBaseShape, aCenterPoint, - aScaleFactorX, aScaleFactorY, aScaleFactorZ); - - if (!aScaleAlgo.check()) { - setError(aScaleAlgo.getError()); + std::shared_ptr aScaleAlgo(new GeomAlgoAPI_Scale(aBaseShape, + aCenterPoint, + aScaleFactorX, + aScaleFactorY, + aScaleFactorZ)); + + if (!aScaleAlgo->check()) { + setError(aScaleAlgo->getError()); return; } - aScaleAlgo.build(); + aScaleAlgo->build(); // Checking that the algorithm worked properly. - if(!aScaleAlgo.isDone()) { + if(!aScaleAlgo->isDone()) { static const std::string aFeatureError = "Error: Symmetry algorithm failed."; setError(aFeatureError); break; } - if(aScaleAlgo.shape()->isNull()) { + if(aScaleAlgo->shape()->isNull()) { static const std::string aShapeError = "Error: Resulting shape is Null."; setError(aShapeError); break; } - if(!aScaleAlgo.isValid()) { + if(!aScaleAlgo->isValid()) { std::string aFeatureError = "Error: Resulting shape is not valid."; setError(aFeatureError); break; } ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aScaleAlgo, aResultBody, aBaseShape); + aResultBody->storeModified(aBaseShape, aScaleAlgo->shape()); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShape, aScaleAlgo, "Scaled"); setResult(aResultBody, aResultIndex); aResultIndex++; } @@ -240,19 +246,3 @@ void FeaturesPlugin_Scale::performScaleByDimensions() // Remove the rest results if there were produced in the previous pass. removeResults(aResultIndex); } - -//================================================================================================= -void FeaturesPlugin_Scale::loadNamingDS(GeomAlgoAPI_Scale& theScaleAlgo, - std::shared_ptr theResultBody, - std::shared_ptr theBaseShape) -{ - // Store and name the result. - theResultBody->storeModified(theBaseShape, theScaleAlgo.shape()); - - // Name the faces - std::shared_ptr aSubShapes = theScaleAlgo.mapOfSubShapes(); - std::string aScaledName = "Scaled"; - FeaturesPlugin_Tools::storeModifiedShapes(theScaleAlgo, theResultBody, - theBaseShape, 1, 2, 3, aScaledName, - *aSubShapes.get()); -} diff --git a/src/FeaturesPlugin/FeaturesPlugin_Scale.h b/src/FeaturesPlugin/FeaturesPlugin_Scale.h index 519dec4e4..9700331f7 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Scale.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Scale.h @@ -126,11 +126,6 @@ private: /// Perform symmetry using a central point and three dimensions void performScaleByDimensions(); - - /// Perform the naming - void loadNamingDS(GeomAlgoAPI_Scale& theScaleAlgo, - std::shared_ptr theResultBody, - std::shared_ptr theBaseShape); }; #endif // FEATURESPLUGIN_SCALE_H_ \ No newline at end of file diff --git a/src/FeaturesPlugin/FeaturesPlugin_Symmetry.cpp b/src/FeaturesPlugin/FeaturesPlugin_Symmetry.cpp index d50b74aa2..9fa897e5e 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Symmetry.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Symmetry.cpp @@ -345,8 +345,8 @@ void FeaturesPlugin_Symmetry::buildResult( std::shared_ptr& theSymmetryAlgo, std::shared_ptr theBaseShape, int theResultIndex) { - GeomAlgoAPI_MakeShapeList anAlgoList; - anAlgoList.appendAlgo(theSymmetryAlgo); + std::shared_ptr anAlgoList(new GeomAlgoAPI_MakeShapeList()); + anAlgoList->appendAlgo(theSymmetryAlgo); // Compose source shape and the result of symmetry. GeomShapePtr aCompound; if (boolean(KEEP_ORIGINAL_RESULT())->value()) { @@ -354,7 +354,7 @@ void FeaturesPlugin_Symmetry::buildResult( // add a copy of a base shape otherwise selection of this base shape is bad (2592) std::shared_ptr aCopyAlgo(new GeomAlgoAPI_Copy(theBaseShape)); aShapes.push_back(aCopyAlgo->shape()); - anAlgoList.appendAlgo(aCopyAlgo); + anAlgoList->appendAlgo(aCopyAlgo); aShapes.push_back(theSymmetryAlgo->shape()); aCompound = GeomAlgoAPI_CompoundBuilder::compound(aShapes); @@ -364,7 +364,7 @@ void FeaturesPlugin_Symmetry::buildResult( // Store and name the result. ResultBodyPtr aResultBody = document()->createBody(data(), theResultIndex); aResultBody->storeModified(theBaseShape, aCompound); - loadNamingDS(anAlgoList, aResultBody, theBaseShape); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, theBaseShape, anAlgoList, "Symmetried"); setResult(aResultBody, theResultIndex); } @@ -385,16 +385,3 @@ void FeaturesPlugin_Symmetry::buildResult(ResultPartPtr theOriginal, aResultPart->setTrsf(theOriginal, theTrsf); setResult(aResultPart, theResultIndex); } - -//================================================================================================= -void FeaturesPlugin_Symmetry::loadNamingDS(GeomAlgoAPI_MakeShapeList& theAlgo, - std::shared_ptr theResultBody, - std::shared_ptr theBaseShape) -{ - // Name the faces - std::shared_ptr aSubShapes = theAlgo.mapOfSubShapes(); - std::string aReflectedName = "Symmetried"; - FeaturesPlugin_Tools::storeModifiedShapes(theAlgo, theResultBody, - theBaseShape, 1, 2, 3, aReflectedName, - *aSubShapes.get()); -} diff --git a/src/FeaturesPlugin/FeaturesPlugin_Symmetry.h b/src/FeaturesPlugin/FeaturesPlugin_Symmetry.h index a19d143cf..d03cc141b 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Symmetry.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Symmetry.h @@ -137,11 +137,6 @@ private: /// Perform symmetry with respect to a plane. void performSymmetryByPlane(); - /// Perform the naming - void loadNamingDS(GeomAlgoAPI_MakeShapeList& theSymmetryAlgo, - std::shared_ptr theResultBody, - std::shared_ptr theBaseShape); - /// Create new result on given shapes and the index of result void buildResult(std::shared_ptr& theSymmetryAlgo, std::shared_ptr theBaseShape, diff --git a/src/FeaturesPlugin/FeaturesPlugin_Tools.cpp b/src/FeaturesPlugin/FeaturesPlugin_Tools.cpp index 07709d1ed..e18c6f44e 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Tools.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Tools.cpp @@ -24,47 +24,114 @@ #include -void FeaturesPlugin_Tools::storeModifiedShapes(GeomAlgoAPI_MakeShape& theAlgo, - std::shared_ptr theResultBody, - std::shared_ptr theBaseShape, - const int theFaceTag, - const int theEdgeTag, - const int theVertexTag, - const std::string theName, - GeomAPI_DataMapOfShapeShape& theSubShapes) +//================================================================================================== +void FeaturesPlugin_Tools::loadModifiedShapes(ResultBodyPtr theResultBody, + const GeomShapePtr theBaseShape, + const ListOfShape& theTools, + const GeomMakeShapePtr& theMakeShape, + const GeomShapePtr theResultShape) +{ + if (theBaseShape->isEqual(theResultShape)) { + theResultBody->store(theResultShape, false); + return; + } + + theResultBody->storeModified(theBaseShape, theResultShape); + + ListOfShape aShapes = theTools; + aShapes.push_front(theBaseShape); + + for (ListOfShape::const_iterator anIter = aShapes.begin(); anIter != aShapes.end(); ++anIter) + { + theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::VERTEX); + theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::EDGE); + theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::FACE); + } +} + +//================================================================================================== +void FeaturesPlugin_Tools::loadModifiedShapes(ResultBodyPtr theResultBody, + const GeomShapePtr theBaseShape, + const GeomMakeShapePtr& theMakeShape, + const std::string theName) { switch(theBaseShape->shapeType()) { case GeomAPI_Shape::COMPOUND: { for(GeomAPI_ShapeIterator anIt(theBaseShape); anIt.more(); anIt.next()) { - storeModifiedShapes(theAlgo, - theResultBody, - anIt.current(), - theFaceTag, - theEdgeTag, - theVertexTag, - theName, - theSubShapes); + loadModifiedShapes(theResultBody, + anIt.current(), + theMakeShape, + theName); } break; } case GeomAPI_Shape::COMPSOLID: case GeomAPI_Shape::SOLID: case GeomAPI_Shape::SHELL: { - theResultBody->loadAndOrientModifiedShapes(&theAlgo, - theBaseShape, GeomAPI_Shape::FACE, - theFaceTag, theName + "_Face", theSubShapes, false, true); + theResultBody->loadModifiedShapes(theMakeShape, + theBaseShape, + GeomAPI_Shape::FACE, + theName + "_Face"); } case GeomAPI_Shape::FACE: case GeomAPI_Shape::WIRE: { - theResultBody->loadAndOrientModifiedShapes(&theAlgo, - theBaseShape, GeomAPI_Shape::EDGE, - theEdgeTag, theName + "_Edge", theSubShapes, false, true); + theResultBody->loadModifiedShapes(theMakeShape, + theBaseShape, + GeomAPI_Shape::EDGE, + theName + "_Edge"); } case GeomAPI_Shape::EDGE: { - theResultBody->loadAndOrientModifiedShapes(&theAlgo, - theBaseShape, GeomAPI_Shape::VERTEX, - theVertexTag, theName + "_Vertex", theSubShapes, false, true); + theResultBody->loadModifiedShapes(theMakeShape, + theBaseShape, + GeomAPI_Shape::VERTEX, + theName + "_Vertex"); } } } + +//================================================================================================== +void FeaturesPlugin_Tools::loadDeletedShapes(ResultBodyPtr theResultBody, + const GeomShapePtr theBaseShape, + const ListOfShape& theTools, + const GeomMakeShapePtr& theMakeShape, + const GeomShapePtr theResultShapesCompound) +{ + ListOfShape aShapes = theTools; + aShapes.push_front(theBaseShape); + + for (ListOfShape::const_iterator anIter = aShapes.begin(); anIter != aShapes.end(); anIter++) + { + theResultBody->loadDeletedShapes(theMakeShape, + *anIter, + GeomAPI_Shape::VERTEX, + theResultShapesCompound); + theResultBody->loadDeletedShapes(theMakeShape, + *anIter, + GeomAPI_Shape::EDGE, + theResultShapesCompound); + theResultBody->loadDeletedShapes(theMakeShape, + *anIter, + GeomAPI_Shape::FACE, + theResultShapesCompound); + } +} + +//================================================================================================== +void FeaturesPlugin_Tools::loadDeletedShapes( + std::vector& theResultBaseAlgoList, + const ListOfShape& theTools, + const GeomShapePtr theResultShapesCompound) +{ + for (std::vector::iterator anIt = theResultBaseAlgoList.begin(); + anIt != theResultBaseAlgoList.end(); + ++anIt) + { + ResultBaseAlgo& aRCA = *anIt; + loadDeletedShapes(aRCA.resultBody, + aRCA.baseShape, + theTools, + aRCA.makeShape, + theResultShapesCompound); + } +} diff --git a/src/FeaturesPlugin/FeaturesPlugin_Tools.h b/src/FeaturesPlugin/FeaturesPlugin_Tools.h index 02a0b5e45..22b269b04 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Tools.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Tools.h @@ -21,20 +21,42 @@ #ifndef FeaturesPlugin_Tools_H_ #define FeaturesPlugin_Tools_H_ -#include +#include +#include -class ModelAPI_ResultBody; +#include class FeaturesPlugin_Tools { public: - static void storeModifiedShapes(GeomAlgoAPI_MakeShape& theAlgo, - std::shared_ptr theResultBody, - std::shared_ptr theBaseShape, - const int theFaceTag, - const int theEdgeTag, - const int theVertexTag, - const std::string theName, - GeomAPI_DataMapOfShapeShape& theSubShapes); + struct ResultBaseAlgo { + ResultBodyPtr resultBody; + GeomShapePtr baseShape; + GeomMakeShapePtr makeShape; + }; + +public: + static void loadModifiedShapes(ResultBodyPtr theResultBody, + const GeomShapePtr theBaseShape, + const ListOfShape& theTools, + const GeomMakeShapePtr& theMakeShape, + const GeomShapePtr theResultShape); + + static void loadModifiedShapes(ResultBodyPtr theResultBody, + const GeomShapePtr theBaseShape, + const GeomMakeShapePtr& theMakeShape, + const std::string theName); + + /// Stores deleted shapes. + static void loadDeletedShapes(ResultBodyPtr theResultBody, + const GeomShapePtr theBaseShape, + const ListOfShape& theTools, + const GeomMakeShapePtr& theMakeShape, + const GeomShapePtr theResultShapesCompound); + + /// Stores deleted shapes. + static void loadDeletedShapes(std::vector& theResultBaseAlgoList, + const ListOfShape& theTools, + const GeomShapePtr theResultShapesCompound); }; #endif /* FeaturesPlugin_Tools_H_ */ diff --git a/src/FeaturesPlugin/FeaturesPlugin_Translation.cpp b/src/FeaturesPlugin/FeaturesPlugin_Translation.cpp index 0da4b6acc..19ec3564a 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Translation.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Translation.cpp @@ -147,34 +147,39 @@ void FeaturesPlugin_Translation::performTranslationByAxisAndDistance() aResultPart->setTrsf(*aContext, aTrsf); setResult(aResultPart, aResultIndex); } else { - GeomAlgoAPI_Translation aTranslationAlgo(aBaseShape, anAxis, aDistance); + std::shared_ptr aTranslationAlgo( + new GeomAlgoAPI_Translation(aBaseShape, anAxis, aDistance)); - if (!aTranslationAlgo.check()) { - setError(aTranslationAlgo.getError()); + if (!aTranslationAlgo->check()) { + setError(aTranslationAlgo->getError()); return; } - aTranslationAlgo.build(); + aTranslationAlgo->build(); // Checking that the algorithm worked properly. - if(!aTranslationAlgo.isDone()) { + if(!aTranslationAlgo->isDone()) { static const std::string aFeatureError = "Error: Translation algorithm failed."; setError(aFeatureError); break; } - if(aTranslationAlgo.shape()->isNull()) { + if(aTranslationAlgo->shape()->isNull()) { static const std::string aShapeError = "Error: Resulting shape is Null."; setError(aShapeError); break; } - if(!aTranslationAlgo.isValid()) { + if(!aTranslationAlgo->isValid()) { std::string aFeatureError = "Error: Resulting shape is not valid."; setError(aFeatureError); break; } ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aTranslationAlgo, aResultBody, aBaseShape); + aResultBody->storeModified(aBaseShape, aTranslationAlgo->shape()); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, + aBaseShape, + aTranslationAlgo, + "Translated"); setResult(aResultBody, aResultIndex); } aResultIndex++; @@ -229,34 +234,39 @@ void FeaturesPlugin_Translation::performTranslationByDimensions() aResultPart->setTrsf(*aContext, aTrsf); setResult(aResultPart, aResultIndex); } else { - GeomAlgoAPI_Translation aTranslationAlgo(aBaseShape, aDX, aDY, aDZ); + std::shared_ptr aTranslationAlgo( + new GeomAlgoAPI_Translation(aBaseShape, aDX, aDY, aDZ)); - if (!aTranslationAlgo.check()) { - setError(aTranslationAlgo.getError()); + if (!aTranslationAlgo->check()) { + setError(aTranslationAlgo->getError()); return; } - aTranslationAlgo.build(); + aTranslationAlgo->build(); // Checking that the algorithm worked properly. - if(!aTranslationAlgo.isDone()) { + if(!aTranslationAlgo->isDone()) { static const std::string aFeatureError = "Error: Translation algorithm failed."; setError(aFeatureError); break; } - if(aTranslationAlgo.shape()->isNull()) { + if(aTranslationAlgo->shape()->isNull()) { static const std::string aShapeError = "Error: Resulting shape is Null."; setError(aShapeError); break; } - if(!aTranslationAlgo.isValid()) { + if(!aTranslationAlgo->isValid()) { std::string aFeatureError = "Error: Resulting shape is not valid."; setError(aFeatureError); break; } ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aTranslationAlgo, aResultBody, aBaseShape); + aResultBody->storeModified(aBaseShape, aTranslationAlgo->shape()); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, + aBaseShape, + aTranslationAlgo, + "Translated"); setResult(aResultBody, aResultIndex); } aResultIndex++; @@ -324,34 +334,39 @@ void FeaturesPlugin_Translation::performTranslationByTwoPoints() aResultPart->setTrsf(*aContext, aTrsf); setResult(aResultPart, aResultIndex); } else { - GeomAlgoAPI_Translation aTranslationAlgo(aBaseShape, aFirstPoint, aSecondPoint); + std::shared_ptr aTranslationAlgo( + new GeomAlgoAPI_Translation(aBaseShape, aFirstPoint, aSecondPoint)); - if (!aTranslationAlgo.check()) { - setError(aTranslationAlgo.getError()); + if (!aTranslationAlgo->check()) { + setError(aTranslationAlgo->getError()); return; } - aTranslationAlgo.build(); + aTranslationAlgo->build(); // Checking that the algorithm worked properly. - if(!aTranslationAlgo.isDone()) { + if(!aTranslationAlgo->isDone()) { static const std::string aFeatureError = "Error: Translation algorithm failed."; setError(aFeatureError); break; } - if(aTranslationAlgo.shape()->isNull()) { + if(aTranslationAlgo->shape()->isNull()) { static const std::string aShapeError = "Error: Resulting shape is Null."; setError(aShapeError); break; } - if(!aTranslationAlgo.isValid()) { + if(!aTranslationAlgo->isValid()) { std::string aFeatureError = "Error: Resulting shape is not valid."; setError(aFeatureError); break; } ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aTranslationAlgo, aResultBody, aBaseShape); + aResultBody->storeModified(aBaseShape, aTranslationAlgo->shape()); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, + aBaseShape, + aTranslationAlgo, + "Translated"); setResult(aResultBody, aResultIndex); } aResultIndex++; @@ -360,19 +375,3 @@ void FeaturesPlugin_Translation::performTranslationByTwoPoints() // Remove the rest results if there were produced in the previous pass. removeResults(aResultIndex); } - -//================================================================================================= -void FeaturesPlugin_Translation::loadNamingDS(GeomAlgoAPI_Translation& theTranslationAlgo, - std::shared_ptr theResultBody, - std::shared_ptr theBaseShape) -{ - // Store result. - theResultBody->storeModified(theBaseShape, theTranslationAlgo.shape()); - - std::string aTranslatedName = "Translated"; - std::shared_ptr aSubShapes = theTranslationAlgo.mapOfSubShapes(); - - FeaturesPlugin_Tools::storeModifiedShapes(theTranslationAlgo, theResultBody, - theBaseShape, 1, 2, 3, aTranslatedName, - *aSubShapes.get()); -} diff --git a/src/FeaturesPlugin/FeaturesPlugin_Translation.h b/src/FeaturesPlugin/FeaturesPlugin_Translation.h index 191f208ab..624d8de39 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Translation.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Translation.h @@ -149,10 +149,6 @@ private: ///Perform the translation usind two points void performTranslationByTwoPoints(); - - void loadNamingDS(GeomAlgoAPI_Translation& theTranslationAlgo, - std::shared_ptr theResultBody, - std::shared_ptr theBaseShape); }; #endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_Union.cpp b/src/FeaturesPlugin/FeaturesPlugin_Union.cpp index 775da23a3..9c9cfdc5a 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Union.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Union.cpp @@ -121,7 +121,7 @@ void FeaturesPlugin_Union::execute() } // Checking that the algorithm worked properly. - GeomAlgoAPI_MakeShapeList aMakeShapeList; + std::shared_ptr aMakeShapeList(new GeomAlgoAPI_MakeShapeList()); GeomAPI_DataMapOfShapeShape aMapOfShapes; if(!anAlgo->isDone()) { setError("Error: Boolean algorithm failed."); @@ -137,7 +137,7 @@ void FeaturesPlugin_Union::execute() } GeomShapePtr aShape = anAlgo->shape(); - aMakeShapeList.appendAlgo(anAlgo); + aMakeShapeList->appendAlgo(anAlgo); aMapOfShapes.merge(anAlgo->mapOfSubShapes()); // Store original shapes for naming. @@ -163,30 +163,21 @@ void FeaturesPlugin_Union::execute() } aShape = aFillerAlgo->shape(); - aMakeShapeList.appendAlgo(aFillerAlgo); + aMakeShapeList->appendAlgo(aFillerAlgo); aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes()); } // workaround: make copy to name edges correctly // Store result and naming. - const int aModifyEdgeTag = 1; - const int aModifyFaceTag = 2; - const int aDeletedTag = 3; - /// sub solids will be placed at labels 4, 5 etc. if result is compound of solids - const int aSubsolidsTag = 4; const std::string aModEName = "Modified_Edge"; const std::string aModFName = "Modified_Face"; std::shared_ptr aResultBody = document()->createBody(data()); - aResultBody->storeModified(anObjects.front(), aShape, aSubsolidsTag); + aResultBody->storeModified(anObjects.front(), aShape); for(ListOfShape::const_iterator anIter = anObjects.begin(); anIter != anObjects.end(); ++anIter) { - aResultBody->loadAndOrientModifiedShapes(&aMakeShapeList, *anIter, GeomAPI_Shape::EDGE, - aModifyEdgeTag, aModEName, aMapOfShapes, - false, true, true); - aResultBody->loadAndOrientModifiedShapes(&aMakeShapeList, *anIter, GeomAPI_Shape::FACE, - aModifyFaceTag, aModFName, aMapOfShapes, - false, true, true); + aResultBody->loadModifiedShapes(aMakeShapeList, *anIter, GeomAPI_Shape::EDGE, aModEName); + aResultBody->loadModifiedShapes(aMakeShapeList, *anIter, GeomAPI_Shape::FACE, aModFName); //aResultBody->loadDeletedShapes(&aMakeShapeList, *anIter, GeomAPI_Shape::FACE, aDeletedTag); } diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.cpp index 6ed3adf8e..ded490e1f 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.cpp @@ -21,6 +21,7 @@ #include "GeomAlgoAPI_MakeShape.h" #include +#include #include #include #include @@ -31,7 +32,9 @@ #include #include #include +#include #include +#include // new shape -> old shapes -> index in the old shape typedef NCollection_DataMap > HistoryMap; -//================================================================================================= +//================================================================================================== GeomAlgoAPI_MakeShape::GeomAlgoAPI_MakeShape() : myBuilderType(Unknown), myDone(false) @@ -49,32 +52,34 @@ GeomAlgoAPI_MakeShape::GeomAlgoAPI_MakeShape() myHist = 0; } -GeomAlgoAPI_MakeShape::~GeomAlgoAPI_MakeShape() { +//================================================================================================== +GeomAlgoAPI_MakeShape::~GeomAlgoAPI_MakeShape() +{ if (myHist) { delete (HistoryMap*)myHist; } } -//================================================================================================= +//================================================================================================== bool GeomAlgoAPI_MakeShape::isDone() const { return myDone; } -//================================================================================================= -const std::shared_ptr GeomAlgoAPI_MakeShape::shape() const +//================================================================================================== +const GeomShapePtr GeomAlgoAPI_MakeShape::shape() const { return myShape; } -//================================================================================================= +//================================================================================================== bool GeomAlgoAPI_MakeShape::isValid() const { BRepCheck_Analyzer aChecker(myShape->impl()); return (aChecker.IsValid() == Standard_True); } -//================================================================================================= +//================================================================================================== bool GeomAlgoAPI_MakeShape::hasVolume() const { bool hasVolume = false; @@ -88,88 +93,86 @@ bool GeomAlgoAPI_MakeShape::hasVolume() const return hasVolume; } -//================================================================================================= +//================================================================================================== std::shared_ptr GeomAlgoAPI_MakeShape::mapOfSubShapes() const { return myMap; } -//================================================================================================= -void GeomAlgoAPI_MakeShape::generated(const std::shared_ptr theShape, - ListOfShape& theHistory) +//================================================================================================== +void GeomAlgoAPI_MakeShape::generated(const GeomShapePtr theOldShape, + ListOfShape& theNewShapes) { TopTools_ListOfShape aList; if(myBuilderType == OCCT_BRepBuilderAPI_MakeShape) { BRepBuilderAPI_MakeShape* aMakeShape = implPtr(); - aList = aMakeShape->Generated(theShape->impl()); + aList = aMakeShape->Generated(theOldShape->impl()); } else if(myBuilderType == OCCT_BOPAlgo_Builder) { BOPAlgo_Builder* aBOPBuilder = implPtr(); - aList = aBOPBuilder->Generated(theShape->impl()); + aList = aBOPBuilder->Generated(theOldShape->impl()); } for(TopTools_ListIteratorOfListOfShape anIt(aList); anIt.More(); anIt.Next()) { - if(anIt.Value().IsNull()) { - continue; - } - std::shared_ptr aShape(new GeomAPI_Shape()); + GeomShapePtr aShape(new GeomAPI_Shape()); aShape->setImpl(new TopoDS_Shape(anIt.Value())); - theHistory.push_back(aShape); + if (!isValidForHistory(aShape)) continue; + fixOrientation(aShape); + theNewShapes.push_back(aShape); } } -//================================================================================================= -void GeomAlgoAPI_MakeShape::modified(const std::shared_ptr theShape, - ListOfShape& theHistory) +//================================================================================================== +void GeomAlgoAPI_MakeShape::modified(const GeomShapePtr theOldShape, + ListOfShape& theNewShapes) { TopTools_ListOfShape aList; if(myBuilderType == OCCT_BRepBuilderAPI_MakeShape) { BRepBuilderAPI_MakeShape* aMakeShape = implPtr(); try { - aList = aMakeShape->Modified(theShape->impl()); + aList = aMakeShape->Modified(theOldShape->impl()); } catch(Standard_NoSuchObject) { } } else if(myBuilderType == OCCT_BOPAlgo_Builder) { BOPAlgo_Builder* aBOPBuilder = implPtr(); - aList = aBOPBuilder->Modified(theShape->impl()); + aList = aBOPBuilder->Modified(theOldShape->impl()); } for(TopTools_ListIteratorOfListOfShape anIt(aList); anIt.More(); anIt.Next()) { - if(anIt.Value().IsNull()) { - continue; - } - std::shared_ptr aShape(new GeomAPI_Shape()); + GeomShapePtr aShape(new GeomAPI_Shape()); aShape->setImpl(new TopoDS_Shape(anIt.Value())); - theHistory.push_back(aShape); + if (!isValidForHistory(aShape)) continue; + fixOrientation(aShape); + theNewShapes.push_back(aShape); } } -//================================================================================================= -bool GeomAlgoAPI_MakeShape::isDeleted(const std::shared_ptr theShape) +//================================================================================================== +bool GeomAlgoAPI_MakeShape::isDeleted(const GeomShapePtr theOldShape) { bool isDeleted = false; if(myBuilderType == OCCT_BRepBuilderAPI_MakeShape) { BRepBuilderAPI_MakeShape* aMakeShape = implPtr(); - isDeleted = aMakeShape->IsDeleted(theShape->impl()) == Standard_True; + isDeleted = aMakeShape->IsDeleted(theOldShape->impl()) == Standard_True; } else if(myBuilderType == OCCT_BOPAlgo_Builder) { BOPAlgo_Builder* aBOPBuilder = implPtr(); - isDeleted = aBOPBuilder->IsDeleted(theShape->impl()) == Standard_True; + isDeleted = aBOPBuilder->IsDeleted(theOldShape->impl()) == Standard_True; } return isDeleted; } -//================================================================================================= +//================================================================================================== void GeomAlgoAPI_MakeShape::setBuilderType(const BuilderType theBuilderType) { myBuilderType = theBuilderType; } -//================================================================================================= +//================================================================================================== void GeomAlgoAPI_MakeShape::setDone(const bool theFlag) { myDone = theFlag; } -//================================================================================================= -void GeomAlgoAPI_MakeShape::setShape(const std::shared_ptr theShape) +//================================================================================================== +void GeomAlgoAPI_MakeShape::setShape(const GeomShapePtr theShape) { if(myShape.get() && myShape->isEqual(theShape)) { return; @@ -187,17 +190,17 @@ void GeomAlgoAPI_MakeShape::setShape(const std::shared_ptr theSha const TopoDS_Shape& aTopoDSShape = myShape->impl(); for(TopExp_Explorer anExp(aTopoDSShape,TopAbs_VERTEX); anExp.More(); anExp.Next()) { - std::shared_ptr aCurrentShape(new GeomAPI_Shape()); + GeomShapePtr aCurrentShape(new GeomAPI_Shape()); aCurrentShape->setImpl(new TopoDS_Shape(anExp.Current())); myMap->bind(aCurrentShape, aCurrentShape); } for(TopExp_Explorer anExp(aTopoDSShape,TopAbs_EDGE); anExp.More(); anExp.Next()) { - std::shared_ptr aCurrentShape(new GeomAPI_Shape()); + GeomShapePtr aCurrentShape(new GeomAPI_Shape()); aCurrentShape->setImpl(new TopoDS_Shape(anExp.Current())); myMap->bind(aCurrentShape, aCurrentShape); } for(TopExp_Explorer anExp(aTopoDSShape,TopAbs_FACE); anExp.More(); anExp.Next()) { - std::shared_ptr aCurrentShape(new GeomAPI_Shape()); + GeomShapePtr aCurrentShape(new GeomAPI_Shape()); aCurrentShape->setImpl(new TopoDS_Shape(anExp.Current())); myMap->bind(aCurrentShape, aCurrentShape); } @@ -208,8 +211,30 @@ void GeomAlgoAPI_MakeShape::setShape(const std::shared_ptr theSha } } -//================================================================================================= -void GeomAlgoAPI_MakeShape::initialize() { +//================================================================================================== +bool GeomAlgoAPI_MakeShape::isValidForHistory(const GeomShapePtr theShape) +{ + if (!theShape.get()) return false; + + const TopoDS_Shape& aShape_ = theShape->impl(); + if (aShape_.IsNull()) return false; + + if (aShape_.ShapeType() == TopAbs_EDGE) { + TopoDS_Edge anEdge_ = TopoDS::Edge(aShape_); + if (BRep_Tool::Degenerated(anEdge_)) return false; + } + + return true; +} + +//================================================================================================== +void GeomAlgoAPI_MakeShape::fixOrientation(GeomShapePtr& theShape) { + if (myMap->isBound(theShape)) theShape = myMap->find(theShape); +} + +//================================================================================================== +void GeomAlgoAPI_MakeShape::initialize() +{ switch (myBuilderType) { case OCCT_BRepBuilderAPI_MakeShape: { myDone = implPtr()->IsDone() == Standard_True; @@ -233,7 +258,7 @@ void GeomAlgoAPI_MakeShape::initialize() { const TopoDS_Shape& aTopoDSShape = myShape->impl(); for(TopExp_Explorer anExp(aTopoDSShape,TopAbs_FACE); anExp.More(); anExp.Next()) { - std::shared_ptr aCurrentShape(new GeomAPI_Shape()); + GeomShapePtr aCurrentShape(new GeomAPI_Shape()); aCurrentShape->setImpl(new TopoDS_Shape(anExp.Current())); myMap->bind(aCurrentShape, aCurrentShape); } @@ -241,21 +266,21 @@ void GeomAlgoAPI_MakeShape::initialize() { } -//================================================================================================= +//================================================================================================== void GeomAlgoAPI_MakeShape::prepareNamingFaces() { long long index = 1; GeomAPI_ShapeExplorer anExp(shape(), GeomAPI_Shape::FACE); for(GeomAPI_ShapeExplorer anExp(shape(), GeomAPI_Shape::FACE); anExp.more(); anExp.next()) { - std::shared_ptr aFace = anExp.current(); + GeomShapePtr aFace = anExp.current(); myCreatedFaces["Face_" + std::to_string(index++)] = aFace; } } -//================================================================================================= -bool GeomAlgoAPI_MakeShape::checkValid(std::string theMessage){ - +//================================================================================================== +bool GeomAlgoAPI_MakeShape::checkValid(std::string theMessage) +{ // isValid() is called from this method if (!isValid()) { myError = theMessage + " :: resulting shape is not valid."; @@ -278,8 +303,9 @@ bool GeomAlgoAPI_MakeShape::checkValid(std::string theMessage){ return true ; } -bool GeomAlgoAPI_MakeShape::newShapesCollected( - std::shared_ptr theWholeOld, const int theShapeType) +//================================================================================================== +bool GeomAlgoAPI_MakeShape::isNewShapesCollected(GeomShapePtr theWholeOld, + const int theShapeType) { if (!myHist) return false; @@ -290,7 +316,7 @@ bool GeomAlgoAPI_MakeShape::newShapesCollected( } void GeomAlgoAPI_MakeShape::collectNewShapes( - std::shared_ptr theWholeOld, const int theShapeType) + GeomShapePtr theWholeOld, const int theShapeType) { if (!myHist) myHist = new HistoryMap; @@ -339,9 +365,10 @@ static void addAllSubs(const TopoDS_Shape& theNewShape, } } -std::shared_ptr GeomAlgoAPI_MakeShape::oldShapesForNew( - std::shared_ptr theWholeOld, - std::shared_ptr theNewShape, const int theShapeType) +//================================================================================================== +GeomShapePtr GeomAlgoAPI_MakeShape::oldShapesForNew(GeomShapePtr theWholeOld, + GeomShapePtr theNewShape, + const int theShapeType) { GeomShapePtr aResult(new GeomAPI_Shape); TopoDS_Compound aResComp; diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h index eb2396c96..cb5d3f0eb 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h @@ -52,7 +52,8 @@ public: /// \brief Constructor by builder and builder type. /// \param[in] theBuilder pointer to the builder. /// \param[in] theBuilderType builder type. - template explicit GeomAlgoAPI_MakeShape(T* theBuilder, + template explicit GeomAlgoAPI_MakeShape( + T* theBuilder, const BuilderType theBuilderType = OCCT_BRepBuilderAPI_MakeShape) : GeomAPI_Interface(theBuilder), myBuilderType(theBuilderType) @@ -63,7 +64,8 @@ public: /// \brief Initializes internals. /// \param[in] theBuilder pointer to the builder. /// \param[in] theBuilderType builder type. - template void initialize(T* theBuilder, + template void initialize( + T* theBuilder, const BuilderType theBuilderType = OCCT_BRepBuilderAPI_MakeShape) { setImpl(theBuilder); @@ -75,7 +77,7 @@ public: GEOMALGOAPI_EXPORT bool isDone() const; /// \return a shape built by the shape construction algorithm. - GEOMALGOAPI_EXPORT virtual const std::shared_ptr shape() const; + GEOMALGOAPI_EXPORT virtual const GeomShapePtr shape() const; /// \return true if resulting shape is valid. GEOMALGOAPI_EXPORT bool isValid() const; @@ -87,34 +89,35 @@ public: GEOMALGOAPI_EXPORT std::shared_ptr mapOfSubShapes() const; /// \return the list of shapes generated from the shape \a theShape. - /// \param[in] theShape base shape. - /// \param[out] theHistory generated shapes. - GEOMALGOAPI_EXPORT virtual void generated(const std::shared_ptr theShape, - ListOfShape& theHistory); + /// \param[in] theOldShape base shape. + /// \param[out] theNewShapes shapes generated from \a theShape. Does not cleared! + GEOMALGOAPI_EXPORT virtual void generated(const GeomShapePtr theOldShape, + ListOfShape& theNewShapes); /// \return the list of shapes modified from the shape \a theShape. - /// \param[in] theShape base shape. - /// \param[out] theHistory modified shapes. Does not cleared! - GEOMALGOAPI_EXPORT virtual void modified(const std::shared_ptr theShape, - ListOfShape& theHistory); + /// \param[in] theOldShape base shape. + /// \param[out] theNewShapes shapes modified from \a theShape. Does not cleared! + GEOMALGOAPI_EXPORT virtual void modified(const GeomShapePtr theOldShape, + ListOfShape& theNewShapes); /// \return true if theShape was deleted. - /// \param[in] theShape base shape. - GEOMALGOAPI_EXPORT virtual bool isDeleted(const std::shared_ptr theShape); + /// \param[in] theOldShape base shape. + GEOMALGOAPI_EXPORT virtual bool isDeleted(const GeomShapePtr theOldShape); /// \return true if the data were correct. GEOMALGOAPI_EXPORT virtual bool check() { return true; }; + /// \brief Prepare the naming of faces. + GEOMALGOAPI_EXPORT virtual void prepareNamingFaces(); + /// \return the list of created faces. - GEOMALGOAPI_EXPORT std::map< std::string, std::shared_ptr > getCreatedFaces() - {return myCreatedFaces;} + GEOMALGOAPI_EXPORT std::map< std::string, GeomShapePtr > getCreatedFaces() { + return myCreatedFaces; + } /// \return the error. GEOMALGOAPI_EXPORT std::string getError() { return myError; } - /// \brief Prepare the naming of faces. - GEOMALGOAPI_EXPORT virtual void prepareNamingFaces(); - /// \brief Check the validity of the produced shape. GEOMALGOAPI_EXPORT bool checkValid(std::string theMessage); @@ -122,24 +125,24 @@ public: /// \param theWholeOld the whole old shape /// \param theShapeType type of the sub-shapes that is used for optimization /// \returns true if optimization containers are already filled - GEOMALGOAPI_EXPORT bool newShapesCollected( - std::shared_ptr theWholeOld, const int theShapeType); + GEOMALGOAPI_EXPORT bool isNewShapesCollected(GeomShapePtr theWholeOld, + const int theShapeType); /// Optimization of access the new shapes by old shapes for the limited set of needed new shapes. /// \param theWholeOld the whole old shape /// \param theShapeType type of the sub-shapes that is used for optimization /// \returns true if optimization containers are already filled - GEOMALGOAPI_EXPORT void collectNewShapes( - std::shared_ptr theWholeOld, const int theShapeType); + GEOMALGOAPI_EXPORT void collectNewShapes(GeomShapePtr theWholeOld, + const int theShapeType); /// Optimization of access the new shapes by old shapes for the limited set of needed new shapes. /// \param theWholeOld the whole old shape /// \param theNewShape the whole new shape /// \param theShapeType type of the old sub-shapes /// \returns compound of all old shapes that were used for creation of the given new - GEOMALGOAPI_EXPORT std::shared_ptr oldShapesForNew( - std::shared_ptr theWholeOld, - std::shared_ptr theNewShape, const int theShapeType); + GEOMALGOAPI_EXPORT GeomShapePtr oldShapesForNew(GeomShapePtr theWholeOld, + GeomShapePtr theNewShape, + const int theShapeType); protected: /// \brief Sets builder type. @@ -152,7 +155,13 @@ protected: /// \brief Sets result shape. /// \param[in] theShape new shape. - void setShape(const std::shared_ptr theShape); + void setShape(const GeomShapePtr theShape); + + /// \return true if passed shape is valid for history. + bool isValidForHistory(const GeomShapePtr theShape); + + /// Replaces \a theShape with shape from \a myMap. + void fixOrientation(GeomShapePtr& theShape); protected: /// Data map to keep correct orientation of sub-shapes. @@ -160,7 +169,7 @@ protected: /// Error occurred during the execution of an algorithm. std::string myError; /// Map of created faces with their name for naming. - std::map< std::string, std::shared_ptr > myCreatedFaces; + std::map< std::string, GeomShapePtr > myCreatedFaces; private: /// \brief Initializes internals. @@ -169,13 +178,14 @@ private: private: GeomAlgoAPI_MakeShape::BuilderType myBuilderType; ///< Type of make shape builder. bool myDone; ///< Builder status. - std::shared_ptr myShape; ///< Resulting shape. + GeomShapePtr myShape; ///< Resulting shape. /// map that is used to keep the optimization structure for access to the history /// kind of sub-shapes -> whole old shape -> new shape -> list of old shapes that create this new void* myHist; }; -typedef std::list > ListOfMakeShape; +typedef std::shared_ptr GeomMakeShapePtr; +typedef std::list ListOfMakeShape; #endif diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeCustom.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeCustom.cpp index 01bf7a88a..81f16868e 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeCustom.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeCustom.cpp @@ -20,58 +20,64 @@ #include -//================================================================================================= +//================================================================================================== GeomAlgoAPI_MakeShapeCustom::GeomAlgoAPI_MakeShapeCustom() {} -//================================================================================================= -void GeomAlgoAPI_MakeShapeCustom::setResult(const std::shared_ptr theShape) +//================================================================================================== +void GeomAlgoAPI_MakeShapeCustom::setResult(const GeomShapePtr theShape) { setShape(theShape); } -//================================================================================================= -bool GeomAlgoAPI_MakeShapeCustom::addModified(const std::shared_ptr theBase, - const std::shared_ptr theResult) +//================================================================================================== +bool GeomAlgoAPI_MakeShapeCustom::addModified(const GeomShapePtr theOldShape, + const GeomShapePtr theNewShape) { - return myModified.add(theBase, theResult); + if (!isValidForHistory(theNewShape)) return false; + GeomShapePtr aNewShape = theNewShape; + fixOrientation(aNewShape); + return myModified.add(theOldShape, aNewShape); } -//================================================================================================= -bool GeomAlgoAPI_MakeShapeCustom::addGenerated(const std::shared_ptr theBase, - const std::shared_ptr theResult) +//================================================================================================== +bool GeomAlgoAPI_MakeShapeCustom::addGenerated(const GeomShapePtr theOldShape, + const GeomShapePtr theNewShape) { - return myGenerated.add(theBase, theResult); + if (!isValidForHistory(theNewShape)) return false; + GeomShapePtr aNewShape = theNewShape; + fixOrientation(aNewShape); + return myGenerated.add(theOldShape, aNewShape); } -//================================================================================================= -bool GeomAlgoAPI_MakeShapeCustom::addDeleted(const std::shared_ptr theShape) +//================================================================================================== +bool GeomAlgoAPI_MakeShapeCustom::addDeleted(const GeomShapePtr theOldShape) { - return myDeleted.bind(theShape, theShape); + return myDeleted.bind(theOldShape, theOldShape); } -//================================================================================================= -void GeomAlgoAPI_MakeShapeCustom::generated(const std::shared_ptr theShape, - ListOfShape& theHistory) +//================================================================================================== +void GeomAlgoAPI_MakeShapeCustom::generated(const GeomShapePtr theOldShape, + ListOfShape& theNewShapes) { ListOfShape aGenerated; - if(myGenerated.find(theShape, aGenerated)) { - theHistory.insert(theHistory.end(), aGenerated.begin(), aGenerated.end()); + if(myGenerated.find(theOldShape, aGenerated)) { + theNewShapes.insert(theNewShapes.end(), aGenerated.begin(), aGenerated.end()); } } -//================================================================================================= -void GeomAlgoAPI_MakeShapeCustom::modified(const std::shared_ptr theShape, - ListOfShape& theHistory) +//================================================================================================== +void GeomAlgoAPI_MakeShapeCustom::modified(const GeomShapePtr theOldShape, + ListOfShape& theNewShapes) { ListOfShape aModified; - if(myModified.find(theShape, aModified)) { - theHistory.insert(theHistory.end(), aModified.begin(), aModified.end()); + if(myModified.find(theOldShape, aModified)) { + theNewShapes.insert(theNewShapes.end(), aModified.begin(), aModified.end()); } } -//================================================================================================= -bool GeomAlgoAPI_MakeShapeCustom::isDeleted(const std::shared_ptr theShape) +//================================================================================================== +bool GeomAlgoAPI_MakeShapeCustom::isDeleted(const GeomShapePtr theOldShape) { - return myDeleted.isBound(theShape); -} \ No newline at end of file + return myDeleted.isBound(theOldShape); +} diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeCustom.h b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeCustom.h index 77bfac0e2..6fca968ea 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeCustom.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeCustom.h @@ -37,29 +37,29 @@ public: GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShapeCustom(); /// Sets result shape. - GEOMALGOAPI_EXPORT void setResult(const std::shared_ptr theShape); + GEOMALGOAPI_EXPORT void setResult(const GeomShapePtr theShape); /// Adds modified shape. - GEOMALGOAPI_EXPORT bool addModified(const std::shared_ptr theBase, - const std::shared_ptr theResult); + GEOMALGOAPI_EXPORT bool addModified(const GeomShapePtr theOldShape, + const GeomShapePtr theNewShape); /// Adds generated shape. - GEOMALGOAPI_EXPORT bool addGenerated(const std::shared_ptr theBase, - const std::shared_ptr theResult); + GEOMALGOAPI_EXPORT bool addGenerated(const GeomShapePtr theOldShape, + const GeomShapePtr theNewShape); /// Adds deleted shape. - GEOMALGOAPI_EXPORT bool addDeleted(const std::shared_ptr theShape); + GEOMALGOAPI_EXPORT bool addDeleted(const GeomShapePtr theOldShape); /// \return the list of shapes generated from the shape theShape - GEOMALGOAPI_EXPORT void generated(const std::shared_ptr theShape, - ListOfShape& theHistory); + GEOMALGOAPI_EXPORT void generated(const GeomShapePtr theOldShape, + ListOfShape& theNewShapes); /// \return the list of shapes modified from the shape theShape - GEOMALGOAPI_EXPORT void modified(const std::shared_ptr theShape, - ListOfShape& theHistory); + GEOMALGOAPI_EXPORT void modified(const GeomShapePtr theShape, + ListOfShape& theNewShapes); /// \return whether the shape is deleted - GEOMALGOAPI_EXPORT bool isDeleted(const std::shared_ptr theShape); + GEOMALGOAPI_EXPORT bool isDeleted(const GeomShapePtr theOldShape); private: GeomAPI_DataMapOfShapeMapOfShapes myGenerated; diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeList.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeList.cpp index 1c615ced3..659399f58 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeList.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeList.cpp @@ -25,19 +25,19 @@ #include #include -//================================================================================================= +//================================================================================================== GeomAlgoAPI_MakeShapeList::GeomAlgoAPI_MakeShapeList() : GeomAlgoAPI_MakeShape() {} -//================================================================================================= +//================================================================================================== GeomAlgoAPI_MakeShapeList::GeomAlgoAPI_MakeShapeList(const ListOfMakeShape& theMakeShapeList) : GeomAlgoAPI_MakeShape() { init(theMakeShapeList); } -//================================================================================================= +//================================================================================================== void GeomAlgoAPI_MakeShapeList::init(const ListOfMakeShape& theMakeShapeList) { if(myMap.get()) { @@ -54,9 +54,9 @@ void GeomAlgoAPI_MakeShapeList::init(const ListOfMakeShape& theMakeShapeList) } } -//================================================================================================= +//================================================================================================== void GeomAlgoAPI_MakeShapeList::appendAlgo( - const std::shared_ptr theMakeShape) + const GeomMakeShapePtr theMakeShape) { myListOfMakeShape.push_back(theMakeShape); if(!myMap.get()) { @@ -65,38 +65,41 @@ void GeomAlgoAPI_MakeShapeList::appendAlgo( myMap->merge(theMakeShape->mapOfSubShapes()); } -//================================================================================================= -const std::shared_ptr GeomAlgoAPI_MakeShapeList::shape() const +//================================================================================================== +const GeomShapePtr GeomAlgoAPI_MakeShapeList::shape() const { - std::shared_ptr aShape = GeomAlgoAPI_MakeShape::shape(); + GeomShapePtr aShape = GeomAlgoAPI_MakeShape::shape(); if(aShape.get() && !aShape->impl().IsNull()) { return aShape; } else if(!myListOfMakeShape.empty()) { return myListOfMakeShape.back()->shape(); } - return std::shared_ptr(); + return GeomShapePtr(); } -//================================================================================================= -void GeomAlgoAPI_MakeShapeList::generated(const std::shared_ptr theShape, - ListOfShape& theHistory) +//================================================================================================== +void GeomAlgoAPI_MakeShapeList::generated(const GeomShapePtr theOldShape, + ListOfShape& theNewShapes) { - result(theShape, GeomAlgoAPI_MakeShapeList::Generated, theHistory); + result(theOldShape, GeomAlgoAPI_MakeShapeList::Generated, theNewShapes); } -//================================================================================================= -void GeomAlgoAPI_MakeShapeList::modified(const std::shared_ptr theShape, - ListOfShape& theHistory) +//================================================================================================== +void GeomAlgoAPI_MakeShapeList::modified(const GeomShapePtr theOldShape, + ListOfShape& theNewShapes) { - result(theShape, GeomAlgoAPI_MakeShapeList::Modified, theHistory); + result(theOldShape, GeomAlgoAPI_MakeShapeList::Modified, theNewShapes); } -bool GeomAlgoAPI_MakeShapeList::isDeleted(const std::shared_ptr theShape) +//================================================================================================== +bool GeomAlgoAPI_MakeShapeList::isDeleted(const GeomShapePtr theOldShape) { - for(ListOfMakeShape::iterator aBuilderIt = myListOfMakeShape.begin(); - aBuilderIt != myListOfMakeShape.end(); aBuilderIt++) { - std::shared_ptr aMakeShape = *aBuilderIt; - if(aMakeShape->isDeleted(theShape)) { + for (ListOfMakeShape::iterator aBuilderIt = myListOfMakeShape.begin(); + aBuilderIt != myListOfMakeShape.end(); + ++aBuilderIt) + { + GeomMakeShapePtr aMakeShape = *aBuilderIt; + if(aMakeShape->isDeleted(theOldShape)) { return true; } } @@ -104,9 +107,10 @@ bool GeomAlgoAPI_MakeShapeList::isDeleted(const std::shared_ptr t return false; } -void GeomAlgoAPI_MakeShapeList::result(const std::shared_ptr theShape, +//================================================================================================== +void GeomAlgoAPI_MakeShapeList::result(const GeomShapePtr theOldShape, OperationType theOperationType, - ListOfShape& theHistory) + ListOfShape& theNewShapes) { if(myListOfMakeShape.empty()) { return; @@ -115,24 +119,30 @@ void GeomAlgoAPI_MakeShapeList::result(const std::shared_ptr theS NCollection_Map anAlgoShapes; NCollection_Map aResultShapesMap; NCollection_List aResultShapesList; - anAlgoShapes.Add(theShape->impl()); - aResultShapesMap.Add(theShape->impl()); - aResultShapesList.Append(theShape->impl()); + anAlgoShapes.Add(theOldShape->impl()); + aResultShapesMap.Add(theOldShape->impl()); + aResultShapesList.Append(theOldShape->impl()); for(ListOfMakeShape::iterator aBuilderIt = myListOfMakeShape.begin(); - aBuilderIt != myListOfMakeShape.end(); aBuilderIt++) { - std::shared_ptr aMakeShape = *aBuilderIt; + aBuilderIt != myListOfMakeShape.end(); + ++aBuilderIt) + { + GeomMakeShapePtr aMakeShape = *aBuilderIt; NCollection_Map aTempShapes; - for(NCollection_Map::Iterator - aShapeIt(anAlgoShapes); aShapeIt.More(); aShapeIt.Next()) { + for (NCollection_Map::Iterator aShapeIt(anAlgoShapes); + aShapeIt.More(); + aShapeIt.Next()) + { bool hasResults = false; bool anArgumentIsInResult = false; - std::shared_ptr aShape(new GeomAPI_Shape); + GeomShapePtr aShape(new GeomAPI_Shape); aShape->setImpl(new TopoDS_Shape(aShapeIt.Value())); ListOfShape aGeneratedShapes; aMakeShape->generated(aShape, aGeneratedShapes); - for (ListOfShape::const_iterator - anIt = aGeneratedShapes.cbegin(); anIt != aGeneratedShapes.cend(); anIt++) { + for (ListOfShape::const_iterator anIt = aGeneratedShapes.cbegin(); + anIt != aGeneratedShapes.cend(); + ++anIt) + { const TopoDS_Shape& anItShape = (*anIt)->impl(); if (anItShape.IsSame(aShapeIt.Value())) { anArgumentIsInResult = true; @@ -146,8 +156,10 @@ void GeomAlgoAPI_MakeShapeList::result(const std::shared_ptr theS } ListOfShape aModifiedShapes; aMakeShape->modified(aShape, aModifiedShapes); - for(ListOfShape::const_iterator - anIt = aModifiedShapes.cbegin(); anIt != aModifiedShapes.cend(); anIt++) { + for (ListOfShape::const_iterator anIt = aModifiedShapes.cbegin(); + anIt != aModifiedShapes.cend(); + ++anIt) + { const TopoDS_Shape& anItShape = (*anIt)->impl(); if (anItShape.IsSame(aShapeIt.Value())) { anArgumentIsInResult = true; @@ -175,10 +187,14 @@ void GeomAlgoAPI_MakeShapeList::result(const std::shared_ptr theS anAlgoShapes.Unite(aTempShapes); } - for(NCollection_List::Iterator - aShapeIt(aResultShapesList); aShapeIt.More(); aShapeIt.Next()) { - std::shared_ptr aShape(new GeomAPI_Shape()); + for (NCollection_List::Iterator aShapeIt(aResultShapesList); + aShapeIt.More(); + aShapeIt.Next()) + { + GeomShapePtr aShape(new GeomAPI_Shape()); aShape->setImpl(new TopoDS_Shape(aShapeIt.Value())); - theHistory.push_back(aShape); + if (!isValidForHistory(aShape)) continue; + fixOrientation(aShape); + theNewShapes.push_back(aShape); } } diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeList.h b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeList.h index e79826e89..3a5bdf1ab 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeList.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeList.h @@ -51,24 +51,24 @@ public: /// \brief Adds algo to the end of list. /// \param[in] theMakeShape algo to be added. - GEOMALGOAPI_EXPORT void appendAlgo(const std::shared_ptr theMakeShape); + GEOMALGOAPI_EXPORT void appendAlgo(const GeomMakeShapePtr theMakeShape); /// \return a shape built by the shape construction algorithms - GEOMALGOAPI_EXPORT virtual const std::shared_ptr shape() const; + GEOMALGOAPI_EXPORT virtual const GeomShapePtr shape() const; /// \return the list of shapes generated from the shape \a theShape - GEOMALGOAPI_EXPORT virtual void generated(const std::shared_ptr theShape, + GEOMALGOAPI_EXPORT virtual void generated(const GeomShapePtr theShape, ListOfShape& theHistory); /// \return the list of shapes modified from the shape \a theShape - GEOMALGOAPI_EXPORT virtual void modified(const std::shared_ptr theShape, + GEOMALGOAPI_EXPORT virtual void modified(const GeomShapePtr theShape, ListOfShape& theHistory); /// \return whether the shape is deleted - GEOMALGOAPI_EXPORT virtual bool isDeleted(const std::shared_ptr theShape); + GEOMALGOAPI_EXPORT virtual bool isDeleted(const GeomShapePtr theShape); private: - void result(const std::shared_ptr theShape, + void result(const GeomShapePtr theShape, OperationType theOperationType, ListOfShape& theHistory); diff --git a/src/Model/Model_BodyBuilder.cpp b/src/Model/Model_BodyBuilder.cpp index dbed19f4b..c17c9b8d5 100755 --- a/src/Model/Model_BodyBuilder.cpp +++ b/src/Model/Model_BodyBuilder.cpp @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include @@ -57,11 +58,70 @@ //#include //#define DEB_IMPORT 1 -static const int VERTICES_TAG = 1; -static const int EDGES_TAG = 2; -static const int FACES_TAG = 3; -static const int DELETED_TAG = 4; -static const int PRIMITIVES_START_TAG = 11; +static const int INVALID_TAG = -1; +static const int GENERATED_VERTICES_TAG = 1; +static const int GENERATED_EDGES_TAG = 2; +static const int GENERATED_FACES_TAG = 3; +static const int MODIFIED_VERTICES_TAG = 4; +static const int MODIFIED_EDGES_TAG = 5; +static const int MODIFIED_FACES_TAG = 6; +static const int DELETED_TAG = 7; +static const int PRIMITIVES_START_TAG = 11; + +static int getGenerationTag(const TopoDS_Shape& theShape) { + TopAbs_ShapeEnum aShapeType = theShape.ShapeType(); + switch (aShapeType) { + case TopAbs_VERTEX: return GENERATED_VERTICES_TAG; + case TopAbs_EDGE: return GENERATED_EDGES_TAG; + case TopAbs_FACE: return GENERATED_FACES_TAG; + } + + return INVALID_TAG; +} + +static int getModificationTag(const TopoDS_Shape& theShape) { + TopAbs_ShapeEnum aShapeType = theShape.ShapeType(); + switch (aShapeType) { + case TopAbs_VERTEX: return MODIFIED_VERTICES_TAG; + case TopAbs_EDGE: return MODIFIED_EDGES_TAG; + case TopAbs_FACE: return MODIFIED_FACES_TAG; + } + + return INVALID_TAG; +} + +static TopAbs_ShapeEnum convertShapeType(const GeomAPI_Shape::ShapeType theType) { + switch (theType) { + case GeomAPI_Shape::VERTEX: return TopAbs_VERTEX; + case GeomAPI_Shape::EDGE: return TopAbs_EDGE; + case GeomAPI_Shape::WIRE: return TopAbs_WIRE; + case GeomAPI_Shape::FACE: return TopAbs_FACE; + case GeomAPI_Shape::SHELL: return TopAbs_SHELL; + case GeomAPI_Shape::SOLID: return TopAbs_SOLID; + case GeomAPI_Shape::COMPSOLID: return TopAbs_COMPSOLID; + case GeomAPI_Shape::COMPOUND: return TopAbs_COMPOUND; + case GeomAPI_Shape::SHAPE: return TopAbs_SHAPE; + } + return TopAbs_SHAPE; +} + +static bool isAlreadyStored(const TNaming_Builder* theBuilder, + const TopoDS_Shape& theOldShape, + const TopoDS_Shape& theNewShape) +{ + for (TNaming_Iterator aNamingIt(theBuilder->NamedShape()); + aNamingIt.More(); + aNamingIt.Next()) + { + if (aNamingIt.NewShape().IsSame(theNewShape) + && aNamingIt.OldShape().IsSame(theOldShape)) + { + return true; + } + } + + return false; +} Model_BodyBuilder::Model_BodyBuilder(ModelAPI_Object* theOwner) : ModelAPI_BodyBuilder(theOwner), @@ -142,7 +202,7 @@ void Model_BodyBuilder::evolutionToSelection(const bool theFlag) evolutionToSelectionRec(aShapeLab, theFlag); } -void Model_BodyBuilder::store(const std::shared_ptr& theShape, +void Model_BodyBuilder::store(const GeomShapePtr& theShape, const bool theIsStoreSameShapes) { std::shared_ptr aData = std::dynamic_pointer_cast(data()); @@ -186,8 +246,8 @@ void Model_BodyBuilder::store(const std::shared_ptr& theShape, } } -void Model_BodyBuilder::storeGenerated(const std::shared_ptr& theFromShape, - const std::shared_ptr& theToShape) +void Model_BodyBuilder::storeGenerated(const GeomShapePtr& theFromShape, + const GeomShapePtr& theToShape) { std::shared_ptr aData = std::dynamic_pointer_cast(data()); if (aData) { @@ -232,15 +292,15 @@ TNaming_Builder* Model_BodyBuilder::builder(const int theTag) return aFind->second; } -void Model_BodyBuilder::storeModified(const std::shared_ptr& theOldShape, - const std::shared_ptr& theNewShape, const int theDecomposeSolidsTag) +void Model_BodyBuilder::storeModified(const GeomShapePtr& theOldShape, + const GeomShapePtr& theNewShape, + const bool theIsCleanStored) { std::shared_ptr aData = std::dynamic_pointer_cast(data()); if (aData) { TDF_Label& aShapeLab = aData->shapeLab(); // clean builders - if (theDecomposeSolidsTag != -2) - clean(); + if (theIsCleanStored) clean(); // store the new shape as primitive TNaming_Builder* aBuilder = builder(0); if (!theOldShape || !theNewShape) @@ -266,7 +326,7 @@ void Model_BodyBuilder::storeModified(const std::shared_ptr& theO } } -void Model_BodyBuilder::storeWithoutNaming(const std::shared_ptr& theShape) +void Model_BodyBuilder::storeWithoutNaming(const GeomShapePtr& theShape) { std::shared_ptr aData = std::dynamic_pointer_cast(data()); if (aData) { @@ -313,10 +373,19 @@ Model_BodyBuilder::~Model_BodyBuilder() void Model_BodyBuilder::buildName(const int theTag, const std::string& theName) { std::shared_ptr aDoc = std::dynamic_pointer_cast(document()); - //aDoc->addNamingName(builder(theTag)->NamedShape()->Label(), theName); - TDataStd_Name::Set(builder(theTag)->NamedShape()->Label(), theName.c_str()); + std::string aName = theName; + switch (theTag) { + case GENERATED_VERTICES_TAG: aName += aName.empty() ? "Generated_Vertex" : "_GV"; break; + case GENERATED_EDGES_TAG: aName += aName.empty() ? "Generated_Edge" : "_GE"; break; + case GENERATED_FACES_TAG: aName += aName.empty() ? "Generated_Face" : "_GF"; break; + case MODIFIED_VERTICES_TAG: aName += aName.empty() ? "Modified_Vertex" : "_MV"; break; + case MODIFIED_EDGES_TAG: aName += aName.empty() ? "Modified_Edge" : "_ME"; break; + case MODIFIED_FACES_TAG: aName += aName.empty() ? "Modified_Face" : "_MF"; break; + } + + TDataStd_Name::Set(builder(theTag)->NamedShape()->Label(), aName.c_str()); } -void Model_BodyBuilder::generated(const std::shared_ptr& theNewShape, +void Model_BodyBuilder::generated(const GeomShapePtr& theNewShape, const std::string& theName) { TopoDS_Shape aShape = theNewShape->impl(); @@ -328,76 +397,78 @@ void Model_BodyBuilder::generated(const std::shared_ptr& theNewSh ++myPrimitiveTag; } -void Model_BodyBuilder::generated(const std::shared_ptr& theOldShape, - const std::shared_ptr& theNewShape, const std::string& theName, const int theTag) +void Model_BodyBuilder::generated(const GeomShapePtr& theOldShape, + const GeomShapePtr& theNewShape, + const std::string& theName) { TopoDS_Shape anOldShape = theOldShape->impl(); TopoDS_Shape aNewShape = theNewShape->impl(); - builder(theTag)->Generated(anOldShape, aNewShape); - if(!theName.empty()) - buildName(theTag, theName); - TopAbs_ShapeEnum aGenShapeType = aNewShape.ShapeType(); - if(aGenShapeType == TopAbs_WIRE || aGenShapeType == TopAbs_SHELL) { - TopAbs_ShapeEnum anExplodeShapeType = aGenShapeType == TopAbs_WIRE ? TopAbs_EDGE : TopAbs_FACE; - const TDF_Label aLabel = builder(theTag)->NamedShape()->Label(); - int aTag = 1; - std::shared_ptr aDoc = std::dynamic_pointer_cast(document()); - for(TopExp_Explorer anExp(aNewShape, anExplodeShapeType); anExp.More(); anExp.Next()) { - TDF_Label aChildLabel = aLabel.FindChild(aTag); - TNaming_Builder aBuilder(aChildLabel); - aBuilder.Generated(anOldShape, anExp.Current()); - TCollection_AsciiString aChildName = TCollection_AsciiString((theName + "_").c_str()) + aTag; - //aDoc->addNamingName(aChildLabel, aChildName.ToCString()); - TDataStd_Name::Set(aChildLabel, aChildName.ToCString()); - aTag++; + TopAbs_ShapeEnum aNewShapeType = aNewShape.ShapeType(); + int aTag; + if (aNewShapeType == TopAbs_WIRE || aNewShapeType == TopAbs_SHELL) { + // TODO: This is a workaround. New shape should be only vertex, edge or face. + TopAbs_ShapeEnum anExplodeShapeType = aNewShapeType == TopAbs_WIRE ? TopAbs_EDGE : TopAbs_FACE; + aTag = TopAbs_WIRE ? GENERATED_EDGES_TAG : GENERATED_FACES_TAG; + for (TopExp_Explorer anExp(aNewShape, anExplodeShapeType); anExp.More(); anExp.Next()) { + builder(aTag)->Generated(anOldShape, anExp.Current()); + buildName(aTag, theName); } + } else { + aTag = getGenerationTag(aNewShape); + if (aTag == INVALID_TAG) return; + builder(aTag)->Generated(anOldShape, aNewShape); + buildName(aTag, theName); } } - -void Model_BodyBuilder::modified(const std::shared_ptr& theOldShape, - const std::shared_ptr& theNewShape, const std::string& theName, const int theTag) +void Model_BodyBuilder::modified(const GeomShapePtr& theOldShape, + const GeomShapePtr& theNewShape, + const std::string& theName) { TopoDS_Shape anOldShape = theOldShape->impl(); TopoDS_Shape aNewShape = theNewShape->impl(); - builder(theTag)->Modify(anOldShape, aNewShape); - if(!theName.empty()) - buildName(theTag, theName); + int aTag = getModificationTag(aNewShape); + if (aTag == INVALID_TAG) return; + builder(aTag)->Modify(anOldShape, aNewShape); + buildName(aTag, theName); } -void Model_BodyBuilder::deleted(const std::shared_ptr& theOldShape, - const int theTag) +void Model_BodyBuilder::deleted(const GeomShapePtr& theOldShape) { TopoDS_Shape aShape = theOldShape->impl(); - builder(theTag)->Delete(aShape); + builder(DELETED_TAG)->Delete(aShape); } -void Model_BodyBuilder::loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS, - std::shared_ptr theShapeIn, - const int theKindOfShape, - const int theTag, - const GeomShapePtr theShapes) +void Model_BodyBuilder::loadDeletedShapes(const GeomMakeShapePtr& theAlgo, + const GeomShapePtr& theOldShape, + const GeomAPI_Shape::ShapeType theShapeTypeToExplore, + const GeomShapePtr& theShapesToExclude) { - TopoDS_Shape aShapeIn = theShapeIn->impl(); - TopTools_MapOfShape aView; - TopExp_Explorer ShapeExplorer (aShapeIn, (TopAbs_ShapeEnum)theKindOfShape); + TopTools_MapOfShape anAlreadyProcessedShapes; GeomShapePtr aResultShape = shape(); - for (; ShapeExplorer.More(); ShapeExplorer.Next ()) { - const TopoDS_Shape& aRoot = ShapeExplorer.Current (); - if (!aView.Add(aRoot)) continue; - std::shared_ptr aRShape(new GeomAPI_Shape()); - aRShape->setImpl((new TopoDS_Shape(aRoot))); - if (!theMS->isDeleted(aRShape) - || aResultShape->isSubShape(aRShape, false) - || (theShapes.get() && theShapes->isSubShape(aRShape, false))) { + for (GeomAPI_ShapeExplorer anExp(theOldShape, theShapeTypeToExplore); + anExp.more(); + anExp.next()) + { + GeomShapePtr anOldSubShape = anExp.current(); + const TopoDS_Shape& anOldSubShape_ = anOldSubShape->impl(); + if (!anAlreadyProcessedShapes.Add(anOldSubShape_) + || !theAlgo->isDeleted(anOldSubShape) + || aResultShape->isSubShape(anOldSubShape, false) + || (theShapesToExclude.get() && theShapesToExclude->isSubShape(anOldSubShape, false))) + { continue; } - ListOfShape aHist; - if (BRepTools_History::IsSupportedType(aRoot)) // to avoid crash in #2572 - theMS->modified(aRShape, aHist); - if (aHist.size() == 0 || (aHist.size() == 1 && aHist.front()->isSame(aRShape))) - builder(theTag)->Delete(aRoot); + ListOfShape aNewShapes; + if (BRepTools_History::IsSupportedType(anOldSubShape_)) { // to avoid crash in #2572 + theAlgo->modified(anOldSubShape, aNewShapes); + } + + if (aNewShapes.size() == 0 + || (aNewShapes.size() == 1 && aNewShapes.front()->isSame(anOldSubShape))) { + builder(DELETED_TAG)->Delete(anOldSubShape_); + } } } @@ -457,285 +528,102 @@ TopAbs_ShapeEnum typeOfAncestor(const TopAbs_ShapeEnum theSubType) { return TopAbs_VERTEX; // bad case } -void Model_BodyBuilder::loadAndOrientModifiedShapes ( - GeomAlgoAPI_MakeShape* theMS, - std::shared_ptr theShapeIn, - const int theKindOfShape, - const int theTag, - const std::string& theName, - GeomAPI_DataMapOfShapeShape& theSubShapes, - const bool theIsStoreSeparate, - const bool theIsStoreAsGenerated) +void Model_BodyBuilder::loadModifiedShapes(const GeomMakeShapePtr& theAlgo, + const GeomShapePtr& theOldShape, + const GeomAPI_Shape::ShapeType theShapeTypeToExplore, + const std::string& theName) { - static const int THE_ANCHOR_TAG = 100000; - - int anIndex = 1; - int aTag = theTag; - bool isBuilt = !theName.empty(); - std::string aName = theName; - std::ostringstream aStream; GeomShapePtr aResultShape = shape(); - TopoDS_Shape aShapeIn = theShapeIn->impl(); - TopTools_MapOfShape aView; - std::shared_ptr aData = std::dynamic_pointer_cast(data()); - - TopoDS_Shape aShapeToIterate; - if (theMS->newShapesCollected(theShapeIn, theKindOfShape)) { + GeomShapePtr aShapeToExplore = theOldShape; + if (theAlgo->isNewShapesCollected(theOldShape, theShapeTypeToExplore)) { // use optimized set of old shapes for this - GeomShapePtr aCompound = theMS->oldShapesForNew(theShapeIn, aResultShape, theKindOfShape); - if (aCompound.get()) - aShapeToIterate = aCompound->impl(); - } else { - aShapeToIterate = aShapeIn; + GeomShapePtr aCompound = theAlgo->oldShapesForNew(theOldShape, + aResultShape, + theShapeTypeToExplore); + if (aCompound.get()) aShapeToExplore = aCompound; } - TopExp_Explorer aShapeExplorer (aShapeToIterate, (TopAbs_ShapeEnum)theKindOfShape); - for (; aShapeExplorer.More(); aShapeExplorer.Next ()) { - const TopoDS_Shape& aRoot = aShapeExplorer.Current (); - if (!aView.Add(aRoot)) continue; - - bool aNotInTree = - TNaming_Tool::NamedShape(aRoot, aData->shapeLab()).IsNull(); - if (aNotInTree && !theIsStoreSeparate) { - // there is no sense to write history if old shape does not exist in the document - continue; // but if it is stored separately, it will be builded as a primitive - } - ListOfShape aList; - std::shared_ptr aRShape(new GeomAPI_Shape()); - aRShape->setImpl((new TopoDS_Shape(aRoot))); - theMS->modified(aRShape, aList); + TopTools_MapOfShape anAlreadyProcessedShapes; + std::shared_ptr aData = std::dynamic_pointer_cast(data()); + for (GeomAPI_ShapeExplorer anOldShapeExp(aShapeToExplore, theShapeTypeToExplore); + anOldShapeExp.more(); + anOldShapeExp.next()) + { + GeomShapePtr anOldSubShape = anOldShapeExp.current(); + const TopoDS_Shape& anOldSubShape_ = anOldSubShape->impl(); - if (!theIsStoreSeparate) { - //keepTopLevelShapes(aList, aRoot, aResultShape); - removeBadShapes(aList); + // There is no sense to write history if shape already processed + // or old shape does not exist in the document. + bool anOldSubShapeAlreadyProcessed = !anAlreadyProcessedShapes.Add(anOldSubShape_); + bool anOldSubShapeNotInTree = TNaming_Tool::NamedShape(anOldSubShape_, aData->shapeLab()) + .IsNull(); + if (anOldSubShapeAlreadyProcessed + || anOldSubShapeNotInTree) + { + continue; } - // sort the list of images before naming - GeomAlgoAPI_SortListOfShapes::sort(aList); - - // to trace situation where several objects are produced by one parent (#2317) - int aSameParentShapes = (aShapeIn.ShapeType() == TopAbs_WIRE - || aShapeIn.ShapeType() == TopAbs_SHELL - || aShapeIn.ShapeType() == TopAbs_COMPOUND) ? 0 : -1; - std::list >::const_iterator - anIt = aList.begin(), aLast = aList.end(); - for (; anIt != aLast; anIt++) { - TopoDS_Shape aNewShape = (*anIt)->impl(); - if (theSubShapes.isBound(*anIt)) { - std::shared_ptr aMapShape(theSubShapes.find(*anIt)); - aNewShape.Orientation(aMapShape->impl().Orientation()); - } - isBuilt = !theName.empty(); - if(!aRoot.IsSame(aNewShape) - && aResultShape->isSubShape((*anIt), false) - && !aResultShape->isSame(*anIt)) // to avoid put of same shape on main label and sub - { - if (!theIsStoreSeparate) { - aSameParentShapes++; - } else if (aNotInTree) // check this new shape can not be represented as - // a sub-shape of higher level sub-shapes - { - TopAbs_ShapeEnum aNewType = aNewShape.ShapeType(); - TopAbs_ShapeEnum anAncestorType = typeOfAncestor(aNewType); - if (anAncestorType != TopAbs_VERTEX) { - bool aFound = false; - TopoDS_Shape aResultTShape = aResultShape->impl(); - TopExp_Explorer anAncestorExp(aResultTShape, anAncestorType); - for(; anAncestorExp.More() && !aFound; anAncestorExp.Next()) { - if (aResultTShape.IsSame(anAncestorExp.Current())) - continue; - TopExp_Explorer aSubExp(anAncestorExp.Current(), aNewType); - for(; aSubExp.More(); aSubExp.Next()) { - if (aNewShape.IsSame(aSubExp.Current())) { - aFound = true; - break; - } - } - } - if (aFound) { - continue; // not need to store this shape in the BRep structure - } - } - } - int aFoundTag = 0; - bool isFoundSameOld = false; - bool isFoundDiffOld = false; + // Get new shapes. + ListOfShape aNewShapes; + theAlgo->modified(anOldSubShape, aNewShapes); - // Check if new shape was already stored. - for (std::map::iterator aBuildersIt = myBuilders.begin(); - aBuildersIt != myBuilders.end(); - ++aBuildersIt) - { - TNaming_Builder* aBuilder = aBuildersIt->second; - for (TNaming_Iterator aNamingIt(aBuilder->NamedShape()); - aNamingIt.More(); - aNamingIt.Next()) - { - if (aNamingIt.NewShape().IsSame(aNewShape)) - { - aNamingIt.OldShape().IsSame(aRoot) ? isFoundSameOld = true - : isFoundDiffOld = true; - aFoundTag = aBuildersIt->first; - } - } + for (ListOfShape::const_iterator aNewShapesIt = aNewShapes.cbegin(); + aNewShapesIt != aNewShapes.cend(); + ++aNewShapesIt) + { + GeomShapePtr aNewShape = *aNewShapesIt; + const TopoDS_Shape& aNewShape_ = aNewShape->impl(); + bool isGenerated = anOldSubShape_.ShapeType() != aNewShape_.ShapeType(); - if (isFoundSameOld || isFoundDiffOld) break; - } + bool aNewShapeIsSameAsOldShape = anOldSubShape->isSame(aNewShape); + bool aNewShapeIsNotInResultShape = !aResultShape->isSubShape(aNewShape, false); + if (aNewShapeIsSameAsOldShape + || aNewShapeIsNotInResultShape) + { + continue; + } - if (isFoundSameOld) { - // Builder already contains same old->new shapes, don't store it twice. + TNaming_Builder* aBuilder; + if (aResultShape->isSame(aNewShape)) { + // keep the modification evolution on the root level (2241 - history propagation issue) + aBuilder = builder(0); + TDF_Label aShapeLab = aBuilder->NamedShape()->Label(); + Handle(TDF_Reference) aRef; + if (aShapeLab.FindAttribute(TDF_Reference::GetID(), aRef)) { + // Store only in case if it does not have reference. continue; } - int aBuilderTag = aSameParentShapes > 0 ? THE_ANCHOR_TAG : aTag; - - int aCurShapeType = (int)((*anIt)->shapeType()); - bool needSuffix = false; // suffix for the name based on the shape type - if (aCurShapeType != theKindOfShape) { - // modified shape has different type => set another tag - // to avoid shapes of different types on the same label - aBuilderTag = THE_ANCHOR_TAG; - needSuffix = true; - } - std::string aSuffix; - if (needSuffix) { - switch (aCurShapeType) { - case GeomAPI_Shape::VERTEX: aSuffix = "_v_" + std::to_string(myVIndex++); break; - case GeomAPI_Shape::EDGE: aSuffix = "_e_" + std::to_string(myEIndex++); break; - case GeomAPI_Shape::FACE: aSuffix = "_f_" + std::to_string(myFIndex++); break; - default: break; - } - } - - std::vector> aKeepShapes, aMoveShapes; - if (isFoundDiffOld) { - // Found same new shape with different old shape. - if (aFoundTag >= THE_ANCHOR_TAG) { - // Found on separated tag. - aBuilderTag = aFoundTag; // Store it on the same tag. - isBuilt = false; // Don't change name; - } else { - // Found on previous tag. - if (aBuilderTag < THE_ANCHOR_TAG) { - // New shape shouls not be separated. - aBuilderTag = aFoundTag; // Store it on the same tag. - isBuilt = false; // Don't change name; - } else { - // New shape should be separated from others. Move shapes from found tag to new tag. - while (myBuilders.find(aBuilderTag) != myBuilders.end()) { - ++aBuilderTag; - } - - TNaming_Builder* aFoundBuilder = myBuilders.at(aFoundTag); - Handle(TNaming_NamedShape) aFoundNamedShape = aFoundBuilder->NamedShape(); - TDF_Label aFoundLabel = aFoundNamedShape->Label(); - TNaming_Evolution anEvolution = aFoundNamedShape->Evolution(); - for (TNaming_Iterator aNamingIt(aFoundNamedShape); - aNamingIt.More(); - aNamingIt.Next()) - { - std::pair aShapesPair = - std::make_pair(aNamingIt.OldShape(), aNamingIt.NewShape()); - aNamingIt.NewShape().IsSame(aNewShape) ? aMoveShapes.push_back(aShapesPair) - : aKeepShapes.push_back(aShapesPair); - } - - aFoundNamedShape->Clear(); - for (std::vector>::iterator aKeepIt = - aKeepShapes.begin(); - aKeepIt != aKeepShapes.end(); - ++aKeepIt) - { - if (anEvolution == TNaming_GENERATED) { - aFoundBuilder->Generated(aKeepIt->first, aKeepIt->second); - } else { - aFoundBuilder->Modify(aKeepIt->first, aKeepIt->second); - } - } - } - } - } else if (aBuilderTag == THE_ANCHOR_TAG) { - while (myBuilders.find(aBuilderTag) != myBuilders.end()) { - ++aBuilderTag; - } - } + // Check if new shape was already stored. + if (isAlreadyStored(aBuilder, anOldSubShape_, aNewShape_)) continue; - if(theIsStoreAsGenerated) { - // Here we store shapes as generated, to avoid problem when one parent shape produce - // several child shapes. In this case naming could not determine which shape to select. - builder(aBuilderTag)->Generated(aRoot, aNewShape); - for (std::vector>::iterator aMoveIt = - aMoveShapes.begin(); - aMoveIt != aMoveShapes.end(); - ++aMoveIt) - { - builder(aBuilderTag)->Generated(aMoveIt->first, aMoveIt->second); - } - } else if (aNotInTree) { - // not in tree -> store as primitive (stored as separated) - builder(aBuilderTag)->Generated(aNewShape); - } else if (aCurShapeType != theKindOfShape) { - // if different shape type is produced, make it as generated - builder(aBuilderTag)->Generated(aRoot, aNewShape); - } else { - builder(aBuilderTag)->Modify(aRoot, aNewShape); - for (std::vector>::iterator aMoveIt = - aMoveShapes.begin(); - aMoveIt != aMoveShapes.end(); - ++aMoveIt) { - builder(aBuilderTag)->Modify(aMoveIt->first, aMoveIt->second); - } + if (!aBuilder->NamedShape().IsNull() && + ((isGenerated && aBuilder->NamedShape()->Evolution() != TNaming_GENERATED) + || (!isGenerated && aBuilder->NamedShape()->Evolution() != TNaming_MODIFY))) + { + myBuilders.erase(0); // clear old builder to avoid different evolutions crash + aBuilder = builder(0); } - if(isBuilt) { - aStream.str(std::string()); - aStream.clear(); - aStream << theName; - if (theIsStoreSeparate && !isFoundDiffOld) - aStream << "_" << anIndex++; + } else { + int aTag = isGenerated ? getGenerationTag(aNewShape_) + : getModificationTag(aNewShape_); + aBuilder = builder(aTag); - if (aSameParentShapes > 0) { - aStream.str(std::string()); - aStream.clear(); - aStream << aName << "_" << "divided" << "_" << myDividedIndex++; - } + // Check if new shape was already stored. + if (isAlreadyStored(aBuilder, anOldSubShape_, aNewShape_)) continue; - aStream << aSuffix; - buildName(aBuilderTag, aStream.str()); - } - if(theIsStoreSeparate && !isFoundDiffOld) { - aTag++; - } - } else if (aResultShape->isSame(*anIt)) { - // keep the modification evolution on the root level (2241 - history propagation issue) - TNaming_Builder* aBuilder = builder(0); - TDF_Label aShapeLab = aBuilder->NamedShape()->Label(); - Handle(TDF_Reference) aRef; - // Store only in case if it does not have reference. - if (!aShapeLab.FindAttribute(TDF_Reference::GetID(), aRef)) { - if (theIsStoreAsGenerated) { - TNaming_Builder* aBuilder = builder(0); - if (!aBuilder->NamedShape().IsNull() && - aBuilder->NamedShape()->Evolution() != TNaming_GENERATED) { - myBuilders.erase(0); // clear old builder to avoid different evolutions crash - } - builder(0)->Generated(aRoot, aNewShape); - } else { - TNaming_Builder* aBuilder = builder(0); - if (!aBuilder->NamedShape().IsNull() && - aBuilder->NamedShape()->Evolution() != TNaming_MODIFY) { - myBuilders.erase(0); // clear old builder to avoid different evolutions crash - } - builder(0)->Modify(aRoot, aNewShape); - } - } + buildName(aTag, theName); } + + isGenerated ? aBuilder->Generated(anOldSubShape_, aNewShape_) + : aBuilder->Modify(anOldSubShape_, aNewShape_); } } } void Model_BodyBuilder::loadAndOrientGeneratedShapes ( GeomAlgoAPI_MakeShape* theMS, - std::shared_ptr theShapeIn, + GeomShapePtr theShapeIn, const int theKindOfShape, const int theTag, const std::string& theName, @@ -751,16 +639,16 @@ void Model_BodyBuilder::loadAndOrientGeneratedShapes ( //if (TNaming_Tool::NamedShape(aRoot, builder(theTag)->NamedShape()->Label()).IsNull()) // continue; // there is no sense to write history if old shape does not exist in the document ListOfShape aList; - std::shared_ptr aRShape(new GeomAPI_Shape()); + GeomShapePtr aRShape(new GeomAPI_Shape()); aRShape->setImpl((new TopoDS_Shape(aRoot))); theMS->generated(aRShape, aList); keepTopLevelShapes(aList, aRoot); - std::list >::const_iterator + std::list::const_iterator anIt = aList.begin(), aLast = aList.end(); for (; anIt != aLast; anIt++) { TopoDS_Shape aNewShape = (*anIt)->impl(); if (theSubShapes.isBound(*anIt)) { - std::shared_ptr aMapShape(theSubShapes.find(*anIt)); + GeomShapePtr aMapShape(theSubShapes.find(*anIt)); aNewShape.Orientation(aMapShape->impl().Orientation()); } if (!aRoot.IsSame (aNewShape)) { @@ -824,7 +712,7 @@ void loadGeneratedDangleShapes( } //======================================================================= -void Model_BodyBuilder::loadNextLevels(std::shared_ptr theShape, +void Model_BodyBuilder::loadNextLevels(GeomShapePtr theShape, const std::string& theName, int& theTag) { if(theShape->isNull()) return; @@ -981,7 +869,7 @@ int findAmbiguities(const TopoDS_Shape& theShapeIn, //======================================================================= void Model_BodyBuilder::loadFirstLevel( - std::shared_ptr theShape, const std::string& theName, int& theTag) + GeomShapePtr theShape, const std::string& theName, int& theTag) { if(theShape->isNull()) return; TopoDS_Shape aShape = theShape->impl(); @@ -998,17 +886,17 @@ void Model_BodyBuilder::loadFirstLevel( if (itr.Value().ShapeType() == TopAbs_COMPOUND || itr.Value().ShapeType() == TopAbs_COMPSOLID) { - std::shared_ptr itrShape(new GeomAPI_Shape()); + GeomShapePtr itrShape(new GeomAPI_Shape()); itrShape->setImpl(new TopoDS_Shape(itr.Value())); loadFirstLevel(itrShape, theName, theTag); } else { - std::shared_ptr itrShape(new GeomAPI_Shape()); + GeomShapePtr itrShape(new GeomAPI_Shape()); itrShape->setImpl(new TopoDS_Shape(itr.Value())); loadNextLevels(itrShape, theName, theTag); } } } else { - std::shared_ptr itrShape(new GeomAPI_Shape()); + GeomShapePtr itrShape(new GeomAPI_Shape()); itrShape->setImpl(new TopoDS_Shape(aShape)); loadNextLevels(itrShape, theName, theTag); } @@ -1026,7 +914,7 @@ void Model_BodyBuilder::loadFirstLevel( //======================================================================= void Model_BodyBuilder::loadDisconnectedEdges( - std::shared_ptr theShape, const std::string& theName, int& theTag) + GeomShapePtr theShape, const std::string& theName, int& theTag) { if(theShape->isNull()) return; TopoDS_Shape aShape = theShape->impl(); @@ -1099,7 +987,7 @@ void Model_BodyBuilder::loadDisconnectedEdges( } } -void Model_BodyBuilder::loadDisconnectedVertexes(std::shared_ptr theShape, +void Model_BodyBuilder::loadDisconnectedVertexes(GeomShapePtr theShape, const std::string& theName, int& theTag) { if(theShape->isNull()) return; @@ -1140,7 +1028,7 @@ void Model_BodyBuilder::loadDisconnectedVertexes(std::shared_ptr } } -std::shared_ptr Model_BodyBuilder::shape() +GeomShapePtr Model_BodyBuilder::shape() { std::shared_ptr aData = std::dynamic_pointer_cast(data()); if (aData && aData->isValid()) { @@ -1153,16 +1041,16 @@ std::shared_ptr Model_BodyBuilder::shape() if (aShapeLab.FindAttribute(TNaming_NamedShape::GetID(), aName)) { TopoDS_Shape aShape = aName->Get(); if (!aShape.IsNull()) { - std::shared_ptr aRes(new GeomAPI_Shape); + GeomShapePtr aRes(new GeomAPI_Shape); aRes->setImpl(new TopoDS_Shape(aShape)); return aRes; } } } - return std::shared_ptr(); + return GeomShapePtr(); } -bool Model_BodyBuilder::isLatestEqual(const std::shared_ptr& theShape) +bool Model_BodyBuilder::isLatestEqual(const GeomShapePtr& theShape) { if (theShape.get()) { TopoDS_Shape aShape = theShape->impl(); diff --git a/src/Model/Model_BodyBuilder.h b/src/Model/Model_BodyBuilder.h index 36be6cfbb..0217fb3a7 100755 --- a/src/Model/Model_BodyBuilder.h +++ b/src/Model/Model_BodyBuilder.h @@ -41,89 +41,89 @@ class Model_BodyBuilder : public ModelAPI_BodyBuilder std::map myBuilders; public: /// Stores the shape (called by the execution method). - MODEL_EXPORT virtual void store(const std::shared_ptr& theShape, + MODEL_EXPORT virtual void store(const GeomShapePtr& theShape, const bool theIsStoreSameShapes = true); /// Stores the generated shape (called by the execution method). - MODEL_EXPORT virtual void storeGenerated(const std::shared_ptr& theFromShape, - const std::shared_ptr& theToShape); + MODEL_EXPORT virtual void storeGenerated(const GeomShapePtr& theFromShape, + const GeomShapePtr& theToShape); /// Stores the modified shape (called by the execution method). /// \param theOldShape shape that produces result /// \param theNewShape resulting shape /// \param theDecomposeSolidsTag tag for starting of solids sub-elements placement in case /// theNewShape is compound of solids, if zero it is not used - MODEL_EXPORT virtual void storeModified(const std::shared_ptr& theOldShape, - const std::shared_ptr& theNewShape, - const int theDecomposeSolidsTag = 0); + MODEL_EXPORT virtual void storeModified(const GeomShapePtr& theOldShape, + const GeomShapePtr& theNewShape, + const bool theIsCleanStored = true) override; /// Stores the shape without naming support /// \param theShape shape to store - MODEL_EXPORT virtual void storeWithoutNaming(const std::shared_ptr& theShape); + MODEL_EXPORT virtual void storeWithoutNaming(const GeomShapePtr& theShape); /// Returns the shape-result produced by this feature - MODEL_EXPORT virtual std::shared_ptr shape(); + MODEL_EXPORT virtual GeomShapePtr shape(); /// Records the subshape newShape which was generated during a topological construction. /// As an example, consider the case of a face generated in construction of a box. - MODEL_EXPORT virtual void generated(const std::shared_ptr& theNewShape, + MODEL_EXPORT virtual void generated(const GeomShapePtr& theNewShape, const std::string& theName) override; /// Records the shape newShape which was generated from the shape oldShape during a topological /// construction. As an example, consider the case of a face generated from an edge in /// construction of a prism. - MODEL_EXPORT virtual void generated(const std::shared_ptr& theOldShape, - const std::shared_ptr& theNewShape, - const std::string& theName, const int theTag = 1); + MODEL_EXPORT virtual void generated(const GeomShapePtr& theOldShape, + const GeomShapePtr& theNewShape, + const std::string& theName = "") override; /// Records the shape newShape which is a modification of the shape oldShape. /// As an example, consider the case of a face split or merged in a Boolean operation. - MODEL_EXPORT virtual void modified(const std::shared_ptr& theOldShape, - const std::shared_ptr& theNewShape, - const std::string& theName, const int theTag = 1); + MODEL_EXPORT virtual void modified(const GeomShapePtr& theOldShape, + const GeomShapePtr& theNewShape, + const std::string& theName = "") override; /// Records the shape oldShape which was deleted from the current label. /// As an example, consider the case of a face removed by a Boolean operation. - MODEL_EXPORT virtual void deleted(const std::shared_ptr& theOldShape, - const int theTag = 1); + MODEL_EXPORT virtual void deleted(const GeomShapePtr& theOldShape) override; /// load deleted shapes - MODEL_EXPORT virtual void loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS, - std::shared_ptr theShapeIn, - const int theKindOfShape, - const int theTag, - const GeomShapePtr theShapes = GeomShapePtr()); + MODEL_EXPORT + virtual void loadDeletedShapes(const GeomMakeShapePtr& theAlgo, + const GeomShapePtr& theOldShape, + const GeomAPI_Shape::ShapeType theShapeTypeToExplore, + const GeomShapePtr& theShapesToExclude = GeomShapePtr()) override; + /// load and orient modified shapes - MODEL_EXPORT virtual void loadAndOrientModifiedShapes ( - GeomAlgoAPI_MakeShape* theMS, - std::shared_ptr theShapeIn, - const int theKindOfShape, - const int theTag, - const std::string& theName, - GeomAPI_DataMapOfShapeShape& theSubShapes, - const bool theIsStoreSeparate = false, - const bool theIsStoreAsGenerated = false); - /// load and orient generated shapes - MODEL_EXPORT virtual void loadAndOrientGeneratedShapes ( - GeomAlgoAPI_MakeShape* theMS, - std::shared_ptr theShapeIn, - const int theKindOfShape, - const int theTag, - const std::string& theName, - GeomAPI_DataMapOfShapeShape& theSubShapes); + MODEL_EXPORT + virtual void loadModifiedShapes(const GeomMakeShapePtr& theAlgo, + const GeomShapePtr& theOldShape, + const GeomAPI_Shape::ShapeType theShapeTypeToExplore, + const std::string& theName = "") override; + + /// load and orient generated shapes + MODEL_EXPORT + virtual void loadAndOrientGeneratedShapes(GeomAlgoAPI_MakeShape* theMS, + GeomShapePtr theShapeIn, + const int theKindOfShape, + const int theTag, + const std::string& theName, + GeomAPI_DataMapOfShapeShape& theSubShapes); /// Loads shapes of the first level (to be used during shape import) - MODEL_EXPORT virtual void loadFirstLevel(std::shared_ptr theShape, - const std::string& theName, int& theTag); + MODEL_EXPORT virtual void loadFirstLevel(GeomShapePtr theShape, + const std::string& theName, + int& theTag); /// Loads disconnected edges - MODEL_EXPORT virtual void loadDisconnectedEdges(std::shared_ptr theShape, - const std::string& theName, int& theTag); + MODEL_EXPORT virtual void loadDisconnectedEdges(GeomShapePtr theShape, + const std::string& theName, + int& theTag); /// Loads disconnected vetexes - MODEL_EXPORT virtual void loadDisconnectedVertexes(std::shared_ptr theShape, - const std::string& theName, int& theTag); + MODEL_EXPORT virtual void loadDisconnectedVertexes(GeomShapePtr theShape, + const std::string& theName, + int& theTag); /// Removes the stored builders MODEL_EXPORT virtual ~Model_BodyBuilder(); @@ -134,7 +134,7 @@ public: /// Returns true if the latest modification of this body in the naming history // is equal to the given shape - MODEL_EXPORT virtual bool isLatestEqual(const std::shared_ptr& theShape); + MODEL_EXPORT virtual bool isLatestEqual(const GeomShapePtr& theShape); protected: /// Default constructor accessible only by Model_Objects @@ -148,7 +148,7 @@ protected: private: /// Loads shapes of the next level (to be used during shape import) - void loadNextLevels(std::shared_ptr theShape, + void loadNextLevels(GeomShapePtr theShape, const std::string& theName, int& theTag); /// builds name for the shape kept at the specified tag diff --git a/src/Model/Model_ResultBody.cpp b/src/Model/Model_ResultBody.cpp index eaee3ac1e..746bbd792 100644 --- a/src/Model/Model_ResultBody.cpp +++ b/src/Model/Model_ResultBody.cpp @@ -52,17 +52,16 @@ Model_ResultBody::~Model_ResultBody() delete myBuilder; } -void Model_ResultBody::loadAndOrientModifiedShapes(GeomAlgoAPI_MakeShape* theMS, - std::shared_ptr theShapeIn, const int theKindOfShape, const int theTag, - const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes, - const bool theIsStoreSeparate, - const bool theIsStoreAsGenerated, - const bool theSplitInSubs) +void Model_ResultBody::loadModifiedShapes( + const std::shared_ptr& theAlgo, + const GeomShapePtr& theOldShape, + const GeomAPI_Shape::ShapeType theShapeTypeToExplore, + const std::string& theName) { - if (theSplitInSubs && mySubs.size()) { // consists of subs + if (/*theSplitInSubs &&*/ mySubs.size()) { // consists of subs // optimization of getting of new shapes for specific sub-result - if (!theMS->newShapesCollected(theShapeIn, theKindOfShape)) - theMS->collectNewShapes(theShapeIn, theKindOfShape); + if (!theAlgo->isNewShapesCollected(theOldShape, theShapeTypeToExplore)) + theAlgo->collectNewShapes(theOldShape, theShapeTypeToExplore); std::vector::const_iterator aSubIter = mySubs.cbegin(); for(; aSubIter != mySubs.cend(); aSubIter++) { // check that sub-shape was also created as modification of ShapeIn @@ -84,14 +83,10 @@ void Model_ResultBody::loadAndOrientModifiedShapes(GeomAlgoAPI_MakeShape* theMS, } } }*/ - (*aSubIter)->loadAndOrientModifiedShapes( - theMS, theShapeIn, theKindOfShape, theTag, theName, theSubShapes, theIsStoreSeparate, - theIsStoreAsGenerated, theSplitInSubs); + (*aSubIter)->loadModifiedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theName); } } else { // do for this directly - myBuilder->loadAndOrientModifiedShapes( - theMS, theShapeIn, theKindOfShape, theTag, theName, theSubShapes, theIsStoreSeparate, - theIsStoreAsGenerated); + myBuilder->loadModifiedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theName); } } diff --git a/src/Model/Model_ResultBody.h b/src/Model/Model_ResultBody.h index 6047bc059..eda74f541 100644 --- a/src/Model/Model_ResultBody.h +++ b/src/Model/Model_ResultBody.h @@ -50,11 +50,11 @@ public: MODEL_EXPORT virtual ~Model_ResultBody(); /// load and orient modified shapes for sub-objects - MODEL_EXPORT virtual void loadAndOrientModifiedShapes (GeomAlgoAPI_MakeShape* theMS, - std::shared_ptr theShapeIn, const int theKindOfShape, const int theTag, - const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes, - const bool theIsStoreSeparate = false, const bool theIsStoreAsGenerated = false, - const bool theSplitInSubs = false); + MODEL_EXPORT + virtual void loadModifiedShapes(const std::shared_ptr& theAlgo, + const GeomShapePtr& theOldShape, + const GeomAPI_Shape::ShapeType theShapeTypeToExplore, + const std::string& theName) override; /// Returns the number of sub-elements diff --git a/src/ModelAPI/ModelAPI_BodyBuilder.h b/src/ModelAPI/ModelAPI_BodyBuilder.h index 90bd71015..6edfd2c00 100755 --- a/src/ModelAPI/ModelAPI_BodyBuilder.h +++ b/src/ModelAPI/ModelAPI_BodyBuilder.h @@ -42,83 +42,80 @@ public: MODELAPI_EXPORT virtual ~ModelAPI_BodyBuilder() {}; /// Stores the shape (called by the execution method). - virtual void store(const std::shared_ptr& theShape, + virtual void store(const GeomShapePtr& theShape, const bool theIsStoreSameShapes = true) = 0; /// Stores the generated shape (called by the execution method). - virtual void storeGenerated(const std::shared_ptr& theFromShape, - const std::shared_ptr& theToShape) = 0; + virtual void storeGenerated(const GeomShapePtr& theFromShape, + const GeomShapePtr& theToShape) = 0; /// Stores the modified shape (called by the execution method). - virtual void storeModified(const std::shared_ptr& theOldShape, - const std::shared_ptr& theNewShape, - const int theDecomposeSolidsTag = 0) = 0; + virtual void storeModified(const GeomShapePtr& theOldShape, + const GeomShapePtr& theNewShape, + const bool theIsCleanStored = true) = 0; /// Stores the shape without naming support - virtual void storeWithoutNaming(const std::shared_ptr& theShape) = 0; + virtual void storeWithoutNaming(const GeomShapePtr& theShape) = 0; /// Returns the shape-result produced by this feature - virtual std::shared_ptr shape() = 0; + virtual GeomShapePtr shape() = 0; /// Records the subshape newShape which was generated during a topological construction. /// As an example, consider the case of a face generated in construction of a box. - virtual void generated(const std::shared_ptr& theNewShape, + virtual void generated(const GeomShapePtr& theNewShape, const std::string& theName) = 0; /// Records the shape newShape which was generated from the shape oldShape during a topological /// construction. As an example, consider the case of a face generated from an edge in /// construction of a prism. - virtual void generated(const std::shared_ptr& theOldShape, - const std::shared_ptr& theNewShape, const std::string& theName, - const int theTag = 1) = 0; + virtual void generated(const GeomShapePtr& theOldShape, + const GeomShapePtr& theNewShape, + const std::string& theName = "") = 0; /// Records the shape newShape which is a modification of the shape oldShape. /// As an example, consider the case of a face split or merged in a Boolean operation. - virtual void modified(const std::shared_ptr& theOldShape, - const std::shared_ptr& theNewShape, const std::string& theName, - const int theTag = 1) = 0; + virtual void modified(const GeomShapePtr& theOldShape, + const GeomShapePtr& theNewShape, + const std::string& theName = "") = 0; /// Records the shape oldShape which was deleted from the current label. /// As an example, consider the case of a face removed by a Boolean operation. - virtual void deleted( - const std::shared_ptr& theOldShape, const int theTag = 1) = 0; + virtual void deleted(const GeomShapePtr& theOldShape) = 0; /// load deleted shapes - virtual void loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS, - std::shared_ptr theShapeIn, - const int theKindOfShape, - const int theTag, - const GeomShapePtr theShapes = GeomShapePtr()) = 0; + virtual void loadDeletedShapes(const GeomMakeShapePtr& theAlgo, + const GeomShapePtr& theOldShape, + const GeomAPI_Shape::ShapeType theShapeTypeToExplore, + const GeomShapePtr& theShapesToAvoid = GeomShapePtr()) = 0; + /// load and orient modified shapes - virtual void loadAndOrientModifiedShapes ( - GeomAlgoAPI_MakeShape* theMS, - std::shared_ptr theShapeIn, - const int theKindOfShape, - const int theTag, - const std::string& theName, - GeomAPI_DataMapOfShapeShape& theSubShapes, - const bool theIsStoreSeparate = false, - const bool theIsStoreAsGenerated = false) = 0; + virtual void loadModifiedShapes(const GeomMakeShapePtr& theAlgo, + const GeomShapePtr& theOldShape, + const GeomAPI_Shape::ShapeType theShapeTypeToExplore, + const std::string& theName = "") = 0; + /// load and orient generated shapes - virtual void loadAndOrientGeneratedShapes ( - GeomAlgoAPI_MakeShape* theMS, - std::shared_ptr theShapeIn, - const int theKindOfShape, - const int theTag, - const std::string& theName, - GeomAPI_DataMapOfShapeShape& theSubShapes) = 0; + virtual void loadAndOrientGeneratedShapes(GeomAlgoAPI_MakeShape* theMS, + GeomShapePtr theShapeIn, + const int theKindOfShape, + const int theTag, + const std::string& theName, + GeomAPI_DataMapOfShapeShape& theSubShapes) = 0; /// load shapes of the first level (to be used during shape import) - virtual void loadFirstLevel(std::shared_ptr theShape, - const std::string& theName, int& theTag) = 0; + virtual void loadFirstLevel(GeomShapePtr theShape, + const std::string& theName, + int& theTag) = 0; /// load disconnected edges - virtual void loadDisconnectedEdges(std::shared_ptr theShape, - const std::string& theName, int& theTag) = 0; + virtual void loadDisconnectedEdges(GeomShapePtr theShape, + const std::string& theName, + int& theTag) = 0; /// load disconnected vetexes - virtual void loadDisconnectedVertexes(std::shared_ptr theShape, - const std::string& theName,int& theTag) = 0; + virtual void loadDisconnectedVertexes(GeomShapePtr theShape, + const std::string& theName, + int& theTag) = 0; /// Converts evolution of sub-shapes stored in naming structure to selection /// (theFlag = true) and back (theFlag = false) @@ -126,7 +123,7 @@ public: /// Returns true if the latest modification of this body in the naming history // is equal to the given shape - virtual bool isLatestEqual(const std::shared_ptr& theShape) = 0; + virtual bool isLatestEqual(const GeomShapePtr& theShape) = 0; protected: /// Returns the data manager of this object: attributes diff --git a/src/ModelAPI/ModelAPI_ResultBody.cpp b/src/ModelAPI/ModelAPI_ResultBody.cpp index 9ca7a38ec..c973853cd 100644 --- a/src/ModelAPI/ModelAPI_ResultBody.cpp +++ b/src/ModelAPI/ModelAPI_ResultBody.cpp @@ -39,8 +39,8 @@ std::string ModelAPI_ResultBody::groupName() return group(); } -void ModelAPI_ResultBody::store(const std::shared_ptr& theShape, - const bool theIsStoreSameShapes) +void ModelAPI_ResultBody::store(const GeomShapePtr& theShape, + const bool theIsStoreSameShapes) { myBuilder->store(theShape, theIsStoreSameShapes); myConnect = ConnectionNotComputed; @@ -53,8 +53,8 @@ void ModelAPI_ResultBody::store(const std::shared_ptr& theShape, updateSubs(theShape); } -void ModelAPI_ResultBody::storeGenerated(const std::shared_ptr& theFromShape, - const std::shared_ptr& theToShape) +void ModelAPI_ResultBody::storeGenerated(const GeomShapePtr& theFromShape, + const GeomShapePtr& theToShape) { myBuilder->storeGenerated(theFromShape, theToShape); myConnect = ConnectionNotComputed; @@ -67,11 +67,11 @@ void ModelAPI_ResultBody::storeGenerated(const std::shared_ptr& t updateSubs(theToShape); } -void ModelAPI_ResultBody::storeModified(const std::shared_ptr& theOldShape, - const std::shared_ptr& theNewShape, - const int theDecomposeSolidsTag) +void ModelAPI_ResultBody::storeModified(const GeomShapePtr& theOldShape, + const GeomShapePtr& theNewShape, + const bool theIsCleanStored) { - myBuilder->storeModified(theOldShape, theNewShape, theDecomposeSolidsTag); + myBuilder->storeModified(theOldShape, theNewShape, theIsCleanStored); myConnect = ConnectionNotComputed; static Events_Loop* aLoop = Events_Loop::loop(); @@ -82,7 +82,7 @@ void ModelAPI_ResultBody::storeModified(const std::shared_ptr& th updateSubs(theNewShape); } -void ModelAPI_ResultBody::storeWithoutNaming(const std::shared_ptr& theShape) +void ModelAPI_ResultBody::storeWithoutNaming(const GeomShapePtr& theShape) { myBuilder->storeWithoutNaming(theShape); myConnect = ConnectionNotComputed; @@ -93,81 +93,81 @@ void ModelAPI_ResultBody::storeWithoutNaming(const std::shared_ptrsendUpdated(data()->owner(), aRedispEvent); } -std::shared_ptr ModelAPI_ResultBody::shape() +GeomShapePtr ModelAPI_ResultBody::shape() { return myBuilder->shape(); } -void ModelAPI_ResultBody::generated(const std::shared_ptr& theNewShape, +void ModelAPI_ResultBody::generated(const GeomShapePtr& theNewShape, const std::string& theName) { myBuilder->generated(theNewShape, theName); } -void ModelAPI_ResultBody::generated(const std::shared_ptr& theOldShape, - const std::shared_ptr& theNewShape, const std::string& theName, - const int theTag) +void ModelAPI_ResultBody::generated(const GeomShapePtr& theOldShape, + const GeomShapePtr& theNewShape, + const std::string& theName) { - myBuilder->generated(theOldShape, theNewShape, theName, theTag); + myBuilder->generated(theOldShape, theNewShape, theName); } -void ModelAPI_ResultBody::modified(const std::shared_ptr& theOldShape, - const std::shared_ptr& theNewShape, const std::string& theName, - const int theTag) +void ModelAPI_ResultBody::modified(const GeomShapePtr& theOldShape, + const GeomShapePtr& theNewShape, + const std::string& theName) { - myBuilder->modified(theOldShape, theNewShape, theName, theTag); + myBuilder->modified(theOldShape, theNewShape, theName); } -void ModelAPI_ResultBody::deleted( - const std::shared_ptr& theOldShape, const int theTag) +void ModelAPI_ResultBody::deleted(const GeomShapePtr& theOldShape) { - myBuilder->deleted(theOldShape, theTag); + myBuilder->deleted(theOldShape); } -void ModelAPI_ResultBody::loadDeletedShapes(GeomAlgoAPI_MakeShape* theMS, - std::shared_ptr theShapeIn, - const int theKindOfShape, - const int theTag, - const GeomShapePtr theShapes) +void ModelAPI_ResultBody::loadDeletedShapes(const GeomMakeShapePtr& theAlgo, + const GeomShapePtr& theOldShape, + const GeomAPI_Shape::ShapeType theShapeTypeToExplore, + const GeomShapePtr& theShapesToExclude) { - myBuilder->loadDeletedShapes(theMS, theShapeIn, theKindOfShape, theTag, theShapes); + myBuilder->loadDeletedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theShapesToExclude); } -void ModelAPI_ResultBody::loadAndOrientModifiedShapes(GeomAlgoAPI_MakeShape* theMS, - std::shared_ptr theShapeIn, const int theKindOfShape, const int theTag, - const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes, - const bool theIsStoreSeparate, - const bool theIsStoreAsGenerated, - const bool /*theSplitInSubs*/) +void ModelAPI_ResultBody::loadModifiedShapes(const GeomMakeShapePtr& theAlgo, + const GeomShapePtr& theOldShape, + const GeomAPI_Shape::ShapeType theShapeTypeToExplore, + const std::string& theName) { - myBuilder->loadAndOrientModifiedShapes( - theMS, theShapeIn, theKindOfShape, theTag, theName, theSubShapes, theIsStoreSeparate, - theIsStoreAsGenerated); + myBuilder->loadModifiedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theName); } void ModelAPI_ResultBody::loadAndOrientGeneratedShapes(GeomAlgoAPI_MakeShape* theMS, - std::shared_ptr theShapeIn, const int theKindOfShape, - const int theTag, const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes) + GeomShapePtr theShapeIn, + const int theKindOfShape, + const int theTag, + const std::string& theName, + GeomAPI_DataMapOfShapeShape& theSubShapes) { myBuilder->loadAndOrientGeneratedShapes( theMS, theShapeIn, theKindOfShape, theTag, theName, theSubShapes); } -void ModelAPI_ResultBody::loadFirstLevel(std::shared_ptr theShape, - const std::string& theName, int& theTag) +void ModelAPI_ResultBody::loadFirstLevel(GeomShapePtr theShape, + const std::string& theName, + int& theTag) { myBuilder->loadFirstLevel(theShape, theName, theTag); } -void ModelAPI_ResultBody::loadDisconnectedEdges(std::shared_ptr theShape, - const std::string& theName, int& theTag) +void ModelAPI_ResultBody::loadDisconnectedEdges(GeomShapePtr theShape, + const std::string& theName, + int& theTag) { myBuilder->loadDisconnectedEdges(theShape, theName, theTag); } -void ModelAPI_ResultBody::loadDisconnectedVertexes(std::shared_ptr theShape, - const std::string& theName, int& theTag) +void ModelAPI_ResultBody::loadDisconnectedVertexes(GeomShapePtr theShape, + const std::string& theName, + int& theTag) { myBuilder->loadDisconnectedVertexes(theShape, theName, theTag); } diff --git a/src/ModelAPI/ModelAPI_ResultBody.h b/src/ModelAPI/ModelAPI_ResultBody.h index 9bc81dfc4..4b40d7d21 100644 --- a/src/ModelAPI/ModelAPI_ResultBody.h +++ b/src/ModelAPI/ModelAPI_ResultBody.h @@ -95,81 +95,87 @@ public: /// param[in] theShape shape to store. /// param[in] theIsStoreSameShapes if false stores reference to the same shape /// if it is already in document. - MODELAPI_EXPORT virtual void store(const std::shared_ptr& theShape, - const bool theIsStoreSameShapes = true); + MODELAPI_EXPORT virtual void store(const GeomShapePtr& theShape, + const bool theIsStoreSameShapes = true); /// Stores the generated shape (called by the execution method). - MODELAPI_EXPORT virtual void storeGenerated(const std::shared_ptr& theFromShape, - const std::shared_ptr& theToShape); + MODELAPI_EXPORT virtual void storeGenerated(const GeomShapePtr& theFromShape, + const GeomShapePtr& theToShape); /// Stores the modified shape (called by the execution method). - MODELAPI_EXPORT virtual void storeModified(const std::shared_ptr& theOldShape, - const std::shared_ptr& theNewShape, const int theDecomposeSolidsTag = 0); + MODELAPI_EXPORT virtual void storeModified(const GeomShapePtr& theOldShape, + const GeomShapePtr& theNewShape, + const bool theIsCleanStored = true); /// Stores the shape without naming support - MODELAPI_EXPORT virtual void storeWithoutNaming( - const std::shared_ptr& theShape); + MODELAPI_EXPORT virtual void storeWithoutNaming(const GeomShapePtr& theShape); /// Returns the shape-result produced by this feature - MODELAPI_EXPORT virtual std::shared_ptr shape(); + MODELAPI_EXPORT virtual GeomShapePtr shape(); /// Records the subshape newShape which was generated during a topological construction. /// As an example, consider the case of a face generated in construction of a box. - MODELAPI_EXPORT virtual void generated(const std::shared_ptr& theNewShape, + MODELAPI_EXPORT virtual void generated(const GeomShapePtr& theNewShape, const std::string& theName); /// Records the shape newShape which was generated from the shape oldShape during a topological /// construction. As an example, consider the case of a face generated from an edge in /// construction of a prism. - MODELAPI_EXPORT virtual void generated(const std::shared_ptr& theOldShape, - const std::shared_ptr& theNewShape, const std::string& theName, - const int theTag = 1); + MODELAPI_EXPORT virtual void generated(const GeomShapePtr& theOldShape, + const GeomShapePtr& theNewShape, + const std::string& theName = ""); /// Records the shape newShape which is a modification of the shape oldShape. /// As an example, consider the case of a face split or merged in a Boolean operation. - MODELAPI_EXPORT virtual void modified(const std::shared_ptr& theOldShape, - const std::shared_ptr& theNewShape, const std::string& theName, - const int theTag = 1); + MODELAPI_EXPORT virtual void modified(const GeomShapePtr& theOldShape, + const GeomShapePtr& theNewShape, + const std::string& theName = ""); /// Records the shape oldShape which was deleted from the current label. /// As an example, consider the case of a face removed by a Boolean operation. - MODELAPI_EXPORT virtual void deleted( - const std::shared_ptr& theOldShape, const int theTag = 1); + MODELAPI_EXPORT virtual void deleted(const GeomShapePtr& theOldShape); /// load deleted shapes - MODELAPI_EXPORT virtual void loadDeletedShapes(GeomAlgoAPI_MakeShape* theMS, - std::shared_ptr theShapeIn, - const int theKindOfShape, - const int theTag, - const GeomShapePtr theShapes = GeomShapePtr()); + MODELAPI_EXPORT + virtual void loadDeletedShapes(const std::shared_ptr& theAlgo, + const GeomShapePtr& theOldShape, + const GeomAPI_Shape::ShapeType theShapeTypeToExplore, + const GeomShapePtr& theShapesToExclude = GeomShapePtr()); /// load and orient modified shapes - MODELAPI_EXPORT virtual void loadAndOrientModifiedShapes(GeomAlgoAPI_MakeShape* theMS, - std::shared_ptr theShapeIn, const int theKindOfShape, const int theTag, - const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes, - const bool theIsStoreSeparate = false, const bool theIsStoreAsGenerated = false, - const bool theSplitInSubs = false); + MODELAPI_EXPORT + virtual void loadModifiedShapes(const std::shared_ptr& theAlgo, + const GeomShapePtr& theOldShape, + const GeomAPI_Shape::ShapeType theShapeTypeToExplore, + const std::string& theName = ""); /// load and orient generated shapes - MODELAPI_EXPORT virtual void loadAndOrientGeneratedShapes(GeomAlgoAPI_MakeShape* theMS, - std::shared_ptr theShapeIn, const int theKindOfShape, - const int theTag, const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes); + MODELAPI_EXPORT + virtual void loadAndOrientGeneratedShapes(GeomAlgoAPI_MakeShape* theMS, + GeomShapePtr theShapeIn, + const int theKindOfShape, + const int theTag, + const std::string& theName, + GeomAPI_DataMapOfShapeShape& theSubShapes); /// load shapes of the first level (to be used during shape import) - MODELAPI_EXPORT virtual void loadFirstLevel(std::shared_ptr theShape, - const std::string& theName, int& theTag); + MODELAPI_EXPORT virtual void loadFirstLevel(GeomShapePtr theShape, + const std::string& theName, + int& theTag); /// load disconnected edges - MODELAPI_EXPORT virtual void loadDisconnectedEdges(std::shared_ptr theShape, - const std::string& theName, int& theTag); + MODELAPI_EXPORT virtual void loadDisconnectedEdges(GeomShapePtr theShape, + const std::string& theName, + int& theTag); /// load disconnected vetexes - MODELAPI_EXPORT virtual void loadDisconnectedVertexes(std::shared_ptr theShape, - const std::string& theName, int& theTag); + MODELAPI_EXPORT virtual void loadDisconnectedVertexes(GeomShapePtr theShape, + const std::string& theName, + int& theTag); /// Returns true if the latest modification of this body in the naming history // is equal to the given shape - MODELAPI_EXPORT virtual bool isLatestEqual(const std::shared_ptr& theShape) = 0; + MODELAPI_EXPORT virtual bool isLatestEqual(const GeomShapePtr& theShape) = 0; /// Returns true is the topology is connected. MODELAPI_EXPORT virtual bool isConnectedTopology() = 0; @@ -179,7 +185,7 @@ public: MODELAPI_EXPORT virtual void setDisplayed(const bool theDisplay); /// Updates the sub-bodies if shape of this object is compsolid or compound - MODELAPI_EXPORT virtual void updateSubs(const std::shared_ptr& theThisShape, + MODELAPI_EXPORT virtual void updateSubs(const GeomShapePtr& theThisShape, const bool theShapeChanged = true) = 0; protected: -- 2.39.2