X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FModel%2FModel_BodyBuilder.cpp;h=bfa8d62fe1a32d7a78b6a20dd77aa45c8e1e4172;hb=64981a525f8bc2c450475822e96dcc2766454ad3;hp=476e22ace55e122a536b9f91fc66e80b49c8b1ee;hpb=a4de236e09b921bc33a28b6a6e0fc3208a86355b;p=modules%2Fshaper.git diff --git a/src/Model/Model_BodyBuilder.cpp b/src/Model/Model_BodyBuilder.cpp index 476e22ace..bfa8d62fe 100755 --- a/src/Model/Model_BodyBuilder.cpp +++ b/src/Model/Model_BodyBuilder.cpp @@ -8,7 +8,6 @@ #include #include -#include #include #include #include @@ -79,7 +78,7 @@ static void evolutionToSelectionRec(TDF_Label theLab, const bool theFlag) { std::list >::iterator aPairsIter = aShapePairs.begin(); for(; aPairsIter != aShapePairs.end(); aPairsIter++) { if (theFlag) { // disabled => make selection - aBuilder.Select(aPairsIter->first, aPairsIter->second); + aBuilder.Select(aPairsIter->second, aPairsIter->first); } else if (anEvol == TNaming_GENERATED) { aBuilder.Generated(aPairsIter->first, aPairsIter->second); } else if (anEvol == TNaming_MODIFY) { @@ -89,7 +88,7 @@ static void evolutionToSelectionRec(TDF_Label theLab, const bool theFlag) { } else if (anEvol == TNaming_PRIMITIVE) { aBuilder.Generated(aPairsIter->second); } else if (anEvol == TNaming_SELECTED) { - aBuilder.Select(aPairsIter->first, aPairsIter->second); + aBuilder.Select(aPairsIter->second, aPairsIter->first); } } // recursive call for all sub-labels @@ -130,12 +129,14 @@ void Model_BodyBuilder::store(const std::shared_ptr& theShape, // This shape is already in document, store reference instead of shape; const TDF_Label aFoundLabel = aNS->Label(); TDF_Reference::Set(aShapeLab, aFoundLabel); + aShapeLab.ForgetAttribute(TNaming_NamedShape::GetID()); return; } } aBuilder.Generated(aShape); // register name + aShapeLab.ForgetAttribute(TDF_Reference::GetID()); if(!aBuilder.NamedShape()->IsEmpty()) { Handle(TDataStd_Name) anAttr; if(aBuilder.NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(),anAttr)) { @@ -223,8 +224,11 @@ void Model_BodyBuilder::storeModified(const std::shared_ptr& theO TNaming_Builder aSubBuilder(aShapeLab.FindChild(aTag++)); aSubBuilder.Generated(aSubIter.Value()); if(!aName.IsEmpty()) { + TCollection_AsciiString aShapeType = aShape.ShapeType() == TopAbs_EDGE ? "_Edge_" : + aShape.ShapeType() == TopAbs_FACE ? "_Face_" : + aShape.ShapeType() == TopAbs_SOLID ? "_Solid_" : "_Shape_"; std::string aSolidName = - (aName + "_Solid_" + TCollection_AsciiString(aTag - theDecomposeSolidsTag)).ToCString(); + (aName + aShapeType + TCollection_AsciiString(aTag - theDecomposeSolidsTag)).ToCString(); std::shared_ptr aDoc = std::dynamic_pointer_cast(document()); aDoc->addNamingName(aSubBuilder.NamedShape()->Label(), aSolidName); @@ -302,6 +306,22 @@ void Model_BodyBuilder::generated(const std::shared_ptr& theOldSh 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((data()->name() + "/" + theName + "_").c_str()) + aTag; + aDoc->addNamingName(aChildLabel, aChildName.ToCString()); + TDataStd_Name::Set(aChildLabel, aChildName.ToCString()); + aTag++; + } + } } @@ -350,13 +370,14 @@ void Model_BodyBuilder::loadAndOrientModifiedShapes ( GeomAPI_DataMapOfShapeShape& theSubShapes, const bool theIsStoreSeparate) { + int anIndex = 1; int aTag = theTag; + bool isBuilt = !theName.empty(); std::string aName = theName; std::ostringstream aStream; - int anIndex = 1; + GeomShapePtr aResultShape = shape(); TopoDS_Shape aShapeIn = theShapeIn->impl(); TopTools_MapOfShape aView; - bool isBuilt = theName.empty(); TopExp_Explorer aShapeExplorer (aShapeIn, (TopAbs_ShapeEnum)theKindOfShape); for (; aShapeExplorer.More(); aShapeExplorer.Next ()) { const TopoDS_Shape& aRoot = aShapeExplorer.Current (); @@ -367,14 +388,16 @@ void Model_BodyBuilder::loadAndOrientModifiedShapes ( theMS->modified(aRShape, aList); std::list >::const_iterator anIt = aList.begin(), aLast = aList.end(); for (; anIt != aLast; anIt++) { - TopoDS_Shape aNewShape = (*anIt)->impl(); + TopoDS_Shape aNewShape = (*anIt)->impl(); if (theSubShapes.isBound(*anIt)) { std::shared_ptr aMapShape(theSubShapes.find(*anIt)); aNewShape.Orientation(aMapShape->impl().Orientation()); } - if (!aRoot.IsSame (aNewShape)) { + GeomShapePtr aGeomNewShape(new GeomAPI_Shape()); + aGeomNewShape->setImpl(new TopoDS_Shape(aNewShape)); + if(!aRoot.IsSame(aNewShape) && aResultShape->isSubShape(aGeomNewShape)) { builder(aTag)->Modify(aRoot,aNewShape); - if(!isBuilt) { + if(isBuilt) { if(theIsStoreSeparate) { aStream.str(std::string()); aStream.clear(); @@ -401,7 +424,7 @@ void Model_BodyBuilder::loadAndOrientGeneratedShapes ( { TopoDS_Shape aShapeIn = theShapeIn->impl(); TopTools_MapOfShape aView; - bool isBuilt = theName.empty(); + bool isBuilt = !theName.empty(); TopExp_Explorer aShapeExplorer (aShapeIn, (TopAbs_ShapeEnum)theKindOfShape); for (; aShapeExplorer.More(); aShapeExplorer.Next ()) { const TopoDS_Shape& aRoot = aShapeExplorer.Current (); @@ -412,15 +435,31 @@ void Model_BodyBuilder::loadAndOrientGeneratedShapes ( theMS->generated(aRShape, aList); std::list >::const_iterator anIt = aList.begin(), aLast = aList.end(); for (; anIt != aLast; anIt++) { - TopoDS_Shape aNewShape = (*anIt)->impl(); + TopoDS_Shape aNewShape = (*anIt)->impl(); if (theSubShapes.isBound(*anIt)) { std::shared_ptr aMapShape(theSubShapes.find(*anIt)); aNewShape.Orientation(aMapShape->impl().Orientation()); } if (!aRoot.IsSame (aNewShape)) { builder(theTag)->Generated(aRoot,aNewShape); - if(!isBuilt) - buildName(theTag, theName); + if(isBuilt) + 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(aRoot, anExp.Current()); + TCollection_AsciiString aChildName = TCollection_AsciiString((data()->name() + "/" + theName + "_").c_str()) + aTag; + aDoc->addNamingName(aChildLabel, aChildName.ToCString()); + TDataStd_Name::Set(aChildLabel, aChildName.ToCString()); + aTag++; + } } } } @@ -780,7 +819,7 @@ std::shared_ptr Model_BodyBuilder::shape() { std::shared_ptr aData = std::dynamic_pointer_cast(data()); if (aData) { - TDF_Label& aShapeLab = aData->shapeLab(); + TDF_Label aShapeLab = aData->shapeLab(); Handle(TDF_Reference) aRef; if (aShapeLab.FindAttribute(TDF_Reference::GetID(), aRef)) { aShapeLab = aRef->Get();