Salome HOME
Bug #740 - name of group entity is wrong
authordbv <dbv@opencascade.com>
Fri, 10 Jul 2015 12:10:14 +0000 (15:10 +0300)
committerdbv <dbv@opencascade.com>
Fri, 10 Jul 2015 12:47:31 +0000 (15:47 +0300)
src/FeaturesPlugin/FeaturesPlugin_CompositeBoolean.cpp
src/FeaturesPlugin/FeaturesPlugin_CompositeBoolean.h
src/FeaturesPlugin/FeaturesPlugin_ExtrusionBoolean.cpp
src/FeaturesPlugin/FeaturesPlugin_ExtrusionBoolean.h
src/FeaturesPlugin/FeaturesPlugin_RevolutionBoolean.cpp
src/FeaturesPlugin/FeaturesPlugin_RevolutionBoolean.h

index e15cf507aad3b7bf5c86a83ecf965627f822182e..56323a20b7fcef68cf61b5c661473016c5dd4f4e 100644 (file)
@@ -11,6 +11,8 @@
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_ResultConstruction.h>
 
+#include <GeomAlgoAPI_Prism.h>
+#include <GeomAlgoAPI_Revolution.h>
 #include <GeomAlgoAPI_ShapeProps.h>
 
 //=================================================================================================
@@ -118,7 +120,9 @@ void FeaturesPlugin_CompositeBoolean::execute()
   }
 
   // Pass faces to soldis creation function.
-  ListOfShape aBooleanTools = MakeSolids(aSketchFacesList);
+  ListOfShape aBooleanTools;
+  std::list<std::shared_ptr<GeomAPI_Interface>> theSolidsAlgos;
+  makeSolids(aSketchFacesList, aBooleanTools, theSolidsAlgos);
   if(aBooleanTools.empty()) {
     return;
   }
@@ -159,7 +163,7 @@ void FeaturesPlugin_CompositeBoolean::execute()
 
         if(GeomAlgoAPI_ShapeProps::volume(aBoolAlgo.shape()) > 1.e-7) {
           std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data(), aResultIndex);
-          LoadNamingDS(aResultBody, anObject, aBooleanTools, aBoolAlgo);
+          loadNamingDS(aResultBody, anObject, aSketchFacesList, theSolidsAlgos, aBooleanTools, aBoolAlgo);
           setResult(aResultBody, aResultIndex);
           aResultIndex++;
         }
@@ -177,7 +181,7 @@ void FeaturesPlugin_CompositeBoolean::execute()
       }
 
       std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data(), aResultIndex);
-      LoadNamingDS(aResultBody, aBooleanObjects.front(), aBooleanTools, aBoolAlgo);
+      loadNamingDS(aResultBody, aBooleanObjects.front(), aSketchFacesList, theSolidsAlgos, aBooleanTools, aBoolAlgo);
       setResult(aResultBody, aResultIndex);
       aResultIndex++;
       break;
@@ -193,8 +197,10 @@ void FeaturesPlugin_CompositeBoolean::execute()
 }
 
 //=================================================================================================
-void FeaturesPlugin_CompositeBoolean::LoadNamingDS(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+void FeaturesPlugin_CompositeBoolean::loadNamingDS(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
                                                    const std::shared_ptr<GeomAPI_Shape>& theBaseShape,
+                                                   const ListOfShape& theFaces,
+                                                   const std::list<std::shared_ptr<GeomAPI_Interface>>& theSolidsAlgos,
                                                    const ListOfShape& theTools,
                                                    const GeomAlgoAPI_Boolean& theAlgo)
 {
@@ -202,23 +208,69 @@ void FeaturesPlugin_CompositeBoolean::LoadNamingDS(std::shared_ptr<ModelAPI_Resu
   if(theBaseShape->isEqual(theAlgo.shape())) {
     theResultBody->store(theAlgo.shape());
   } else {
-    const int aModTag = 1;
-    const int aDeleteTag = 2;
-    const int aSubsolidsTag=3; /// sub solids will be placed at labels 3, 4, etc. if result is compound of solids
+    const int aGenTag = 1;
+    const int aFrTag = 2;
+    const int aToTag = 3;
+    const int aModTag = 4;
+    const int aDelTag = 5;
+    const int aSubsolidsTag=6; /// sub solids will be placed at labels 6, 7, etc. if result is compound of solids
+    const std::string aGenName = "Generated";
+    const std::string aModName = "Modified";
+    const std::string aLatName = "LateralFace";
+    const std::string aFrName = "FromFace";
+    const std::string aToName = "ToFace";
 
     theResultBody->storeModified(theBaseShape, theAlgo.shape(), aSubsolidsTag);
 
-    GeomAPI_DataMapOfShapeShape* aSubShapes = new GeomAPI_DataMapOfShapeShape();
+    ListOfShape::const_iterator aFaceIter = theFaces.begin();
+    std::list<std::shared_ptr<GeomAPI_Interface>>::const_iterator aSolidsAlgosIter = theSolidsAlgos.begin();
+    for(; aFaceIter != theFaces.end() && aSolidsAlgosIter != theSolidsAlgos.end(); aFaceIter++, aSolidsAlgosIter++) {
+      std::shared_ptr<GeomAPI_Shape> aFromFace;
+      std::shared_ptr<GeomAPI_Shape> aToFace;
+      std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes;
+
+      //Insert lateral face : Face from Edge
+      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,
+                                                    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,
+                                                    aLatName, *aSubShapes.get());
+        aFromFace = aRevolAlgo->firstShape();
+        aToFace = aRevolAlgo->lastShape();
+      }
+
+      //Insert bottom face
+      if(!aFromFace->isNull()) {
+        if(aSubShapes->isBound(aFromFace)) {
+          aFromFace = aSubShapes->find(aFromFace);
+        }
+        theResultBody->generated(aFromFace, aFrName, aFrTag);
+      }
+
+      //Insert top face
+      if (!aToFace->isNull()) {
+        if (aSubShapes->isBound(aToFace)) {
+          aToFace = aSubShapes->find(aToFace);
+        }
+        theResultBody->generated(aToFace, aToName, aToTag);
+      }
+    }
 
-    const std::string aModName = "Modified";
     theResultBody->loadAndOrientModifiedShapes(theAlgo.makeShape().get(), theBaseShape, GeomAPI_Shape::FACE,
                                                aModTag, aModName, *theAlgo.mapOfShapes().get());
-    theResultBody->loadDeletedShapes(theAlgo.makeShape().get(), theBaseShape, GeomAPI_Shape::FACE, aDeleteTag);
+    theResultBody->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,
                                                  aModTag, aModName, *theAlgo.mapOfShapes().get());
-      theResultBody->loadDeletedShapes(theAlgo.makeShape().get(), *anIter, GeomAPI_Shape::FACE, aDeleteTag);
+      theResultBody->loadDeletedShapes(theAlgo.makeShape().get(), *anIter, GeomAPI_Shape::FACE, aDelTag);
     }
   }
 }
index 6838e931bb972ef32f3995eeb0feaeaa67d5f175..0b16d5df7c0d95fa89bc2ed746abbb3e6371f58c 100644 (file)
@@ -68,10 +68,14 @@ protected:
   virtual void initMakeSolidsAttributes() = 0;
 
   /// Define this function to create solids from faces with extrusion/revolution.
-  virtual ListOfShape MakeSolids(const ListOfShape& theFaces) = 0;
+  virtual void makeSolids(const ListOfShape& theFaces,
+                          ListOfShape& theResults,
+                          std::list<std::shared_ptr<GeomAPI_Interface>>& theAlgos) = 0;
 
-  void LoadNamingDS(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+  void loadNamingDS(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
                     const std::shared_ptr<GeomAPI_Shape>& theBaseShape,
+                    const ListOfShape& theFaces,
+                    const std::list<std::shared_ptr<GeomAPI_Interface>>& theAlgos,
                     const ListOfShape& theTools,
                     const GeomAlgoAPI_Boolean& theAlgo);
 
index 2a564e95540dae77837132b211f7484e8500d60d..cc0b7b783e2eacf370bfa191a056ea2a4889f706 100644 (file)
@@ -33,7 +33,9 @@ void FeaturesPlugin_ExtrusionBoolean::initMakeSolidsAttributes()
 }
 
 //=================================================================================================
-ListOfShape FeaturesPlugin_ExtrusionBoolean::MakeSolids(const ListOfShape& theFaces)
+void FeaturesPlugin_ExtrusionBoolean::makeSolids(const ListOfShape& theFaces,
+                                                 ListOfShape& theResults,
+                                                 std::list<std::shared_ptr<GeomAPI_Interface>>& theAlgos)
 {
   // Getting extrusion sizes.
   double aToSize = 0.0;
@@ -69,18 +71,20 @@ ListOfShape FeaturesPlugin_ExtrusionBoolean::MakeSolids(const ListOfShape& theFa
   }
 
   // Extrude faces.
-  ListOfShape anExtrusionList;
+  theResults.clear();
   for(ListOfShape::const_iterator aFacesIt = theFaces.begin(); aFacesIt != theFaces.end(); aFacesIt++) {
     std::shared_ptr<GeomAPI_Shape> aBaseShape = *aFacesIt;
-    GeomAlgoAPI_Prism aPrismAlgo(aBaseShape, aToShape, aToSize, aFromShape, aFromSize);
+    std::shared_ptr<GeomAlgoAPI_Prism> aPrismAlgo = std::make_shared<GeomAlgoAPI_Prism>(aBaseShape,
+                                                                                        aToShape, aToSize,
+                                                                                        aFromShape, aFromSize);
 
     // Checking that the algorithm worked properly.
-    if(!aPrismAlgo.isDone() || aPrismAlgo.shape()->isNull() || !aPrismAlgo.isValid()) {
+    if(!aPrismAlgo->isDone() || aPrismAlgo->shape()->isNull() || !aPrismAlgo->isValid()) {
       setError("Extrusion algorithm failed");
-      return ListOfShape();
+      theResults.clear();
+      return;
     }
-    anExtrusionList.push_back(aPrismAlgo.shape());
+    theResults.push_back(aPrismAlgo->shape());
+    theAlgos.push_back(aPrismAlgo);
   }
-
-  return anExtrusionList;
 }
\ No newline at end of file
index f83ec91474e3acf91e6ca45902eb3c5de8a91d2c..6ae91aeec7ded5744b9410fcdf504db90dddf639 100644 (file)
@@ -70,7 +70,9 @@ protected:
   virtual void initMakeSolidsAttributes();
 
   /// Create solids from faces with extrusion.
-  virtual ListOfShape MakeSolids(const ListOfShape& theFaces);
+  virtual void makeSolids(const ListOfShape& theFaces,
+                          ListOfShape& theResults,
+                          std::list<std::shared_ptr<GeomAPI_Interface>>& theAlgos);
 
 protected:
   FeaturesPlugin_ExtrusionBoolean(){};
index ef3af8ec681fefc767839551d2aa0a006affb61e..7fd3e44cdfbebd936661899d0c745375dac657a6 100644 (file)
@@ -37,7 +37,9 @@ void FeaturesPlugin_RevolutionBoolean::initMakeSolidsAttributes()
 }
 
 //=================================================================================================
-ListOfShape FeaturesPlugin_RevolutionBoolean::MakeSolids(const ListOfShape& theFaces)
+void FeaturesPlugin_RevolutionBoolean::makeSolids(const ListOfShape& theFaces,
+                                                  ListOfShape& theResults,
+                                                  std::list<std::shared_ptr<GeomAPI_Interface>>& theAlgos)
 {
   //Getting axis.
   std::shared_ptr<GeomAPI_Ax1> anAxis;
@@ -86,18 +88,20 @@ ListOfShape FeaturesPlugin_RevolutionBoolean::MakeSolids(const ListOfShape& theF
   }
 
   // Revol faces.
-  ListOfShape aRevolutionList;
+  theResults.clear();
   for(ListOfShape::const_iterator aFacesIt = theFaces.begin(); aFacesIt != theFaces.end(); aFacesIt++) {
     std::shared_ptr<GeomAPI_Shape> aBaseShape = *aFacesIt;
-    GeomAlgoAPI_Revolution aRevolAlgo(aBaseShape, anAxis, aToShape, aToAngle, aFromShape, aFromAngle);
+    std::shared_ptr<GeomAlgoAPI_Revolution> aRevolAlgo = std::make_shared<GeomAlgoAPI_Revolution>(aBaseShape, anAxis,
+                                                                                                  aToShape, aToAngle,
+                                                                                                  aFromShape, aFromAngle);
 
     // Checking that the algorithm worked properly.
-    if(!aRevolAlgo.isDone() || aRevolAlgo.shape()->isNull() || !aRevolAlgo.isValid()) {
+    if(!aRevolAlgo->isDone() || aRevolAlgo->shape()->isNull() || !aRevolAlgo->isValid()) {
       setError("Revolution algorithm failed");
-      return ListOfShape();
+      theResults.clear();
+      return;
     }
-    aRevolutionList.push_back(aRevolAlgo.shape());
+    theResults.push_back(aRevolAlgo->shape());
+    theAlgos.push_back(aRevolAlgo);
   }
-
-  return aRevolutionList;
 }
\ No newline at end of file
index 3e8576aad1484019b304eea28ff92e5ef9781b82..ce01edd8078b0a25f2c27c7e48b989c924cd67e2 100644 (file)
@@ -76,7 +76,9 @@ protected:
   virtual void initMakeSolidsAttributes();
 
   /// Create solids from faces with revolution.
-  virtual ListOfShape MakeSolids(const ListOfShape& theFaces);
+  virtual void makeSolids(const ListOfShape& theFaces,
+                          ListOfShape& theResults,
+                          std::list<std::shared_ptr<GeomAPI_Interface>>& theAlgos);
 
 protected:
   FeaturesPlugin_RevolutionBoolean(){};