]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Partition naming for infinite planes
authordbv <dbv@opencascade.com>
Fri, 4 Sep 2015 13:20:29 +0000 (16:20 +0300)
committerdbv <dbv@opencascade.com>
Fri, 4 Sep 2015 13:20:46 +0000 (16:20 +0300)
15 files changed:
src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp
src/FeaturesPlugin/FeaturesPlugin_Boolean.h
src/FeaturesPlugin/FeaturesPlugin_Partition.cpp
src/FeaturesPlugin/FeaturesPlugin_Partition.h
src/GeomAPI/CMakeLists.txt
src/GeomAPI/GeomAPI.i
src/GeomAPI/GeomAPI_DataMapOfShapeMapOfShapes.cpp [new file with mode: 0644]
src/GeomAPI/GeomAPI_DataMapOfShapeMapOfShapes.h [new file with mode: 0644]
src/GeomAPI/GeomAPI_ShapeExplorer.h
src/GeomAlgoAPI/CMakeLists.txt
src/GeomAlgoAPI/GeomAlgoAPI.i
src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h
src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeCustom.cpp [new file with mode: 0644]
src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeCustom.h [new file with mode: 0644]
src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeList.h

index b761d0665459c905c90dc0f85aedf4ff23ba2df2..9ab80ccfe545f2bc959017efead61a5a284e6093 100644 (file)
@@ -152,7 +152,7 @@ void FeaturesPlugin_Boolean::execute()
 
         if(GeomAlgoAPI_ShapeTools::volume(aBoolAlgo.shape()) > 1.e-7) {
           std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data(), aResultIndex);
-          loadNamingDS(aResultBody, anObject, aBoolAlgo.shape(), aTools, *aBoolAlgo.makeShape(), *aBoolAlgo.mapOfShapes());
+          loadNamingDS(aResultBody, anObject, aTools, aBoolAlgo.shape(), *aBoolAlgo.makeShape(), *aBoolAlgo.mapOfShapes());
           setResult(aResultBody, aResultIndex);
           aResultIndex++;
         }
@@ -218,7 +218,7 @@ void FeaturesPlugin_Boolean::execute()
 
         if(GeomAlgoAPI_ShapeTools::volume(aFillerAlgo.shape()) > 1.e-7) {
           std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data(), aResultIndex);
-          loadNamingDS(aResultBody, aCompSolid, aFillerAlgo.shape(), aTools, aMakeShapeList, aMapOfShapes);
+          loadNamingDS(aResultBody, aCompSolid, aTools, aFillerAlgo.shape(), aMakeShapeList, aMapOfShapes);
           setResult(aResultBody, aResultIndex);
           aResultIndex++;
         }
@@ -336,7 +336,7 @@ void FeaturesPlugin_Boolean::execute()
       }
 
       std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data(), aResultIndex);
-      loadNamingDS(aResultBody, anOriginalSolids.front(), aShape, anOriginalSolids, aMakeShapeList, aMapOfShapes);
+      loadNamingDS(aResultBody, anOriginalSolids.front(), anOriginalSolids, aShape, aMakeShapeList, aMapOfShapes);
       setResult(aResultBody, aResultIndex);
       aResultIndex++;
       break;
@@ -354,8 +354,8 @@ void FeaturesPlugin_Boolean::execute()
 //=================================================================================================
 void FeaturesPlugin_Boolean::loadNamingDS(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
                                           const std::shared_ptr<GeomAPI_Shape> theBaseShape,
-                                          const std::shared_ptr<GeomAPI_Shape> theResultShape,
                                           const ListOfShape& theTools,
+                                          const std::shared_ptr<GeomAPI_Shape> theResultShape,
                                           GeomAlgoAPI_MakeShape& theMakeShape,
                                           GeomAPI_DataMapOfShapeShape& theMapOfShapes)
 {
index 7ac31e35ba2e1445d8f0c334792288b39671db9c..0a072e8229cf9a0f1a2a7849129286e05f0df949 100644 (file)
@@ -89,8 +89,8 @@ private:
   /// Load Naming data structure of the feature to the document
   void loadNamingDS(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
                     const std::shared_ptr<GeomAPI_Shape> theBaseShape,
-                    const std::shared_ptr<GeomAPI_Shape> theResultShape,
                     const ListOfShape& theTools,
+                    const std::shared_ptr<GeomAPI_Shape> theResultShape,
                     GeomAlgoAPI_MakeShape& theMakeShape,
                     GeomAPI_DataMapOfShapeShape& theMapOfShapes);
 };
index 6000c9d8431e8cc102bd828e01f2ddbafd2c7910..e165b5a760e3e7ad619a796e802d2e26a1a6a183 100755 (executable)
@@ -17,6 +17,7 @@
 #include <ModelAPI_Validator.h>
 
 #include <GeomAlgoAPI_Partition.h>
+#include <GeomAlgoAPI_MakeShapeCustom.h>
 #include <GeomAlgoAPI_MakeShapeList.h>
 #include <GeomAlgoAPI_ShapeTools.h>
 
@@ -59,7 +60,7 @@ std::shared_ptr<GeomAPI_Shape> FeaturesPlugin_Partition::getShape(const std::str
 //=================================================================================================
 void FeaturesPlugin_Partition::execute()
 {
-  ListOfShape anObjects, aTools;
+  ListOfShape anObjects, aTools, aToolsForNaming;
 
   // Getting objects.
   AttributeSelectionListPtr anObjectsSelList = selectionList(FeaturesPlugin_Partition::OBJECT_LIST_ID());
@@ -72,22 +73,28 @@ void FeaturesPlugin_Partition::execute()
     anObjects.push_back(anObject);
   }
 
+  GeomAlgoAPI_MakeShapeList aMakeShapeList;
+
   // Getting tools.
   AttributeSelectionListPtr aToolsSelList = selectionList(FeaturesPlugin_Partition::TOOL_LIST_ID());
   for (int aToolsIndex = 0; aToolsIndex < aToolsSelList->size(); aToolsIndex++) {
     std::shared_ptr<ModelAPI_AttributeSelection> aToolAttr = aToolsSelList->value(aToolsIndex);
     std::shared_ptr<GeomAPI_Shape> aTool = aToolAttr->value();
-    if (!aTool.get()) {
+    if(!aTool.get()) {
       // it could be a construction plane
       ResultPtr aContext = aToolAttr->context();
-      if (aContext.get()) {
+      if(aContext.get()) {
         aTool = GeomAlgoAPI_ShapeTools::faceToInfinitePlane(aContext->shape());
+        std::shared_ptr<GeomAlgoAPI_MakeShapeCustom> aMkShCustom(new GeomAlgoAPI_MakeShapeCustom);
+        aMkShCustom->addModified(aContext->shape(), aTool);
+        aMakeShapeList.append(aMkShCustom);
+        aTools.push_back(aTool);
+        aToolsForNaming.push_back(aContext->shape());
       }
+    } else {
+      aTools.push_back(aTool);
+      aToolsForNaming.push_back(aTool);
     }
-    if (!aTool.get()) {
-      return;
-    }
-    aTools.push_back(aTool);
   }
 
   int aResultIndex = 0;
@@ -123,8 +130,9 @@ void FeaturesPlugin_Partition::execute()
 
     if (GeomAlgoAPI_ShapeTools::volume(aPartitionAlgo.shape()) > 1.e-7) {
       std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data(), aResultIndex);
-      aResultBody->store(aPartitionAlgo.shape());
-      loadNamingDS(aResultBody, anObject, aTools, aPartitionAlgo);
+      aMakeShapeList.append(aPartitionAlgo.makeShape());
+      GeomAPI_DataMapOfShapeShape aMapOfShapes = *aPartitionAlgo.mapOfShapes().get();
+      loadNamingDS(aResultBody, anObject, aToolsForNaming, aPartitionAlgo.shape(), aMakeShapeList, aMapOfShapes);
       setResult(aResultBody, aResultIndex);
       aResultIndex++;
     }
@@ -138,30 +146,29 @@ void FeaturesPlugin_Partition::execute()
 void FeaturesPlugin_Partition::loadNamingDS(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
                                             const std::shared_ptr<GeomAPI_Shape> theBaseShape,
                                             const ListOfShape& theTools,
-                                            const GeomAlgoAPI_Partition& thePartitionAlgo)
+                                            const std::shared_ptr<GeomAPI_Shape> theResultShape,
+                                            GeomAlgoAPI_MakeShape& theMakeShape,
+                                            GeomAPI_DataMapOfShapeShape& theMapOfShapes)
 {
   //load result
-  if(theBaseShape->isEqual(thePartitionAlgo.shape())) {
-    theResultBody->store(thePartitionAlgo.shape());
+  if(theBaseShape->isEqual(theResultShape)) {
+    theResultBody->store(theResultShape);
   } else {
     const int aModifyTag = 1;
     const int aDeletedTag = 2;
     const int aSubsolidsTag = 3; /// sub solids will be placed at labels 3, 4, etc. if result is compound of solids
 
-    theResultBody->storeModified(theBaseShape, thePartitionAlgo.shape(), aSubsolidsTag);
-
-    std::shared_ptr<GeomAlgoAPI_MakeShape> aMkShape = thePartitionAlgo.makeShape();
-    std::shared_ptr<GeomAPI_DataMapOfShapeShape> aMapOfShapes = thePartitionAlgo.mapOfShapes();
+    theResultBody->storeModified(theBaseShape, theResultShape, aSubsolidsTag);
 
     std::string aModName = "Modified";
-    theResultBody->loadAndOrientModifiedShapes(aMkShape.get(), theBaseShape, GeomAPI_Shape::FACE,
-                                               aModifyTag, aModName, *aMapOfShapes.get());
-    theResultBody->loadDeletedShapes(aMkShape.get(), theBaseShape, GeomAPI_Shape::FACE, aDeletedTag);
+    theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::FACE,
+                                               aModifyTag, aModName, theMapOfShapes);
+    theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::FACE, aDeletedTag);
 
     for(ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++) {
-      theResultBody->loadAndOrientModifiedShapes(aMkShape.get(), *anIter, GeomAPI_Shape::FACE,
-                                                 aModifyTag, aModName, *aMapOfShapes.get());
-      theResultBody->loadDeletedShapes(aMkShape.get(), *anIter, GeomAPI_Shape::FACE, aDeletedTag);
+      theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE,
+                                                 aModifyTag, aModName, theMapOfShapes);
+      theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE, aDeletedTag);
     }
   }
 }
index a058fd8438f6630d832413014692b418472c1663..9ec475f44baadc8fdc4f7185ab9baae35bf933fb 100755 (executable)
@@ -63,7 +63,9 @@ private:
   void loadNamingDS(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
                     const std::shared_ptr<GeomAPI_Shape> theBaseShape,
                     const ListOfShape& theTools,
-                    const GeomAlgoAPI_Partition& thePartitionAlgo);
+                    const std::shared_ptr<GeomAPI_Shape> theResultShape,
+                    GeomAlgoAPI_MakeShape& theMakeShape,
+                    GeomAPI_DataMapOfShapeShape& theMapOfShapes);
 
 };
 
index 12450b5efcd3d7a92bd7d3181b379b17de14d38f..888da4512967b46e44dd90b78344360d07cc0a06 100644 (file)
@@ -26,7 +26,8 @@ SET(PROJECT_HEADERS
     GeomAPI_PlanarEdges.h
     GeomAPI_AISObject.h
     GeomAPI_IPresentable.h
-    GeomAPI_Curve.h 
+    GeomAPI_Curve.h
+    GeomAPI_DataMapOfShapeMapOfShapes.h
     GeomAPI_DataMapOfShapeShape.h
     GeomAPI_ICustomPrs.h
     GeomAPI_Vertex.h
@@ -55,6 +56,7 @@ SET(PROJECT_SOURCES
     GeomAPI_PlanarEdges.cpp
     GeomAPI_AISObject.cpp
     GeomAPI_Curve.cpp
+    GeomAPI_DataMapOfShapeMapOfShapes.cpp
     GeomAPI_DataMapOfShapeShape.cpp
     GeomAPI_Vertex.cpp
     GeomAPI_ICustomPrs.cpp
index ff20e671406c93be2c4927a48d669abedab9516f..2bd0b7857eb3d04e9de18299fd1efe734f74d732 100644 (file)
@@ -8,6 +8,7 @@
   #include "GeomAPI_Circ.h"
   #include "GeomAPI_Circ2d.h"
   #include "GeomAPI_Curve.h"
+  #include "GeomAPI_DataMapOfShapeMapOfShapes.h"
   #include "GeomAPI_DataMapOfShapeShape.h"
   #include "GeomAPI_Dir.h"
   #include "GeomAPI_Dir2d.h"
@@ -48,6 +49,7 @@
 %shared_ptr(GeomAPI_Circ)
 %shared_ptr(GeomAPI_Circ2d)
 %shared_ptr(GeomAPI_Curve)
+%shared_ptr(GeomAPI_DataMapOfShapeMapOfShapes)
 %shared_ptr(GeomAPI_DataMapOfShapeShape)
 %shared_ptr(GeomAPI_Dir)
 %shared_ptr(GeomAPI_Dir2d)
@@ -79,6 +81,7 @@
 %include "GeomAPI_Circ.h"
 %include "GeomAPI_Circ2d.h"
 %include "GeomAPI_Curve.h"
+%include "GeomAPI_DataMapOfShapeMapOfShapes.h"
 %include "GeomAPI_DataMapOfShapeShape.h"
 %include "GeomAPI_Dir.h"
 %include "GeomAPI_Dir2d.h"
diff --git a/src/GeomAPI/GeomAPI_DataMapOfShapeMapOfShapes.cpp b/src/GeomAPI/GeomAPI_DataMapOfShapeMapOfShapes.cpp
new file mode 100644 (file)
index 0000000..53e5411
--- /dev/null
@@ -0,0 +1,90 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        GeomAPI_DataMapOfShapeMapOfShapes.cpp
+// Created:     4 September 2015
+// Author:      Dmitry Bobylev
+
+#include <GeomAPI_DataMapOfShapeMapOfShapes.h>
+
+#include <NCollection_DataMap.hxx>
+#include <NCollection_Map.hxx>
+#include <TopoDS_Shape.hxx>
+
+#define MY_MAP implPtr<NCollection_DataMap<TopoDS_Shape, NCollection_Map<TopoDS_Shape> > >()
+
+//=================================================================================================
+GeomAPI_DataMapOfShapeMapOfShapes::GeomAPI_DataMapOfShapeMapOfShapes()
+: GeomAPI_Interface(new NCollection_DataMap<TopoDS_Shape, NCollection_Map<TopoDS_Shape> >)
+{}
+
+//=================================================================================================
+bool GeomAPI_DataMapOfShapeMapOfShapes::bind(const std::shared_ptr<GeomAPI_Shape> theKey,
+                                             const ListOfShape& theItems)
+{
+  const TopoDS_Shape& aKey = theKey->impl<TopoDS_Shape>();
+  for(ListOfShape::const_iterator anIt = theItems.cbegin(); anIt != theItems.cend(); anIt++) {
+    const TopoDS_Shape& anItem = (*anIt)->impl<TopoDS_Shape>();
+    if(MY_MAP->IsBound(aKey)) {
+      MY_MAP->ChangeFind(aKey).Add(anItem);
+    } else {
+      NCollection_Map<TopoDS_Shape> anItems;
+      anItems.Add(anItem);
+      MY_MAP->Bind(aKey, anItems);
+    }
+  }
+
+  return true;
+}
+
+//=================================================================================================
+bool GeomAPI_DataMapOfShapeMapOfShapes::add(const std::shared_ptr<GeomAPI_Shape> theKey,
+                                            const std::shared_ptr<GeomAPI_Shape> theItem)
+{
+  const TopoDS_Shape& aKey = theKey->impl<TopoDS_Shape>();
+  const TopoDS_Shape& anItem = theItem->impl<TopoDS_Shape>();
+  if(MY_MAP->IsBound(aKey)) {
+    return MY_MAP->ChangeFind(aKey).Add(anItem) == Standard_True;
+  } else {
+    NCollection_Map<TopoDS_Shape> anItems;
+    anItems.Add(anItem);
+    return MY_MAP->Bind(aKey, anItems) == Standard_True;
+  }
+}
+
+//=================================================================================================
+bool GeomAPI_DataMapOfShapeMapOfShapes::isBound(const std::shared_ptr<GeomAPI_Shape> theKey) const
+{
+  const TopoDS_Shape& aKey = theKey->impl<TopoDS_Shape>();
+  return MY_MAP->IsBound(aKey) == Standard_True;
+}
+
+//=================================================================================================
+bool GeomAPI_DataMapOfShapeMapOfShapes::find(const std::shared_ptr<GeomAPI_Shape> theKey,
+                                             ListOfShape& theItems) const
+{
+  const TopoDS_Shape& aKey = theKey->impl<TopoDS_Shape>();
+
+  if(MY_MAP->IsBound(aKey) == Standard_False) {
+    return false;
+  }
+
+  const NCollection_Map<TopoDS_Shape>& aMap = MY_MAP->Find(aKey);
+  for(NCollection_Map<TopoDS_Shape>::Iterator anIt(aMap); anIt.More(); anIt.Next()) {
+    std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape);
+    aShape->setImpl(new TopoDS_Shape(anIt.Value()));
+    theItems.push_back(aShape);
+  }
+}
+
+//=================================================================================================
+bool GeomAPI_DataMapOfShapeMapOfShapes::unBind(const std::shared_ptr<GeomAPI_Shape> theKey)
+{
+  const TopoDS_Shape& aKey = theKey->impl<TopoDS_Shape>();
+  return MY_MAP->UnBind(aKey) == Standard_True;
+}
+
+//=================================================================================================
+int GeomAPI_DataMapOfShapeMapOfShapes::size() const
+{
+  return MY_MAP->Size();
+}
diff --git a/src/GeomAPI/GeomAPI_DataMapOfShapeMapOfShapes.h b/src/GeomAPI/GeomAPI_DataMapOfShapeMapOfShapes.h
new file mode 100644 (file)
index 0000000..5dd4dbd
--- /dev/null
@@ -0,0 +1,54 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        GeomAPI_DataMapOfShapeMapOfShapes.h
+// Created:     4 September 2015
+// Author:      Dmitry Bobylev
+
+#ifndef GeomAPI_DataMapOfShapeMapOfShapes_H_
+#define GeomAPI_DataMapOfShapeMapOfShapes_H_
+
+#include <GeomAPI_Interface.h>
+
+#include <GeomAPI_Shape.h>
+
+/**\class GeomAPI_DataMapOfShapeMapOfShapes
+ * \ingroup DataModel
+ * \brief DataMap of Shape - Map of Shapes defined by TopoDS_Shapes
+ */
+class GeomAPI_DataMapOfShapeMapOfShapes : public GeomAPI_Interface
+{
+public:
+  /// Constructor.Creates empty map.
+  GEOMAPI_EXPORT GeomAPI_DataMapOfShapeMapOfShapes();
+
+  /** \brief Binds list of shapes to the key shape.
+      \param[in] theKey key shape.
+      \param[in] theItems list of shapes. If shapes have duplications in list only one will be stored.
+      \returns true if items bound successfully.
+   */
+  GEOMAPI_EXPORT bool bind(const std::shared_ptr<GeomAPI_Shape> theKey,
+                           const ListOfShape& theItems);
+
+  /** \brief Adds item to the map bounded to the key.
+      \param[in] theKey key shape.
+      \param[in] theItem item shape.
+      \returns true if item bounded successfully. False if it is already bound.
+   */
+  GEOMAPI_EXPORT bool add(const std::shared_ptr<GeomAPI_Shape> theKey,
+                          const std::shared_ptr<GeomAPI_Shape> theItem);
+
+  /// \return true if theKey is stored  in the map.
+  GEOMAPI_EXPORT bool isBound(const std::shared_ptr<GeomAPI_Shape> theKey) const;
+
+  /// \return list of shapes bounded to theKey.
+  GEOMAPI_EXPORT bool find(const std::shared_ptr<GeomAPI_Shape> theKey,
+                           ListOfShape& theItems) const;
+
+  /// Undinds shapes from theKey.
+  GEOMAPI_EXPORT bool unBind(const std::shared_ptr<GeomAPI_Shape> theKey);
+
+  /// \return size of map.
+  GEOMAPI_EXPORT int size() const;
+};
+
+#endif
index fac506fd1589fa20393a039e1e4749fe1dcfffbe..29136a0cb8e21513869d5342e4e84665c25dadeb 100644 (file)
  *  \ingroup DataModel
  *  \brief This class is used to explore subshapes on shape.
  */
-
 class GeomAPI_ShapeExplorer : public GeomAPI_Interface
 {
 public:
   /// Default constructor. Creates an empty explorer, becomes usefull after Init.
-  GEOMAPI_EXPORT 
+  GEOMAPI_EXPORT
   GeomAPI_ShapeExplorer();
 
   /** \brief Constructs an explorer to search on theShape, for shapes of type toFind,
@@ -28,7 +27,7 @@ public:
       \param[in] toFind shape type to find.
       \param[in] toAvoid shape type to avoid.
    */
-  GEOMAPI_EXPORT 
+  GEOMAPI_EXPORT
   GeomAPI_ShapeExplorer(const std::shared_ptr<GeomAPI_Shape>& theShape,
                         const GeomAPI_Shape::ShapeType toFind,
                         const GeomAPI_Shape::ShapeType toAvoid = GeomAPI_Shape::SHAPE);
@@ -39,33 +38,33 @@ public:
       \param[in] toFind shape type to find.
       \param[in] toAvoid shape type to avoid.
    */
-  GEOMAPI_EXPORT 
+  GEOMAPI_EXPORT
   void init(const std::shared_ptr<GeomAPI_Shape>& theShape,
             const GeomAPI_Shape::ShapeType toFind,
             const GeomAPI_Shape::ShapeType toAvoid = GeomAPI_Shape::SHAPE);
 
   /// \return true if there are more shapes in the exploration.
-  GEOMAPI_EXPORT 
+  GEOMAPI_EXPORT
   bool more() const;
 
   /// Moves to the next Shape in the exploration or do nothing if there are no more shapes to explore.
-  GEOMAPI_EXPORT 
+  GEOMAPI_EXPORT
   void next();
 
-  /// Returns the current shape in the exploration or empty pointer if this explorer has no more shapes to explore.
-  GEOMAPI_EXPORT 
+  /// \return the current shape in the exploration or empty pointer if this explorer has no more shapes to explore.
+  GEOMAPI_EXPORT
   std::shared_ptr<GeomAPI_Shape> current();
 
   /// Reinitialize the exploration with the original arguments.
-  GEOMAPI_EXPORT 
+  GEOMAPI_EXPORT
   void reinit();
 
-  /// Returns the current depth of the exploration. 0 is the shape to explore itself.
-  GEOMAPI_EXPORT 
+  /// \return the current depth of the exploration. 0 is the shape to explore itself.
+  GEOMAPI_EXPORT
   int depth() const;
 
   /// Clears the content of the explorer. It will return False on more().
-  GEOMAPI_EXPORT 
+  GEOMAPI_EXPORT
   void clear();
 
 };
index 4354f0f72a85c608b23caa84ec9d5e3e40ed7654..9c85cf7bd615981cf6a121ade552394d59dd1b92 100644 (file)
@@ -20,6 +20,7 @@ SET(PROJECT_HEADERS
     GeomAlgoAPI_Rotation.h
     GeomAlgoAPI_Movement.h
     GeomAlgoAPI_MakeShape.h
+    GeomAlgoAPI_MakeShapeCustom.h
     GeomAlgoAPI_MakeShapeList.h
     GeomAlgoAPI_DFLoader.h
     GeomAlgoAPI_Placement.h
@@ -49,6 +50,7 @@ SET(PROJECT_SOURCES
     GeomAlgoAPI_Rotation.cpp
     GeomAlgoAPI_Movement.cpp
     GeomAlgoAPI_MakeShape.cpp
+    GeomAlgoAPI_MakeShapeCustom.cpp
     GeomAlgoAPI_MakeShapeList.cpp
     GeomAlgoAPI_DFLoader.cpp
     GeomAlgoAPI_Placement.cpp
index cd5474eec177f97149c18da010214ed53d3102f2..1c1c2528303e60609bbbba8bb220a14640e3ebf7 100644 (file)
@@ -9,6 +9,7 @@
   #include "GeomAlgoAPI_Extrusion.h"
   #include "GeomAlgoAPI_FaceBuilder.h"
   #include "GeomAlgoAPI_MakeShape.h"
+  #include "GeomAlgoAPI_MakeShapeCustom.h"
   #include "GeomAlgoAPI_MakeShapeList.h"
   #include "GeomAlgoAPI_Movement.h"
   #include "GeomAlgoAPI_Placement.h"
@@ -50,6 +51,7 @@
 %include "GeomAlgoAPI_Extrusion.h"
 %include "GeomAlgoAPI_FaceBuilder.h"
 %include "GeomAlgoAPI_MakeShape.h"
+%include "GeomAlgoAPI_MakeShapeCustom.h"
 %include "GeomAlgoAPI_MakeShapeList.h"
 %include "GeomAlgoAPI_Movement.h"
 %include "GeomAlgoAPI_Placement.h"
index 594283819d70d6bd5dafb4b781543ef0f8d41806..a4c19e8c2961dd4403f2551b6112206a14277586 100644 (file)
@@ -36,7 +36,7 @@ public:
                                            const std::shared_ptr<GeomAPI_Shape> theBaseShape);
 
   /// Returns a shape built by the shape construction algorithm
-  GEOMALGOAPI_EXPORT const std::shared_ptr<GeomAPI_Shape> shape() const;
+  GEOMALGOAPI_EXPORT virtual const std::shared_ptr<GeomAPI_Shape> shape() const;
 
   /// Returns the list of shapes generated from the shape \a theShape
   GEOMALGOAPI_EXPORT virtual void generated(
@@ -46,7 +46,7 @@ public:
   GEOMALGOAPI_EXPORT virtual void modified(
     const std::shared_ptr<GeomAPI_Shape> theShape, ListOfShape& theHistory);
 
-  /// Returns whether the shape is an edge
+  /// Returns whether the shape is deleted
   GEOMALGOAPI_EXPORT virtual bool isDeleted(const std::shared_ptr<GeomAPI_Shape> theShape);
 
 protected:
diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeCustom.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeCustom.cpp
new file mode 100644 (file)
index 0000000..318f9b6
--- /dev/null
@@ -0,0 +1,68 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        GeomAlgoAPI_MakeShapeCustom.cpp
+// Created:     4 September 2015
+// Author:      Dmitry Bobylev
+
+#include <GeomAlgoAPI_MakeShapeCustom.h>
+
+//=================================================================================================
+GeomAlgoAPI_MakeShapeCustom::GeomAlgoAPI_MakeShapeCustom()
+: GeomAlgoAPI_MakeShape()
+{}
+
+//=================================================================================================
+void GeomAlgoAPI_MakeShapeCustom::setResult(const std::shared_ptr<GeomAPI_Shape> theShape)
+{
+  myShape = theShape;
+}
+
+//=================================================================================================
+bool GeomAlgoAPI_MakeShapeCustom::addModified(const std::shared_ptr<GeomAPI_Shape> theBase,
+                                              const std::shared_ptr<GeomAPI_Shape> theResult)
+{
+  return myModified.add(theBase, theResult);
+}
+
+//=================================================================================================
+bool GeomAlgoAPI_MakeShapeCustom::addGenerated(const std::shared_ptr<GeomAPI_Shape> theBase,
+                                               const std::shared_ptr<GeomAPI_Shape> theResult)
+{
+  return myGenerated.add(theBase, theResult);
+}
+
+//=================================================================================================
+bool GeomAlgoAPI_MakeShapeCustom::addDeleted(const std::shared_ptr<GeomAPI_Shape> theShape)
+{
+  return myDeleted.bind(theShape, theShape);
+}
+
+//=================================================================================================
+const std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_MakeShapeCustom::shape() const
+{
+  return myShape;
+}
+
+//=================================================================================================
+void GeomAlgoAPI_MakeShapeCustom::generated(const std::shared_ptr<GeomAPI_Shape> theShape,
+                                            ListOfShape& theHistory)
+{
+  ListOfShape aGenerated;
+  myGenerated.find(theShape, aGenerated);
+  theHistory.insert(theHistory.end(), aGenerated.begin(), aGenerated.end());
+}
+
+//=================================================================================================
+void GeomAlgoAPI_MakeShapeCustom::modified(const std::shared_ptr<GeomAPI_Shape> theShape,
+                                           ListOfShape& theHistory)
+{
+  ListOfShape aModified;
+  myModified.find(theShape, aModified);
+  theHistory.insert(theHistory.end(), aModified.begin(), aModified.end());
+}
+
+//=================================================================================================
+bool GeomAlgoAPI_MakeShapeCustom::isDeleted(const std::shared_ptr<GeomAPI_Shape> theShape)
+{
+  return myDeleted.isBound(theShape);
+}
\ No newline at end of file
diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeCustom.h b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeCustom.h
new file mode 100644 (file)
index 0000000..062e3aa
--- /dev/null
@@ -0,0 +1,60 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        GeomAlgoAPI_MakeShapeCustom.h
+// Created:     4 September 2015
+// Author:      Dmitry Bobylev
+
+#ifndef GeomAlgoAPI_MakeShapeCustom_H_
+#define GeomAlgoAPI_MakeShapeCustom_H_
+
+#include <GeomAlgoAPI_MakeShape.h>
+
+#include <GeomAPI_DataMapOfShapeMapOfShapes.h>
+#include <GeomAPI_DataMapOfShapeShape.h>
+
+/** \class GeomAlgoAPI_MakeShapeCustom
+ *  \ingroup DataAlgo
+ *  \brief Interface to the root class of all topological shapes constructions
+ */
+class GeomAlgoAPI_MakeShapeCustom : public GeomAlgoAPI_MakeShape
+{
+public:
+  /// Default constructor
+  GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShapeCustom();
+
+  /// Sets result shape.
+  GEOMALGOAPI_EXPORT void setResult(const std::shared_ptr<GeomAPI_Shape> theShape);
+
+  /// Adds modified shape.
+  GEOMALGOAPI_EXPORT bool addModified(const std::shared_ptr<GeomAPI_Shape> theBase,
+                                      const std::shared_ptr<GeomAPI_Shape> theResult);
+
+  /// Adds generated shape.
+  GEOMALGOAPI_EXPORT bool addGenerated(const std::shared_ptr<GeomAPI_Shape> theBase,
+                                       const std::shared_ptr<GeomAPI_Shape> theResult);
+
+  /// Adds deleted shape.
+  GEOMALGOAPI_EXPORT bool addDeleted(const std::shared_ptr<GeomAPI_Shape> theShape);
+
+  /// \return a shape built by the shape construction algorithms
+  GEOMALGOAPI_EXPORT virtual const std::shared_ptr<GeomAPI_Shape> shape() const;
+
+  /// \return the list of shapes generated from the shape theShape
+  GEOMALGOAPI_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape> theShape,
+                                            ListOfShape& theHistory);
+
+  /// \return the list of shapes modified from the shape theShape
+  GEOMALGOAPI_EXPORT virtual void modified(const std::shared_ptr<GeomAPI_Shape> theShape,
+                                           ListOfShape& theHistory);
+
+  /// \return whether the shape is deleted
+  GEOMALGOAPI_EXPORT virtual bool isDeleted(const std::shared_ptr<GeomAPI_Shape> theShape);
+
+private:
+  std::shared_ptr<GeomAPI_Shape>    myShape;
+  GeomAPI_DataMapOfShapeMapOfShapes myGenerated;
+  GeomAPI_DataMapOfShapeMapOfShapes myModified;
+  GeomAPI_DataMapOfShapeShape       myDeleted;
+};
+
+#endif
\ No newline at end of file
index 92f1c04dfd7c2f0ef83e2bf3f2336a9a03b5d3aa..6b6682c1cfa0fb02f79284160381e08404ecafc3 100644 (file)
@@ -14,7 +14,7 @@
 
 /** \class GeomAlgoAPI_MakeShapeList
  *  \ingroup DataAlgo
- *  \brief Interface to the root class of all topological shapes constructions
+ *  \brief List of topological shapes constructions
  */
 class GeomAlgoAPI_MakeShapeList : public GeomAlgoAPI_MakeShape
 {
@@ -48,7 +48,7 @@ public:
   GEOMALGOAPI_EXPORT void append(const GeomAlgoAPI_MakeShapeList& theMakeShapeList);
 
   /// \return a shape built by the shape construction algorithms
-  GEOMALGOAPI_EXPORT const std::shared_ptr<GeomAPI_Shape> shape() const;
+  GEOMALGOAPI_EXPORT virtual const std::shared_ptr<GeomAPI_Shape> shape() const;
 
   /// \return the list of shapes generated from the shape \a theShape
   GEOMALGOAPI_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape> theShape,
@@ -58,7 +58,7 @@ public:
   GEOMALGOAPI_EXPORT virtual void modified(const std::shared_ptr<GeomAPI_Shape> theShape,
                                            ListOfShape& theHistory);
 
-  /// Returns whether the shape is deleted
+  /// \return whether the shape is deleted
   GEOMALGOAPI_EXPORT virtual bool isDeleted(const std::shared_ptr<GeomAPI_Shape> theShape);
 
 private: