]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
CPP API for FeaturesPlugin_Placement
authordbv <dbv@opencascade.com>
Tue, 7 Jun 2016 14:11:52 +0000 (17:11 +0300)
committerspo <sergey.pokhodenko@opencascade.com>
Fri, 17 Jun 2016 11:41:06 +0000 (14:41 +0300)
src/FeaturesAPI/CMakeLists.txt
src/FeaturesAPI/FeaturesAPI.i
src/FeaturesAPI/FeaturesAPI_Placement.cpp [new file with mode: 0644]
src/FeaturesAPI/FeaturesAPI_Placement.h [new file with mode: 0644]
src/FeaturesAPI/FeaturesAPI_swig.h
src/PythonAPI/Test/TestFeatures.py

index bae756a300dfb45a33c3e600840bfe1988ca0f73..c5701e9edcbbb83248308f2e29ef9c109de01904 100644 (file)
@@ -4,11 +4,13 @@ INCLUDE(Common)
 
 SET(PROJECT_HEADERS
   FeaturesAPI.h
+  FeaturesAPI_Placement.h
   FeaturesAPI_Rotation.h
   FeaturesAPI_Translation.h
 )
 
 SET(PROJECT_SOURCES
+  FeaturesAPI_Placement.cpp
   FeaturesAPI_Rotation.cpp
   FeaturesAPI_Translation.cpp
 )
index 5879100c85fbd721c44070ffcfcdfbeacb448a57..81ab3f8a667eae7efb3c5f44c4b3dca2c52d4999 100644 (file)
 %include "std_shared_ptr.i"
 
 // shared pointers
+%shared_ptr(FeaturesAPI_Placement)
 %shared_ptr(FeaturesAPI_Rotation)
 %shared_ptr(FeaturesAPI_Translation)
 
 // all supported interfaces
+%include "FeaturesAPI_Placement.h"
 %include "FeaturesAPI_Rotation.h"
 %include "FeaturesAPI_Translation.h"
diff --git a/src/FeaturesAPI/FeaturesAPI_Placement.cpp b/src/FeaturesAPI/FeaturesAPI_Placement.cpp
new file mode 100644 (file)
index 0000000..4d08706
--- /dev/null
@@ -0,0 +1,98 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        FeaturesAPI_Placement.cpp
+// Created:     07 June 2016
+// Author:      Dmitry Bobylev
+
+#include "FeaturesAPI_Placement.h"
+
+#include <ModelHighAPI_Tools.h>
+
+//==================================================================================================
+FeaturesAPI_Placement::FeaturesAPI_Placement(const std::shared_ptr<ModelAPI_Feature> & theFeature)
+: ModelHighAPI_Interface(theFeature)
+{
+  initialize();
+}
+
+//==================================================================================================
+FeaturesAPI_Placement::FeaturesAPI_Placement(const std::shared_ptr<ModelAPI_Feature> & theFeature,
+                                             const std::list<ModelHighAPI_Selection>& theObjects,
+                                             const ModelHighAPI_Selection& theStartShape,
+                                             const ModelHighAPI_Selection& theEndShape,
+                                             const bool theReverseDirection,
+                                             const bool theCentering)
+: ModelHighAPI_Interface(theFeature)
+{
+  if(initialize()) {
+    setObjects(theObjects);
+    setStartShape(theStartShape);
+    setEndShape(theEndShape);
+    setReverseDirection(theReverseDirection);
+    setCentering(theCentering);
+  }
+}
+
+//==================================================================================================
+FeaturesAPI_Placement::~FeaturesAPI_Placement()
+{
+
+}
+
+//==================================================================================================
+void FeaturesAPI_Placement::setObjects(const std::list<ModelHighAPI_Selection>& theObjects)
+{
+  fillAttribute(theObjects, myobjects);
+
+  execute();
+}
+
+//==================================================================================================
+void FeaturesAPI_Placement::setStartShape(const ModelHighAPI_Selection& theStartShape)
+{
+  fillAttribute(theStartShape, mystartShape);
+
+  execute();
+}
+
+//==================================================================================================
+void FeaturesAPI_Placement::setEndShape(const ModelHighAPI_Selection& theEndShape)
+{
+  fillAttribute(theEndShape, myendShape);
+
+  execute();
+}
+
+//==================================================================================================
+void FeaturesAPI_Placement::setReverseDirection(const bool theReverseDirection)
+{
+  fillAttribute(theReverseDirection, myreverseDirection);
+
+  execute();
+}
+
+//==================================================================================================
+void FeaturesAPI_Placement::setCentering(const bool theCentering)
+{
+  fillAttribute(theCentering, mycentering);
+
+  execute();
+}
+
+// TODO(spo): make add* as static functions of the class
+//==================================================================================================
+PlacementPtr addPlacement(const std::shared_ptr<ModelAPI_Document> & thePart,
+                          const std::list<ModelHighAPI_Selection>& theObjects,
+                          const ModelHighAPI_Selection& theStartShape,
+                          const ModelHighAPI_Selection& theEndShape,
+                          const bool theReverseDirection,
+                          const bool theCentering)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Placement::ID());
+  return PlacementPtr(new FeaturesAPI_Placement(aFeature,
+                                                theObjects,
+                                                theStartShape,
+                                                theEndShape,
+                                                theReverseDirection,
+                                                theCentering));
+}
diff --git a/src/FeaturesAPI/FeaturesAPI_Placement.h b/src/FeaturesAPI/FeaturesAPI_Placement.h
new file mode 100644 (file)
index 0000000..7d053e9
--- /dev/null
@@ -0,0 +1,84 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        FeaturesAPI_Placement.h
+// Created:     07 June 2016
+// Author:      Dmitry Bobylev
+
+#ifndef FeaturesAPI_Placement_H_
+#define FeaturesAPI_Placement_H_
+
+#include "FeaturesAPI.h"
+
+#include <FeaturesPlugin_Placement.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+
+class ModelHighAPI_Double;
+class ModelHighAPI_Selection;
+
+/// \class FeaturesAPI_Placement
+/// \ingroup CPPHighAPI
+/// \brief Interface for Placement feature.
+class FeaturesAPI_Placement : public ModelHighAPI_Interface
+{
+public:
+  /// Constructor without values.
+  FEATURESAPI_EXPORT
+  explicit FeaturesAPI_Placement(const std::shared_ptr<ModelAPI_Feature> & theFeature);
+
+  /// Constructor with values.
+  FEATURESAPI_EXPORT
+  FeaturesAPI_Placement(const std::shared_ptr<ModelAPI_Feature> & theFeature,
+                        const std::list<ModelHighAPI_Selection>& theObjects,
+                        const ModelHighAPI_Selection& theStartShape,
+                        const ModelHighAPI_Selection& theEndShape,
+                        const bool theReverseDirection = false,
+                        const bool theCentering = false);
+
+  /// Destructor.
+  FEATURESAPI_EXPORT
+  virtual ~FeaturesAPI_Placement();
+
+  INTERFACE_5(FeaturesPlugin_Placement::ID(),
+              objects, FeaturesPlugin_Placement::OBJECTS_LIST_ID(), ModelAPI_AttributeSelectionList, /** Main objects */,
+              startShape, FeaturesPlugin_Placement::START_SHAPE_ID(), ModelAPI_AttributeSelection, /** Start shape */,
+              endShape, FeaturesPlugin_Placement::END_SHAPE_ID(), ModelAPI_AttributeSelection, /** End shape */,
+              reverseDirection, FeaturesPlugin_Placement::REVERSE_ID(), ModelAPI_AttributeBoolean, /** Reverse direction flag */,
+              centering, FeaturesPlugin_Placement::CENTERING_ID(), ModelAPI_AttributeBoolean, /** Centering flag */)
+
+  /// Set objects.
+  FEATURESAPI_EXPORT
+  void setObjects(const std::list<ModelHighAPI_Selection>& theObjects);
+
+  /// Set start shape.
+  FEATURESAPI_EXPORT
+  void setStartShape(const ModelHighAPI_Selection& theStartShape);
+
+  /// Set end shape.
+  FEATURESAPI_EXPORT
+  void setEndShape(const ModelHighAPI_Selection& theEndShape);
+
+  /// Set reverse direction flag.
+  FEATURESAPI_EXPORT
+  void setReverseDirection(const bool theReverseDirection);
+
+  /// Set centering flag.
+  FEATURESAPI_EXPORT
+  void setCentering(const bool theCentering);
+};
+
+/// Pointer on Placement object.
+typedef std::shared_ptr<FeaturesAPI_Placement> PlacementPtr;
+
+/// \ingroup CPPHighAPI
+/// \brief Create Placement feature.
+FEATURESAPI_EXPORT
+PlacementPtr addPlacement(const std::shared_ptr<ModelAPI_Document> & thePart,
+                          const std::list<ModelHighAPI_Selection>& theObjects,
+                          const ModelHighAPI_Selection& theStartShape,
+                          const ModelHighAPI_Selection& theEndShape,
+                          const bool theReverseDirection = false,
+                          const bool theCentering = false);
+
+#endif // FeaturesAPI_Placement_H_
index cbfd4acdf5e0a0003278682937fabd851139ec2d..e73a541b6e37fc41dff663e30968f2232b1f58ab 100644 (file)
@@ -10,6 +10,7 @@
   #include <ModelHighAPI_swig.h>
 
   #include "FeaturesAPI.h"
+  #include "FeaturesAPI_Placement.h"
   #include "FeaturesAPI_Rotation.h"
   #include "FeaturesAPI_Translation.h"
 
index ac83e141b79af4cffb19ea19c35bdd0a27b47444..d7e6130105186c7b13ed2ba100a1cf2a473ef491 100644 (file)
@@ -69,7 +69,7 @@ class FeaturesTestCase(FeaturesFixture):
         model.features.revolution.Revolution(self.part.addFeature("Revolution"))
         # model.features.revolution_boolean.RevolutionBoolean(self.part.addFeature("RevolutionCut"))
         # model.features.revolution_boolean.RevolutionBoolean(self.part.addFeature("RevolutionFuse"))
-        model.features.placement.Placement(self.part.addFeature("Placement"))
+        FeaturesAPI.FeaturesAPI_Placement(self.part.addFeature("Placement"))
         FeaturesAPI.FeaturesAPI_Rotation(self.part.addFeature("Rotation"))
         FeaturesAPI.FeaturesAPI_Translation(self.part.addFeature("Translation"))
         model.features.group.Group(self.part.addFeature("Group"))