From 404d3f9cf25a17875338b7097b234ea8ed06a7cf Mon Sep 17 00:00:00 2001 From: dbv Date: Fri, 20 Nov 2015 16:16:19 +0300 Subject: [PATCH] Partition naming --- CMakeLists.txt | 1 + .../FeaturesPlugin_Partition.cpp | 19 +++++++++++---- src/Model/Model_AttributeSelection.cpp | 9 ++++++-- src/Model/Model_BodyBuilder.cpp | 23 +++++++++++++++---- src/Model/Model_BodyBuilder.h | 3 ++- src/ModelAPI/ModelAPI_BodyBuilder.h | 3 ++- src/ModelAPI/ModelAPI_ResultBody.cpp | 4 ++-- src/ModelAPI/ModelAPI_ResultBody.h | 2 +- 8 files changed, 48 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bd81e2107..5117aeb10 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,6 +58,7 @@ ADD_SUBDIRECTORY (src/SketchPlugin) ADD_SUBDIRECTORY (src/SketchSolver) ADD_SUBDIRECTORY (src/ModuleBase) ADD_SUBDIRECTORY (src/PartSet) +ADD_SUBDIRECTORY (src/DFBrowser) IF(NOT ${HAVE_SALOME}) ADD_SUBDIRECTORY (src/AppElements) diff --git a/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp b/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp index 5929e1e9f..2a584910c 100755 --- a/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp @@ -22,6 +22,8 @@ #include #include +#include + //================================================================================================= FeaturesPlugin_Partition::FeaturesPlugin_Partition() { @@ -191,21 +193,28 @@ void FeaturesPlugin_Partition::loadNamingDS(std::shared_ptr if(theBaseShape->isEqual(theResultShape)) { theResultBody->store(theResultShape); } else { - const int aModifyTag = 1; - const int aDeletedTag = 2; - const int aSubsolidsTag = 3; /// sub solids will be placed at labels 3, 4, etc. if result is compound of solids + const int aDeletedTag = 1; + const int aSubsolidsTag = 2; /// sub solids will be placed at labels 3, 4, etc. if result is compound of solids + const int aModifyTag = 100000; + int aModifyToolsTag = 200000; + std::ostringstream aStream; theResultBody->storeModified(theBaseShape, theResultShape, aSubsolidsTag); std::string aModName = "Modified"; theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::FACE, - aModifyTag, aModName, theMapOfShapes); + aModifyTag, aModName, theMapOfShapes, true); theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::FACE, aDeletedTag); + int anIndex = 1; for(ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++) { + aStream.str(std::string()); + aStream.clear(); + aStream << aModName << "_" << anIndex++; theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE, - aModifyTag, aModName, theMapOfShapes); + aModifyToolsTag, aStream.str(), theMapOfShapes, true); theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE, aDeletedTag); + aModifyToolsTag += 10000; } } } diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index 76514a28d..84d4c2974 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -98,8 +98,13 @@ void Model_AttributeSelection::setValue(const ResultPtr& theContext, (theSubShape == anOldShape || (theSubShape && anOldShape && theSubShape->isEqual(anOldShape))); if (isOldShape) return; // shape is the same, so context is also unchanged // update the referenced object if needed - if (!isOldContext) - myRef.setValue(theContext); + if (!isOldContext) { + ResultCompSolidPtr anOwner = ModelAPI_Tools::compSolidOwner(theContext); + if (anOwner.get()) + myRef.setValue(anOwner); + else + myRef.setValue(theContext); + } // do noth use naming if selected shape is result shape itself, but not sub-shape TDF_Label aSelLab = selectionLabel(); diff --git a/src/Model/Model_BodyBuilder.cpp b/src/Model/Model_BodyBuilder.cpp index 22a621d62..45befbcb4 100755 --- a/src/Model/Model_BodyBuilder.cpp +++ b/src/Model/Model_BodyBuilder.cpp @@ -329,8 +329,13 @@ void Model_BodyBuilder::loadAndOrientModifiedShapes ( const int theKindOfShape, const int theTag, const std::string& theName, - GeomAPI_DataMapOfShapeShape& theSubShapes) + GeomAPI_DataMapOfShapeShape& theSubShapes, + const bool theIsStoreSeparate) { + int aTag = theTag; + std::string aName = theName; + std::ostringstream aStream; + int anIndex = 1; TopoDS_Shape aShapeIn = theShapeIn->impl(); TopTools_MapOfShape aView; bool isBuilt = theName.empty(); @@ -350,9 +355,19 @@ void Model_BodyBuilder::loadAndOrientModifiedShapes ( aNewShape.Orientation(aMapShape->impl().Orientation()); } if (!aRoot.IsSame (aNewShape)) { - builder(theTag)->Modify(aRoot,aNewShape); - if(!isBuilt) - buildName(theTag, theName); + builder(aTag)->Modify(aRoot,aNewShape); + if(!isBuilt) { + if(theIsStoreSeparate) { + aStream.str(std::string()); + aStream.clear(); + aStream << theName << "_" << anIndex++; + aName = aStream.str(); + } + buildName(aTag, aName); + } + if(theIsStoreSeparate) { + aTag++; + } } } } diff --git a/src/Model/Model_BodyBuilder.h b/src/Model/Model_BodyBuilder.h index 3785d2164..90092e59e 100755 --- a/src/Model/Model_BodyBuilder.h +++ b/src/Model/Model_BodyBuilder.h @@ -83,7 +83,8 @@ public: const int theKindOfShape, const int theTag, const std::string& theName, - GeomAPI_DataMapOfShapeShape& theSubShapes); + GeomAPI_DataMapOfShapeShape& theSubShapes, + const bool theIsStoreSeparate = false); /// load and orient generated shapes MODEL_EXPORT virtual void loadAndOrientGeneratedShapes ( GeomAlgoAPI_MakeShape* theMS, diff --git a/src/ModelAPI/ModelAPI_BodyBuilder.h b/src/ModelAPI/ModelAPI_BodyBuilder.h index 38f2868a9..424f9857b 100755 --- a/src/ModelAPI/ModelAPI_BodyBuilder.h +++ b/src/ModelAPI/ModelAPI_BodyBuilder.h @@ -78,7 +78,8 @@ public: const int theKindOfShape, const int theTag, const std::string& theName, - GeomAPI_DataMapOfShapeShape& theSubShapes) = 0; + GeomAPI_DataMapOfShapeShape& theSubShapes, + const bool theIsStoreSeparate = false) = 0; /// load and orient generated shapes virtual void loadAndOrientGeneratedShapes ( GeomAlgoAPI_MakeShape* theMS, diff --git a/src/ModelAPI/ModelAPI_ResultBody.cpp b/src/ModelAPI/ModelAPI_ResultBody.cpp index 6f3543548..bcdc0bcb5 100644 --- a/src/ModelAPI/ModelAPI_ResultBody.cpp +++ b/src/ModelAPI/ModelAPI_ResultBody.cpp @@ -110,10 +110,10 @@ void ModelAPI_ResultBody::loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS, 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 std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes, const bool theIsStoreSeparate) { myBuilder->loadAndOrientModifiedShapes( - theMS, theShapeIn, theKindOfShape, theTag, theName, theSubShapes); + theMS, theShapeIn, theKindOfShape, theTag, theName, theSubShapes, theIsStoreSeparate); } void ModelAPI_ResultBody::loadAndOrientGeneratedShapes (GeomAlgoAPI_MakeShape* theMS, diff --git a/src/ModelAPI/ModelAPI_ResultBody.h b/src/ModelAPI/ModelAPI_ResultBody.h index 272d94e3e..a09c80638 100644 --- a/src/ModelAPI/ModelAPI_ResultBody.h +++ b/src/ModelAPI/ModelAPI_ResultBody.h @@ -93,7 +93,7 @@ public: /// 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 std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes, const bool theIsStoreSeparate = false); /// load and orient generated shapes MODELAPI_EXPORT virtual void loadAndOrientGeneratedShapes (GeomAlgoAPI_MakeShape* theMS, std::shared_ptr theShapeIn, const int theKindOfShape, -- 2.39.2