]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
29.10.2014.Extrusion feature update.
authorszy <szy@opencascade.com>
Wed, 29 Oct 2014 12:41:54 +0000 (15:41 +0300)
committerszy <szy@opencascade.com>
Wed, 29 Oct 2014 12:41:54 +0000 (15:41 +0300)
16 files changed:
src/ExchangePlugin/CMakeLists.txt
src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp
src/FeaturesPlugin/FeaturesPlugin_Extrusion.h
src/GeomAPI/GeomAPI_DataMapOfShapeShape.cpp
src/GeomAPI/GeomAPI_DataMapOfShapeShape.h
src/GeomAlgoAPI/GeomAlgoAPI_DFLoader.cpp
src/GeomAlgoAPI/GeomAlgoAPI_DFLoader.h
src/GeomAlgoAPI/GeomAlgoAPI_Extrusion.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Extrusion.h
src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.cpp
src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h
src/Model/Model_ResultBody.cpp
src/Model/Model_ResultBody.h
src/ModelAPI/CMakeLists.txt
src/ModelAPI/ModelAPI_ResultBody.h
src/XGUI/CMakeLists.txt

index ad3f24fdf9f15be9edb5ddef92e407c031a1a9a7..8200a6d93799cf1ffb92664fd0ce207de1224fce 100644 (file)
@@ -4,6 +4,7 @@ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/Events
                     ${PROJECT_SOURCE_DIR}/src/Config
                     ${PROJECT_SOURCE_DIR}/src/ModelAPI
                     ${PROJECT_SOURCE_DIR}/src/GeomAPI
+                    ${PROJECT_SOURCE_DIR}/src/GeomAlgoAPI
                     ${CAS_INCLUDE_DIRS}
 ) 
 
index b32f2e97a5e09841d36fb2602636c248b78121f4..eeafb1db61e0e7557ff59706166146f75c41b219 100644 (file)
@@ -18,6 +18,7 @@ using namespace std;
 #define _LATERAL_TAG 1
 #define _FIRST_TAG 2
 #define _LAST_TAG 3
+#define EDGE 6
 #ifdef _DEBUG
 #include <iostream>
 #include <ostream>
@@ -65,7 +66,6 @@ void FeaturesPlugin_Extrusion::execute()
     aSize = -aSize;
 
   boost::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data());
-  //TCollection_AsciiString anError;
   GeomAlgoAPI_Extrusion aFeature(aFace, aSize);
   if(!aFeature.isDone()) {
     std::string aFeatureError = "Extrusion algorithm failed";  
@@ -105,44 +105,19 @@ void FeaturesPlugin_Extrusion::LoadNamingDS(GeomAlgoAPI_Extrusion& theFeature,
   if(theBasis->isEqual(theContext))
     theResultBody->store(theFeature.shape());
   else
-    theResultBody->storeGenerated(theContext, theFeature.shape());
-  /*
-  TopTools_DataMapOfShapeShape aSubShapes;
-  for (TopExp_Explorer Exp(theFeature.shape()->impl<TopoDS_Shape>(),TopAbs_FACE); Exp.More(); Exp.Next()) {
-    aSubShapes.Bind(Exp.Current(),Exp.Current());
-  }
+    theResultBody->storeGenerated(theContext, theFeature.shape()); 
+
+  GeomAPI_DataMapOfShapeShape* aSubShapes = new GeomAPI_DataMapOfShapeShape();
+  theFeature.mapOfShapes(*aSubShapes);
+
+    //Insert lateral face : Face from Edge
+  theResultBody->loadAndOrientGeneratedShapes(theFeature.makeShape(), theFeature.shape(), EDGE,_LATERAL_TAG, *aSubShapes);
 
-  //Insert lateral face : Face from Edge
-  //GeomAlgoAPI_DFLoader::loadAndOrientGeneratedShapes(*myBuilder, myBasis, TopAbs_EDGE, aLateralFaceBuilder, aSubShapes);
-
-
-  TopTools_MapOfShape aView;
-  TopExp_Explorer aShapeExplorer (theFeature.shape()->impl<TopoDS_Shape>(), TopAbs_EDGE);
-  for (; aShapeExplorer.More(); aShapeExplorer.Next ()) {
-    const TopoDS_Shape& aRoot = aShapeExplorer.Current ();
-    if (!aView.Add(aRoot)) continue;
-    boost::shared_ptr<GeomAPI_Shape> aRootG(new GeomAPI_Shape());
-    aRootG->setImpl((void *)&aRoot);
-    const ListOfShape& aShapes = theFeature.generated(aRootG);
-    std::list<boost::shared_ptr<GeomAPI_Shape> >::const_iterator anIt = aShapes.begin(), aLast = aShapes.end();          
-    for (; anIt != aLast; anIt++) {
-      TopoDS_Shape aNewShape = (*anIt)->impl<TopoDS_Shape>(); 
-      if (aSubShapes.IsBound(aNewShape)) {
-        aNewShape.Orientation((aSubShapes(aNewShape)).Orientation());
-      }
-
-      if (!aRoot.IsSame (aNewShape)) {
-        boost::shared_ptr<GeomAPI_Shape> aNew(new GeomAPI_Shape());
-        aNew->setImpl((void *)&aNewShape);
-        theResultBody->generated(aRootG, aNew,_LATERAL_TAG); 
-      }
-    }
-  }
   //Insert bottom face
-  const boost::shared_ptr<GeomAPI_Shape>& aBottomFace = theFeature.firstShape();
+  boost::shared_ptr<GeomAPI_Shape> aBottomFace = theFeature.firstShape();  
   if (!aBottomFace->isNull()) {
-    if (aSubShapes.IsBound(aBottomFace->impl<TopoDS_Shape>())) {
-      aBottomFace->setImpl((void *)&aSubShapes(aBottomFace->impl<TopoDS_Shape>()));
+       if (aSubShapes->isBound(aBottomFace)) {  
+               aBottomFace = aSubShapes->find(aBottomFace);            
     }    
     theResultBody->generated(aBottomFace, _FIRST_TAG);
   }
@@ -152,11 +127,11 @@ void FeaturesPlugin_Extrusion::LoadNamingDS(GeomAlgoAPI_Extrusion& theFeature,
   //Insert top face
   boost::shared_ptr<GeomAPI_Shape> aTopFace = theFeature.lastShape();
   if (!aTopFace->isNull()) {
-    if (aSubShapes.IsBound(aTopFace->impl<TopoDS_Shape>())) {
-      aTopFace->setImpl((void *)&aSubShapes(aTopFace->impl<TopoDS_Shape>()));
+    if (aSubShapes->isBound(aTopFace)) {        
+      aTopFace = aSubShapes->find(aTopFace);   
     }
-    theResultBody->generated(aTopFace, _FIRST_TAG);
+    theResultBody->generated(aTopFace, _LAST_TAG);
   }
-  */
 
+  
 }
index d136c84915156754b490365fc715d73ad09d2d91..c6c500fe211a9caaab4ddbd2f1b6852f9a81db32 100644 (file)
@@ -9,6 +9,7 @@
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_ResultBody.h>
 #include <GeomAlgoAPI_Extrusion.h>
+#include <GeomAPI_Shape.h>
 class FeaturesPlugin_Extrusion : public ModelAPI_Feature
 {
  public:
index b573c5a0ad685452a4fcffdce14b17864843c0e4..56002d3a58018623bd1bc2895313e9f52124003b 100644 (file)
@@ -5,6 +5,7 @@
 #include <GeomAPI_Shape.h>
 #include <GeomAPI_DataMapOfShapeShape.h>
 #include <TopTools_DataMapOfShapeShape.hxx>
+#include <TopoDS_Shape.hxx>
 using namespace std;
 
 
@@ -18,7 +19,7 @@ void GeomAPI_DataMapOfShapeShape::clear()
 }
 
 /// Adds the Key <K> to  the Map <me>  with  the  Item. Returns True  if the Key  was not already in the map
-bool GeomAPI_DataMapOfShapeShape::bind (const boost::shared_ptr<GeomAPI_Shape>& theKey, const boost::shared_ptr<GeomAPI_Shape>& theItem)
+bool GeomAPI_DataMapOfShapeShape::bind (boost::shared_ptr<GeomAPI_Shape> theKey, boost::shared_ptr<GeomAPI_Shape> theItem)
 {
   bool flag(false);
   if(implPtr<TopTools_DataMapOfShapeShape>()->Bind(theKey->impl<TopoDS_Shape>(), theItem->impl<TopoDS_Shape>()))
@@ -27,7 +28,7 @@ bool GeomAPI_DataMapOfShapeShape::bind (const boost::shared_ptr<GeomAPI_Shape>&
 }
 
 /// Returns true if theKey is stored  in the map.
-bool GeomAPI_DataMapOfShapeShape::isBound (const boost::shared_ptr<GeomAPI_Shape>& theKey)
+bool GeomAPI_DataMapOfShapeShape::isBound (boost::shared_ptr<GeomAPI_Shape> theKey)
 {
   bool flag(false);
   if(impl<TopTools_DataMapOfShapeShape>().IsBound(theKey->impl<TopoDS_Shape>()))
@@ -36,18 +37,26 @@ bool GeomAPI_DataMapOfShapeShape::isBound (const boost::shared_ptr<GeomAPI_Shape
 }
 
 /// Returns  the Item stored  with the Key in the Map. To be checked before with isBound()
-const boost::shared_ptr<GeomAPI_Shape> GeomAPI_DataMapOfShapeShape::find(const boost::shared_ptr<GeomAPI_Shape>& theKey)
+const boost::shared_ptr<GeomAPI_Shape> GeomAPI_DataMapOfShapeShape::find(boost::shared_ptr<GeomAPI_Shape> theKey)
 {
   boost::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());  
-  aShape->setImpl((void *)&(impl<TopTools_DataMapOfShapeShape>().Find(theKey->impl<TopoDS_Shape>())));
+  aShape->setImpl(new TopoDS_Shape(impl<TopTools_DataMapOfShapeShape>().Find(theKey->impl<TopoDS_Shape>())));
   return aShape;
 }  
   
 /// Removes the Key from the  map. Returns true if the Key was in the Map
-bool GeomAPI_DataMapOfShapeShape::unBind(const boost::shared_ptr<GeomAPI_Shape>& theKey)
+bool GeomAPI_DataMapOfShapeShape::unBind(boost::shared_ptr<GeomAPI_Shape> theKey)
 {
   bool flag(false);
   if(implPtr<TopTools_DataMapOfShapeShape>()->UnBind(theKey->impl<TopoDS_Shape>()))
        flag = true;
   return flag;
-}
\ No newline at end of file
+}
+
+ GeomAPI_DataMapOfShapeShape::~GeomAPI_DataMapOfShapeShape()
+ {
+  if (myImpl) {
+       implPtr<TopTools_DataMapOfShapeShape>()->Clear();
+    //delete myImpl;
+  }
+ }
\ No newline at end of file
index 119cfda0ee5ad624fa213fa878d35108cf1005a3..20b63903afe1b72998522857b96d60d7fcf4eaf4 100644 (file)
@@ -26,16 +26,19 @@ class GEOMAPI_EXPORT GeomAPI_DataMapOfShapeShape : public GeomAPI_Interface
   void clear();
 
   /// Adds the Key <K> to  the Map <me>  with  the  Item. Returns True  if the Key  was not already in the map
-  bool bind (const boost::shared_ptr<GeomAPI_Shape>& theKey, const boost::shared_ptr<GeomAPI_Shape>& theItem);
+  bool bind (boost::shared_ptr<GeomAPI_Shape> theKey, boost::shared_ptr<GeomAPI_Shape> theItem);
 
   /// Returns true if theKey is stored  in the map.
-  bool isBound (const boost::shared_ptr<GeomAPI_Shape>& theKey);
+  bool isBound (boost::shared_ptr<GeomAPI_Shape> theKey);
 
   /// Returns  the Item stored  with the Key in the Map.
-  const boost::shared_ptr<GeomAPI_Shape> find(const boost::shared_ptr<GeomAPI_Shape>& theKey);  
+  const boost::shared_ptr<GeomAPI_Shape> find(boost::shared_ptr<GeomAPI_Shape> theKey);  
   
   /// Removes the Key from the  map. Returns true if the Key was in the Map
-  bool unBind(const boost::shared_ptr<GeomAPI_Shape>& theKey);
+  bool unBind(boost::shared_ptr<GeomAPI_Shape> theKey);
+
+  /// Destructor
+  ~GeomAPI_DataMapOfShapeShape();
 };
 
 #endif
index d309de4a26e573d85a930dae7f92738f839161bf..89fb0237b90da2e6df870adce9476e08f2572154 100644 (file)
@@ -25,79 +25,3 @@ const TopoDS_Shape GeomAlgoAPI_DFLoader::refineResult(const  TopoDS_Shape& theRe
   }
   return aResult;
 }
-/*
-//=======================================================================
-//function : loadDeletedShapes
-//purpose  : load deleted shapes in DF
-//=======================================================================
-void GeomAlgoAPI_DFLoader::loadDeletedShapes (BRepBuilderAPI_MakeShape& theMS,
-                                       const TopoDS_Shape&     theShapeIn,
-                                       const TopAbs_ShapeEnum  theKindOfShape,
-                                       TNaming_Builder&        theBuilder)
-{
-  TopTools_MapOfShape aView;
-  TopExp_Explorer ShapeExplorer (theShapeIn, theKindOfShape);
-  for (; ShapeExplorer.More(); ShapeExplorer.Next ()) {
-    const TopoDS_Shape& aRoot = ShapeExplorer.Current ();
-    if (!aView.Add(aRoot)) continue;
-    if (theMS.IsDeleted (aRoot)) {
-      theBuilder.Delete (aRoot);
-    }
-  }
-}
-
-//=======================================================================
-//function : loadAndOrientModifiedShapes
-//purpose  : load modified shapes in DF with preliminary orientation adjustment
-//=======================================================================
-void GeomAlgoAPI_DFLoader::loadAndOrientModifiedShapes (BRepBuilderAPI_MakeShape&    theMS,
-                                           const TopoDS_Shape&        theShapeIn,
-                                           const TopAbs_ShapeEnum     theKindOfShape,
-                                           TNaming_Builder&           theBuilder,
-                                           const TopTools_DataMapOfShapeShape& theSubShapes)
-{
-  TopTools_MapOfShape aView;
-  TopExp_Explorer aShapeExplorer (theShapeIn, theKindOfShape);
-  for (; aShapeExplorer.More(); aShapeExplorer.Next ()) {
-    const TopoDS_Shape& aRoot = aShapeExplorer.Current ();
-    if (!aView.Add(aRoot)) continue;
-    const TopTools_ListOfShape& aShapes = theMS.Modified (aRoot);
-    TopTools_ListIteratorOfListOfShape aShapesIterator (aShapes);
-    for (;aShapesIterator.More (); aShapesIterator.Next ()) {
-      TopoDS_Shape aNewShape = aShapesIterator.Value ();
-      if (theSubShapes.IsBound(aNewShape)) {
-        aNewShape.Orientation((theSubShapes(aNewShape)).Orientation());
-      }
-      if (!aRoot.IsSame (aNewShape)) theBuilder.Modify (aRoot, aNewShape );
-    }
-  }
-}
-
-//=======================================================================
-//function : loadAndOrientGeneratedShapes
-//purpose  : load generated shapes in DF with preliminary orientation adjustment
-//=======================================================================
-
-void GeomAlgoAPI_DFLoader::loadAndOrientGeneratedShapes (BRepBuilderAPI_MakeShape&     theMS,
-                                                const TopoDS_Shape&           theShapeIn,
-                                                const TopAbs_ShapeEnum        theKindOfShape,
-                                                TNaming_Builder&              theBuilder,
-                                                const TopTools_DataMapOfShapeShape&    theSubShapes)
-{
-  TopTools_MapOfShape aView;
-  TopExp_Explorer aShapeExplorer (theShapeIn, theKindOfShape);
-  for (; aShapeExplorer.More(); aShapeExplorer.Next ()) {
-    const TopoDS_Shape& aRoot = aShapeExplorer.Current ();
-    if (!aView.Add(aRoot)) continue;
-    const TopTools_ListOfShape& aShapes = theMS.Generated (aRoot);
-    TopTools_ListIteratorOfListOfShape aShapesIterator (aShapes);
-    for (;aShapesIterator.More (); aShapesIterator.Next ()) {
-      TopoDS_Shape aNewShape = aShapesIterator.Value ();
-      if (theSubShapes.IsBound(aNewShape)) {
-        aNewShape.Orientation((theSubShapes(aNewShape)).Orientation());
-      }
-      if (!aRoot.IsSame (aNewShape)) theBuilder.Generated (aRoot,aNewShape );
-    }
-  }
-}
-*/
\ No newline at end of file
index 815b8cbee5dd1450a1bb7915ee6f54a3646b1092..766e0c734a18b71df50df0b864bbdc2588453c54 100644 (file)
@@ -5,12 +5,7 @@
 #ifndef GeomAlgoAPI_DFLoader_H_
 #define GeomAlgoAPI_DFLoader_H_
 #include <GeomAlgoAPI.h>
-//#include <boost/shared_ptr.hpp>
-#include <BRepBuilderAPI_MakeShape.hxx>
 #include <TopoDS_Shape.hxx>
-#include <TNaming_Builder.hxx>
-#include <TopAbs_ShapeEnum.hxx>
-#include <TopTools_DataMapOfShapeShape.hxx>
 
 /**\class GeomAlgoAPI_DFLoader
  * \ingroup DataAlgo
 class GEOMALGOAPI_EXPORT GeomAlgoAPI_DFLoader 
 {
  public:
-        /*
-  /// Loads to DF deleted shapes
-  static void loadDeletedShapes (BRepBuilderAPI_MakeShape& theMS, const TopoDS_Shape& theShapeIn,
-                                 const TopAbs_ShapeEnum  KindOfShape, TNaming_Builder&  theBuilder);
-
-  /// Loads to DF generated shapes
-  static void loadAndOrientGeneratedShapes (BRepBuilderAPI_MakeShape&                  theMS,
-                                            const TopoDS_Shape&                 theShapeIn,
-                                            const TopAbs_ShapeEnum              theKindOfShape,
-                                            TNaming_Builder&                    theBuilder,
-                                            const TopTools_DataMapOfShapeShape& theSubShapes);
-  /// Loads to DF modified shapes 
-  static void loadAndOrientModifiedShapes (BRepBuilderAPI_MakeShape&                   theMS,
-                                           const TopoDS_Shape&                  theShapeIn,
-                                           const TopAbs_ShapeEnum               theKindOfShape,
-                                           TNaming_Builder&                     theBuilder,
-                                           const TopTools_DataMapOfShapeShape&  theSubShapes);
-  */
   /// Refine result
   static const TopoDS_Shape refineResult(const TopoDS_Shape& theShape);
 };
index b81b0f5fe2b1fa09b9a9150b70ac6ba4dac3f7d7..6955ee89a96e993929a0865ef9d6147cff0cad5f 100644 (file)
@@ -5,7 +5,7 @@
 #include <GeomAlgoAPI_Extrusion.h>
 #include <GeomAlgoAPI_MakeShape.h>
 #include <GeomAlgoAPI_DFLoader.h>
-#include <GeomAlgoAPI_DFLoader.h>
+#include <GeomAlgoAPI_MakeShape.h>
 #include <gp_Pln.hxx>
 #include <BRepPrimAPI_MakePrism.hxx>
 #include <BRepBuilderAPI_MakeShape.hxx>
@@ -27,8 +27,8 @@ const double tolerance = Precision::Angular();
 // Constructor
 GeomAlgoAPI_Extrusion::GeomAlgoAPI_Extrusion(
   boost::shared_ptr<GeomAPI_Shape> theBasis, double theSize)
-: mySize(theSize), myDone(false),
-  myShape(new GeomAPI_Shape()), myFirst(new GeomAPI_Shape()), myLast(new GeomAPI_Shape())
+: mySize(theSize), myDone(false), myShape(new GeomAPI_Shape()),
+  myFirst(new GeomAPI_Shape()), myLast(new GeomAPI_Shape())
 {
   build(theBasis);
 }
@@ -39,7 +39,6 @@ void GeomAlgoAPI_Extrusion::build(const boost::shared_ptr<GeomAPI_Shape>& theBas
   bool isFirstNorm = true;
   gp_Dir aShapeNormal;
 
-  //const TopoDS_Shape& aShape = theShape->impl<TopoDS_Shape>(); 
   TopoDS_Face aBasis = TopoDS::Face(theBasis->impl<TopoDS_Shape>());
   Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(
     BRep_Tool::Surface(aBasis));
@@ -64,9 +63,17 @@ void GeomAlgoAPI_Extrusion::build(const boost::shared_ptr<GeomAPI_Shape>& theBas
         aResult = GeomAlgoAPI_DFLoader::refineResult(aBuilder->Shape());
       else
         aResult = aBuilder->Shape();
+       
+       for (TopExp_Explorer Exp(aResult,TopAbs_FACE); Exp.More(); Exp.Next()) {
+          boost::shared_ptr<GeomAPI_Shape> aCurrentShape(new GeomAPI_Shape());
+       aCurrentShape->setImpl(new TopoDS_Shape(Exp.Current()));
+          myMap.bind(aCurrentShape, aCurrentShape);
+       }   
       myShape->setImpl(new TopoDS_Shape(aResult));
       myFirst->setImpl(new TopoDS_Shape(aBuilder->FirstShape()));
       myLast->setImpl(new TopoDS_Shape(aBuilder-> LastShape()));
+         myMkShape = new GeomAlgoAPI_MakeShape (aBuilder);
     }
   }    
 }
@@ -100,7 +107,7 @@ const boost::shared_ptr<GeomAPI_Shape>& GeomAlgoAPI_Extrusion::shape () const
 {return myShape;}
 
 //============================================================================
-void GeomAlgoAPI_Extrusion::generated(
+/*void GeomAlgoAPI_Extrusion::generated(
   const boost::shared_ptr<GeomAPI_Shape> theShape, ListOfShape& theHistory)
 {
   theHistory.clear();
@@ -115,7 +122,7 @@ void GeomAlgoAPI_Extrusion::generated(
     }
   }
 }
-
+*/
 //============================================================================
 const boost::shared_ptr<GeomAPI_Shape>& GeomAlgoAPI_Extrusion::firstShape()
 {
@@ -129,71 +136,22 @@ const boost::shared_ptr<GeomAPI_Shape>& GeomAlgoAPI_Extrusion::lastShape()
 }
 
 //============================================================================
-/*
-void GeomAlgoAPI_Extrusion::LoadNamingDS(boost::shared_ptr<ModelAPI_ResultBody> theResultBody, 
-boost::shared_ptr<GeomAPI_Shape> theContext)
+void GeomAlgoAPI_Extrusion::mapOfShapes (GeomAPI_DataMapOfShapeShape& theMap) const
 {
-if(isValid()) {
-const TopoDS_Shape& aShape = myBuilder->Shape();
-TopoDS_Shape aResult = GeomAlgoAPI_DFLoader::refineResult(aShape);
-boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>(theResultBody->data());
-if (aData) {
-const TDF_Label& aShapeLab = aData->shapeLab();
-const Handle(TDF_TagSource)& Tagger = TDF_TagSource::Set(aShapeLab);
-if (Tagger.IsNull()) return;
-Tagger->Set(0);
-
-TNaming_Builder aBuilder (aShapeLab);
-if(myBasis.IsEqual(theContext->impl<TopoDS_Shape>()))
-aBuilder.Generated(aResult);
-else
-aBuilder.Generated(theContext->impl<TopoDS_Shape>(), aResult);
-
-TopTools_DataMapOfShapeShape aSubShapes;
-for (TopExp_Explorer Exp(aResult,TopAbs_FACE); Exp.More(); Exp.Next()) {
-aSubShapes.Bind(Exp.Current(),Exp.Current());
-}
-
-//Insert lateral face : Face from Edge
-TNaming_Builder  aLateralFaceBuilder(aShapeLab.NewChild());
-GeomAlgoAPI_DFLoader::loadAndOrientGeneratedShapes(*myBuilder, myBasis, TopAbs_EDGE, aLateralFaceBuilder, aSubShapes);
-
-//Insert bottom face
-TopoDS_Shape aBottomFace = myBuilder->FirstShape();
-if (!aBottomFace.IsNull()) {
-if (aBottomFace.ShapeType() != TopAbs_COMPOUND) {
-TNaming_Builder aBottomBuilder(aShapeLab.NewChild());  //2
-if (aSubShapes.IsBound(aBottomFace)) {
-aBottomFace = aSubShapes(aBottomFace);
-}
-aBottomBuilder.Generated(aBottomFace);
-} else {
-TopoDS_Iterator itr(aBottomFace);
-for (; itr.More(); itr.Next()) {
-TNaming_Builder aBottomBuilder(aShapeLab.NewChild());
-aBottomBuilder.Generated(itr.Value());
-}
+  theMap = myMap;
 }
 
+//============================================================================
+GeomAlgoAPI_MakeShape * GeomAlgoAPI_Extrusion::makeShape() const
+{
+  return myMkShape;
 }
 
-//Insert top face
-TopoDS_Shape aTopFace = myBuilder->LastShape();
-if (!aTopFace.IsNull()) {
-if (aTopFace.ShapeType() != TopAbs_COMPOUND) {
-TNaming_Builder aTopBuilder(aShapeLab.NewChild()); //3
-if (aSubShapes.IsBound(aTopFace)) {
-aTopFace = aSubShapes(aTopFace);
-}
-aTopBuilder.Generated(aTopFace);
-} else {
-TopoDS_Iterator itr(aTopFace);
-for (; itr.More(); itr.Next()) {
-TNaming_Builder aTopBuilder(aShapeLab.NewChild());
-aTopBuilder.Generated(itr.Value());
-}
-}
-}
-}
-}
-*/
\ No newline at end of file
+//============================================================================
+GeomAlgoAPI_Extrusion::~GeomAlgoAPI_Extrusion()
+{
+  if (myImpl) {    
+       myMap.clear();
+       //delete myImpl;
+  }
+}
\ No newline at end of file
index bebeb35f5cdbb70df4b18946f26dcbfb6ae1137a..7a033a6aeb61c1095994bfa7553a5f9f88557350 100644 (file)
@@ -9,13 +9,15 @@
 #include <GeomAPI_Shape.h>
 #include <GeomAPI_Dir.h>
 #include <ModelAPI_ResultBody.h>
+#include <GeomAlgoAPI_MakeShape.h>
+#include <GeomAPI_DataMapOfShapeShape.h>
 #include <boost/shared_ptr.hpp>
 /**\class GeomAlgoAPI_Extrusion
  * \ingroup DataAlgo
  * \brief Allows to create the prism based on a given face and a direction
  */
 
-class GeomAlgoAPI_Extrusion : public GeomAPI_Interface
+class GeomAlgoAPI_Extrusion : public GeomAPI_Interface//GeomAlgoAPI_MakeShape
 {
  public:
 
@@ -44,15 +46,21 @@ class GeomAlgoAPI_Extrusion : public GeomAPI_Interface
   GEOMALGOAPI_EXPORT const boost::shared_ptr<GeomAPI_Shape>& shape () const;
 
   /// Returns list of shapes generated from theShape
-  GEOMALGOAPI_EXPORT void generated(const boost::shared_ptr<GeomAPI_Shape> theShape,
-                                    ListOfShape& theHistory);
// GEOMALGOAPI_EXPORT void generated(const boost::shared_ptr<GeomAPI_Shape> theShape,
+                                   // ListOfShape& theHistory);
 
   /// Returns the first shape 
   GEOMALGOAPI_EXPORT const boost::shared_ptr<GeomAPI_Shape>& firstShape();
 
   /// returns last shape
-  GEOMALGOAPI_EXPORT const boost::shared_ptr<GeomAPI_Shape>& lastShape();       
+  GEOMALGOAPI_EXPORT const boost::shared_ptr<GeomAPI_Shape>& lastShape();      
+  /// Returns map of sub-shapes of the result
+  GEOMALGOAPI_EXPORT void  mapOfShapes (GeomAPI_DataMapOfShapeShape& theMap) const;
 
+  GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShape* makeShape () const;
+
+  GEOMALGOAPI_EXPORT  ~GeomAlgoAPI_Extrusion();
 private:
   /// builds resulting shape
   void build(const boost::shared_ptr<GeomAPI_Shape>& theBasis);
@@ -62,6 +70,8 @@ private:
   boost::shared_ptr<GeomAPI_Shape> myShape;
   boost::shared_ptr<GeomAPI_Shape> myFirst;
   boost::shared_ptr<GeomAPI_Shape> myLast;
+  GeomAPI_DataMapOfShapeShape myMap;
+  GeomAlgoAPI_MakeShape * myMkShape;
 };
 
 #endif
index 679526befc0e3e94fad7d9fa0f636cd8516ac822..70cfad9f831744218604d9b6ffd778533a6f042e 100644 (file)
@@ -3,11 +3,22 @@
 // Author:      Sergey ZARITCHNY
 
 #include <GeomAlgoAPI_MakeShape.h>
+#include <BRepBuilderAPI_MakeShape.hxx>
 #include <TopTools_ListOfShape.hxx>
 #include <TopTools_ListIteratorOfListOfShape.hxx>
 GeomAlgoAPI_MakeShape::GeomAlgoAPI_MakeShape(void* theMkShape)
-  : GeomAPI_Interface(theMkShape)
+  : GeomAPI_Interface(theMkShape),myShape(new GeomAPI_Shape())
+{
+  myShape->setImpl((void *)&implPtr<BRepBuilderAPI_MakeShape>()->Shape());
+}
+
+GeomAlgoAPI_MakeShape::GeomAlgoAPI_MakeShape()
+  : GeomAPI_Interface(),myShape(new GeomAPI_Shape())
 {}
+void GeomAlgoAPI_MakeShape::init(void* theMkShape)
+{
+  setImpl((void *)implPtr<BRepBuilderAPI_MakeShape>());
+}
 
 const boost::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_MakeShape::shape() const
 {
@@ -24,7 +35,7 @@ void GeomAlgoAPI_MakeShape::generated(
     TopTools_ListIteratorOfListOfShape it(aList);
     for(;it.More();it.Next()) {
       boost::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
-      aShape->setImpl(&(it.Value()));
+      aShape->setImpl(new TopoDS_Shape(it.Value()));
       theHistory.push_back(aShape);
     }
   }
@@ -40,7 +51,7 @@ void GeomAlgoAPI_MakeShape::modified(
     TopTools_ListIteratorOfListOfShape it(aList);
     for(;it.More();it.Next()) {
       boost::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
-      aShape->setImpl(&(it.Value()));
+      aShape->setImpl(new TopoDS_Shape(it.Value()));
       theHistory.push_back(aShape);
     }
   }
index 89dae08a5458671271e8a58f8afb2bf445230a40..4fa0ef0a13522ec6d794db8e62369a56c31ca740 100644 (file)
@@ -7,16 +7,19 @@
 #include <GeomAPI_Shape.h>
 #include <boost/shared_ptr.hpp>
 #include <GeomAlgoAPI.h>
-#include <BRepBuilderAPI_MakeShape.hxx>
+//#include <BRepBuilderAPI_MakeShape.hxx>
 /**\class GeomAlgoAPI_MakeShape
  * \ingroup DataModel
  * \Interface to the root class of all topological shapes constructions
  */
-class GeomAlgoAPI_MakeShape : GeomAPI_Interface
+class GeomAlgoAPI_MakeShape : public GeomAPI_Interface
 {
  public:
    /// Constructor
+  GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShape();
+
   GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShape(void* theBuilder);
+
   /// Returns a shape built by the shape construction algorithm
   GEOMALGOAPI_EXPORT const boost::shared_ptr<GeomAPI_Shape>  shape() const;
 
@@ -31,6 +34,8 @@ class GeomAlgoAPI_MakeShape : GeomAPI_Interface
   /// Returns whether the shape is an edge
   GEOMALGOAPI_EXPORT virtual bool isDeleted(const boost::shared_ptr<GeomAPI_Shape> theShape);
 
+  GEOMALGOAPI_EXPORT void init(void* theMkShape);
+
   protected:
        boost::shared_ptr<GeomAPI_Shape> myShape;
 };
index 9b18bc0469d0bc5492d6e270d84aebd05c3012e9..ce342c2e99a07a647388c2d6099a8079b6a75edb 100644 (file)
@@ -8,8 +8,13 @@
 #include <TNaming_NamedShape.hxx>
 #include <TopoDS_Shape.hxx>
 #include <TDF_ChildIterator.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <TopExp_Explorer.hxx>
 #include <GeomAPI_Shape.h>
-
+#include <GeomAlgoAPI_MakeShape.h>
+// DEB
+//#include <TCollection_AsciiString.hxx>
+//#include <TDF_Tool.hxx>
 Model_ResultBody::Model_ResultBody()
 {
   setIsConcealed(false);
@@ -115,12 +120,15 @@ Model_ResultBody::~Model_ResultBody()
 
 TNaming_Builder* Model_ResultBody::builder(const int theTag)
 {
-  if (myBuilders.size() < (unsigned int)theTag) {
+  if (myBuilders.size() <= (unsigned int)theTag) {
     myBuilders.insert(myBuilders.end(), theTag - myBuilders.size() + 1, NULL);
   }
   if (!myBuilders[theTag]) {
     boost::shared_ptr<Model_Data> aData = boost::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];
 }
@@ -155,3 +163,82 @@ void Model_ResultBody::deleted(const boost::shared_ptr<GeomAPI_Shape>& theOldSha
   TopoDS_Shape aShape = theOldShape->impl<TopoDS_Shape>();
   builder(theTag)->Delete(aShape);
 }
+
+void Model_ResultBody::loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
+                                               boost::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;
+       boost::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,
+                                               boost::shared_ptr<GeomAPI_Shape>  theShapeIn,
+                                               const int  theKindOfShape,
+                                               const int  theTag,
+                                               GeomAPI_DataMapOfShapeShape& theSubShapes)
+{
+  TopoDS_Shape aShapeIn = theShapeIn->impl<TopoDS_Shape>();
+  TopTools_MapOfShape aView;
+  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;
+       boost::shared_ptr<GeomAPI_Shape> aRShape(new GeomAPI_Shape());
+       aRShape->setImpl((new TopoDS_Shape(aRoot)));
+       theMS->generated(aRShape, aList);
+       std::list<boost::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)) {
+               boost::shared_ptr<GeomAPI_Shape> aMapShape(theSubShapes.find(*anIt));
+               aNewShape.Orientation(aMapShape->impl<TopoDS_Shape>().Orientation());
+      }
+      if (!aRoot.IsSame (aNewShape)) 
+                 builder(theTag)->Modify(aRoot,aNewShape);
+    }
+  }
+}
+
+void Model_ResultBody::loadAndOrientGeneratedShapes (
+                                                  GeomAlgoAPI_MakeShape* theMS,
+                                               boost::shared_ptr<GeomAPI_Shape>  theShapeIn,
+                                               const int  theKindOfShape,
+                                               const int  theTag,
+                                               GeomAPI_DataMapOfShapeShape& theSubShapes)
+{
+  TopoDS_Shape aShapeIn = theShapeIn->impl<TopoDS_Shape>();
+  TopTools_MapOfShape aView;
+  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;
+       boost::shared_ptr<GeomAPI_Shape> aRShape(new GeomAPI_Shape());
+       aRShape->setImpl((new TopoDS_Shape(aRoot)));
+       theMS->generated(aRShape, aList);
+       std::list<boost::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)) {
+               boost::shared_ptr<GeomAPI_Shape> aMapShape(theSubShapes.find(*anIt));
+               aNewShape.Orientation(aMapShape->impl<TopoDS_Shape>().Orientation());
+      }
+      if (!aRoot.IsSame (aNewShape)) 
+                 builder(theTag)->Generated(aRoot,aNewShape);
+    }
+  }
+}
\ No newline at end of file
index f6174cdee1cb82798e836f80e67b954754e331e3..340b35bb515e9699b244f69d22680eb7acd2cebe 100644 (file)
@@ -7,6 +7,8 @@
 
 #include "Model.h"
 #include <ModelAPI_ResultBody.h>
+#include <GeomAlgoAPI_MakeShape.h>
+#include <GeomAPI_DataMapOfShapeShape.h>
 #include <vector>
 
 class TNaming_Builder;
@@ -64,6 +66,26 @@ public:
   MODEL_EXPORT virtual void deleted(const boost::shared_ptr<GeomAPI_Shape>& theOldShape,
     const int theTag = 1);
 
+  /// load deleted shapes
+  MODEL_EXPORT virtual void loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
+                                               boost::shared_ptr<GeomAPI_Shape>  theShapeIn,
+                                               const int  theKindOfShape,
+                                               const int  theTag);
+  /// load and orient modified shapes
+  MODEL_EXPORT virtual void loadAndOrientModifiedShapes (
+                                                  GeomAlgoAPI_MakeShape* theMS,
+                                               boost::shared_ptr<GeomAPI_Shape>  theShapeIn,
+                                               const int  theKindOfShape,
+                                               const int  theTag,
+                                               GeomAPI_DataMapOfShapeShape& theSubShapes);
+   /// load and orient generated shapes
+  MODEL_EXPORT virtual void loadAndOrientGeneratedShapes (
+                                                  GeomAlgoAPI_MakeShape* theMS,
+                                               boost::shared_ptr<GeomAPI_Shape>  theShapeIn,
+                                               const int  theKindOfShape,
+                                               const int  theTag,
+                                               GeomAPI_DataMapOfShapeShape& theSubShapes);
+
   /// Removes the stored builders
   MODEL_EXPORT virtual ~Model_ResultBody();
 
index 9bebf30fbb0812a0ed77c4f41b42b5c004d372a2..0bfa08a58c57ad2e1486feafaa3df577f0cb887a 100644 (file)
@@ -56,6 +56,7 @@ INCLUDE_DIRECTORIES(
   ../Config 
   ../Events
   ../GeomAPI
+  ../GeomAlgoAPI
 )
 
 SET(CMAKE_SWIG_FLAGS "")
index 8942a62f207a10a6917389e718c386b721a1559e..4991cf27986c61ab24453c3873a87628baad583d 100644 (file)
@@ -7,7 +7,9 @@
 
 #include "ModelAPI_Result.h"
 #include <GeomAPI_Shape.h>
-
+#include <GeomAlgoAPI_MakeShape.h>
+#include <GeomAPI_DataMapOfShapeShape.h>
+#include <boost/shared_ptr.hpp>
 #include <string>
 
 /**\class ModelAPI_ResultBody
@@ -68,7 +70,26 @@ public:
   /// As an example, consider the case of a face removed by a Boolean operation.
   virtual void deleted(
     const boost::shared_ptr<GeomAPI_Shape>& theOldShape, const int theTag = 1) = 0;
-
+  
+  /// load deleted shapes
+  virtual void loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
+                                               boost::shared_ptr<GeomAPI_Shape>  theShapeIn,
+                                               const int  theKindOfShape,
+                                               const int  theTag) = 0;
+  /// load and orient modified shapes
+  virtual void loadAndOrientModifiedShapes (
+                                                  GeomAlgoAPI_MakeShape* theMS,
+                                               boost::shared_ptr<GeomAPI_Shape>  theShapeIn,
+                                               const int  theKindOfShape,
+                                               const int  theTag,
+                                               GeomAPI_DataMapOfShapeShape& theSubShapes) = 0;
+  /// load and orient generated shapes
+  virtual void loadAndOrientGeneratedShapes (
+                                                  GeomAlgoAPI_MakeShape* theMS,
+                                               boost::shared_ptr<GeomAPI_Shape>  theShapeIn,
+                                               const int  theKindOfShape,
+                                               const int  theTag,
+                                               GeomAPI_DataMapOfShapeShape& theSubShapes) = 0;
 protected:
 };
 
index 0a07539a44b075b2805d7a9701310ff92948d9a2..5ceda79603cc6772b9892f5b90e4443776859be6 100644 (file)
@@ -124,6 +124,7 @@ INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/src/Events
                                         ${PROJECT_SOURCE_DIR}/src/GeomAPI
                                         ${PROJECT_SOURCE_DIR}/src/ModuleBase
                                         ${PROJECT_SOURCE_DIR}/src/PartSetPlugin
+                                        ${PROJECT_SOURCE_DIR}/src/GeomAlgoAPI
                                         ${CAS_INCLUDE_DIRS}
                                         ${SUIT_INCLUDE})