X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_BodyBuilder.cpp;h=bacee75ebf41ae62d1dca4d11fa31add5e425b7c;hb=cdfb03d58ed695e291aa3b7cd3c342051e18e444;hp=604c99b2c4181186cda4529d1e05b7c280ff4e75;hpb=b6be33d3af5a10e204e3bd69708d49b8b9f1a127;p=modules%2Fshaper.git diff --git a/src/Model/Model_BodyBuilder.cpp b/src/Model/Model_BodyBuilder.cpp index 604c99b2c..bacee75eb 100755 --- a/src/Model/Model_BodyBuilder.cpp +++ b/src/Model/Model_BodyBuilder.cpp @@ -46,7 +46,7 @@ Model_BodyBuilder::Model_BodyBuilder(ModelAPI_Object* theOwner) // Converts evolution of naming shape to selection evelution and back to avoid // naming support on the disabled results. Deeply in the labels tree, recursively. -static void EvolutionToSelection(TDF_Label theLab, const bool theFlag) { +static void evolutionToSelectionRec(TDF_Label theLab, const bool theFlag) { std::list > aShapePairs; // to store old and new shapes Handle(TNaming_NamedShape) aName; int anEvolution = -1; @@ -86,15 +86,26 @@ static void EvolutionToSelection(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 TDF_ChildIterator anIter(theLab, Standard_False); for(; anIter.More(); anIter.Next()) { - EvolutionToSelection(anIter.Value(), theFlag); + evolutionToSelectionRec(anIter.Value(), theFlag); } } +void Model_BodyBuilder::evolutionToSelection(const bool theFlag) +{ + std::shared_ptr aData = std::dynamic_pointer_cast(data()); + if (!aData) // unknown case + return; + TDF_Label& aShapeLab = aData->shapeLab(); + evolutionToSelectionRec(aShapeLab, theFlag); +} + void Model_BodyBuilder::store(const std::shared_ptr& theShape) { std::shared_ptr aData = std::dynamic_pointer_cast(data()); @@ -204,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(); @@ -714,3 +741,21 @@ void Model_BodyBuilder::loadDisconnectedVertexes(std::shared_ptr } } } + +std::shared_ptr Model_BodyBuilder::shape() +{ + std::shared_ptr aData = std::dynamic_pointer_cast(data()); + if (aData) { + TDF_Label& aShapeLab = aData->shapeLab(); + Handle(TNaming_NamedShape) aName; + if (aShapeLab.FindAttribute(TNaming_NamedShape::GetID(), aName)) { + TopoDS_Shape aShape = aName->Get(); + if (!aShape.IsNull()) { + std::shared_ptr aRes(new GeomAPI_Shape); + aRes->setImpl(new TopoDS_Shape(aShape)); + return aRes; + } + } + } + return std::shared_ptr(); +}