]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Result CompSolid should inherits ResultBody. All model realization concerned Naming...
authornds <natalia.donis@opencascade.com>
Fri, 31 Jul 2015 06:57:49 +0000 (09:57 +0300)
committernds <natalia.donis@opencascade.com>
Fri, 31 Jul 2015 06:57:49 +0000 (09:57 +0300)
21 files changed:
src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp
src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp
src/FeaturesPlugin/FeaturesPlugin_CompositeBoolean.cpp
src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp
src/FeaturesPlugin/FeaturesPlugin_Movement.cpp
src/FeaturesPlugin/FeaturesPlugin_Placement.cpp
src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp
src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp
src/Model/CMakeLists.txt
src/Model/Model_BodyBuilder.cpp [new file with mode: 0755]
src/Model/Model_BodyBuilder.h [new file with mode: 0755]
src/Model/Model_ResultBody.cpp
src/Model/Model_ResultBody.h
src/Model/Model_ResultCompSolid.cpp
src/ModelAPI/CMakeLists.txt
src/ModelAPI/ModelAPI_BodyBuilder.cpp [new file with mode: 0755]
src/ModelAPI/ModelAPI_BodyBuilder.h [new file with mode: 0755]
src/ModelAPI/ModelAPI_ResultBody.cpp
src/ModelAPI/ModelAPI_ResultBody.h
src/ModelAPI/ModelAPI_ResultCompSolid.cpp
src/ModelAPI/ModelAPI_ResultCompSolid.h

index e7e9e1b981bd6dbdb76bf94ada1c5e2c1136b4cc..e2d29c9c85ad7b2c8255a96617f8e068d9c1e5b0 100644 (file)
@@ -17,6 +17,7 @@
 #include <Config_PropManager.h>
 
 #include <ModelAPI_AttributeString.h>
+#include <ModelAPI_BodyBuilder.h>
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Object.h>
@@ -112,9 +113,9 @@ void ExchangePlugin_ImportFeature::loadNamingDS(
     std::shared_ptr<ModelAPI_ResultBody> theResultBody)
 {
   //load result
-  theResultBody->store(theGeomShape);
+  theResultBody->getBodyBuilder()->store(theGeomShape);
 
   int aTag(1);
   std::string aNameMS = "Shape";
-  theResultBody->loadFirstLevel(theGeomShape, aNameMS, aTag);
+  theResultBody->getBodyBuilder()->loadFirstLevel(theGeomShape, aNameMS, aTag);
 }
index 7fb46f2c998cac3abd103ee68124d04c81f45a1b..7f414c613d81e747b8651f91ce16ee372d16cb9b 100644 (file)
@@ -10,6 +10,7 @@
 #include <ModelAPI_Document.h>
 #include <ModelAPI_AttributeReference.h>
 #include <ModelAPI_AttributeInteger.h>
+#include <ModelAPI_BodyBuilder.h>
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_Session.h>
@@ -198,23 +199,24 @@ void FeaturesPlugin_Boolean::LoadNamingDS(std::shared_ptr<ModelAPI_ResultBody> t
                                           const ListOfShape& theTools,
                                           const GeomAlgoAPI_Boolean& theAlgo)
 {
+  ModelAPI_BodyBuilder* aResultBuilder = theResultBody->getBodyBuilder();
   //load result
   if(theBaseShape->isEqual(theAlgo.shape())) {
-    theResultBody->store(theAlgo.shape());
+    aResultBuilder->store(theAlgo.shape());
   } else {
-    theResultBody->storeModified(theBaseShape, theAlgo.shape(), _SUBSOLIDS_TAG);
+    aResultBuilder->storeModified(theBaseShape, theAlgo.shape(), _SUBSOLIDS_TAG);
 
     GeomAPI_DataMapOfShapeShape* aSubShapes = new GeomAPI_DataMapOfShapeShape();
 
     std::string aModName = "Modified";
-    theResultBody->loadAndOrientModifiedShapes(theAlgo.makeShape().get(), theBaseShape, FACE,
+    aResultBuilder->loadAndOrientModifiedShapes(theAlgo.makeShape().get(), theBaseShape, FACE,
                                                _MODIFY_TAG, aModName, *theAlgo.mapOfShapes().get());
-    theResultBody->loadDeletedShapes(theAlgo.makeShape().get(), theBaseShape, FACE, _DELETED_TAG);
+    aResultBuilder->loadDeletedShapes(theAlgo.makeShape().get(), theBaseShape, FACE, _DELETED_TAG);
 
     for(ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++) {
-      theResultBody->loadAndOrientModifiedShapes(theAlgo.makeShape().get(), *anIter, FACE,
+      aResultBuilder->loadAndOrientModifiedShapes(theAlgo.makeShape().get(), *anIter, FACE,
                                                  _MODIFY_TAG, aModName, *theAlgo.mapOfShapes().get());
-      theResultBody->loadDeletedShapes(theAlgo.makeShape().get(), *anIter, FACE, _DELETED_TAG);
+      aResultBuilder->loadDeletedShapes(theAlgo.makeShape().get(), *anIter, FACE, _DELETED_TAG);
     }
   }
 }
index 56323a20b7fcef68cf61b5c661473016c5dd4f4e..6bc4ae5d04d19406d8c93891cb7b4fe164f1ba14 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_AttributeReference.h>
+#include <ModelAPI_BodyBuilder.h>
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_ResultConstruction.h>
 
@@ -204,9 +205,10 @@ void FeaturesPlugin_CompositeBoolean::loadNamingDS(std::shared_ptr<ModelAPI_Resu
                                                    const ListOfShape& theTools,
                                                    const GeomAlgoAPI_Boolean& theAlgo)
 {
+  ModelAPI_BodyBuilder* aResultBuilder = theResultBody->getBodyBuilder();
   //load result
   if(theBaseShape->isEqual(theAlgo.shape())) {
-    theResultBody->store(theAlgo.shape());
+    aResultBuilder->store(theAlgo.shape());
   } else {
     const int aGenTag = 1;
     const int aFrTag = 2;
@@ -220,7 +222,7 @@ void FeaturesPlugin_CompositeBoolean::loadNamingDS(std::shared_ptr<ModelAPI_Resu
     const std::string aFrName = "FromFace";
     const std::string aToName = "ToFace";
 
-    theResultBody->storeModified(theBaseShape, theAlgo.shape(), aSubsolidsTag);
+    aResultBuilder->storeModified(theBaseShape, theAlgo.shape(), aSubsolidsTag);
 
     ListOfShape::const_iterator aFaceIter = theFaces.begin();
     std::list<std::shared_ptr<GeomAPI_Interface>>::const_iterator aSolidsAlgosIter = theSolidsAlgos.begin();
@@ -233,14 +235,14 @@ void FeaturesPlugin_CompositeBoolean::loadNamingDS(std::shared_ptr<ModelAPI_Resu
       if(std::dynamic_pointer_cast<GeomAlgoAPI_Prism>(*aSolidsAlgosIter)) {
         std::shared_ptr<GeomAlgoAPI_Prism> aPrismAlgo = std::dynamic_pointer_cast<GeomAlgoAPI_Prism>(*aSolidsAlgosIter);
         aSubShapes = aPrismAlgo->mapOfShapes();
-        theResultBody->loadAndOrientGeneratedShapes(aPrismAlgo->makeShape().get(), *aFaceIter, GeomAPI_Shape::EDGE, aGenTag,
+        aResultBuilder->loadAndOrientGeneratedShapes(aPrismAlgo->makeShape().get(), *aFaceIter, GeomAPI_Shape::EDGE, aGenTag,
                                                     aLatName, *aSubShapes.get());
         aFromFace = aPrismAlgo->firstShape();
         aToFace = aPrismAlgo->lastShape();
       } else if(std::dynamic_pointer_cast<GeomAlgoAPI_Revolution>(*aSolidsAlgosIter)) {
         std::shared_ptr<GeomAlgoAPI_Revolution> aRevolAlgo = std::dynamic_pointer_cast<GeomAlgoAPI_Revolution>(*aSolidsAlgosIter);
         aSubShapes = aRevolAlgo->mapOfShapes();
-        theResultBody->loadAndOrientGeneratedShapes(aRevolAlgo->makeShape().get(), *aFaceIter, GeomAPI_Shape::EDGE, aGenTag,
+        aResultBuilder->loadAndOrientGeneratedShapes(aRevolAlgo->makeShape().get(), *aFaceIter, GeomAPI_Shape::EDGE, aGenTag,
                                                     aLatName, *aSubShapes.get());
         aFromFace = aRevolAlgo->firstShape();
         aToFace = aRevolAlgo->lastShape();
@@ -251,7 +253,7 @@ void FeaturesPlugin_CompositeBoolean::loadNamingDS(std::shared_ptr<ModelAPI_Resu
         if(aSubShapes->isBound(aFromFace)) {
           aFromFace = aSubShapes->find(aFromFace);
         }
-        theResultBody->generated(aFromFace, aFrName, aFrTag);
+        aResultBuilder->generated(aFromFace, aFrName, aFrTag);
       }
 
       //Insert top face
@@ -259,18 +261,18 @@ void FeaturesPlugin_CompositeBoolean::loadNamingDS(std::shared_ptr<ModelAPI_Resu
         if (aSubShapes->isBound(aToFace)) {
           aToFace = aSubShapes->find(aToFace);
         }
-        theResultBody->generated(aToFace, aToName, aToTag);
+        aResultBuilder->generated(aToFace, aToName, aToTag);
       }
     }
 
-    theResultBody->loadAndOrientModifiedShapes(theAlgo.makeShape().get(), theBaseShape, GeomAPI_Shape::FACE,
+    aResultBuilder->loadAndOrientModifiedShapes(theAlgo.makeShape().get(), theBaseShape, GeomAPI_Shape::FACE,
                                                aModTag, aModName, *theAlgo.mapOfShapes().get());
-    theResultBody->loadDeletedShapes(theAlgo.makeShape().get(), theBaseShape, GeomAPI_Shape::FACE, aDelTag);
+    aResultBuilder->loadDeletedShapes(theAlgo.makeShape().get(), theBaseShape, GeomAPI_Shape::FACE, aDelTag);
 
     for(ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++) {
-      theResultBody->loadAndOrientModifiedShapes(theAlgo.makeShape().get(), *anIter, GeomAPI_Shape::FACE,
+      aResultBuilder->loadAndOrientModifiedShapes(theAlgo.makeShape().get(), *anIter, GeomAPI_Shape::FACE,
                                                  aModTag, aModName, *theAlgo.mapOfShapes().get());
-      theResultBody->loadDeletedShapes(theAlgo.makeShape().get(), *anIter, GeomAPI_Shape::FACE, aDelTag);
+      aResultBuilder->loadDeletedShapes(theAlgo.makeShape().get(), *anIter, GeomAPI_Shape::FACE, aDelTag);
     }
   }
 }
index 63ba5d3b71b8b4f22221ed5ee5920fe8f0af3379..4b57ee2b728ad8858d90dc0b418b0a3aeaf43920 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <FeaturesPlugin_Extrusion.h>
 
+#include <ModelAPI_BodyBuilder.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
 #include <ModelAPI_Document.h>
@@ -177,16 +178,17 @@ void FeaturesPlugin_Extrusion::LoadNamingDS(GeomAlgoAPI_Prism& theFeature,
                                             std::shared_ptr<GeomAPI_Shape> theContext)
 {
   //load result
+  ModelAPI_BodyBuilder* aResultBuilder = theResultBody->getBodyBuilder();
   if(theBasis->isEqual(theContext))
-    theResultBody->store(theFeature.shape());
+    aResultBuilder->store(theFeature.shape());
   else
-    theResultBody->storeGenerated(theBasis, theFeature.shape());
+    aResultBuilder->storeGenerated(theBasis, theFeature.shape());
 
   std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theFeature.mapOfShapes();
 
   //Insert lateral face : Face from Edge
   std::string aLatName = "LateralFace";
-  theResultBody->loadAndOrientGeneratedShapes(theFeature.makeShape().get(), theBasis, EDGE,_LATERAL_TAG, aLatName, *aSubShapes);
+  aResultBuilder->loadAndOrientGeneratedShapes(theFeature.makeShape().get(), theBasis, EDGE,_LATERAL_TAG, aLatName, *aSubShapes);
 
   //Insert bottom face
   std::string aBotName = "BottomFace";
@@ -195,7 +197,7 @@ void FeaturesPlugin_Extrusion::LoadNamingDS(GeomAlgoAPI_Prism& theFeature,
     if(aSubShapes->isBound(aBottomFace)) {
       aBottomFace = aSubShapes->find(aBottomFace);
     }
-    theResultBody->generated(aBottomFace, aBotName, _FIRST_TAG);
+    aResultBuilder->generated(aBottomFace, aBotName, _FIRST_TAG);
   }
 
   //Insert top face
@@ -205,6 +207,6 @@ void FeaturesPlugin_Extrusion::LoadNamingDS(GeomAlgoAPI_Prism& theFeature,
     if (aSubShapes->isBound(aTopFace)) {
       aTopFace = aSubShapes->find(aTopFace);
     }
-    theResultBody->generated(aTopFace, aTopName, _LAST_TAG);
+    aResultBuilder->generated(aTopFace, aTopName, _LAST_TAG);
   }
 }
index ca4b8a579b5ec2febefb0378692021732a71d939..bebbcd735c6ee6584d19a427e01de07c98d04628 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_BodyBuilder.h>
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_ResultPart.h>
 #include <ModelAPI_Session.h>
@@ -128,15 +129,16 @@ void FeaturesPlugin_Movement::LoadNamingDS(const GeomAlgoAPI_Movement& theMoveme
                                            std::shared_ptr<ModelAPI_ResultBody> theResultBody,
                                            std::shared_ptr<GeomAPI_Shape> theBaseShape)
 {
+  ModelAPI_BodyBuilder* aResultBuilder = theResultBody->getBodyBuilder();
   // Store result.
-  theResultBody->storeModified(theBaseShape, theMovementAlgo.shape());
+  aResultBuilder->storeModified(theBaseShape, theMovementAlgo.shape());
 
   std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theMovementAlgo.mapOfShapes();
 
   int aMovedTag = 1;
   std::string aMovedName = "Moved";
-  theResultBody->loadAndOrientModifiedShapes(theMovementAlgo.makeShape().get(),
-                                             theBaseShape, GeomAPI_Shape::FACE,
-                                             aMovedTag, aMovedName, *aSubShapes.get());
+  aResultBuilder->loadAndOrientModifiedShapes(theMovementAlgo.makeShape().get(),
+                                              theBaseShape, GeomAPI_Shape::FACE,
+                                              aMovedTag, aMovedName, *aSubShapes.get());
 
 }
index ee954f593161602b26ea927311725caffcab773f..69d3cc4a7240f893056b7c79e940ab474f7b5945 100644 (file)
@@ -12,6 +12,7 @@
 #include <ModelAPI_AttributeSelection.h>
 #include <ModelAPI_AttributeBoolean.h>
 #include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_BodyBuilder.h>
 
 #include <GeomAPI_Edge.h>
 #include <GeomAPI_Face.h>
@@ -170,14 +171,15 @@ void FeaturesPlugin_Placement::LoadNamingDS(GeomAlgoAPI_Transform& theTransformA
                                             std::shared_ptr<ModelAPI_ResultBody> theResultBody,
                                             std::shared_ptr<GeomAPI_Shape> theSlaveObject)
 {
+  ModelAPI_BodyBuilder* aResultBuilder = theResultBody->getBodyBuilder();
   //load result
-  theResultBody->storeModified(theSlaveObject, theTransformAlgo.shape()); // the initial Slave, the resulting Slave
+  aResultBuilder->storeModified(theSlaveObject, theTransformAlgo.shape()); // the initial Slave, the resulting Slave
 
   std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theTransformAlgo.mapOfShapes();
 
     // put modifed faces in DF
   std::string aModName = "Modified";
-  theResultBody->loadAndOrientModifiedShapes(theTransformAlgo.makeShape().get(),
-                                             theSlaveObject, _FACE,
-                                             _MODIFIEDF_TAG, aModName, *aSubShapes.get());
+  aResultBuilder->loadAndOrientModifiedShapes(theTransformAlgo.makeShape().get(),
+                                              theSlaveObject, _FACE,
+                                              _MODIFIEDF_TAG, aModName, *aSubShapes.get());
 }
index 3bd64910c877776803eceff05277c89e9ef5f975..26cd5fe0be67b565d59433c8eb3688bc8dd2c088 100644 (file)
@@ -9,6 +9,7 @@
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_AttributeString.h>
+#include <ModelAPI_BodyBuilder.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
 #include <ModelAPI_ResultConstruction.h>
@@ -179,15 +180,17 @@ void FeaturesPlugin_Revolution::LoadNamingDS(GeomAlgoAPI_Revolution& theFeature,
                                              std::shared_ptr<GeomAPI_Shape> theContext)
 {
   //load result
+  ModelAPI_BodyBuilder* aResultBuilder = theResultBody->getBodyBuilder();
+
   if(theBasis->isEqual(theContext))
-    theResultBody->store(theFeature.shape());
+    aResultBuilder->store(theFeature.shape());
   else
-    theResultBody->storeGenerated(theContext, theFeature.shape());
+    aResultBuilder->storeGenerated(theContext, theFeature.shape());
 
   std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theFeature.mapOfShapes();
 
   std::string aGeneratedName = "LateralFace";
-  theResultBody->loadAndOrientGeneratedShapes(theFeature.makeShape().get(), theBasis, EDGE,_LATERAL_TAG, aGeneratedName, *aSubShapes);
+  aResultBuilder->loadAndOrientGeneratedShapes(theFeature.makeShape().get(), theBasis, EDGE,_LATERAL_TAG, aGeneratedName, *aSubShapes);
 
   //Insert from face
   std::string aBotName = "FromFace";
@@ -196,7 +199,7 @@ void FeaturesPlugin_Revolution::LoadNamingDS(GeomAlgoAPI_Revolution& theFeature,
     if(aSubShapes->isBound(aBottomFace)) {
       aBottomFace = aSubShapes->find(aBottomFace);
     }
-    theResultBody->generated(aBottomFace, aBotName, _FROM_TAG);
+    aResultBuilder->generated(aBottomFace, aBotName, _FROM_TAG);
   }
 
   //Insert to face
@@ -206,7 +209,7 @@ void FeaturesPlugin_Revolution::LoadNamingDS(GeomAlgoAPI_Revolution& theFeature,
     if (aSubShapes->isBound(aTopFace)) {
       aTopFace = aSubShapes->find(aTopFace);
     }
-    theResultBody->generated(aTopFace, aTopName, _TO_TAG);
+    aResultBuilder->generated(aTopFace, aTopName, _TO_TAG);
   }
 
 }
index a2229a95d9d7d2dde6b9276184795e7ceb9441cf..aea860dcb5c98830f5b7fed93f74c355d2c348c3 100755 (executable)
@@ -8,6 +8,7 @@
 
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_BodyBuilder.h>
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_ResultPart.h>
@@ -128,15 +129,16 @@ void FeaturesPlugin_Rotation::LoadNamingDS(const GeomAlgoAPI_Rotation& theRotaio
                                            std::shared_ptr<ModelAPI_ResultBody> theResultBody,
                                            std::shared_ptr<GeomAPI_Shape> theBaseShape)
 {
+  ModelAPI_BodyBuilder* aResultBuilder = theResultBody->getBodyBuilder();
   // Store result.
-  theResultBody->storeModified(theBaseShape, theRotaionAlgo.shape());
+  aResultBuilder->storeModified(theBaseShape, theRotaionAlgo.shape());
 
   std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theRotaionAlgo.mapOfShapes();
 
   int aRotatedTag = 1;
   std::string aRotatedName = "Rotated";
-  theResultBody->loadAndOrientModifiedShapes(theRotaionAlgo.makeShape().get(),
-                                             theBaseShape, GeomAPI_Shape::FACE,
-                                             aRotatedTag, aRotatedName, *aSubShapes.get());
+  aResultBuilder->loadAndOrientModifiedShapes(theRotaionAlgo.makeShape().get(),
+                                              theBaseShape, GeomAPI_Shape::FACE,
+                                              aRotatedTag, aRotatedName, *aSubShapes.get());
 
 }
index b8486e53ddb9b523f43db96b8cf2675330eef378..1567641253c14c3f88c39588c6c545db7a9f49c5 100644 (file)
@@ -20,6 +20,7 @@ SET(PROJECT_HEADERS
     Model_AttributeInteger.h
     Model_AttributeSelection.h
     Model_AttributeSelectionList.h
+    Model_BodyBuilder.h
     Model_Events.h
     Model_Update.h
     Model_Validator.h
@@ -49,6 +50,7 @@ SET(PROJECT_SOURCES
     Model_AttributeInteger.cpp
     Model_AttributeSelection.cpp
     Model_AttributeSelectionList.cpp
+    Model_BodyBuilder.cpp
     Model_Events.cpp
     Model_Update.cpp
     Model_Validator.cpp
diff --git a/src/Model/Model_BodyBuilder.cpp b/src/Model/Model_BodyBuilder.cpp
new file mode 100755 (executable)
index 0000000..604c99b
--- /dev/null
@@ -0,0 +1,716 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        Model_ResultBody.cpp
+// Created:     08 Jul 2014
+// Author:      Mikhail PONIKAROV
+
+#include <Model_BodyBuilder.h>
+
+#include <Model_Data.h>
+#include <Model_Document.h>
+#include <ModelAPI_AttributeIntArray.h>
+#include <TNaming_Builder.hxx>
+#include <TNaming_NamedShape.hxx>
+#include <TNaming_Iterator.hxx>
+#include <TDataStd_Name.hxx>
+#include <TDataStd_Integer.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Face.hxx>
+#include <TDF_ChildIterator.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_DataMapOfShapeListOfShape.hxx>
+#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
+#include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
+#include <TopTools_MapIteratorOfMapOfShape.hxx>
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopTools_DataMapOfShapeShape.hxx>
+#include <TopExp.hxx>
+#include <BRepTools.hxx>
+#include <BRep_Tool.hxx>
+#include <GeomAPI_Shape.h>
+#include <GeomAlgoAPI_MakeShape.h>
+#include <Config_PropManager.h>
+// DEB
+//#include <TCollection_AsciiString.hxx>
+//#include <TDF_Tool.hxx>
+//#define DEB_IMPORT 1
+
+Model_BodyBuilder::Model_BodyBuilder(ModelAPI_Object* theOwner)
+: ModelAPI_BodyBuilder(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) {
+  std::list<std::pair<TopoDS_Shape, TopoDS_Shape> > aShapePairs; // to store old and new shapes
+  Handle(TNaming_NamedShape) aName;
+  int anEvolution = -1;
+  if (theLab.FindAttribute(TNaming_NamedShape::GetID(), aName)) {
+    TNaming_Evolution aNSEvol = aName->Evolution();
+    if ((aNSEvol == TNaming_SELECTED && theFlag) ||
+        (aNSEvol != TNaming_SELECTED && !theFlag)) { // nothing to do, it is already correct
+      return;
+    }
+    anEvolution = (int)(aNSEvol);
+    if (!theFlag) {
+      Handle(TDataStd_Integer) anAttrEvol;
+      if (theLab.FindAttribute(TDataStd_Integer::GetID(), anAttrEvol)) {
+        anEvolution = anAttrEvol->Get();
+      }
+    } else {
+      TDataStd_Integer::Set(theLab, anEvolution);
+    }
+
+    for(TNaming_Iterator anIter(aName); anIter.More(); anIter.Next()) {
+      aShapePairs.push_back(std::pair<TopoDS_Shape, TopoDS_Shape>
+        (anIter.OldShape(), anIter.NewShape()));
+    }
+  }
+  // create new
+  TNaming_Builder aBuilder(theLab);
+  TNaming_Evolution anEvol = (TNaming_Evolution)(anEvolution);
+  std::list<std::pair<TopoDS_Shape, TopoDS_Shape> >::iterator aPairsIter = aShapePairs.begin();
+  for(; aPairsIter != aShapePairs.end(); aPairsIter++) {
+    if (theFlag) { // disabled => make selection
+      aBuilder.Select(aPairsIter->first, aPairsIter->second);
+    } else 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);
+    }
+  }
+  // recursive call for all sub-labels
+  TDF_ChildIterator anIter(theLab, Standard_False);
+  for(; anIter.More(); anIter.Next()) {
+    EvolutionToSelection(anIter.Value(), theFlag);
+  }
+}
+
+void Model_BodyBuilder::store(const std::shared_ptr<GeomAPI_Shape>& theShape)
+{
+  std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
+  if (aData) {
+    TDF_Label& aShapeLab = aData->shapeLab();
+    // clean builders
+    clean();   
+    // store the new shape as primitive
+    TNaming_Builder aBuilder(aShapeLab);
+    if (!theShape)
+      return;  // bad shape
+    TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
+    if (aShape.IsNull())
+      return;  // null shape inside
+
+    aBuilder.Generated(aShape);        
+    // register name
+    if(!aBuilder.NamedShape()->IsEmpty()) {
+      Handle(TDataStd_Name) anAttr;
+      if(aBuilder.NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(),anAttr)) {
+        std::string aName (TCollection_AsciiString(anAttr->Get()).ToCString());
+        if(!aName.empty()) {
+          std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(document());
+          aDoc->addNamingName(aBuilder.NamedShape()->Label(), aName);
+        }
+      }
+    }
+  }
+}
+
+void Model_BodyBuilder::storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
+  const std::shared_ptr<GeomAPI_Shape>& theToShape)
+{
+  std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
+  if (aData) {
+    TDF_Label& aShapeLab = aData->shapeLab();
+    // clean builders
+    clean();   
+    // store the new shape as primitive
+    TNaming_Builder aBuilder(aShapeLab);
+    if (!theFromShape || !theToShape)
+      return;  // bad shape
+    TopoDS_Shape aShapeBasis = theFromShape->impl<TopoDS_Shape>();
+    if (aShapeBasis.IsNull())
+      return;  // null shape inside
+    TopoDS_Shape aShapeNew = theToShape->impl<TopoDS_Shape>();
+    if (aShapeNew.IsNull())
+      return;  // null shape inside
+    aBuilder.Generated(aShapeBasis, aShapeNew);
+    // register name
+    if(!aBuilder.NamedShape()->IsEmpty()) {
+      Handle(TDataStd_Name) anAttr;
+      if(aBuilder.NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(),anAttr)) {
+        std::string aName (TCollection_AsciiString(anAttr->Get()).ToCString());
+        if(!aName.empty()) {
+          std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(document());
+          aDoc->addNamingName(aBuilder.NamedShape()->Label(), aName);
+        }
+      }
+    }
+  }
+}
+
+void Model_BodyBuilder::storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
+  const std::shared_ptr<GeomAPI_Shape>& theNewShape, const int theDecomposeSolidsTag)
+{
+  std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
+  if (aData) {
+    TDF_Label& aShapeLab = aData->shapeLab();
+    // clean builders
+    clean();   
+    // store the new shape as primitive
+    TNaming_Builder aBuilder(aShapeLab);
+    if (!theOldShape || !theNewShape)
+      return;  // bad shape
+    TopoDS_Shape aShapeOld = theOldShape->impl<TopoDS_Shape>();
+    if (aShapeOld.IsNull())
+      return;  // null shape inside
+    TopoDS_Shape aShapeNew = theNewShape->impl<TopoDS_Shape>();
+    if (aShapeNew.IsNull())
+      return;  // null shape inside
+    aBuilder.Modify(aShapeOld, aShapeNew);
+    if (theDecomposeSolidsTag && aShapeNew.ShapeType() == TopAbs_COMPOUND) { // make sub elements as subs
+
+      // register name if it is possible
+      TCollection_AsciiString aName;
+      if(!aBuilder.NamedShape()->IsEmpty()) {
+        Handle(TDataStd_Name) anAttr;
+        if(aBuilder.NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(),anAttr)) {
+          aName = TCollection_AsciiString(anAttr->Get()).ToCString();
+        }
+      }
+
+      TopoDS_Iterator aSubIter(aShapeNew);
+      for(int aTag = theDecomposeSolidsTag; aSubIter.More(); aSubIter.Next()) {
+        TNaming_Builder aSubBuilder(aShapeLab.FindChild(aTag++));
+        aSubBuilder.Generated(aSubIter.Value());
+        if(!aName.IsEmpty()) {
+          std::string aSolidName = 
+            (aName + "_Solid_" + TCollection_AsciiString(aTag - theDecomposeSolidsTag)).ToCString(); 
+          std::shared_ptr<Model_Document> aDoc = 
+            std::dynamic_pointer_cast<Model_Document>(document());
+          aDoc->addNamingName(aSubBuilder.NamedShape()->Label(), aSolidName);
+          TDataStd_Name::Set(aSubBuilder.NamedShape()->Label(), aSolidName.c_str());
+        }
+      }
+    }
+  }
+}
+void Model_BodyBuilder::clean()
+{
+  std::vector<TNaming_Builder*>::iterator aBuilder = myBuilders.begin();
+  for(; aBuilder != myBuilders.end(); aBuilder++)
+    delete *aBuilder;
+  myBuilders.clear();
+}
+
+Model_BodyBuilder::~Model_BodyBuilder()
+{
+  clean();
+}
+
+TNaming_Builder* Model_BodyBuilder::builder(const int theTag)
+{
+  if (myBuilders.size() <= (unsigned int)theTag) {
+    myBuilders.insert(myBuilders.end(), theTag - myBuilders.size() + 1, NULL);
+  }
+  if (!myBuilders[theTag]) {
+    std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
+    myBuilders[theTag] = new TNaming_Builder(aData->shapeLab().FindChild(theTag));
+    //TCollection_AsciiString entry;//
+    //TDF_Tool::Entry(aData->shapeLab().FindChild(theTag), entry);
+    //cout << "Label = " <<entry.ToCString() <<endl;
+  }
+  return myBuilders[theTag];
+}
+
+void Model_BodyBuilder::buildName(const int theTag, const std::string& theName)
+{
+  std::string aName = data()->name() + "/" + theName; 
+  std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(document());
+  aDoc->addNamingName(builder(theTag)->NamedShape()->Label(), aName);
+  TDataStd_Name::Set(builder(theTag)->NamedShape()->Label(),aName.c_str());
+}
+void Model_BodyBuilder::generated(
+  const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag)
+{
+  TopoDS_Shape aShape = theNewShape->impl<TopoDS_Shape>();
+  builder(theTag)->Generated(aShape);
+  if(!theName.empty()) 
+    buildName(theTag, theName);
+}
+
+void Model_BodyBuilder::generated(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
+  const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag)
+{
+  TopoDS_Shape anOldShape = theOldShape->impl<TopoDS_Shape>();
+  TopoDS_Shape aNewShape = theNewShape->impl<TopoDS_Shape>();
+  builder(theTag)->Generated(anOldShape, aNewShape);
+  if(!theName.empty()) 
+    buildName(theTag, theName);
+}
+
+
+void Model_BodyBuilder::modified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
+  const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag)
+{
+  TopoDS_Shape anOldShape = theOldShape->impl<TopoDS_Shape>();
+  TopoDS_Shape aNewShape = theNewShape->impl<TopoDS_Shape>();
+  builder(theTag)->Modify(anOldShape, aNewShape);
+  if(!theName.empty()) 
+    buildName(theTag, theName);
+}
+
+void Model_BodyBuilder::deleted(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
+  const int theTag)
+{
+  TopoDS_Shape aShape = theOldShape->impl<TopoDS_Shape>();
+  builder(theTag)->Delete(aShape);
+}
+
+void Model_BodyBuilder::loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
+  std::shared_ptr<GeomAPI_Shape>  theShapeIn,
+  const int  theKindOfShape,
+  const int  theTag)
+{
+  TopoDS_Shape aShapeIn = theShapeIn->impl<TopoDS_Shape>();
+  TopTools_MapOfShape aView;
+  TopExp_Explorer ShapeExplorer (aShapeIn, (TopAbs_ShapeEnum)theKindOfShape);
+  for (; ShapeExplorer.More(); ShapeExplorer.Next ()) {
+    const TopoDS_Shape& aRoot = ShapeExplorer.Current ();
+    if (!aView.Add(aRoot)) continue;
+    std::shared_ptr<GeomAPI_Shape> aRShape(new GeomAPI_Shape());
+    aRShape->setImpl((new TopoDS_Shape(aRoot)));
+    if (theMS->isDeleted (aRShape)) {
+      builder(theTag)->Delete(aRoot);
+    }
+  }
+}
+
+void Model_BodyBuilder::loadAndOrientModifiedShapes (
+  GeomAlgoAPI_MakeShape* theMS,
+  std::shared_ptr<GeomAPI_Shape>  theShapeIn,
+  const int  theKindOfShape,
+  const int  theTag,
+  const std::string& theName,
+  GeomAPI_DataMapOfShapeShape& theSubShapes)
+{
+  TopoDS_Shape aShapeIn = theShapeIn->impl<TopoDS_Shape>();
+  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 ();
+    if (!aView.Add(aRoot)) continue;
+    ListOfShape aList;
+    std::shared_ptr<GeomAPI_Shape> aRShape(new GeomAPI_Shape());
+    aRShape->setImpl((new TopoDS_Shape(aRoot)));
+    theMS->modified(aRShape, aList);
+    std::list<std::shared_ptr<GeomAPI_Shape> >::const_iterator anIt = aList.begin(), aLast = aList.end();
+    for (; anIt != aLast; anIt++) {
+      TopoDS_Shape aNewShape = (*anIt)->impl<TopoDS_Shape>();    
+      if (theSubShapes.isBound(*anIt)) {
+        std::shared_ptr<GeomAPI_Shape> aMapShape(theSubShapes.find(*anIt));
+        aNewShape.Orientation(aMapShape->impl<TopoDS_Shape>().Orientation());
+      }
+      if (!aRoot.IsSame (aNewShape)) {
+        builder(theTag)->Modify(aRoot,aNewShape);
+        if(!isBuilt) 
+          buildName(theTag, theName);          
+      }
+    }
+  }
+}
+
+void Model_BodyBuilder::loadAndOrientGeneratedShapes (
+  GeomAlgoAPI_MakeShape* theMS,
+  std::shared_ptr<GeomAPI_Shape>  theShapeIn,
+  const int  theKindOfShape,
+  const int  theTag,
+  const std::string& theName,
+  GeomAPI_DataMapOfShapeShape& theSubShapes)
+{
+  TopoDS_Shape aShapeIn = theShapeIn->impl<TopoDS_Shape>();
+  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 ();
+    if (!aView.Add(aRoot)) continue;
+    ListOfShape aList;
+    std::shared_ptr<GeomAPI_Shape> aRShape(new GeomAPI_Shape());
+    aRShape->setImpl((new TopoDS_Shape(aRoot)));
+    theMS->generated(aRShape, aList);
+    std::list<std::shared_ptr<GeomAPI_Shape> >::const_iterator anIt = aList.begin(), aLast = aList.end();
+    for (; anIt != aLast; anIt++) {
+      TopoDS_Shape aNewShape = (*anIt)->impl<TopoDS_Shape>();    
+      if (theSubShapes.isBound(*anIt)) {
+        std::shared_ptr<GeomAPI_Shape> aMapShape(theSubShapes.find(*anIt));
+        aNewShape.Orientation(aMapShape->impl<TopoDS_Shape>().Orientation());
+      }
+      if (!aRoot.IsSame (aNewShape)) {
+        builder(theTag)->Generated(aRoot,aNewShape);
+        if(!isBuilt) 
+          buildName(theTag, theName);  
+      }
+    }
+  }
+}
+
+//=======================================================================
+int getDangleShapes(const TopoDS_Shape&           theShapeIn, 
+  const TopAbs_ShapeEnum        theGeneratedFrom,
+  TopTools_DataMapOfShapeShape& theDangles) 
+{
+  theDangles.Clear();
+  TopTools_IndexedDataMapOfShapeListOfShape subShapeAndAncestors;
+  TopAbs_ShapeEnum GeneratedTo;
+  if (theGeneratedFrom == TopAbs_FACE) GeneratedTo = TopAbs_EDGE;
+  else if (theGeneratedFrom == TopAbs_EDGE) GeneratedTo = TopAbs_VERTEX;
+  else return Standard_False;
+  TopExp::MapShapesAndAncestors(theShapeIn, GeneratedTo, theGeneratedFrom, subShapeAndAncestors);
+  for (Standard_Integer i = 1; i <= subShapeAndAncestors.Extent(); i++) {
+    const TopoDS_Shape& mayBeDangle = subShapeAndAncestors.FindKey(i);
+    const TopTools_ListOfShape& ancestors = subShapeAndAncestors.FindFromIndex(i);
+    if (ancestors.Extent() == 1) theDangles.Bind(ancestors.First(), mayBeDangle);
+  }
+  return theDangles.Extent();
+}
+
+//=======================================================================
+void loadGeneratedDangleShapes(
+  const TopoDS_Shape&      theShapeIn,
+  const TopAbs_ShapeEnum   theGeneratedFrom,
+  TNaming_Builder *        theBuilder)
+{
+  TopTools_DataMapOfShapeShape dangles;
+  if (!getDangleShapes(theShapeIn, theGeneratedFrom, dangles)) return;
+  TopTools_DataMapIteratorOfDataMapOfShapeShape itr(dangles);
+  for (; itr.More(); itr.Next()) 
+    theBuilder->Generated(itr.Key(), itr.Value());
+}
+
+//=======================================================================
+void Model_BodyBuilder::loadNextLevels(std::shared_ptr<GeomAPI_Shape> theShape, 
+  const std::string& theName, int&  theTag)
+{
+  if(theShape->isNull()) return;
+  TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();    
+  std::string aName;
+  if (aShape.ShapeType() == TopAbs_SOLID) {                
+    TopExp_Explorer expl(aShape, TopAbs_FACE);
+    for (; expl.More(); expl.Next()) {  
+      builder(theTag)->Generated(expl.Current()); 
+      TCollection_AsciiString aStr(theTag);
+      aName = theName + aStr.ToCString();
+      buildName(theTag, aName);
+      theTag++;
+    }
+  }
+  else if (aShape.ShapeType() == TopAbs_SHELL || aShape.ShapeType() == TopAbs_FACE) {
+    // load faces and all the free edges
+    TopTools_IndexedMapOfShape Faces;
+    TopExp::MapShapes(aShape, TopAbs_FACE, Faces);
+    if (Faces.Extent() > 1 || (aShape.ShapeType() == TopAbs_SHELL && Faces.Extent() == 1)) {
+      TopExp_Explorer expl(aShape, TopAbs_FACE);
+      for (; expl.More(); expl.Next()) {
+        builder(theTag)->Generated(expl.Current());          
+        TCollection_AsciiString aStr(theTag);
+        aName = theName + aStr.ToCString();
+        buildName(theTag, aName);
+        theTag++;
+      }
+    }
+    TopTools_IndexedDataMapOfShapeListOfShape anEdgeAndNeighbourFaces;
+    TopExp::MapShapesAndAncestors(aShape, TopAbs_EDGE, TopAbs_FACE, anEdgeAndNeighbourFaces);
+    for (Standard_Integer i = 1; i <= anEdgeAndNeighbourFaces.Extent(); i++) 
+    {
+      const TopTools_ListOfShape& aLL = anEdgeAndNeighbourFaces.FindFromIndex(i);
+      if (aLL.Extent() < 2) {
+        if (BRep_Tool::Degenerated(TopoDS::Edge(anEdgeAndNeighbourFaces.FindKey(i))))
+          continue;
+        builder(theTag)->Generated(anEdgeAndNeighbourFaces.FindKey(i));
+        TCollection_AsciiString aStr(theTag);
+        aName = theName + aStr.ToCString();
+        buildName(theTag, aName);
+        theTag++;
+      } else {
+        TopTools_ListIteratorOfListOfShape anIter(aLL);
+        const TopoDS_Face& aFace = TopoDS::Face(anIter.Value());
+        anIter.Next();
+        if(aFace.IsEqual(anIter.Value())) {
+          builder(theTag)->Generated(anEdgeAndNeighbourFaces.FindKey(i));
+          TCollection_AsciiString aStr(theTag);
+          aName = theName + aStr.ToCString();
+          buildName(theTag, aName);
+          theTag++;
+        }
+      }
+    }
+  } else if (aShape.ShapeType() == TopAbs_WIRE) {
+    TopTools_IndexedMapOfShape Edges;
+    BRepTools::Map3DEdges(aShape, Edges);
+    if (Edges.Extent() == 1) {
+      builder(++theTag)->Generated(Edges.FindKey(1));
+      TopExp_Explorer expl(aShape, TopAbs_VERTEX);
+      for (; expl.More(); expl.Next()) {
+        builder(theTag)->Generated(expl.Current());
+        TCollection_AsciiString aStr(theTag);
+        aName = theName + aStr.ToCString();
+        buildName(theTag, aName);
+        theTag++;
+      }
+    } else {
+      TopExp_Explorer expl(aShape, TopAbs_EDGE); 
+      for (; expl.More(); expl.Next()) {       
+        builder(theTag)->Generated(expl.Current());
+        TCollection_AsciiString aStr(theTag);
+        aName = theName + aStr.ToCString();
+        buildName(theTag, aName);
+        theTag++;
+      }   
+      // and load generated vertices.
+      TopTools_DataMapOfShapeShape generated;
+      if (getDangleShapes(aShape, TopAbs_EDGE, generated)) 
+      {
+        TNaming_Builder* pBuilder = builder(theTag++);
+        loadGeneratedDangleShapes(aShape, TopAbs_EDGE, pBuilder);  
+      }
+    }
+  } else if (aShape.ShapeType() == TopAbs_EDGE) {
+    TopExp_Explorer expl(aShape, TopAbs_VERTEX);
+    for (; expl.More(); expl.Next()) {      
+      builder(theTag)->Generated(expl.Current());
+      TCollection_AsciiString aStr(theTag);
+      aName = theName + aStr.ToCString();
+      buildName(theTag, aName);
+      theTag++;
+    }
+  }
+}
+
+//=======================================================================
+int findAmbiguities(const TopoDS_Shape&           theShapeIn,                                  
+  TopTools_ListOfShape&   theList) 
+{
+  int aNumEdges(0);
+  theList.Clear();
+  TopTools_IndexedDataMapOfShapeListOfShape subShapeAndAncestors;
+  TopAbs_ShapeEnum aTS(TopAbs_EDGE);
+  TopAbs_ShapeEnum aTA(TopAbs_FACE);
+  TopTools_MapOfShape aMap1, aMap2; // map1 - for edge ancestors; map2 - for keys => edges
+  TopTools_ListOfShape aKeyList;
+  TopExp::MapShapesAndAncestors(theShapeIn, aTS, aTA, subShapeAndAncestors);
+  for (Standard_Integer i = 1; i <= subShapeAndAncestors.Extent(); i++) {
+    const TopoDS_Shape& aKeyEdge1 = subShapeAndAncestors.FindKey(i);
+    const TopTools_ListOfShape& ancestors1 = subShapeAndAncestors.FindFromIndex(i);
+    aMap1.Clear();
+    TopTools_ListIteratorOfListOfShape it(ancestors1);
+    for(;it.More();it.Next()) aMap1.Add(it.Value()); // fill map with key ancestors => aKey1
+    for (Standard_Integer j = 1; j <= subShapeAndAncestors.Extent(); j++) {
+      if (i == j) continue;
+      const TopoDS_Shape& aKeyEdge2 = subShapeAndAncestors.FindKey(j);
+      const TopTools_ListOfShape& ancestors2 = subShapeAndAncestors.FindFromIndex(j);
+      if(ancestors1.Extent() == ancestors2.Extent() && ancestors1.Extent() > 1) {
+        int aNum (ancestors2.Extent());
+        TopTools_ListIteratorOfListOfShape it(ancestors2);
+        for(;it.More();it.Next()) 
+          if(aMap1.Contains(it.Value())) aNum--;
+        if(aNum == 0) {
+          if(aMap2.Add(aKeyEdge1)) 
+            aKeyList.Append(aKeyEdge1);
+          if(aMap2.Add(aKeyEdge2))
+            aKeyList.Append(aKeyEdge2);
+        }
+      }
+    } // at the end ==> List of edges to be named in addition  
+  }
+  aNumEdges = aKeyList.Extent();
+  if(aNumEdges)
+    theList.Assign(aKeyList);  
+  return aNumEdges; 
+}
+
+//=======================================================================
+void Model_BodyBuilder::loadFirstLevel(
+  std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int&  theTag)
+{
+  if(theShape->isNull()) return;
+  TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>(); 
+  std::string aName;
+  if (aShape.ShapeType() == TopAbs_COMPOUND || aShape.ShapeType() == TopAbs_COMPSOLID) {
+    TopoDS_Iterator itr(aShape);
+    for (; itr.More(); itr.Next(),theTag++) {
+      builder(theTag)->Generated(itr.Value());
+      TCollection_AsciiString aStr(theTag);
+      aName = theName + aStr.ToCString();
+      buildName(theTag, aName);
+      if(!theName.empty()) buildName(theTag, aName);
+      if (itr.Value().ShapeType() == TopAbs_COMPOUND || 
+        itr.Value().ShapeType() == TopAbs_COMPSOLID) 
+      {
+        std::shared_ptr<GeomAPI_Shape> itrShape(new GeomAPI_Shape());
+        itrShape->setImpl(new TopoDS_Shape(itr.Value()));
+        loadFirstLevel(itrShape, theName, theTag);
+      } else {
+        std::shared_ptr<GeomAPI_Shape> itrShape(new GeomAPI_Shape());
+        itrShape->setImpl(new TopoDS_Shape(itr.Value()));              
+        loadNextLevels(itrShape, theName, theTag);
+      }
+    }
+  } else {
+    std::shared_ptr<GeomAPI_Shape> itrShape(new GeomAPI_Shape());
+    itrShape->setImpl(new TopoDS_Shape(aShape));
+    loadNextLevels(itrShape, theName, theTag); 
+  }
+  TopTools_ListOfShape   aList;
+  if(findAmbiguities(aShape, aList)) {
+    TopTools_ListIteratorOfListOfShape it(aList);
+    for (; it.More(); it.Next(),theTag++) {
+      builder(theTag)->Generated(it.Value());
+      TCollection_AsciiString aStr(theTag);
+      aName = theName + aStr.ToCString();
+      buildName(theTag, aName);
+    }
+  }
+}
+
+//=======================================================================
+void Model_BodyBuilder::loadDisconnectedEdges(
+  std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int&  theTag)
+{
+  if(theShape->isNull()) return;
+  TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();  
+  TopTools_DataMapOfShapeListOfShape edgeNaborFaces;
+  TopTools_ListOfShape empty;
+  TopExp_Explorer explF(aShape, TopAbs_FACE);
+  for (; explF.More(); explF.Next()) {
+    const TopoDS_Shape& aFace = explF.Current();
+    TopExp_Explorer explV(aFace, TopAbs_EDGE);
+    for (; explV.More(); explV.Next()) {
+      const TopoDS_Shape& anEdge = explV.Current();
+      if (!edgeNaborFaces.IsBound(anEdge)) edgeNaborFaces.Bind(anEdge, empty);
+      Standard_Boolean faceIsNew = Standard_True;
+      TopTools_ListIteratorOfListOfShape itrF(edgeNaborFaces.Find(anEdge));
+      for (; itrF.More(); itrF.Next()) {
+        if (itrF.Value().IsSame(aFace)) {
+          faceIsNew = Standard_False;
+          break;
+        }
+      }
+      if (faceIsNew) 
+        edgeNaborFaces.ChangeFind(anEdge).Append(aFace);      
+    }
+  }
+
+  /*  TopTools_IndexedDataMapOfShapeListOfShape aDM;
+  TopExp::MapShapesAndAncestors(aShape, TopAbs_EDGE, TopAbs_FACE, aDM);
+  for(int i=1; i <= aDM.Extent(); i++) {
+  if(aDM.FindFromIndex(i).Extent() > 1) continue;
+  if (BRep_Tool::Degenerated(TopoDS::Edge(aDM.FindKey(i))))
+  continue;
+  builder(theTag)->Generated(aDM.FindKey(i));
+  TCollection_AsciiString aStr(theTag);
+  std::string aName = theName + aStr.ToCString();
+  buildName(theTag, aName);
+  #ifdef DEB_IMPORT
+  aName +=  + ".brep";
+  BRepTools::Write(aDM.FindKey(i), aName.c_str());
+  #endif
+  theTag++;
+  }
+  */
+  TopTools_MapOfShape anEdgesToDelete;
+  TopExp_Explorer anEx(aShape,TopAbs_EDGE); 
+  std::string aName;
+  for(;anEx.More();anEx.Next()) {
+    Standard_Boolean aC0 = Standard_False;
+    TopoDS_Shape anEdge1 = anEx.Current();
+    if (edgeNaborFaces.IsBound(anEdge1)) {
+      const TopTools_ListOfShape& aList1 = edgeNaborFaces.Find(anEdge1);
+      if (aList1.Extent()<2) continue;
+      TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itr(edgeNaborFaces);
+      for (; itr.More(); itr.Next()) {
+        TopoDS_Shape anEdge2 = itr.Key();
+        if(anEdgesToDelete.Contains(anEdge2)) continue;
+        if (anEdge1.IsSame(anEdge2)) continue;
+        const TopTools_ListOfShape& aList2 = itr.Value();
+        // compare lists of the neighbour faces of edge1 and edge2
+        if (aList1.Extent() == aList2.Extent()) {
+          Standard_Integer aMatches = 0;
+          for(TopTools_ListIteratorOfListOfShape aLIter1(aList1);aLIter1.More();aLIter1.Next())
+            for(TopTools_ListIteratorOfListOfShape aLIter2(aList2);aLIter2.More();aLIter2.Next())
+              if (aLIter1.Value().IsSame(aLIter2.Value())) aMatches++;
+          if (aMatches == aList1.Extent()) {
+            aC0=Standard_True;
+            builder(theTag)->Generated(anEdge2);
+            anEdgesToDelete.Add(anEdge2);
+            TCollection_AsciiString aStr(theTag);
+            aName = theName + aStr.ToCString();
+            buildName(theTag, aName);
+            theTag++;
+          }
+        }
+      }      
+      TopTools_MapIteratorOfMapOfShape itDelete(anEdgesToDelete);
+      for(;itDelete.More();itDelete.Next()) 
+        edgeNaborFaces.UnBind(itDelete.Key());      
+      edgeNaborFaces.UnBind(anEdge1);
+    }
+    if (aC0) {
+      builder(theTag)->Generated(anEdge1);
+      TCollection_AsciiString aStr(theTag);
+      aName = theName + aStr.ToCString();
+      buildName(theTag, aName);         
+      theTag++;
+    }
+  }  
+}
+
+void Model_BodyBuilder::loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int&  theTag)
+{
+  if(theShape->isNull()) return;
+  TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();  
+  TopTools_DataMapOfShapeListOfShape vertexNaborEdges;
+  TopTools_ListOfShape empty;
+  TopExp_Explorer explF(aShape, TopAbs_EDGE);
+  for (; explF.More(); explF.Next()) {
+    const TopoDS_Shape& anEdge = explF.Current();
+    TopExp_Explorer explV(anEdge, TopAbs_VERTEX);
+    for (; explV.More(); explV.Next()) {
+      const TopoDS_Shape& aVertex = explV.Current();
+      if (!vertexNaborEdges.IsBound(aVertex)) vertexNaborEdges.Bind(aVertex, empty);
+      Standard_Boolean faceIsNew = Standard_True;
+      TopTools_ListIteratorOfListOfShape itrF(vertexNaborEdges.Find(aVertex));
+      for (; itrF.More(); itrF.Next()) {
+        if (itrF.Value().IsSame(anEdge)) {
+          faceIsNew = Standard_False;
+          break;
+        }
+      }
+      if (faceIsNew) {
+        vertexNaborEdges.ChangeFind(aVertex).Append(anEdge);
+      }
+    }
+  }
+  std::string aName;
+  TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itr(vertexNaborEdges);
+  for (; itr.More(); itr.Next()) {
+    const TopTools_ListOfShape& naborEdges = itr.Value();
+    if (naborEdges.Extent() < 2) {             
+      builder(theTag)->Generated(itr.Key());
+      TCollection_AsciiString aStr(theTag);
+      aName = theName + aStr.ToCString();
+      buildName(theTag, aName);         
+      theTag++;
+    }
+  }
+}
diff --git a/src/Model/Model_BodyBuilder.h b/src/Model/Model_BodyBuilder.h
new file mode 100755 (executable)
index 0000000..7548439
--- /dev/null
@@ -0,0 +1,120 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        Model_ResultBody.h
+// Created:     08 Jul 2014
+// Author:      Mikhail PONIKAROV
+
+#ifndef Model_BodyBuilder_H_
+#define Model_BodyBuilder_H_
+
+#include "Model.h"
+#include <ModelAPI_BodyBuilder.h>
+
+#include <GeomAlgoAPI_MakeShape.h>
+#include <GeomAPI_DataMapOfShapeShape.h>
+#include <vector>
+
+class TNaming_Builder;
+
+/**\class Model_BodyBuilder
+ * \ingroup DataModel
+ * \brief The body (shape) result of a feature.
+ */
+class Model_BodyBuilder : public ModelAPI_BodyBuilder
+{
+  /// builders that tores the naming history: one per label to allow store several shapes to one 
+  /// label; index in vector corresponds to the label tag
+  std::vector<TNaming_Builder*> myBuilders;
+public:
+  /// Stores the shape (called by the execution method).
+  MODEL_EXPORT virtual void store(const std::shared_ptr<GeomAPI_Shape>& theShape);
+
+  /// Stores the generated shape (called by the execution method).
+  MODEL_EXPORT virtual void storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
+                                              const std::shared_ptr<GeomAPI_Shape>& theToShape);
+
+  /// Stores the modified shape (called by the execution method).
+  /// \param theOldShape shape that produces result
+  /// \param theNewShape resulting shape
+  /// \param theDecomposeSolidsTag tag for starting of solids sub-elements placement in case 
+  ///          theNewShape is compound of solids, if zero it is not used
+  MODEL_EXPORT virtual void storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
+                                               const std::shared_ptr<GeomAPI_Shape>& theNewShape,
+                                          const int theDecomposeSolidsTag = 0);
+  /// Records the subshape newShape which was generated during a topological construction.
+  /// As an example, consider the case of a face generated in construction of a box.
+  MODEL_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape>& theNewShape, 
+    const std::string& theName, const int theTag = 1);
+
+  /// Records the shape newShape which was generated from the shape oldShape during a topological 
+  /// construction. As an example, consider the case of a face generated from an edge in 
+  /// construction of a prism.
+  MODEL_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
+    const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag = 1);
+
+
+  /// Records the shape newShape which is a modification of the shape oldShape.
+  /// As an example, consider the case of a face split or merged in a Boolean operation.
+  MODEL_EXPORT virtual void modified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
+    const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag = 1);
+
+  /// Records the shape oldShape which was deleted from the current label.
+  /// As an example, consider the case of a face removed by a Boolean operation.
+  MODEL_EXPORT virtual void deleted(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
+    const int theTag = 1);
+
+  /// load deleted shapes
+  MODEL_EXPORT virtual void loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
+                                               std::shared_ptr<GeomAPI_Shape>  theShapeIn,
+                                               const int  theKindOfShape,
+                                               const int  theTag);
+  /// load and orient modified shapes
+  MODEL_EXPORT virtual void loadAndOrientModifiedShapes (
+                                                  GeomAlgoAPI_MakeShape* theMS,
+                                               std::shared_ptr<GeomAPI_Shape>  theShapeIn,
+                                               const int  theKindOfShape,
+                                               const int  theTag,
+                                                                                          const std::string& theName,
+                                               GeomAPI_DataMapOfShapeShape& theSubShapes);
+   /// load and orient generated shapes
+  MODEL_EXPORT virtual void loadAndOrientGeneratedShapes (
+                                                  GeomAlgoAPI_MakeShape* theMS,
+                                               std::shared_ptr<GeomAPI_Shape>  theShapeIn,
+                                               const int  theKindOfShape,
+                                               const int  theTag,
+                                                                                          const std::string& theName,
+                                               GeomAPI_DataMapOfShapeShape& theSubShapes);
+  
+  /// Loads shapes of the first level (to be used during shape import)
+  MODEL_EXPORT virtual void loadFirstLevel(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int&  theTag);
+  
+  /// Loads disconnected edges
+  MODEL_EXPORT virtual void loadDisconnectedEdges(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int&  theTag);
+
+  /// Loads disconnected vetexes
+  MODEL_EXPORT virtual void loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int&  theTag);
+
+  /// Removes the stored builders
+  MODEL_EXPORT virtual ~Model_BodyBuilder();
+
+protected:
+  Model_BodyBuilder(ModelAPI_Object* theOwner);
+
+  /// Removes the stored builders
+  void clean();
+
+  /// Returns (creates if necessary) the builder created on the needed tag of sub-label
+  TNaming_Builder* builder(const int theTag);
+
+private:
+  /// Loads shapes of the next level (to be used during shape import)
+  void loadNextLevels(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int&  theTag);
+
+  /// builds name for the shape kept at the specified tag 
+  void buildName(const int theTag, const std::string& theName);
+
+  friend class Model_ResultBody;
+  friend class Model_ResultCompSolid;
+};
+
+#endif
index 8cecd4a92d837d8ed336dba3218e673456270b35..cb285aafdb182f4437ee99b790ceb29d94e17a19 100644 (file)
@@ -5,9 +5,11 @@
 // Author:      Mikhail PONIKAROV
 
 #include <Model_ResultBody.h>
+#include <Model_BodyBuilder.h>
 #include <Model_Data.h>
 #include <Model_Document.h>
 #include <ModelAPI_AttributeIntArray.h>
+
 #include <TNaming_Builder.hxx>
 #include <TNaming_NamedShape.hxx>
 #include <TNaming_Iterator.hxx>
@@ -32,6 +34,7 @@
 #include <BRep_Tool.hxx>
 #include <GeomAPI_Shape.h>
 #include <GeomAlgoAPI_MakeShape.h>
+
 #include <Config_PropManager.h>
 // DEB
 //#include <TCollection_AsciiString.hxx>
@@ -40,6 +43,8 @@
 
 Model_ResultBody::Model_ResultBody()
 {
+  myBuilder = new Model_BodyBuilder(this);
+
   myIsDisabled = true; // by default it is not initialized and false to be after created
   setIsConcealed(false);
 }
@@ -123,6 +128,7 @@ bool Model_ResultBody::setDisabled(std::shared_ptr<ModelAPI_Result> theThis, con
   return aChanged;
 }
 
+/*
 void Model_ResultBody::store(const std::shared_ptr<GeomAPI_Shape>& theShape)
 {
   std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
@@ -232,7 +238,7 @@ void Model_ResultBody::storeModified(const std::shared_ptr<GeomAPI_Shape>& theOl
     }
   }
 }
-
+*/
 std::shared_ptr<GeomAPI_Shape> Model_ResultBody::shape()
 {
   std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
@@ -250,7 +256,7 @@ std::shared_ptr<GeomAPI_Shape> Model_ResultBody::shape()
   }
   return std::shared_ptr<GeomAPI_Shape>();
 }
-
+/*
 void Model_ResultBody::clean()
 {
   std::vector<TNaming_Builder*>::iterator aBuilder = myBuilders.begin();
@@ -674,7 +680,7 @@ void Model_ResultBody::loadDisconnectedEdges(
   #endif
   theTag++;
   }
-  */
+  *+/
   TopTools_MapOfShape anEdgesToDelete;
   TopExp_Explorer anEx(aShape,TopAbs_EDGE); 
   std::string aName;
@@ -761,3 +767,4 @@ void Model_ResultBody::loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> t
     }
   }
 }
+*/
\ No newline at end of file
index 1bb3f6870aba1633150bc361e5816d4c705a5f46..f8c83a3f87ca8333e8c252c59a37cb735326ccf1 100644 (file)
@@ -9,11 +9,11 @@
 
 #include "Model.h"
 #include <ModelAPI_ResultBody.h>
-#include <GeomAlgoAPI_MakeShape.h>
-#include <GeomAPI_DataMapOfShapeShape.h>
-#include <vector>
+//#include <GeomAlgoAPI_MakeShape.h>
+//#include <GeomAPI_DataMapOfShapeShape.h>
+//#include <vector>
 
-class TNaming_Builder;
+//class TNaming_Builder;
 
 /**\class Model_ResultBody
  * \ingroup DataModel
@@ -27,7 +27,7 @@ class Model_ResultBody : public ModelAPI_ResultBody
 {
   /// builders that tores the naming history: one per label to allow store several shapes to one 
   /// label; index in vector corresponds to the label tag
-  std::vector<TNaming_Builder*> myBuilders;
+  //std::vector<TNaming_Builder*> myBuilders;
 public:
   /// Request for initialization of data model of the result: adding all attributes
   virtual void initAttributes();
@@ -40,7 +40,7 @@ public:
   /// naming data structure if theFlag if false. Or restores everything on theFlag is true.
   MODEL_EXPORT virtual bool setDisabled(std::shared_ptr<ModelAPI_Result> theThis,
     const bool theFlag);
-
+  /*
   /// Stores the shape (called by the execution method).
   MODEL_EXPORT virtual void store(const std::shared_ptr<GeomAPI_Shape>& theShape);
 
@@ -56,10 +56,10 @@ public:
   MODEL_EXPORT virtual void storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
                                                const std::shared_ptr<GeomAPI_Shape>& theNewShape,
                                           const int theDecomposeSolidsTag = 0);
-
+                                          */
   /// Returns the shape-result produced by this feature
   MODEL_EXPORT virtual std::shared_ptr<GeomAPI_Shape> shape();
-
+  /*
   /// Records the subshape newShape which was generated during a topological construction.
   /// As an example, consider the case of a face generated in construction of a box.
   MODEL_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape>& theNewShape, 
@@ -112,14 +112,14 @@ public:
 
   /// Loads disconnected vetexes
   MODEL_EXPORT virtual void loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int&  theTag);
-
+*/
   /// Removes the stored builders
-  MODEL_EXPORT virtual ~Model_ResultBody();
+  MODEL_EXPORT virtual ~Model_ResultBody() {};
 
 protected:
   /// Makes a body on the given feature
   Model_ResultBody();
-
+/*
   /// Removes the stored builders
   void clean();
 
@@ -132,7 +132,7 @@ private:
 
   /// builds name for the shape kept at the specified tag 
   void buildName(const int theTag, const std::string& theName);
-
+  */
   friend class Model_Objects;
 };
 
index cc3a09015ab2a8cf4b32eb5295cf0fab4b3694bd..2472d68e2dfceef6066823af2a8993d07836ecc8 100755 (executable)
@@ -9,10 +9,13 @@
 #include <ModelAPI_AttributeRefList.h>
 #include <ModelAPI_Object.h>
 
+#include <Model_BodyBuilder.h>
+
 #include <Model_Document.h>
 
 Model_ResultCompSolid::Model_ResultCompSolid()
 {
+  myBuilder = new Model_BodyBuilder(this);
 }
 
 Model_ResultCompSolid::~Model_ResultCompSolid()
index 6036d9e0c4eafc4b35f1cdb82ac71c76cdf9d43f..51e7a18ff33bcd1623e2de5cd0c792898635dd27 100644 (file)
@@ -20,6 +20,7 @@ SET(PROJECT_HEADERS
     ModelAPI_AttributeSelectionList.h
     ModelAPI_AttributeString.h
     ModelAPI_AttributeValidator.h
+    ModelAPI_BodyBuilder.h
     ModelAPI_CompositeFeature.h
     ModelAPI_Data.h
     ModelAPI_Document.h
@@ -55,6 +56,7 @@ SET(PROJECT_SOURCES
     ModelAPI_AttributeSelection.cpp
     ModelAPI_AttributeSelectionList.cpp
     ModelAPI_AttributeString.cpp
+    ModelAPI_BodyBuilder.cpp
     ModelAPI_CompositeFeature.cpp
     ModelAPI_Data.cpp
     ModelAPI_Document.cpp
diff --git a/src/ModelAPI/ModelAPI_BodyBuilder.cpp b/src/ModelAPI/ModelAPI_BodyBuilder.cpp
new file mode 100755 (executable)
index 0000000..8535ced
--- /dev/null
@@ -0,0 +1,23 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ModelAPI_ResultBody.cpp
+// Created:     07 Jul 2014
+// Author:      Mikhail PONIKAROV
+
+#include "ModelAPI_BodyBuilder.h"
+#include "ModelAPI_Object.h"
+
+ModelAPI_BodyBuilder::ModelAPI_BodyBuilder(ModelAPI_Object* theOwner)
+: myOwner(theOwner)
+{
+}
+
+std::shared_ptr<ModelAPI_Data> ModelAPI_BodyBuilder::data() const
+{
+  return myOwner->data();
+}
+
+std::shared_ptr<ModelAPI_Document> ModelAPI_BodyBuilder::document() const
+{
+  return myOwner->document();
+}
diff --git a/src/ModelAPI/ModelAPI_BodyBuilder.h b/src/ModelAPI/ModelAPI_BodyBuilder.h
new file mode 100755 (executable)
index 0000000..537c4e4
--- /dev/null
@@ -0,0 +1,109 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ModelAPI_BodyBuilder.hxx
+// Created:     07 Jul 2014
+// Author:      Mikhail PONIKAROV
+
+#ifndef ModelAPI_BodyBuilder_H_
+#define ModelAPI_BodyBuilder_H_
+
+#include <ModelAPI.h>
+#include <GeomAPI_Shape.h>
+#include <GeomAlgoAPI_MakeShape.h>
+#include <GeomAPI_DataMapOfShapeShape.h>
+#include <memory>
+#include <string>
+
+class ModelAPI_Data;
+class ModelAPI_Document;
+class ModelAPI_Object;
+
+/**\class ModelAPI_BodyBuilder
+* \ingroup DataModel
+*/
+class ModelAPI_BodyBuilder
+{
+public:
+  MODELAPI_EXPORT virtual ~ModelAPI_BodyBuilder() {};
+
+  /// Stores the shape (called by the execution method).
+  virtual void store(const std::shared_ptr<GeomAPI_Shape>& theShape) = 0;
+
+  /// Stores the generated shape (called by the execution method).
+  virtual void storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
+                                 const std::shared_ptr<GeomAPI_Shape>& theToShape) = 0;
+
+  /// Stores the modified shape (called by the execution method).
+  virtual void storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
+                                 const std::shared_ptr<GeomAPI_Shape>& theNewShape,
+                            const int theDecomposeSolidsTag = 0) = 0;
+
+  /// Records the subshape newShape which was generated during a topological construction.
+  /// As an example, consider the case of a face generated in construction of a box.
+  virtual void generated(
+    const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag = 1) = 0;
+
+  /// Records the shape newShape which was generated from the shape oldShape during a topological 
+  /// construction. As an example, consider the case of a face generated from an edge in 
+  /// construction of a prism.
+  virtual void generated(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
+    const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag = 1) = 0;
+
+  /// Records the shape newShape which is a modification of the shape oldShape.
+  /// As an example, consider the case of a face split or merged in a Boolean operation.
+  virtual void modified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
+    const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag = 1) = 0;
+
+  /// Records the shape oldShape which was deleted from the current label.
+  /// As an example, consider the case of a face removed by a Boolean operation.
+  virtual void deleted(
+    const std::shared_ptr<GeomAPI_Shape>& theOldShape, const int theTag = 1) = 0;
+  
+  /// load deleted shapes
+  virtual void loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
+                                               std::shared_ptr<GeomAPI_Shape>  theShapeIn,
+                                               const int  theKindOfShape,
+                                               const int  theTag) = 0;
+  /// load and orient modified shapes
+  virtual void loadAndOrientModifiedShapes (
+                                                  GeomAlgoAPI_MakeShape* theMS,
+                                               std::shared_ptr<GeomAPI_Shape>  theShapeIn,
+                                               const int  theKindOfShape,
+                                               const int  theTag,
+                                                                                          const std::string& theName,
+                                               GeomAPI_DataMapOfShapeShape& theSubShapes) = 0;
+  /// load and orient generated shapes
+  virtual void loadAndOrientGeneratedShapes (
+                                                  GeomAlgoAPI_MakeShape* theMS,
+                                               std::shared_ptr<GeomAPI_Shape>  theShapeIn,
+                                               const int  theKindOfShape,
+                                               const int  theTag,
+                                                                                          const std::string& theName,
+                                               GeomAPI_DataMapOfShapeShape& theSubShapes) = 0;
+
+  /// load shapes of the first level (to be used during shape import)
+  virtual void loadFirstLevel(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int&  theTag) = 0;
+  
+  /// load disconnected edges
+  virtual void loadDisconnectedEdges(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int&  theTag) = 0;
+
+  /// load disconnected vetexes
+  virtual void loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName,int&  theTag) = 0;
+
+protected:
+  /// Returns the data manager of this object: attributes
+  MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Data> data() const;
+
+  /// Returns document this feature belongs to
+  MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Document> document() const;
+
+protected:
+  MODELAPI_EXPORT ModelAPI_BodyBuilder(ModelAPI_Object* theOwner);
+
+  ModelAPI_Object* myOwner;
+};
+
+//! Pointer on feature object
+typedef std::shared_ptr<ModelAPI_BodyBuilder> BodyBuilderPtr;
+
+#endif
index 9d001619d0922ff39901b3c38c984b677cb9f542..1d5d38824d92622d13d5d6f66deecadde14abe5a 100644 (file)
@@ -6,9 +6,15 @@
 
 #include "ModelAPI_ResultBody.h"
 
+ModelAPI_ResultBody::ModelAPI_ResultBody()
+: myBuilder(0)
+{
+}
+
 ModelAPI_ResultBody::~ModelAPI_ResultBody()
 {
-  
+  if (myBuilder)
+  delete myBuilder;
 }
 
 std::string ModelAPI_ResultBody::groupName()
index 05aeab91c11d215496399b3b091cdc4558faadf6..8c5c9e6b9794186865e254f948606ba551301d1e 100644 (file)
@@ -9,11 +9,13 @@
 
 #include "ModelAPI_Result.h"
 #include <GeomAPI_Shape.h>
-#include <GeomAlgoAPI_MakeShape.h>
-#include <GeomAPI_DataMapOfShapeShape.h>
-#include <memory>
+//#include <GeomAlgoAPI_MakeShape.h>
+//#include <GeomAPI_DataMapOfShapeShape.h>
+//#include <memory>
 #include <string>
 
+class ModelAPI_BodyBuilder;
+
 /**\class ModelAPI_ResultBody
 * \ingroup DataModel
 * \brief The body (shape) result of a feature.
@@ -43,8 +45,11 @@ public:
     return RESULT_BODY_COLOR;
   }
 
+  /// Returns the builder, which processes the shapes
+  ModelAPI_BodyBuilder* getBodyBuilder() { return myBuilder; }
+
   /// Stores the shape (called by the execution method).
-  virtual void store(const std::shared_ptr<GeomAPI_Shape>& theShape) = 0;
+  /*virtual void store(const std::shared_ptr<GeomAPI_Shape>& theShape) = 0;
 
   /// Stores the generated shape (called by the execution method).
   virtual void storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
@@ -106,8 +111,12 @@ public:
 
   /// load disconnected vetexes
   virtual void loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName,int&  theTag) = 0;
+  */
+protected:
+  MODELAPI_EXPORT ModelAPI_ResultBody();
 
 protected:
+  ModelAPI_BodyBuilder* myBuilder; /// provide the body processing in naming shape
 };
 
 //! Pointer on feature object
index b4953c70f40341004ef92f26f2362102576ad240..1942d2cd9643cdf490cbca84a26d4c7bff93b70e 100755 (executable)
@@ -10,11 +10,6 @@ ModelAPI_ResultCompSolid::~ModelAPI_ResultCompSolid()
 {
 }
 
-std::string ModelAPI_ResultCompSolid::groupName()
-{
-  return group();
-}
-
 bool ModelAPI_ResultCompSolid::isDisabled() const
 {
   return false;
index 4a0efd6fc6fbbcf79ff1fefc17121961afd6b136..a953aaff78c218ab4ec545f88c8e9e5e0605e907 100755 (executable)
 *
 * Provides a conainer of body result that may be displayed in the viewer.
 */
-class ModelAPI_ResultCompSolid : public ModelAPI_Result
+class ModelAPI_ResultCompSolid : public ModelAPI_ResultBody
 {
 public:
   MODELAPI_EXPORT virtual ~ModelAPI_ResultCompSolid();
   /// Returns the group identifier of this result
-  MODELAPI_EXPORT virtual std::string groupName();
-
-  /// Returns the group identifier of this result
-  inline static std::string group()
-  {
-    static std::string MY_GROUP = "Bodies";
-    return MY_GROUP;
-  }
 
   /// Returns the feature is disabled or not.
   MODELAPI_EXPORT virtual bool isDisabled() const;