]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Added CPP High API for BuildPlugin_Wire
authordbv <dbv@opencascade.com>
Thu, 16 Jun 2016 15:22:11 +0000 (18:22 +0300)
committerspo <sergey.pokhodenko@opencascade.com>
Fri, 17 Jun 2016 11:41:13 +0000 (14:41 +0300)
src/BuildAPI/BuildAPI.i
src/BuildAPI/BuildAPI_Wire.cpp [new file with mode: 0644]
src/BuildAPI/BuildAPI_Wire.h [new file with mode: 0644]
src/BuildAPI/BuildAPI_swig.h
src/BuildAPI/CMakeLists.txt
src/BuildPlugin/BuildPlugin_Wire.cpp
src/BuildPlugin/BuildPlugin_Wire.h

index 7745dc9e09d74cefc411467f7adaa550f6c703d2..56bd04bd201635b5a158de8506e62058182fec9a 100644 (file)
@@ -21,7 +21,9 @@
 // shared pointers
 %shared_ptr(BuildAPI_Edge)
 %shared_ptr(BuildAPI_Vertex)
+%shared_ptr(BuildAPI_Wire)
 
 // all supported interfaces
 %include "BuildAPI_Edge.h"
 %include "BuildAPI_Vertex.h"
+%include "BuildAPI_Wire.h"
diff --git a/src/BuildAPI/BuildAPI_Wire.cpp b/src/BuildAPI/BuildAPI_Wire.cpp
new file mode 100644 (file)
index 0000000..66631c7
--- /dev/null
@@ -0,0 +1,55 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        BuildAPI_Wire.cpp
+// Created:     09 June 2016
+// Author:      Dmitry Bobylev
+
+#include "BuildAPI_Wire.h"
+
+#include <ModelHighAPI_Tools.h>
+
+//==================================================================================================
+BuildAPI_Wire::BuildAPI_Wire(const std::shared_ptr<ModelAPI_Feature>& theFeature)
+: ModelHighAPI_Interface(theFeature)
+{
+  initialize();
+}
+
+//==================================================================================================
+BuildAPI_Wire::BuildAPI_Wire(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                             const std::list<ModelHighAPI_Selection>& theBaseObjects)
+: ModelHighAPI_Interface(theFeature)
+{
+  if(initialize()) {
+    setBase(theBaseObjects);
+  }
+}
+
+//==================================================================================================
+BuildAPI_Wire::~BuildAPI_Wire()
+{
+
+}
+
+//==================================================================================================
+void BuildAPI_Wire::setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects)
+{
+  fillAttribute(theBaseObjects, mybaseObjects);
+
+  execute();
+}
+
+//==================================================================================================
+void BuildAPI_Wire::addContour()
+{
+  feature()->customAction(BuildPlugin_Wire::ADD_CONTOUR_ACTION_ID());
+}
+
+// TODO(spo): make add* as static functions of the class
+//==================================================================================================
+WirePtr addWire(const std::shared_ptr<ModelAPI_Document>& thePart,
+                const std::list<ModelHighAPI_Selection>& theBaseObjects)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(BuildAPI_Wire::ID());
+  return WirePtr(new BuildAPI_Wire(aFeature, theBaseObjects));
+}
diff --git a/src/BuildAPI/BuildAPI_Wire.h b/src/BuildAPI/BuildAPI_Wire.h
new file mode 100644 (file)
index 0000000..d1d24fa
--- /dev/null
@@ -0,0 +1,59 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        BuildAPI_Wire.h
+// Created:     09 June 2016
+// Author:      Dmitry Bobylev
+
+#ifndef BuildAPI_Wire_H_
+#define BuildAPI_Wire_H_
+
+#include "BuildAPI.h"
+
+#include <BuildPlugin_Wire.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+
+class ModelHighAPI_Selection;
+
+/// \class BuildAPI_Wire
+/// \ingroup CPPHighAPI
+/// \brief Interface for Wire feature.
+class BuildAPI_Wire: public ModelHighAPI_Interface
+{
+public:
+  /// Constructor without values.
+  BUILDAPI_EXPORT
+  explicit BuildAPI_Wire(const std::shared_ptr<ModelAPI_Feature>& theFeature);
+
+  /// Constructor with values.
+  BUILDAPI_EXPORT
+  explicit BuildAPI_Wire(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                         const std::list<ModelHighAPI_Selection>& theBaseObjects);
+
+  /// Destructor.
+  BUILDAPI_EXPORT
+  virtual ~BuildAPI_Wire();
+
+  INTERFACE_1(BuildPlugin_Wire::ID(),
+              baseObjects, BuildPlugin_Wire::BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList, /** Base objects */)
+
+  /// Modify base attribute of the feature.
+  BUILDAPI_EXPORT
+  void setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects);
+
+  /// Adds closed contour.
+  BUILDAPI_EXPORT
+  void addContour();
+};
+
+/// Pointer on Wire object.
+typedef std::shared_ptr<BuildAPI_Wire> WirePtr;
+
+/// \ingroup CPPHighAPI
+/// \brief Create Wire feature.
+BUILDAPI_EXPORT
+WirePtr addWire(const std::shared_ptr<ModelAPI_Document>& thePart,
+                const std::list<ModelHighAPI_Selection>& theBaseObjects);
+
+#endif // BuildAPI_Wire_H_
index dd947e8633ecb2f1a5e4cf0b92cb62afbbf41a4f..f6d982af218c2cec73bb02ec9e8dd0ccd7f9c439 100644 (file)
@@ -11,5 +11,6 @@
 
   #include "BuildAPI_Edge.h"
   #include "BuildAPI_Vertex.h"
+  #include "BuildAPI_Wire.h"
 
 #endif // FeaturesAPI_swig_H_
index 51d197dde6e1ce3075675b735947abe520ada7d8..3cf929265dc313c8582c826ee38c1f71c77a064f 100644 (file)
@@ -6,11 +6,13 @@ SET(PROJECT_HEADERS
   BuildAPI.h
   BuildAPI_Edge.h
   BuildAPI_Vertex.h
+  BuildAPI_Wire.h
 )
 
 SET(PROJECT_SOURCES
   BuildAPI_Edge.cpp
   BuildAPI_Vertex.cpp
+  BuildAPI_Wire.cpp
 )
 
 SET(PROJECT_LIBRARIES
index 6acb80b235d9adaa03896da81799fbe910459172..4b7231a721a7589295d12e63f319b81d07310f3b 100644 (file)
@@ -85,7 +85,7 @@ void BuildPlugin_Wire::execute()
 //=================================================================================================
 bool BuildPlugin_Wire::customAction(const std::string& theActionId)
 {
-  if(theActionId == "add_contour") {
+  if(theActionId == ADD_CONTOUR_ACTION_ID()) {
     return addContour();
   } else {
     std::string aMsg = "Error: Feature \"%1\" does not support action \"%2\".";
index 39128be6b49d93b0cea706502b5f34a1b1747c24..acf500669f4b4953d8938193fbb04fcc2ae326e7 100644 (file)
@@ -34,6 +34,13 @@ public:
     return MY_BASE_OBJECTS_ID;
   }
 
+  /// Attribute name of base objects.
+  inline static const std::string& ADD_CONTOUR_ACTION_ID()
+  {
+    static const std::string MY_ADD_CONTOUR_ACTION_ID("add_contour");
+    return MY_ADD_CONTOUR_ACTION_ID;
+  }
+
   /// \return the kind of a feature.
   BUILDPLUGIN_EXPORT virtual const std::string& getKind()
   {