X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_Session.cpp;h=c73516a43069ef9382894fe3eb1456a588310bb1;hb=10671023698288fff01b8717696d150419dc4475;hp=cbe0e6a523da9f3ebc457e5f65ebf67ec3088a4f;hpb=50c7c4e2d186cf4367fc4d52fa2559289f71d807;p=modules%2Fshaper.git diff --git a/src/Model/Model_Session.cpp b/src/Model/Model_Session.cpp index cbe0e6a52..c73516a43 100644 --- a/src/Model/Model_Session.cpp +++ b/src/Model/Model_Session.cpp @@ -21,14 +21,23 @@ #include #include #include + +#include #include #include +#include #include #include #include #include +#include +#include +#include + +#include + static Model_Session* myImpl = new Model_Session(); // t oredirect all calls to the root document @@ -329,6 +338,50 @@ std::shared_ptr Model_Session::copy( aRT->SetRelocation(aSourceRoot, aTargetRoot); TDF_CopyTool::Copy(aDS, aRT); + // TODO: remove after fix in OCCT. + // All named shapes are stored in reversed order, so to fix this we reverse them back. + for(TDF_ChildIDIterator aChildIter(aTargetRoot, TNaming_NamedShape::GetID(), true); + aChildIter.More(); + aChildIter.Next()) { + Handle(TNaming_NamedShape) aNamedShape = + Handle(TNaming_NamedShape)::DownCast(aChildIter.Value()); + if (aNamedShape.IsNull()) { + continue; + } + + TopoDS_Shape aShape = aNamedShape->Get(); + if(aShape.IsNull() || aShape.ShapeType() != TopAbs_COMPOUND) { + continue; + } + + TNaming_Evolution anEvol = aNamedShape->Evolution(); + std::list > aShapePairs; // to store old and new shapes + for(TNaming_Iterator anIter(aNamedShape); anIter.More(); anIter.Next()) { + aShapePairs.push_back( + std::pair(anIter.OldShape(), anIter.NewShape())); + } + + // Add in reverse order. + TDF_Label aLabel = aNamedShape->Label(); + TNaming_Builder aBuilder(aLabel); + for(std::list >::iterator aPairsIter = + aShapePairs.begin(); + aPairsIter != aShapePairs.end(); + aPairsIter++) { + if (anEvol == TNaming_GENERATED) { + aBuilder.Generated(aPairsIter->first, aPairsIter->second); + } else if (anEvol == TNaming_MODIFY) { + aBuilder.Modify(aPairsIter->first, aPairsIter->second); + } else if (anEvol == TNaming_DELETE) { + aBuilder.Delete(aPairsIter->first); + } else if (anEvol == TNaming_PRIMITIVE) { + aBuilder.Generated(aPairsIter->second); + } else if (anEvol == TNaming_SELECTED) { + aBuilder.Select(aPairsIter->second, aPairsIter->first); + } + } + } + TDF_LabelList anEmptyUpdated; aNew->objects()->synchronizeFeatures(anEmptyUpdated, true, true, true, true); return aNew; @@ -435,7 +488,6 @@ void Model_Session::LoadPluginsInfo() { if (myPluginsInfoLoaded) // nothing to do return; - Config_ModuleReader::loadScript("salome.shaper.initConfig"); // Read plugins information from XML files Config_ModuleReader aModuleReader(Config_FeatureMessage::MODEL_EVENT()); aModuleReader.readAll();