From 35d4b199e4d3581615470404d47e3bfae4def046 Mon Sep 17 00:00:00 2001 From: mpv Date: Thu, 3 Sep 2015 11:38:14 +0300 Subject: [PATCH] Debug of naming of Boolean operation of extrusion and revolution results. --- .../FeaturesPlugin_CompositeBoolean.cpp | 17 +++++++++-------- .../FeaturesPlugin_Extrusion.cpp | 8 ++++---- .../FeaturesPlugin_Revolution.cpp | 8 ++++---- src/Model/Model_BodyBuilder.cpp | 18 ++++++++++++++++++ src/Model/Model_BodyBuilder.h | 4 ++++ src/Model/Model_Update.cpp | 3 ++- src/ModelAPI/ModelAPI_BodyBuilder.h | 3 +++ src/ModelAPI/ModelAPI_ResultBody.cpp | 5 +++++ src/ModelAPI/ModelAPI_ResultBody.h | 4 ++++ 9 files changed, 53 insertions(+), 17 deletions(-) diff --git a/src/FeaturesPlugin/FeaturesPlugin_CompositeBoolean.cpp b/src/FeaturesPlugin/FeaturesPlugin_CompositeBoolean.cpp index 98735660f..64cd49884 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_CompositeBoolean.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_CompositeBoolean.cpp @@ -103,7 +103,7 @@ void FeaturesPlugin_CompositeBoolean::execute() // Getting faces to create solids. std::shared_ptr aSketchFeature = std::dynamic_pointer_cast( reference(SKETCH_OBJECT_ID())->value()); - if(!aSketchFeature) { + if(!aSketchFeature || aSketchFeature->results().empty()) { return; } ResultPtr aSketchRes = aSketchFeature->results().front(); @@ -218,11 +218,11 @@ void FeaturesPlugin_CompositeBoolean::loadNamingDS(std::shared_ptrstore(theAlgo.shape()); } else { const int aGenTag = 1; - const int aFromTag = 2; - const int aToTag = 3; - const int aModTag = 4; - const int aDelTag = 5; - const int aSubsolidsTag=6; /// sub solids will be placed at labels 6, 7, etc. if result is compound of solids + const int aModTag = 2; + const int aDelTag = 3; + const int aSubsolidsTag=4; /// sub solids will be placed at labels 6, 7, etc. if result is compound of solids + int aToTag = 5; // may be many labels, starting from this index + int aFromTag = 10000; // may be many labels, starting from this index or last aToTag index const std::string aGenName = "Generated"; const std::string aModName = "Modified"; const std::string aLatName = "LateralFace"; @@ -262,16 +262,17 @@ void FeaturesPlugin_CompositeBoolean::loadNamingDS(std::shared_ptrisBound(aToFace)) { aToFace = aSubShapes->find(aToFace); } - theResultBody->generated(aToFace, aToName, aToTag); + theResultBody->generated(aToFace, aToName, aToTag++); } //Insert from faces + if (aFromTag < aToTag) aFromTag = aToTag; for(ListOfShape::const_iterator anIt = aFromFaces.cbegin(); anIt != aFromFaces.cend(); anIt++) { std::shared_ptr aFromFace = *anIt; if(aSubShapes->isBound(aFromFace)) { aFromFace = aSubShapes->find(aFromFace); } - theResultBody->generated(aFromFace, aFromName, aFromTag); + theResultBody->generated(aFromFace, aFromName, aFromTag++); } } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp index 85b5b665d..c8ac130c4 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp @@ -190,25 +190,25 @@ void FeaturesPlugin_Extrusion::loadNamingDS(GeomAlgoAPI_Prism& thePrismAlgo, //Insert to faces const std::string aToName = "ToFace"; - const int aToTag = 2; + int aToTag = 2; const ListOfShape& aToFaces = thePrismAlgo.toFaces(); for(ListOfShape::const_iterator anIt = aToFaces.cbegin(); anIt != aToFaces.cend(); anIt++) { std::shared_ptr aToFace = *anIt; if(aSubShapes->isBound(aToFace)) { aToFace = aSubShapes->find(aToFace); } - theResultBody->generated(aToFace, aToName, aToTag); + theResultBody->generated(aToFace, aToName, aToTag++); } //Insert from faces const std::string aFromName = "FromFace"; - const int aFromTag = 3; + int aFromTag = aToTag > 10000 ? aToTag : 10000; const ListOfShape& aFromFaces = thePrismAlgo.fromFaces(); for(ListOfShape::const_iterator anIt = aFromFaces.cbegin(); anIt != aFromFaces.cend(); anIt++) { std::shared_ptr aFromFace = *anIt; if(aSubShapes->isBound(aFromFace)) { aFromFace = aSubShapes->find(aFromFace); } - theResultBody->generated(aFromFace, aFromName, aFromTag); + theResultBody->generated(aFromFace, aFromName, aFromTag++); } } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp b/src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp index 26bbe7010..fd06b5f96 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp @@ -198,25 +198,25 @@ void FeaturesPlugin_Revolution::loadNamingDS(GeomAlgoAPI_Revolution& theRevolAlg //Insert to faces const std::string aToName = "ToFace"; - const int aToTag = 2; + int aToTag = 2; const ListOfShape& aToFaces = theRevolAlgo.toFaces(); for(ListOfShape::const_iterator anIt = aToFaces.cbegin(); anIt != aToFaces.cend(); anIt++) { std::shared_ptr aToFace = *anIt; if(aSubShapes->isBound(aToFace)) { aToFace = aSubShapes->find(aToFace); } - theResultBody->generated(aToFace, aToName, aToTag); + theResultBody->generated(aToFace, aToName, aToTag++); } //Insert from faces const std::string aFromName = "FromFace"; - const int aFromTag = 3; + int aFromTag = aToTag > 10000 ? aToTag : 10000; const ListOfShape& aFromFaces = theRevolAlgo.fromFaces(); for(ListOfShape::const_iterator anIt = aFromFaces.cbegin(); anIt != aFromFaces.cend(); anIt++) { std::shared_ptr aFromFace = *anIt; if(aSubShapes->isBound(aFromFace)) { aFromFace = aSubShapes->find(aFromFace); } - theResultBody->generated(aFromFace, aFromName, aFromTag); + theResultBody->generated(aFromFace, aFromName, aFromTag++); } } diff --git a/src/Model/Model_BodyBuilder.cpp b/src/Model/Model_BodyBuilder.cpp index 0efc17797..bacee75eb 100755 --- a/src/Model/Model_BodyBuilder.cpp +++ b/src/Model/Model_BodyBuilder.cpp @@ -86,6 +86,8 @@ static void evolutionToSelectionRec(TDF_Label theLab, const bool theFlag) { aBuilder.Delete(aPairsIter->first); } else if (anEvol == TNaming_PRIMITIVE) { aBuilder.Generated(aPairsIter->second); + } else if (anEvol == TNaming_SELECTED) { + aBuilder.Select(aPairsIter->first, aPairsIter->second); } } // recursive call for all sub-labels @@ -213,6 +215,22 @@ void Model_BodyBuilder::storeModified(const std::shared_ptr& theO } } } + +void Model_BodyBuilder::storeWithoutNaming(const std::shared_ptr& theShape) +{ + std::shared_ptr aData = std::dynamic_pointer_cast(data()); + if (aData) { + clean(); + if (!theShape.get()) + return; // bad shape + TopoDS_Shape aShape = theShape->impl(); + if (aShape.IsNull()) + return; // null shape inside + TNaming_Builder aBuilder(aData->shapeLab()); + aBuilder.Select(aShape, aShape); + } +} + void Model_BodyBuilder::clean() { std::vector::iterator aBuilder = myBuilders.begin(); diff --git a/src/Model/Model_BodyBuilder.h b/src/Model/Model_BodyBuilder.h index 5097fc17d..fbbcce9f6 100755 --- a/src/Model/Model_BodyBuilder.h +++ b/src/Model/Model_BodyBuilder.h @@ -42,6 +42,10 @@ public: const std::shared_ptr& theNewShape, const int theDecomposeSolidsTag = 0); + /// Stores the shape without naming support + /// \param theShape shape to store + MODEL_EXPORT virtual void storeWithoutNaming(const std::shared_ptr& theShape); + /// Returns the shape-result produced by this feature MODEL_EXPORT virtual std::shared_ptr shape(); diff --git a/src/Model/Model_Update.cpp b/src/Model/Model_Update.cpp index 3ec27e47f..244aa6867 100644 --- a/src/Model/Model_Update.cpp +++ b/src/Model/Model_Update.cpp @@ -222,7 +222,8 @@ void Model_Update::processOperation(const bool theTotalUpdate, const bool theFin for(aFIter = myWaitForFinish.begin(); aFIter != myWaitForFinish.end(); aFIter++) { FeaturePtr aF = std::dynamic_pointer_cast(*aFIter); - if (aF && aF->data()->isValid() && aF->getKind() == "Extrusion") { + if (aF && aF->data()->isValid() && + (aF->getKind() == "Extrusion" || aF->getKind() == "Revolution")) { AttributeSelectionListPtr aBase = aF->selectionList("base"); if (aBase.get()) { for(int a = aBase->size() - 1; a >= 0; a--) { diff --git a/src/ModelAPI/ModelAPI_BodyBuilder.h b/src/ModelAPI/ModelAPI_BodyBuilder.h index 6f857e46c..ff43ca7c4 100755 --- a/src/ModelAPI/ModelAPI_BodyBuilder.h +++ b/src/ModelAPI/ModelAPI_BodyBuilder.h @@ -38,6 +38,9 @@ public: const std::shared_ptr& theNewShape, const int theDecomposeSolidsTag = 0) = 0; + /// Stores the shape without naming support + virtual void storeWithoutNaming(const std::shared_ptr& theShape) = 0; + /// Returns the shape-result produced by this feature virtual std::shared_ptr shape() = 0; diff --git a/src/ModelAPI/ModelAPI_ResultBody.cpp b/src/ModelAPI/ModelAPI_ResultBody.cpp index 5728190de..17d01edc7 100644 --- a/src/ModelAPI/ModelAPI_ResultBody.cpp +++ b/src/ModelAPI/ModelAPI_ResultBody.cpp @@ -41,6 +41,11 @@ void ModelAPI_ResultBody::storeModified(const std::shared_ptr& th myBuilder->storeModified(theOldShape, theNewShape, theDecomposeSolidsTag); } +void ModelAPI_ResultBody::storeWithoutNaming(const std::shared_ptr& theShape) +{ + myBuilder->storeWithoutNaming(theShape); +} + std::shared_ptr ModelAPI_ResultBody::shape() { return myBuilder->shape(); diff --git a/src/ModelAPI/ModelAPI_ResultBody.h b/src/ModelAPI/ModelAPI_ResultBody.h index 7565d07bf..1cce02786 100644 --- a/src/ModelAPI/ModelAPI_ResultBody.h +++ b/src/ModelAPI/ModelAPI_ResultBody.h @@ -55,6 +55,10 @@ public: MODELAPI_EXPORT virtual void storeModified(const std::shared_ptr& theOldShape, const std::shared_ptr& theNewShape, const int theDecomposeSolidsTag = 0); + /// Stores the shape without naming support + MODELAPI_EXPORT virtual void storeWithoutNaming( + const std::shared_ptr& theShape); + /// Returns the shape-result produced by this feature MODELAPI_EXPORT virtual std::shared_ptr shape(); -- 2.39.2