Salome HOME
Added CPP High API for FeaturesPlugin_Pipe
authordbv <dbv@opencascade.com>
Thu, 16 Jun 2016 13:21:29 +0000 (16:21 +0300)
committerspo <sergey.pokhodenko@opencascade.com>
Fri, 17 Jun 2016 11:41:12 +0000 (14:41 +0300)
src/FeaturesAPI/CMakeLists.txt
src/FeaturesAPI/FeaturesAPI.i
src/FeaturesAPI/FeaturesAPI_Pipe.cpp [new file with mode: 0644]
src/FeaturesAPI/FeaturesAPI_Pipe.h [new file with mode: 0644]
src/FeaturesAPI/FeaturesAPI_swig.h
src/FeaturesPlugin/FeaturesPlugin_Pipe.cpp
src/FeaturesPlugin/FeaturesPlugin_Pipe.h

index a04936172f12e6b210550759c530e1fd2713a8d5..e01482c498ac2359165db5f934f6933417058f6f 100644 (file)
@@ -8,6 +8,7 @@ SET(PROJECT_HEADERS
   FeaturesAPI_Extrusion.h
   FeaturesAPI_ExtrusionBoolean.h
   FeaturesAPI_Group.h
+  FeaturesAPI_Pipe.h
   FeaturesAPI_Placement.h
   FeaturesAPI_Revolution.h
   FeaturesAPI_RevolutionBoolean.h
@@ -20,6 +21,7 @@ SET(PROJECT_SOURCES
   FeaturesAPI_Extrusion.cpp
   FeaturesAPI_ExtrusionBoolean.cpp
   FeaturesAPI_Group.cpp
+  FeaturesAPI_Pipe.cpp
   FeaturesAPI_Placement.cpp
   FeaturesAPI_Rotation.cpp
   FeaturesAPI_Revolution.cpp
index b88e019a1a665cf40e79bc38e56249619c8c4587..0bf48a17017993bd700647b4f5c5978b647eb9a5 100644 (file)
@@ -25,6 +25,7 @@
 %shared_ptr(FeaturesAPI_ExtrusionCut)
 %shared_ptr(FeaturesAPI_ExtrusionFuse)
 %shared_ptr(FeaturesAPI_Group)
+%shared_ptr(FeaturesAPI_Pipe)
 %shared_ptr(FeaturesAPI_Placement)
 %shared_ptr(FeaturesAPI_Revolution)
 %shared_ptr(FeaturesAPI_RevolutionBoolean)
@@ -38,6 +39,7 @@
 %include "FeaturesAPI_Extrusion.h"
 %include "FeaturesAPI_ExtrusionBoolean.h"
 %include "FeaturesAPI_Group.h"
+%include "FeaturesAPI_Pipe.h"
 %include "FeaturesAPI_Placement.h"
 %include "FeaturesAPI_Revolution.h"
 %include "FeaturesAPI_RevolutionBoolean.h"
diff --git a/src/FeaturesAPI/FeaturesAPI_Pipe.cpp b/src/FeaturesAPI/FeaturesAPI_Pipe.cpp
new file mode 100644 (file)
index 0000000..a7e49e0
--- /dev/null
@@ -0,0 +1,141 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        FeaturesAPI_Pipe.cpp
+// Created:     09 June 2016
+// Author:      Dmitry Bobylev
+
+#include "FeaturesAPI_Pipe.h"
+
+#include <ModelHighAPI_Tools.h>
+
+//==================================================================================================
+FeaturesAPI_Pipe::FeaturesAPI_Pipe(const std::shared_ptr<ModelAPI_Feature>& theFeature)
+: ModelHighAPI_Interface(theFeature)
+{
+  initialize();
+}
+
+//==================================================================================================
+FeaturesAPI_Pipe::FeaturesAPI_Pipe(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                                   const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                                   const ModelHighAPI_Selection& thePath)
+: ModelHighAPI_Interface(theFeature)
+{
+  if(initialize()) {
+    fillAttribute(theBaseObjects, mybaseObjects);
+    setPath(thePath);
+  }
+}
+
+//==================================================================================================
+FeaturesAPI_Pipe::FeaturesAPI_Pipe(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                                   const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                                   const ModelHighAPI_Selection& thePath,
+                                   const ModelHighAPI_Selection& theBiNoramal)
+: ModelHighAPI_Interface(theFeature)
+{
+  if(initialize()) {
+    setByBasePathBiNormal(theBaseObjects, thePath, theBiNoramal);
+  }
+}
+
+//==================================================================================================
+FeaturesAPI_Pipe::FeaturesAPI_Pipe(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                                   const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                                   const ModelHighAPI_Selection& thePath,
+                                   const std::list<ModelHighAPI_Selection>& theLocations)
+: ModelHighAPI_Interface(theFeature)
+{
+  if(initialize()) {
+    setByBasePathLocations(theBaseObjects, thePath, theLocations);
+  }
+}
+
+//==================================================================================================
+FeaturesAPI_Pipe::~FeaturesAPI_Pipe()
+{
+
+}
+
+//==================================================================================================
+void FeaturesAPI_Pipe::setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects)
+{
+  fillAttribute(theBaseObjects, mybaseObjects);
+
+  execute();
+}
+
+//==================================================================================================
+void FeaturesAPI_Pipe::setPath(const ModelHighAPI_Selection& thePath)
+{
+  fillAttribute(thePath, mypath);
+
+  execute();
+}
+
+//==================================================================================================
+void FeaturesAPI_Pipe::setByBasePath(const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                                     const ModelHighAPI_Selection& thePath)
+{
+  fillAttribute(FeaturesPlugin_Pipe::CREATION_METHOD_SIMPLE(), mycreationMethod);
+  fillAttribute(theBaseObjects, mybaseObjects);
+  fillAttribute(thePath, mypath);
+
+  execute();
+}
+
+//==================================================================================================
+void FeaturesAPI_Pipe::setByBasePathBiNormal(const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                                             const ModelHighAPI_Selection& thePath,
+                                             const ModelHighAPI_Selection& theBiNoramal)
+{
+  fillAttribute(FeaturesPlugin_Pipe::CREATION_METHOD_BINORMAL(), mycreationMethod);
+  fillAttribute(theBaseObjects, mybaseObjects);
+  fillAttribute(thePath, mypath);
+  fillAttribute(theBiNoramal, mybiNormal);
+
+  execute();
+}
+
+//==================================================================================================
+void FeaturesAPI_Pipe::setByBasePathLocations(const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                                              const ModelHighAPI_Selection& thePath,
+                                              const std::list<ModelHighAPI_Selection>& theLocations)
+{
+  fillAttribute(FeaturesPlugin_Pipe::CREATION_METHOD_LOCATIONS(), mycreationMethod);
+  fillAttribute(theBaseObjects, mybaseObjects);
+  fillAttribute(thePath, mypath);
+  fillAttribute(theLocations, mylocations);
+
+  execute();
+}
+
+// TODO(spo): make add* as static functions of the class
+//==================================================================================================
+PipePtr addPipe(const std::shared_ptr<ModelAPI_Document>& thePart,
+                const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                const ModelHighAPI_Selection& thePath)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Pipe::ID());
+  return PipePtr(new FeaturesAPI_Pipe(aFeature, theBaseObjects, thePath));
+}
+
+//==================================================================================================
+PipePtr addPipe(const std::shared_ptr<ModelAPI_Document>& thePart,
+                const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                const ModelHighAPI_Selection& thePath,
+                const ModelHighAPI_Selection& theBiNoramal)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Pipe::ID());
+  return PipePtr(new FeaturesAPI_Pipe(aFeature, theBaseObjects, thePath, theBiNoramal));
+}
+
+//==================================================================================================
+PipePtr addPipe(const std::shared_ptr<ModelAPI_Document>& thePart,
+                const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                const ModelHighAPI_Selection& thePath,
+                const std::list<ModelHighAPI_Selection>& theLocations)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Pipe::ID());
+  return PipePtr(new FeaturesAPI_Pipe(aFeature, theBaseObjects, thePath, theLocations));
+}
diff --git a/src/FeaturesAPI/FeaturesAPI_Pipe.h b/src/FeaturesAPI/FeaturesAPI_Pipe.h
new file mode 100644 (file)
index 0000000..1a3ee09
--- /dev/null
@@ -0,0 +1,112 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        FeaturesAPI_Pipe.h
+// Created:     09 June 2016
+// Author:      Dmitry Bobylev
+
+#ifndef FeaturesAPI_Pipe_H_
+#define FeaturesAPI_Pipe_H_
+
+#include "FeaturesAPI.h"
+
+#include <FeaturesPlugin_Pipe.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+
+class ModelHighAPI_Selection;
+
+/// \class FeaturesAPI_Pipe
+/// \ingroup CPPHighAPI
+/// \brief Interface for Pipe feature.
+class FeaturesAPI_Pipe: public ModelHighAPI_Interface
+{
+public:
+  /// Constructor without values.
+  FEATURESAPI_EXPORT
+  explicit FeaturesAPI_Pipe(const std::shared_ptr<ModelAPI_Feature>& theFeature);
+
+  /// Constructor with values.
+  FEATURESAPI_EXPORT
+  explicit FeaturesAPI_Pipe(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                            const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                            const ModelHighAPI_Selection& thePath);
+
+  /// Constructor with values.
+  FEATURESAPI_EXPORT
+  explicit FeaturesAPI_Pipe(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                            const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                            const ModelHighAPI_Selection& thePath,
+                            const ModelHighAPI_Selection& theBiNoramal);
+
+  /// Constructor with values.
+  FEATURESAPI_EXPORT
+  explicit FeaturesAPI_Pipe(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                            const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                            const ModelHighAPI_Selection& thePath,
+                            const std::list<ModelHighAPI_Selection>& theLocations);
+
+  /// Destructor.
+  FEATURESAPI_EXPORT
+  virtual ~FeaturesAPI_Pipe();
+
+  INTERFACE_5(FeaturesPlugin_Pipe::ID(),
+              baseObjects, FeaturesPlugin_Pipe::BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList, /** Base objects */,
+              path, FeaturesPlugin_Pipe::PATH_OBJECT_ID(), ModelAPI_AttributeSelection, /** Path */,
+              creationMethod, FeaturesPlugin_Pipe::CREATION_METHOD(), ModelAPI_AttributeString, /** Creation method */,
+              biNormal, FeaturesPlugin_Pipe::BINORMAL_ID(), ModelAPI_AttributeSelection, /** Bi-Normal */,
+              locations, FeaturesPlugin_Pipe::LOCATIONS_ID(), ModelAPI_AttributeSelectionList, /** Locations */)
+
+  /// Modify base attribute of the feature.
+  FEATURESAPI_EXPORT
+  void setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects);
+
+  /// Modify path attribute of the feature.
+  FEATURESAPI_EXPORT
+  void setPath(const ModelHighAPI_Selection& thePath);
+
+  /// Modify creation method, base and path.
+  FEATURESAPI_EXPORT
+  void setByBasePath(const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                     const ModelHighAPI_Selection& thePath);
+
+  /// Modify creation method, base, path and bi-normal.
+  FEATURESAPI_EXPORT
+  void setByBasePathBiNormal(const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                             const ModelHighAPI_Selection& thePath,
+                             const ModelHighAPI_Selection& theBiNoramal);
+
+  /// Modify creation method, base, path and locations.
+  FEATURESAPI_EXPORT
+  void setByBasePathLocations(const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                              const ModelHighAPI_Selection& thePath,
+                              const std::list<ModelHighAPI_Selection>& theLocations);
+};
+
+/// Pointer on Pipe object.
+typedef std::shared_ptr<FeaturesAPI_Pipe> PipePtr;
+
+/// \ingroup CPPHighAPI
+/// \brief Create Pipe feature.
+FEATURESAPI_EXPORT
+PipePtr addPipe(const std::shared_ptr<ModelAPI_Document>& thePart,
+                const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                const ModelHighAPI_Selection& thePath);
+
+/// \ingroup CPPHighAPI
+/// \brief Create Pipe feature.
+FEATURESAPI_EXPORT
+PipePtr addPipe(const std::shared_ptr<ModelAPI_Document>& thePart,
+                const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                const ModelHighAPI_Selection& thePath,
+                const ModelHighAPI_Selection& theBiNoramal);
+
+/// \ingroup CPPHighAPI
+/// \brief Create Pipe feature.
+FEATURESAPI_EXPORT
+PipePtr addPipe(const std::shared_ptr<ModelAPI_Document>& thePart,
+                const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                const ModelHighAPI_Selection& thePath,
+                const std::list<ModelHighAPI_Selection>& theLocations);
+
+#endif // FeaturesAPI_Pipe_H_
index a81bc621f17c9215d7993305d8f63359427ace5c..6d4e02b4638c7c0a4adff61ee224822024c1f584 100644 (file)
@@ -14,6 +14,7 @@
   #include "FeaturesAPI_Extrusion.h"
   #include "FeaturesAPI_ExtrusionBoolean.h"
   #include "FeaturesAPI_Group.h"
+  #include "FeaturesAPI_Pipe.h"
   #include "FeaturesAPI_Placement.h"
   #include "FeaturesAPI_Revolution.h"
   #include "FeaturesAPI_RevolutionBoolean.h"
index ca171dd01688e8105dea871d4a18588fb29e7761..787a37fcc07b4582c88c90e030877961a9621da0 100644 (file)
@@ -129,7 +129,7 @@ void FeaturesPlugin_Pipe::execute()
   }
 
   // Searching faces with common edges.
-  if(aCreationMethod == "simple") {
+  if(aCreationMethod == CREATION_METHOD_SIMPLE()) {
     ListOfShape aShells;
     ListOfShape aFreeFaces;
     std::shared_ptr<GeomAPI_Shape> aFacesCompound = GeomAlgoAPI_CompoundBuilder::compound(aBaseFacesList);
@@ -158,7 +158,7 @@ void FeaturesPlugin_Pipe::execute()
 
   // Getting Bi-Normal
   std::shared_ptr<GeomAPI_Shape> aBiNormal;
-  if(aCreationMethod == "binormal") {
+  if(aCreationMethod == CREATION_METHOD_BINORMAL()) {
     AttributeSelectionPtr aBiNormalSelection = selection(BINORMAL_ID());
     if(!aBiNormalSelection.get()) {
       setError("Error: Bi-Normal selection is empty.");
@@ -177,7 +177,7 @@ void FeaturesPlugin_Pipe::execute()
 
   // Getting locations.
   ListOfShape aLocations;
-  if(aCreationMethod == "locations") {
+  if(aCreationMethod == CREATION_METHOD_LOCATIONS()) {
     AttributeSelectionListPtr aLocationsSelectionList = selectionList(LOCATIONS_ID());
     if(!aLocationsSelectionList.get()) {
       setError("Error: Could not get locations selection list.");
@@ -204,12 +204,13 @@ void FeaturesPlugin_Pipe::execute()
 
   // Generating result for each object.
   int aResultIndex = 0;
-  if(aCreationMethod == "simple" || aCreationMethod == "binormal") {
+  if(aCreationMethod == CREATION_METHOD_SIMPLE() || aCreationMethod == CREATION_METHOD_BINORMAL()) {
     for(ListOfShape::const_iterator anIter = aBaseShapesList.cbegin(); anIter != aBaseShapesList.cend(); anIter++) {
       std::shared_ptr<GeomAPI_Shape> aBaseShape = *anIter;
 
-      GeomAlgoAPI_Pipe aPipeAlgo = aCreationMethod == "simple" ? GeomAlgoAPI_Pipe(aBaseShape, aPathShape) :
-                                                                 GeomAlgoAPI_Pipe(aBaseShape, aPathShape, aBiNormal);
+      GeomAlgoAPI_Pipe aPipeAlgo = aCreationMethod ==
+        CREATION_METHOD_SIMPLE() ? GeomAlgoAPI_Pipe(aBaseShape, aPathShape) :
+                                   GeomAlgoAPI_Pipe(aBaseShape, aPathShape, aBiNormal);
 
       if(!aPipeAlgo.isDone()) {
         setError("Error: Pipe algorithm failed.");
@@ -231,7 +232,7 @@ void FeaturesPlugin_Pipe::execute()
 
       storeResult(aBaseShape, aPipeAlgo, aResultIndex++);
     }
-  } else if(aCreationMethod == "locations") {
+  } else if(aCreationMethod == CREATION_METHOD_LOCATIONS()) {
     GeomAlgoAPI_Pipe aPipeAlgo = GeomAlgoAPI_Pipe(aBaseShapesList, aLocations, aPathShape);
 
     if(!aPipeAlgo.isDone()) {
index 6682f230c19f9394ce7c779bae346502185f88d9..aba97b091f2146a5d14ae045d4535e27e4f806e3 100644 (file)
@@ -39,6 +39,27 @@ public:
     return MY_CREATION_METHOD;
   }
 
+  /// Attribute name for creation method.
+  inline static const std::string& CREATION_METHOD_SIMPLE()
+  {
+    static const std::string MY_CREATION_METHOD("simple");
+    return MY_CREATION_METHOD;
+  }
+
+  /// Attribute name for creation method.
+  inline static const std::string& CREATION_METHOD_BINORMAL()
+  {
+    static const std::string MY_CREATION_METHOD("binormal");
+    return MY_CREATION_METHOD;
+  }
+
+  /// Attribute name for creation method.
+  inline static const std::string& CREATION_METHOD_LOCATIONS()
+  {
+    static const std::string MY_CREATION_METHOD("locations");
+    return MY_CREATION_METHOD;
+  }
+
   /// Attribute name of base objects.
   inline static const std::string& BASE_OBJECTS_ID()
   {