]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Compsolids: initial implementation of sub-results of results on the data model level.
authormpv <mpv@opencascade.com>
Fri, 14 Aug 2015 14:24:27 +0000 (17:24 +0300)
committermpv <mpv@opencascade.com>
Fri, 14 Aug 2015 14:24:27 +0000 (17:24 +0300)
25 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/Model_BodyBuilder.cpp
src/Model/Model_BodyBuilder.h
src/Model/Model_Document.cpp
src/Model/Model_Document.h
src/Model/Model_Objects.cpp
src/Model/Model_Objects.h
src/Model/Model_ResultBody.cpp
src/Model/Model_ResultBody.h
src/Model/Model_ResultCompSolid.cpp
src/Model/Model_ResultCompSolid.h
src/ModelAPI/ModelAPI_BodyBuilder.h
src/ModelAPI/ModelAPI_Document.h
src/ModelAPI/ModelAPI_Feature.cpp
src/ModelAPI/ModelAPI_ResultBody.cpp
src/ModelAPI/ModelAPI_ResultBody.h
src/ModelAPI/ModelAPI_ResultCompSolid.h
src/ModelAPI/ModelAPI_Tools.cpp

index e2d29c9c85ad7b2c8255a96617f8e068d9c1e5b0..a0e7ebaaf1fd5faf309e0069699598563b43a292 100644 (file)
@@ -113,9 +113,9 @@ void ExchangePlugin_ImportFeature::loadNamingDS(
     std::shared_ptr<ModelAPI_ResultBody> theResultBody)
 {
   //load result
-  theResultBody->getBodyBuilder()->store(theGeomShape);
+  theResultBody->store(theGeomShape);
 
   int aTag(1);
   std::string aNameMS = "Shape";
-  theResultBody->getBodyBuilder()->loadFirstLevel(theGeomShape, aNameMS, aTag);
+  theResultBody->loadFirstLevel(theGeomShape, aNameMS, aTag);
 }
index 6393cd42b56fc1a1467825577317017e8e7d6d62..364ee8b1cbdcf8a5bc78c6f274e4e2120522ed37 100644 (file)
@@ -199,24 +199,23 @@ 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())) {
-    aResultBuilder->store(theAlgo.shape());
+    theResultBody->store(theAlgo.shape());
   } else {
-    aResultBuilder->storeModified(theBaseShape, theAlgo.shape(), _SUBSOLIDS_TAG);
+    theResultBody->storeModified(theBaseShape, theAlgo.shape(), _SUBSOLIDS_TAG);
 
     GeomAPI_DataMapOfShapeShape* aSubShapes = new GeomAPI_DataMapOfShapeShape();
 
     std::string aModName = "Modified";
-    aResultBuilder->loadAndOrientModifiedShapes(theAlgo.makeShape().get(), theBaseShape, FACE,
+    theResultBody->loadAndOrientModifiedShapes(theAlgo.makeShape().get(), theBaseShape, FACE,
                                                _MODIFY_TAG, aModName, *theAlgo.mapOfShapes().get());
-    aResultBuilder->loadDeletedShapes(theAlgo.makeShape().get(), theBaseShape, FACE, _DELETED_TAG);
+    theResultBody->loadDeletedShapes(theAlgo.makeShape().get(), theBaseShape, FACE, _DELETED_TAG);
 
     for(ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++) {
-      aResultBuilder->loadAndOrientModifiedShapes(theAlgo.makeShape().get(), *anIter, FACE,
+      theResultBody->loadAndOrientModifiedShapes(theAlgo.makeShape().get(), *anIter, FACE,
                                                  _MODIFY_TAG, aModName, *theAlgo.mapOfShapes().get());
-      aResultBuilder->loadDeletedShapes(theAlgo.makeShape().get(), *anIter, FACE, _DELETED_TAG);
+      theResultBody->loadDeletedShapes(theAlgo.makeShape().get(), *anIter, FACE, _DELETED_TAG);
     }
   }
 }
index 9d59c3c376b626486ba53c5cb37355283db483e1..27cc3c6e8c95facea374d8dc4055a6b4ab4d5a5d 100644 (file)
@@ -205,10 +205,9 @@ 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())) {
-    aResultBuilder->store(theAlgo.shape());
+    theResultBody->store(theAlgo.shape());
   } else {
     const int aGenTag = 1;
     const int aFrTag = 2;
@@ -222,7 +221,7 @@ void FeaturesPlugin_CompositeBoolean::loadNamingDS(std::shared_ptr<ModelAPI_Resu
     const std::string aFrName = "FromFace";
     const std::string aToName = "ToFace";
 
-    aResultBuilder->storeModified(theBaseShape, theAlgo.shape(), aSubsolidsTag);
+    theResultBody->storeModified(theBaseShape, theAlgo.shape(), aSubsolidsTag);
 
     ListOfShape::const_iterator aFaceIter = theFaces.begin();
     std::list<std::shared_ptr<GeomAPI_Interface>>::const_iterator aSolidsAlgosIter = theSolidsAlgos.begin();
@@ -235,7 +234,7 @@ 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();
-        aResultBuilder->loadAndOrientGeneratedShapes(aPrismAlgo->makeShape().get(), *aFaceIter, GeomAPI_Shape::EDGE, aGenTag,
+        theResultBody->loadAndOrientGeneratedShapes(aPrismAlgo->makeShape().get(), *aFaceIter, GeomAPI_Shape::EDGE, aGenTag,
                                                     aLatName, *aSubShapes.get());
         //TODO:fix
         //aFromFace = aPrismAlgo->firstShape();
@@ -243,7 +242,7 @@ void FeaturesPlugin_CompositeBoolean::loadNamingDS(std::shared_ptr<ModelAPI_Resu
       } 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();
-        aResultBuilder->loadAndOrientGeneratedShapes(aRevolAlgo->makeShape().get(), *aFaceIter, GeomAPI_Shape::EDGE, aGenTag,
+        theResultBody->loadAndOrientGeneratedShapes(aRevolAlgo->makeShape().get(), *aFaceIter, GeomAPI_Shape::EDGE, aGenTag,
                                                     aLatName, *aSubShapes.get());
         aFromFace = aRevolAlgo->firstShape();
         aToFace = aRevolAlgo->lastShape();
@@ -254,7 +253,7 @@ void FeaturesPlugin_CompositeBoolean::loadNamingDS(std::shared_ptr<ModelAPI_Resu
         if(aSubShapes->isBound(aFromFace)) {
           aFromFace = aSubShapes->find(aFromFace);
         }
-        aResultBuilder->generated(aFromFace, aFrName, aFrTag);
+        theResultBody->generated(aFromFace, aFrName, aFrTag);
       }
 
       //Insert top face
@@ -262,18 +261,18 @@ void FeaturesPlugin_CompositeBoolean::loadNamingDS(std::shared_ptr<ModelAPI_Resu
         if (aSubShapes->isBound(aToFace)) {
           aToFace = aSubShapes->find(aToFace);
         }
-        aResultBuilder->generated(aToFace, aToName, aToTag);
+        theResultBody->generated(aToFace, aToName, aToTag);
       }
     }
 
-    aResultBuilder->loadAndOrientModifiedShapes(theAlgo.makeShape().get(), theBaseShape, GeomAPI_Shape::FACE,
+    theResultBody->loadAndOrientModifiedShapes(theAlgo.makeShape().get(), theBaseShape, GeomAPI_Shape::FACE,
                                                aModTag, aModName, *theAlgo.mapOfShapes().get());
-    aResultBuilder->loadDeletedShapes(theAlgo.makeShape().get(), theBaseShape, GeomAPI_Shape::FACE, aDelTag);
+    theResultBody->loadDeletedShapes(theAlgo.makeShape().get(), theBaseShape, GeomAPI_Shape::FACE, aDelTag);
 
     for(ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++) {
-      aResultBuilder->loadAndOrientModifiedShapes(theAlgo.makeShape().get(), *anIter, GeomAPI_Shape::FACE,
+      theResultBody->loadAndOrientModifiedShapes(theAlgo.makeShape().get(), *anIter, GeomAPI_Shape::FACE,
                                                  aModTag, aModName, *theAlgo.mapOfShapes().get());
-      aResultBuilder->loadDeletedShapes(theAlgo.makeShape().get(), *anIter, GeomAPI_Shape::FACE, aDelTag);
+      theResultBody->loadDeletedShapes(theAlgo.makeShape().get(), *anIter, GeomAPI_Shape::FACE, aDelTag);
     }
   }
 }
index a6372cf9a2b8b7064a70843813886feaac6ba1da..a4436599cb2effca895ee2c31490d5a1ed2a5b7c 100644 (file)
@@ -175,18 +175,17 @@ void FeaturesPlugin_Extrusion::loadNamingDS(GeomAlgoAPI_Prism& thePrismAlgo,
                                             std::shared_ptr<GeomAPI_Shape> theBasis)
 {
   //load result
-  ModelAPI_BodyBuilder* aResultBuilder = theResultBody->getBodyBuilder();
   if(thePrismAlgo.shape()->shapeType() == GeomAPI_Shape::COMPSOLID) {
     int a = 1;
   }
-  aResultBuilder->storeGenerated(theBasis, thePrismAlgo.shape());
+  theResultBody->storeGenerated(theBasis, thePrismAlgo.shape());
 
   std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = thePrismAlgo.mapOfShapes();
 
   //Insert lateral face : Face from Edge
   std::string aLatName = "LateralFace";
   const int aLatTag = 1;
-  aResultBuilder->loadAndOrientGeneratedShapes(thePrismAlgo.makeShape().get(), theBasis, GeomAPI_Shape::EDGE, aLatTag, aLatName, *aSubShapes);
+  theResultBody->loadAndOrientGeneratedShapes(thePrismAlgo.makeShape().get(), theBasis, GeomAPI_Shape::EDGE, aLatTag, aLatName, *aSubShapes);
 
   //Insert to faces
   std::string aToName = "ToFace";
@@ -197,7 +196,7 @@ void FeaturesPlugin_Extrusion::loadNamingDS(GeomAlgoAPI_Prism& thePrismAlgo,
     if(aSubShapes->isBound(aToFace)) {
       aToFace = aSubShapes->find(aToFace);
     }
-    aResultBuilder->generated(aToFace, aToName, aToTag);
+    theResultBody->generated(aToFace, aToName, aToTag);
   }
 
   //Insert from faces
@@ -209,6 +208,6 @@ void FeaturesPlugin_Extrusion::loadNamingDS(GeomAlgoAPI_Prism& thePrismAlgo,
     if(aSubShapes->isBound(aFromFace)) {
       aFromFace = aSubShapes->find(aFromFace);
     }
-    aResultBuilder->generated(aFromFace, aFromName, aFromTag);
+    theResultBody->generated(aFromFace, aFromName, aFromTag);
   }
 }
index 3a298e2a4c255f9c193fc84e6cf1b23dd1e7647d..ebe2eb8081d8a9962bce2f59728abc6ef09ce1f7 100644 (file)
@@ -119,15 +119,14 @@ 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.
-  aResultBuilder->storeModified(theBaseShape, theMovementAlgo.shape());
+  theResultBody->storeModified(theBaseShape, theMovementAlgo.shape());
 
   std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theMovementAlgo.mapOfShapes();
 
   int aMovedTag = 1;
   std::string aMovedName = "Moved";
-  aResultBuilder->loadAndOrientModifiedShapes(theMovementAlgo.makeShape().get(),
+  theResultBody->loadAndOrientModifiedShapes(theMovementAlgo.makeShape().get(),
                                               theBaseShape, GeomAPI_Shape::FACE,
                                               aMovedTag, aMovedName, *aSubShapes.get());
 
index a52a2be08bfbc45a5d5953b4fa6e333963d1a647..38bf6f1d3df4e38a7293fa3fdedcde9d7e6719b7 100644 (file)
@@ -169,15 +169,14 @@ 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
-  aResultBuilder->storeModified(theSlaveObject, theTransformAlgo.shape()); // the initial Slave, the resulting Slave
+  theResultBody->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";
-  aResultBuilder->loadAndOrientModifiedShapes(theTransformAlgo.makeShape().get(),
+  theResultBody->loadAndOrientModifiedShapes(theTransformAlgo.makeShape().get(),
                                               theSlaveObject, _FACE,
                                               _MODIFIEDF_TAG, aModName, *aSubShapes.get());
 }
index 8b8a93ad8237b489649e03f9cdc92fdf2f2e47e1..7716583e1c436bcf655226ae02e640c524c7eab2 100644 (file)
@@ -179,18 +179,15 @@ void FeaturesPlugin_Revolution::LoadNamingDS(GeomAlgoAPI_Revolution& theFeature,
                                              std::shared_ptr<GeomAPI_Shape> theBasis,
                                              std::shared_ptr<GeomAPI_Shape> theContext)
 {
-  //load result
-  ModelAPI_BodyBuilder* aResultBuilder = theResultBody->getBodyBuilder();
-
   if(theBasis->isEqual(theContext))
-    aResultBuilder->store(theFeature.shape());
+    theResultBody->store(theFeature.shape());
   else
-    aResultBuilder->storeGenerated(theContext, theFeature.shape());
+    theResultBody->storeGenerated(theContext, theFeature.shape());
 
   std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theFeature.mapOfShapes();
 
   std::string aGeneratedName = "LateralFace";
-  aResultBuilder->loadAndOrientGeneratedShapes(theFeature.makeShape().get(), theBasis, EDGE,_LATERAL_TAG, aGeneratedName, *aSubShapes);
+  theResultBody->loadAndOrientGeneratedShapes(theFeature.makeShape().get(), theBasis, EDGE,_LATERAL_TAG, aGeneratedName, *aSubShapes);
 
   //Insert from face
   std::string aBotName = "FromFace";
@@ -199,7 +196,7 @@ void FeaturesPlugin_Revolution::LoadNamingDS(GeomAlgoAPI_Revolution& theFeature,
     if(aSubShapes->isBound(aBottomFace)) {
       aBottomFace = aSubShapes->find(aBottomFace);
     }
-    aResultBuilder->generated(aBottomFace, aBotName, _FROM_TAG);
+    theResultBody->generated(aBottomFace, aBotName, _FROM_TAG);
   }
 
   //Insert to face
@@ -209,7 +206,7 @@ void FeaturesPlugin_Revolution::LoadNamingDS(GeomAlgoAPI_Revolution& theFeature,
     if (aSubShapes->isBound(aTopFace)) {
       aTopFace = aSubShapes->find(aTopFace);
     }
-    aResultBuilder->generated(aTopFace, aTopName, _TO_TAG);
+    theResultBody->generated(aTopFace, aTopName, _TO_TAG);
   }
 
 }
index 7007b9bbf5d3bebc7a3566d5f926251a4e6ed2a0..e71fabcfa311a734ce8b5f76d4a2d2758ccf2d43 100755 (executable)
@@ -119,15 +119,14 @@ 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.
-  aResultBuilder->storeModified(theBaseShape, theRotaionAlgo.shape());
+  theResultBody->storeModified(theBaseShape, theRotaionAlgo.shape());
 
   std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theRotaionAlgo.mapOfShapes();
 
   int aRotatedTag = 1;
   std::string aRotatedName = "Rotated";
-  aResultBuilder->loadAndOrientModifiedShapes(theRotaionAlgo.makeShape().get(),
+  theResultBody->loadAndOrientModifiedShapes(theRotaionAlgo.makeShape().get(),
                                               theBaseShape, GeomAPI_Shape::FACE,
                                               aRotatedTag, aRotatedName, *aSubShapes.get());
 
index 604c99b2c4181186cda4529d1e05b7c280ff4e75..0efc177974662432e046e31a3bcbb562d2f2456c 100755 (executable)
@@ -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<std::pair<TopoDS_Shape, TopoDS_Shape> > aShapePairs; // to store old and new shapes
   Handle(TNaming_NamedShape) aName;
   int anEvolution = -1;
@@ -91,10 +91,19 @@ static void EvolutionToSelection(TDF_Label theLab, const bool theFlag) {
   // 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<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
+  if (!aData) // unknown case
+    return;
+  TDF_Label& aShapeLab = aData->shapeLab();
+  evolutionToSelectionRec(aShapeLab, 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());
@@ -714,3 +723,21 @@ void Model_BodyBuilder::loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape>
     }
   }
 }
+
+std::shared_ptr<GeomAPI_Shape> Model_BodyBuilder::shape()
+{
+  std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(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<GeomAPI_Shape> aRes(new GeomAPI_Shape);
+        aRes->setImpl(new TopoDS_Shape(aShape));
+        return aRes;
+      }
+    }
+  }
+  return std::shared_ptr<GeomAPI_Shape>();
+}
index 7548439b1e396051447e4cfbffba6bb0d7628f37..5097fc17ddab71867a196925fe4db492b88da40c 100755 (executable)
@@ -41,6 +41,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, 
@@ -97,6 +101,10 @@ public:
   /// Removes the stored builders
   MODEL_EXPORT virtual ~Model_BodyBuilder();
 
+  /// Converts evolution of sub-shapes stored in naming structure to selection 
+  /// (theFlag = true) and back (theFlag = false)
+  MODEL_EXPORT virtual void evolutionToSelection(const bool theFlag);
+
 protected:
   Model_BodyBuilder(ModelAPI_Object* theOwner);
 
index d123c6b9e0a905aad60fc1898616e0ef8c37f0cc..efdc253aa3f678fa7591117861cd333d6c74c277 100644 (file)
@@ -801,12 +801,6 @@ std::shared_ptr<ModelAPI_ResultBody> Model_Document::createBody(
   return myObjs->createBody(theFeatureData, theIndex);
 }
 
-std::shared_ptr<ModelAPI_ResultCompSolid> Model_Document::createCompSolid(
-    const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex)
-{
-  return myObjs->createCompSolid(theFeatureData, theIndex);
-}
-
 std::shared_ptr<ModelAPI_ResultPart> Model_Document::createPart(
     const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex)
 {
@@ -835,12 +829,7 @@ std::shared_ptr<ModelAPI_ResultParameter> Model_Document::createParameter(
 std::shared_ptr<ModelAPI_Feature> Model_Document::feature(
     const std::shared_ptr<ModelAPI_Result>& theResult)
 {
-  std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(theResult->data());
-  if (aData) {
-    TDF_Label aFeatureLab = aData->label().Father().Father().Father();
-    return myObjs->feature(aFeatureLab);
-  }
-  return FeaturePtr();
+  return myObjs->feature(theResult);
 }
 
 Standard_Integer HashCode(const TDF_Label& theLab, const Standard_Integer theUpper)
index 3b7da979074b2efa6f0054ddb9dfd4c68de82e60..d82b853f65131b7c4bdb7a7c2a338e6fd50deb81 100644 (file)
@@ -151,9 +151,6 @@ class Model_Document : public ModelAPI_Document
   /// Creates a body results
   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_ResultBody> createBody(
       const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
-  /// Creates a compsolid results
-  MODEL_EXPORT virtual std::shared_ptr<ModelAPI_ResultCompSolid> createCompSolid(
-      const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
   /// Creates a part results
   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_ResultPart> createPart(
       const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
@@ -263,6 +260,7 @@ class Model_Document : public ModelAPI_Document
   friend class Model_AttributeRefAttr;
   friend class Model_AttributeRefList;
   friend class Model_ResultPart;
+  friend class Model_ResultCompSolid;
   friend class DFBrowser;
 
  private:
index 9c7a4eafaa6fa3cc08fd6a38460df7a7375908d9..6375e4e2cbd133dffe8e3507a5101889d9af20cb 100644 (file)
@@ -382,14 +382,36 @@ ObjectPtr Model_Objects::object(TDF_Label theLabel)
     return feature(theLabel);
   TDF_Label aFeatureLabel = theLabel.Father().Father();  // let's suppose it is result
   aFeature = feature(aFeatureLabel);
+  bool isSubResult = false;
+  if (!aFeature.get() && aFeatureLabel.Depth() > 1) { // let's suppose this is sub-result of result
+    aFeatureLabel = aFeatureLabel.Father().Father();
+    aFeature = feature(aFeatureLabel);
+    isSubResult = true;
+  }
   if (aFeature) {
     const std::list<std::shared_ptr<ModelAPI_Result> >& aResults = aFeature->results();
     std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.cbegin();
     for (; aRIter != aResults.cend(); aRIter++) {
-      std::shared_ptr<Model_Data> aResData = std::dynamic_pointer_cast<Model_Data>(
-          (*aRIter)->data());
-      if (aResData->label().Father().IsEqual(theLabel))
-        return *aRIter;
+      if (isSubResult) {
+        ResultCompSolidPtr aCompRes = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(*aRIter);
+        if (aCompRes) {
+          int aNumSubs = aCompRes->numberOfSubs();
+          for(int a = 0; a < aNumSubs; a++) {
+            ResultPtr aSub = aCompRes->subResult(a);
+            if (aSub.get()) {
+              std::shared_ptr<Model_Data> aSubData = std::dynamic_pointer_cast<Model_Data>(
+                  aSub->data());
+              if (aSubData->label().Father().IsEqual(theLabel))
+                return aSub;
+            }
+          }
+        }
+      } else {
+        std::shared_ptr<Model_Data> aResData = std::dynamic_pointer_cast<Model_Data>(
+            (*aRIter)->data());
+        if (aResData->label().Father().IsEqual(theLabel))
+          return *aRIter;
+      }
     }
   }
   return FeaturePtr();  // not found
@@ -752,31 +774,27 @@ std::shared_ptr<ModelAPI_ResultBody> Model_Objects::createBody(
     const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex)
 {
   TDF_Label aLab = resultLabel(theFeatureData, theIndex);
-  TDataStd_Comment::Set(aLab, ModelAPI_ResultBody::group().c_str());
-  ObjectPtr anOldObject = object(aLab);
+  // for feature create compsolid, but for result sub create body: 
+  // only one level of recursion is supported now
+  ResultPtr aResultOwner = std::dynamic_pointer_cast<ModelAPI_Result>(theFeatureData->owner());
+  ObjectPtr anOldObject;
+  if (aResultOwner.get()) {
+    TDataStd_Comment::Set(aLab, ModelAPI_ResultBody::group().c_str());
+  } else { // in compsolid (higher level result) old object probably may be found
+    TDataStd_Comment::Set(aLab, ModelAPI_ResultCompSolid::group().c_str());
+    anOldObject = object(aLab);
+  }
   std::shared_ptr<ModelAPI_ResultBody> aResult;
   if (anOldObject) {
     aResult = std::dynamic_pointer_cast<ModelAPI_ResultBody>(anOldObject);
   }
   if (!aResult) {
-    aResult = std::shared_ptr<ModelAPI_ResultBody>(new Model_ResultBody);
-    storeResult(theFeatureData, aResult, theIndex);
-  }
-  return aResult;
-}
-
-std::shared_ptr<ModelAPI_ResultCompSolid> Model_Objects::createCompSolid(
-    const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex)
-{
-  TDF_Label aLab = resultLabel(theFeatureData, theIndex);
-  TDataStd_Comment::Set(aLab, ModelAPI_ResultCompSolid::group().c_str());
-  ObjectPtr anOldObject = object(aLab);
-  std::shared_ptr<ModelAPI_ResultCompSolid> aResult;
-  if (anOldObject) {
-    aResult = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(anOldObject);
-  }
-  if (!aResult) {
-    aResult = std::shared_ptr<ModelAPI_ResultCompSolid>(new Model_ResultCompSolid);
+    // create compsolid anyway; if it is compsolid, it will create sub-bodies internally
+    if (aResultOwner.get()) {
+      aResult = std::shared_ptr<ModelAPI_ResultBody>(new Model_ResultBody);
+    } else {
+      aResult = std::shared_ptr<ModelAPI_ResultBody>(new Model_ResultCompSolid);
+    }
     storeResult(theFeatureData, aResult, theIndex);
   }
   return aResult;
@@ -848,7 +866,12 @@ std::shared_ptr<ModelAPI_Feature> Model_Objects::feature(
   std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(theResult->data());
   if (aData) {
     TDF_Label aFeatureLab = aData->label().Father().Father().Father();
-    return feature(aFeatureLab);
+    FeaturePtr aFeature = feature(aFeatureLab);
+    if (!aFeature.get() && aFeatureLab.Depth() > 1) { // this may be sub-result of result
+      aFeatureLab = aFeatureLab.Father().Father();
+      aFeature = feature(aFeatureLab);
+    }
+    return aFeature;
   }
   return FeaturePtr();
 }
@@ -902,7 +925,8 @@ void Model_Objects::updateResults(FeaturePtr theFeature)
       TDF_Label anArgLab = aLabIter.Value();
       Handle(TDataStd_Comment) aGroup;
       if (anArgLab.FindAttribute(TDataStd_Comment::GetID(), aGroup)) {
-        if (aGroup->Get() == ModelAPI_ResultBody::group().c_str()) {
+        if (aGroup->Get() == ModelAPI_ResultBody::group().c_str() || 
+            aGroup->Get() == ModelAPI_ResultCompSolid::group().c_str()) {
           aNewBody = createBody(theFeature->data(), aResIndex);
         } else if (aGroup->Get() == ModelAPI_ResultPart::group().c_str()) {
           std::shared_ptr<ModelAPI_ResultPart> aNewP = createPart(theFeature->data(), aResIndex); 
index 45c837d624110ef58fe09faabb03b89175143ddd..91124d483b0fb2e9a25b1666fc38606ec1173b46 100644 (file)
@@ -100,9 +100,6 @@ class Model_Objects
   /// Creates a body results
   std::shared_ptr<ModelAPI_ResultBody> createBody(
       const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
-  /// Creates a body results
-  std::shared_ptr<ModelAPI_ResultCompSolid> createCompSolid(
-      const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
   /// Creates a part results
   std::shared_ptr<ModelAPI_ResultPart> createPart(
       const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
index cb285aafdb182f4437ee99b790ceb29d94e17a19..9c5fa59cc1d25ea72ab16fe652160712dd5bad7c 100644 (file)
@@ -6,35 +6,7 @@
 
 #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>
-#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>
@@ -64,707 +36,11 @@ void Model_ResultBody::colorConfigInfo(std::string& theSection, std::string& the
   theDefault = DEFAULT_COLOR();
 }
 
-// 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);
-  }
-}
-
 bool Model_ResultBody::setDisabled(std::shared_ptr<ModelAPI_Result> theThis, const bool theFlag)
 {
   bool aChanged = ModelAPI_ResultBody::setDisabled(theThis, theFlag);
   if (aChanged) { // state is changed, so modifications are needed
-    std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
-    if (!aData) // unknown case
-      return aChanged;
-    TDF_Label& aShapeLab = aData->shapeLab();
-    EvolutionToSelection(aShapeLab, theFlag);
+    myBuilder->evolutionToSelection(theFlag);
   }
   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());
-  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_ResultBody::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_ResultBody::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());
-        }
-      }
-    }
-  }
-}
-*/
-std::shared_ptr<GeomAPI_Shape> Model_ResultBody::shape()
-{
-  std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(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<GeomAPI_Shape> aRes(new GeomAPI_Shape);
-        aRes->setImpl(new TopoDS_Shape(aShape));
-        return aRes;
-      }
-    }
-  }
-  return std::shared_ptr<GeomAPI_Shape>();
-}
-/*
-void Model_ResultBody::clean()
-{
-  std::vector<TNaming_Builder*>::iterator aBuilder = myBuilders.begin();
-  for(; aBuilder != myBuilders.end(); aBuilder++)
-    delete *aBuilder;
-  myBuilders.clear();
-}
-
-Model_ResultBody::~Model_ResultBody()
-{
-  clean();
-}
-
-TNaming_Builder* Model_ResultBody::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_ResultBody::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_ResultBody::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_ResultBody::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_ResultBody::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_ResultBody::deleted(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
-  const int theTag)
-{
-  TopoDS_Shape aShape = theOldShape->impl<TopoDS_Shape>();
-  builder(theTag)->Delete(aShape);
-}
-
-void Model_ResultBody::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_ResultBody::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_ResultBody::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_ResultBody::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_ResultBody::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_ResultBody::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_ResultBody::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++;
-    }
-  }
-}
-*/
\ No newline at end of file
index f8c83a3f87ca8333e8c252c59a37cb735326ccf1..1300be1c53d8f4dab2f607350c2908c8cdc18482 100644 (file)
@@ -40,99 +40,13 @@ 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);
-
-  /// 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);
-                                          */
-  /// 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, 
-    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_ResultBody() {};
 
 protected:
   /// Makes a body on the given feature
   Model_ResultBody();
-/*
-  /// 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_Objects;
 };
 
index 5cb50556c6339dce0a8057f02c601b8804eaea31..c1bfa0f4f0d00a81a84bc494db13c2be27b28c84 100755 (executable)
 
 #include <Model_ResultCompSolid.h>
 
+#include <Model_Document.h>
+#include <Model_Objects.h>
+#include <Model_BodyBuilder.h>
+#include <Model_Document.h>
 #include <ModelAPI_AttributeRefList.h>
+#include <ModelAPI_AttributeIntArray.h>
 #include <ModelAPI_Object.h>
+#include <ModelAPI_Events.h>
+#include <Events_Loop.h>
 
-#include <Model_BodyBuilder.h>
+#include <TopoDS_Shape.hxx>
+#include <TopExp_Explorer.hxx>
 
-#include <Model_Document.h>
 
 Model_ResultCompSolid::Model_ResultCompSolid()
 {
   myBuilder = new Model_BodyBuilder(this);
+  updateSubs(shape()); // in case of open, etc.
 }
 
 Model_ResultCompSolid::~Model_ResultCompSolid()
 {
+  updateSubs(std::shared_ptr<GeomAPI_Shape>()); // erase sub-results
 }
 
 void Model_ResultCompSolid::initAttributes()
 {
-  data()->addAttribute(Model_ResultCompSolid::BODIES_ID(), ModelAPI_AttributeRefList::typeId());
+  DataPtr aData = data();
+  aData->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::typeId());
 }
 
-std::shared_ptr<ModelAPI_ResultBody> Model_ResultCompSolid::addResult(const int theIndex)
+void Model_ResultCompSolid::store(const std::shared_ptr<GeomAPI_Shape>& theShape)
 {
-  std::shared_ptr<ModelAPI_ResultBody> aBody = document()->createBody(data(), theIndex);
-  if (aBody.get()) {
-    data()->reflist(Model_ResultCompSolid::BODIES_ID())->append(aBody);
-  }
-  return aBody;
+  ModelAPI_ResultCompSolid::store(theShape);
+  updateSubs(theShape);
+}
+
+void Model_ResultCompSolid::storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
+    const std::shared_ptr<GeomAPI_Shape>& theToShape)
+{
+  ModelAPI_ResultCompSolid::storeGenerated(theFromShape, theToShape);
+  updateSubs(theToShape);
+}
+
+void Model_ResultCompSolid::storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
+    const std::shared_ptr<GeomAPI_Shape>& theNewShape, const int theDecomposeSolidsTag)
+{
+  ModelAPI_ResultCompSolid::storeModified(theOldShape, theNewShape, theDecomposeSolidsTag);
+  updateSubs(theNewShape);
 }
 
 int Model_ResultCompSolid::numberOfSubs(bool forTree) const
 {
-  if (forTree)
-    return 0;
-  return data()->reflist(Model_ResultCompSolid::BODIES_ID())->size();
+  return mySubs.size();
 }
 
 std::shared_ptr<ModelAPI_ResultBody> Model_ResultCompSolid::subResult(const int theIndex,
                                                                       bool forTree) const
 {
-  if (forTree) {
-    std::shared_ptr<ModelAPI_ResultBody> aBody;
-    return aBody;
-  }
+  return mySubs.at(theIndex);
+}
 
-  ObjectPtr anObj = data()->reflist(Model_ResultCompSolid::BODIES_ID())->object(theIndex);
-  return std::dynamic_pointer_cast<ModelAPI_ResultBody>(anObj);
+bool Model_ResultCompSolid::isSub(ObjectPtr theObject) const
+{
+  std::vector<std::shared_ptr<ModelAPI_ResultBody> >::const_iterator aSubIter = mySubs.cbegin();
+  for(; aSubIter != mySubs.cend(); aSubIter++)
+    if (*aSubIter == theObject)
+      return true;
+  return false;
 }
 
-/*int Model_ResultCompSolid::subResultId(const int theIndex) const
+void Model_ResultCompSolid::colorConfigInfo(std::string& theSection, std::string& theName,
+  std::string& theDefault)
 {
-  return subResult(theIndex)->data()->featureId();
-}*/
+  theSection = "Visualization";
+  theName = "result_body_color";
+  theDefault = DEFAULT_COLOR();
+}
 
-bool Model_ResultCompSolid::isSub(ObjectPtr theObject) const
+bool Model_ResultCompSolid::setDisabled(std::shared_ptr<ModelAPI_Result> theThis, const bool theFlag)
 {
-  // check is this feature of result
-  ResultBodyPtr aResult = std::dynamic_pointer_cast<ModelAPI_ResultBody>(theObject);
-  /*if (!aFeature) {
-    ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
-    if (aRes)
-      aFeature = document()->feature(aRes);
-  }*/
-  if (aResult) {
-    return data()->reflist(Model_ResultCompSolid::BODIES_ID())->isInList(aResult);
+  bool aChanged = ModelAPI_ResultBody::setDisabled(theThis, theFlag);
+  if (aChanged) { // state is changed, so modifications are needed
+    myBuilder->evolutionToSelection(theFlag);
   }
-  return false;
+  return aChanged;
 }
 
-void Model_ResultCompSolid::removeResult(std::shared_ptr<ModelAPI_ResultBody> theResult)
+void Model_ResultCompSolid::updateSubs(const std::shared_ptr<GeomAPI_Shape>& theThisShape)
 {
-  if (!data()->isValid()) // sketch is already removed (case on undo of sketch), sync is not needed
-    return;
-
-  std::list<ObjectPtr> aSubs = data()->reflist(Model_ResultCompSolid::BODIES_ID())->list();
-
-  std::list<ObjectPtr>::iterator aSubIt = aSubs.begin(), aLastIt = aSubs.end();
-  bool isRemoved = false;
-  bool aHasEmtpyResult = false;
-  for(; aSubIt != aLastIt && !isRemoved; aSubIt++) {
-    std::shared_ptr<ModelAPI_ResultBody> aResult = std::dynamic_pointer_cast<ModelAPI_ResultBody>(*aSubIt);
-    if (aResult.get() != NULL && aResult == theResult) {
-      data()->reflist(Model_ResultCompSolid::BODIES_ID())->remove(aResult);
-      isRemoved = true;
+  // iterate all sub-solids of compsolid to make sub-results synchronized with them
+  TopoDS_Shape aThisShape;
+  if (theThisShape.get()) aThisShape = theThisShape->impl<TopoDS_Shape>();
+  if (!aThisShape.IsNull() && (aThisShape.ShapeType() == TopAbs_COMPSOLID ||
+       aThisShape.ShapeType() == TopAbs_COMPOUND)) {
+    Model_Objects* anObjects = std::dynamic_pointer_cast<Model_Document>(document())->objects();
+    unsigned int aSubIndex = 0;
+    TopExp_Explorer aSolids(aThisShape, TopAbs_SOLID);
+    for(; aSolids.More(); aSolids.Next(), aSubIndex++) {
+      std::shared_ptr<GeomAPI_Shape> aSolidShape(new GeomAPI_Shape);
+      aSolidShape->setImpl(new TopoDS_Shape(aSolids.Current()));
+      ResultBodyPtr aSub;
+      if (mySubs.size() >= aSubIndex) { // it is needed to create a new sub-result
+        aSub = anObjects->createBody(this->data(), aSubIndex);
+        mySubs.push_back(aSub);
+      } else { // just update shape of this result
+        aSub = mySubs[aSubIndex];
+      }
+      if (!aSolidShape->isEqual(aSub->shape())) {
+        aSub->store(aSolidShape);
+        static Events_Loop* aLoop = Events_Loop::loop();
+        static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+        static Events_ID EVENT_UPD = aLoop->eventByName(EVENT_OBJECT_UPDATED);
+        static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
+        aECreator->sendUpdated(aSub, EVENT_DISP);
+        aECreator->sendUpdated(aSub, EVENT_UPD);
+      }
+      aSub->setDisabled(aSub, false);
+    }
+    // erase left, unused results
+    while(mySubs.size() > aSubIndex) {
+      ResultBodyPtr anErased = *(mySubs.rbegin());
+      anErased->setDisabled(anErased, true);
+      mySubs.pop_back();
+    }
+  } else { // erase all subs
+    while(!mySubs.empty()) {
+      ResultBodyPtr anErased = *(mySubs.rbegin());
+      anErased->setDisabled(anErased, true);
+      mySubs.pop_back();
     }
-    else if (aResult.get() == NULL)
-      aHasEmtpyResult = true;
   }
-  // if the object is not found in the sketch sub-elements, that means that the object is removed already.
-  // Find the first empty element and remove it
-  if (!isRemoved && aHasEmtpyResult)
-    data()->reflist(Model_ResultCompSolid::BODIES_ID())->remove(ObjectPtr());
-}
+}
\ No newline at end of file
index f1c697e5631fec076819af8933099d3c329290c9..355be572129f08c030d3a05fdaa9f7d55aa09cc1 100755 (executable)
@@ -9,22 +9,20 @@
 
 #include "Model.h"
 #include <ModelAPI_ResultCompSolid.h>
+#include <vector>
 
 /**\class Model_ResultCompSolid
- * \ingroup DataModel
- * \brief The compsolid (container of body results) result of a feature.
- *
- * Provides a container of shapes that may be displayed in the viewer.
- */
+* \ingroup DataModel
+* \brief The compsolid (container of body results) result of a feature.
+*
+* Provides a container of shapes that may be displayed in the viewer.
+*/
 class Model_ResultCompSolid : public ModelAPI_ResultCompSolid
 {
+  /// Sub-bodies if this is compsolid: zero base index to subs
+  std::vector<std::shared_ptr<ModelAPI_ResultBody> > mySubs;
+
 public:
-  /// All features of this sketch (list of references)
-  inline static const std::string& BODIES_ID()
-  {
-    static const std::string MY_BODIES_ID("Bodies");
-    return MY_BODIES_ID;
-  }
 
   /// Removes the stored builders
   MODEL_EXPORT virtual ~Model_ResultCompSolid();
@@ -32,33 +30,43 @@ public:
   /// Request for initialization of data model of the object: adding all attributes
   MODEL_EXPORT virtual void initAttributes();
 
-  /// Adds result to the sketch and to its document
-  /// \param theIndex an index of the created body result in the compsolid
-  /// The real index in the document of the result is an incremented given index
-  /// The reason is that the first index is used for the comp solid result on the data
-  virtual std::shared_ptr<ModelAPI_ResultBody> addResult(const int theIndex);
+  /// Stores the shape (called by the execution method). Creates sub-results for compsolid.
+  MODEL_EXPORT virtual void store(const std::shared_ptr<GeomAPI_Shape>& theShape);
+
+  /// Stores the generated shape.  Creates sub-results for compsolid.
+  MODEL_EXPORT virtual void storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
+    const std::shared_ptr<GeomAPI_Shape>& theToShape);
+
+  /// Stores the modified shape.  Creates sub-results for compsolid.
+  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 number of sub-elements
-  virtual int numberOfSubs(bool forTree = false) const;
+  MODEL_EXPORT virtual int numberOfSubs(bool forTree = false) const;
 
   /// Returns the sub-result by zero-base index
-  virtual std::shared_ptr<ModelAPI_ResultBody> subResult(const int theIndex,
-                                                         bool forTree = false) const;
-
-  /// Returns the sub-feature unique identifier in this composite feature by zero-base index
-  //virtual int subResultId(const int theIndex) const;
+  MODEL_EXPORT virtual std::shared_ptr<ModelAPI_ResultBody> subResult(const int theIndex,
+    bool forTree = false) const;
 
   /// Returns true if feature or reuslt belong to this composite feature as subs
-  virtual bool isSub(ObjectPtr theObject) const;
+  MODEL_EXPORT virtual bool isSub(ObjectPtr theObject) const;
+
+  /// Returns the parameters of color definition in the resources config manager
+  MODEL_EXPORT virtual void colorConfigInfo(std::string& theSection, std::string& theName,
+                                            std::string& theDefault);
 
-  /// This method to inform that sub-feature is removed and must be removed from the internal data
-  /// structures of the owner (the remove from the document will be done outside just after)
-  virtual void removeResult(std::shared_ptr<ModelAPI_ResultBody> theResult);
+  /// Disables the result body: keeps the resulting shape as selection, but erases the underlaying
+  /// 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);
 
 protected:
   /// Makes a body on the given feature
   Model_ResultCompSolid();
 
+  /// Updates the sub-bodies if shape of this object is composite-solid
+  void updateSubs(const std::shared_ptr<GeomAPI_Shape>& theThisShape);
+
   friend class Model_Objects;
 };
 
index 537c4e4929e0987163652d1774623677f40406dc..6f857e46cfd9b8307e7ccdcceb355e9a4779a509 100755 (executable)
@@ -38,6 +38,9 @@ public:
                                  const std::shared_ptr<GeomAPI_Shape>& theNewShape,
                             const int theDecomposeSolidsTag = 0) = 0;
 
+  /// Returns the shape-result produced by this feature
+  virtual std::shared_ptr<GeomAPI_Shape> shape() = 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(
@@ -90,6 +93,10 @@ public:
   /// load disconnected vetexes
   virtual void loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName,int&  theTag) = 0;
 
+  /// Converts evolution of sub-shapes stored in naming structure to selection 
+  /// (theFlag = true) and back (theFlag = false)
+  virtual void evolutionToSelection(const bool theFlag) = 0;
+
 protected:
   /// Returns the data manager of this object: attributes
   MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Data> data() const;
index c05f5c7fe14e9d0753c5f9d95d006b20df29b528..6274305cac47ec7f679f84a0670c20bda2decac3 100644 (file)
@@ -21,7 +21,6 @@ class ModelAPI_Object;
 class ModelAPI_Result;
 class ModelAPI_ResultConstruction;
 class ModelAPI_ResultBody;
-class ModelAPI_ResultCompSolid;
 class ModelAPI_ResultPart;
 class ModelAPI_ResultGroup;
 class ModelAPI_ResultParameter;
@@ -124,9 +123,6 @@ public:
   //! Creates a body results
   virtual std::shared_ptr<ModelAPI_ResultBody> createBody(
       const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
-  /// Creates a compsolid results
-  virtual std::shared_ptr<ModelAPI_ResultCompSolid> createCompSolid(
-      const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
   //! Creates a part results
   virtual std::shared_ptr<ModelAPI_ResultPart> createPart(
       const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
index e7f96587c2be002f7acea66a403d83f1bb18efc9..3d8e5d57f27d488e0159feae9392c3867ed51f79 100644 (file)
@@ -85,7 +85,7 @@ void ModelAPI_Feature::eraseResultFromList(const std::shared_ptr<ModelAPI_Result
       static Events_Loop* aLoop = Events_Loop::loop();
       static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
       static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
-      ModelAPI_EventCreator::get()->sendDeleted(document(), aGroup);
+      aECreator->sendDeleted(document(), aGroup);
       aECreator->sendUpdated(aRes, EVENT_DISP);
       break;
     }
index 93b9961117164953345d83f5a99902d9d0360a40..5728190de96e895371b3285892d906e3b1c03009 100644 (file)
@@ -23,3 +23,94 @@ std::string ModelAPI_ResultBody::groupName()
   return group();
 }
 
+void ModelAPI_ResultBody::store(const std::shared_ptr<GeomAPI_Shape>& theShape)
+{
+  myBuilder->store(theShape);
+}
+
+void ModelAPI_ResultBody::storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
+                                 const std::shared_ptr<GeomAPI_Shape>& theToShape)
+{
+  myBuilder->storeGenerated(theFromShape, theToShape);
+}
+
+void ModelAPI_ResultBody::storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
+                                 const std::shared_ptr<GeomAPI_Shape>& theNewShape,
+                            const int theDecomposeSolidsTag)
+{
+  myBuilder->storeModified(theOldShape, theNewShape, theDecomposeSolidsTag);
+}
+
+std::shared_ptr<GeomAPI_Shape> ModelAPI_ResultBody::shape()
+{
+  return myBuilder->shape();
+}
+
+void ModelAPI_ResultBody::generated(const std::shared_ptr<GeomAPI_Shape>& theNewShape,
+    const std::string& theName, const int theTag)
+{
+  myBuilder->generated(theNewShape, theName, theTag);
+}
+
+void ModelAPI_ResultBody::generated(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
+    const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, 
+    const int theTag)
+{
+  myBuilder->generated(theOldShape, theNewShape, theName, theTag);
+}
+
+void ModelAPI_ResultBody::modified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
+    const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName,
+    const int theTag)
+{
+  myBuilder->modified(theOldShape, theNewShape, theName, theTag);
+}
+
+
+void ModelAPI_ResultBody::deleted(
+    const std::shared_ptr<GeomAPI_Shape>& theOldShape, const int theTag)
+{
+  myBuilder->deleted(theOldShape, theTag);
+}
+  
+void ModelAPI_ResultBody::loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
+                                  std::shared_ptr<GeomAPI_Shape>  theShapeIn,
+                                  const int  theKindOfShape,
+                                  const int  theTag)
+{
+  myBuilder->loadDeletedShapes(theMS, theShapeIn, theKindOfShape, theTag);
+}
+
+void ModelAPI_ResultBody::loadAndOrientModifiedShapes (GeomAlgoAPI_MakeShape* theMS,
+    std::shared_ptr<GeomAPI_Shape>  theShapeIn, const int  theKindOfShape, const int  theTag,
+    const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes)
+{
+  myBuilder->loadAndOrientModifiedShapes(
+    theMS, theShapeIn, theKindOfShape, theTag, theName, theSubShapes);
+}
+
+void ModelAPI_ResultBody::loadAndOrientGeneratedShapes (GeomAlgoAPI_MakeShape* theMS,
+    std::shared_ptr<GeomAPI_Shape>  theShapeIn, const int  theKindOfShape,
+    const int  theTag, const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes)
+{
+  myBuilder->loadAndOrientGeneratedShapes(
+    theMS, theShapeIn, theKindOfShape, theTag, theName, theSubShapes);
+}
+
+void ModelAPI_ResultBody::loadFirstLevel(std::shared_ptr<GeomAPI_Shape> theShape, 
+    const std::string& theName, int&  theTag)
+{
+  myBuilder->loadFirstLevel(theShape, theName, theTag);
+}
+
+void ModelAPI_ResultBody::loadDisconnectedEdges(std::shared_ptr<GeomAPI_Shape> theShape,
+    const std::string& theName, int&  theTag)
+{
+  myBuilder->loadDisconnectedEdges(theShape, theName, theTag);
+}
+
+void ModelAPI_ResultBody::loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape,
+    const std::string& theName,int&  theTag)
+{
+  myBuilder->loadDisconnectedVertexes(theShape, theName, theTag);
+}
index 8c5c9e6b9794186865e254f948606ba551301d1e..8a621e2c83fe661f0b87e38e8511318af710723d 100644 (file)
@@ -9,12 +9,11 @@
 
 #include "ModelAPI_Result.h"
 #include <GeomAPI_Shape.h>
-//#include <GeomAlgoAPI_MakeShape.h>
-//#include <GeomAPI_DataMapOfShapeShape.h>
-//#include <memory>
+#include <GeomAPI_DataMapOfShapeShape.h>
 #include <string>
 
 class ModelAPI_BodyBuilder;
+class GeomAlgoAPI_MakeShape;
 
 /**\class ModelAPI_ResultBody
 * \ingroup DataModel
@@ -45,77 +44,72 @@ 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;
+  MODELAPI_EXPORT virtual void store(const std::shared_ptr<GeomAPI_Shape>& theShape);
 
   /// 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;
+  MODELAPI_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).
-  virtual void storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
-                                 const std::shared_ptr<GeomAPI_Shape>& theNewShape,
-                            const int theDecomposeSolidsTag = 0) = 0;
+  MODELAPI_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
+  MODELAPI_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.
-  virtual void generated(
-    const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag = 1) = 0;
+  MODELAPI_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.
-  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;
+  MODELAPI_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.
-  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;
+  MODELAPI_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.
-  virtual void deleted(
-    const std::shared_ptr<GeomAPI_Shape>& theOldShape, const int theTag = 1) = 0;
+  MODELAPI_EXPORT virtual void deleted(
+    const std::shared_ptr<GeomAPI_Shape>& theOldShape, const int theTag = 1);
   
   /// load deleted shapes
-  virtual void loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
-                                               std::shared_ptr<GeomAPI_Shape>  theShapeIn,
-                                               const int  theKindOfShape,
-                                               const int  theTag) = 0;
+  MODELAPI_EXPORT virtual void loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
+                                  std::shared_ptr<GeomAPI_Shape>  theShapeIn,
+                                  const int  theKindOfShape,
+                                  const int  theTag);
   /// 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;
+  MODELAPI_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
-  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;
+  MODELAPI_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);
 
   /// 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;
+  MODELAPI_EXPORT virtual void loadFirstLevel(std::shared_ptr<GeomAPI_Shape> theShape, 
+    const std::string& theName, int&  theTag);
   
   /// load disconnected edges
-  virtual void loadDisconnectedEdges(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int&  theTag) = 0;
+  MODELAPI_EXPORT virtual void loadDisconnectedEdges(std::shared_ptr<GeomAPI_Shape> theShape,
+    const std::string& theName, int&  theTag);
 
   /// load disconnected vetexes
-  virtual void loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName,int&  theTag) = 0;
-  */
+  MODELAPI_EXPORT virtual void loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape,
+    const std::string& theName,int&  theTag);
+
 protected:
   MODELAPI_EXPORT ModelAPI_ResultBody();
 
-protected:
   ModelAPI_BodyBuilder* myBuilder; /// provide the body processing in naming shape
 };
 
index a953aaff78c218ab4ec545f88c8e9e5e0605e907..fb85fdb176b2bb290dc76bc6dca4868e4d66c1cc 100755 (executable)
@@ -26,10 +26,6 @@ public:
   /// Returns the feature is disabled or not.
   MODELAPI_EXPORT virtual bool isDisabled() const;
 
-  /// Adds result to the sketch and to its document
-  /// \param theIndex an index of the created body result in the compsolid
-  virtual std::shared_ptr<ModelAPI_ResultBody> addResult(const int theIndex) = 0;
-
   /// Returns the number of sub-elements
   virtual int numberOfSubs(bool forTree = false) const = 0;
 
@@ -37,16 +33,9 @@ public:
   virtual std::shared_ptr<ModelAPI_ResultBody> subResult(const int theIndex,
                                                          bool forTree = false) const = 0;
 
-  /// Returns the sub-feature unique identifier in this composite feature by zero-base index
-  //virtual int subResultId(const int theIndex) const = 0;
-
   /// Returns true if feature or reuslt belong to this composite feature as subs
   virtual bool isSub(ObjectPtr theObject) const = 0;
 
-  /// This method to inform that sub-feature is removed and must be removed from the internal data
-  /// structures of the owner (the remove from the document will be done outside just after)
-  virtual void removeResult(std::shared_ptr<ModelAPI_ResultBody> theResult) = 0;
-
 protected:
 };
 
index a8e174d123f9f56e19a1d1632ca3674b3cd17b91..a1e962da29b60ed26eede345e48143809dcc6dfa 100644 (file)
@@ -19,21 +19,6 @@ namespace ModelAPI_Tools {
 
 std::shared_ptr<GeomAPI_Shape> shape(const ResultPtr& theResult)
 {
-/*
-  ResultBodyPtr aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(theResult);
-  if (aBody)
-    return aBody->shape();
-
-  ResultConstructionPtr aConstruct = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(
-    theResult);
-  if (aConstruct)
-    return aConstruct->shape();
-
-  ResultGroupPtr aGroup = std::dynamic_pointer_cast<ModelAPI_ResultGroup>(theResult);
-  if (aGroup)
-    return aGroup->shape();
-  return std::shared_ptr<GeomAPI_Shape>();
-  */
   return theResult->shape();
 }