]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Add resilt() and selectFace()
authorspo <sergey.pokhodenko@opencascade.com>
Tue, 14 Jun 2016 12:12:45 +0000 (15:12 +0300)
committerspo <sergey.pokhodenko@opencascade.com>
Fri, 17 Jun 2016 11:41:07 +0000 (14:41 +0300)
src/ModelHighAPI/ModelHighAPI.i
src/ModelHighAPI/ModelHighAPI_Interface.cpp
src/ModelHighAPI/ModelHighAPI_Interface.h
src/PythonAPI/examples/MakeBrick1.py
src/SketchAPI/SketchAPI_Sketch.cpp
src/SketchAPI/SketchAPI_Sketch.h

index 522ed48deea48e106c76b9829928623f79ee6955..7bea7bc27ce48de52ab4b89d594958615b4c6540 100644 (file)
@@ -3,6 +3,9 @@
 
 %{
   #include "ModelHighAPI_swig.h"
+
+  // fix for SWIG v2.0.4
+  #define SWIGPY_SLICE_ARG(obj) ((PySliceObject*)(obj))
 %}
 
 %include "doxyhelp.i"
 %include "ModelHighAPI_RefAttr.h"
 %include "ModelHighAPI_Selection.h"
 %include "ModelHighAPI_Tools.h"
+
+%template(SelectionList) std::list<ModelHighAPI_Selection>;
index 7e6c41d257081652746f4819fd9fb7cce89dcc60..caa3d7acebe5c1d8f8573e28ff5a998f141da3e1 100644 (file)
@@ -10,6 +10,8 @@
 #include <Events_Error.h>
 
 #include <ModelAPI_Feature.h>
+
+#include "ModelHighAPI_Selection.h"
 //--------------------------------------------------------------------------------------
 ModelHighAPI_Interface::ModelHighAPI_Interface(const std::shared_ptr<ModelAPI_Feature> & theFeature)
 : myFeature(theFeature)
@@ -38,6 +40,18 @@ void ModelHighAPI_Interface::execute()
   feature()->execute();
 }
 
+std::list<ModelHighAPI_Selection> ModelHighAPI_Interface::result() const
+{
+  std::list<ModelHighAPI_Selection> aSelectionList;
+
+  std::list<std::shared_ptr<ModelAPI_Result> > aResults = feature()->results();
+  for (auto it = aResults.begin(), end = aResults.end(); it != end; ++it) {
+    aSelectionList.push_back(ModelHighAPI_Selection(*it));
+  }
+
+  return aSelectionList;
+}
+
 void ModelHighAPI_Interface::throwException(const std::string & theDescription)
 {
   Events_Error::send(theDescription);
index 8298e9badf17a0a557449af01f0a91d883a69f82..fd536ca333427158dcc0a7fa7970814688700fad 100644 (file)
 //--------------------------------------------------------------------------------------
 #include "ModelHighAPI.h"
 
+#include <list>
 #include <memory>
 #include <string>
 //--------------------------------------------------------------------------------------
 class ModelAPI_Feature;
+class ModelHighAPI_Selection;
 //--------------------------------------------------------------------------------------
 /**\class ModelHighAPI_Interface
  * \ingroup CPPHighAPI
@@ -41,6 +43,10 @@ public:
   MODELHIGHAPI_EXPORT
   void execute();
 
+  /// Return all objects of the feature
+  MODELHIGHAPI_EXPORT
+  virtual std::list<ModelHighAPI_Selection> result() const;
+
   /// Throw exception to event loop
   MODELHIGHAPI_EXPORT
   void throwException(const std::string & theDescription);
index ba828e87fd1b48a89407481a7497651726b36a4a..1d44618134517b0ae4550cf361d2e2b99fb046b1 100644 (file)
@@ -30,13 +30,15 @@ mybase.setCoincident(l2.endPoint(), l3.startPoint())
 mybase.setCoincident(l3.endPoint(), l4.startPoint())
 mybase.setCoincident(l4.endPoint(), l1.startPoint())
 
-mybase.setParallel(l1.result(), l3.result())
-mybase.setParallel(l2.result(), l4.result())
+mybase.setParallel(l1, l3)
+mybase.setParallel(l2, l4)
 
-mybase.setPerpendicular(l1.result(), l4.result())
+mybase.setPerpendicular(l1, l4)
 
-mywidth = mybase.setLength(l1.result(), 50)
-mylength = mybase.setDistance(l1.startPoint(), l3.result(), 50)
+mywidth = mybase.setLength(l1, 50)
+mylength = mybase.setDistance(l1.startPoint(), l3, 50)
+
+mybase.execute()
 
 # Creating the extrusion
 
@@ -53,14 +55,14 @@ thiszmax = "Extrusion_1_1/Generated_Face_2&Extrusion_1_1/To_Face_1_1"
 mystand = model.addSketch(mypart, thisface)
 
 c1 = mystand.addCircle(0, 25, 5)
-mystand.setDistance(c1.center(), thisxmin, 10)
-mystand.setDistance(c1.center(), thiszmax, 10)
+mystand.setDistance(c1.center(), mystand.addLine(thisxmin), 10)
+mystand.setDistance(c1.center(), mystand.addLine(thiszmax), 10)
 
-myboss = model.addExtrusion(mypart, mystand.selectFace(c1.result()), -5)
+myboss = model.addExtrusion(mypart, mystand.selectFace(), -5)
 
 # Subtracting the cylinder to the box
 
-model.addSubtraction(mypart, mybox.result(), myboss.result())
+model.addCut(mypart, mybox.result(), myboss.result())
 model.end()
 
 
index 52119f62b44c7f7f6b88a94fd7625c31d04ecb4a..e478339f24d9d1f71fbc8ceb4991e2217ae686b3 100644 (file)
@@ -26,6 +26,7 @@
 #include <SketchPlugin_ConstraintVertical.h>
 //--------------------------------------------------------------------------------------
 #include <ModelAPI_CompositeFeature.h>
+#include <ModelAPI_ResultConstruction.h>
 #include <ModelHighAPI_RefAttr.h>
 #include <ModelHighAPI_Selection.h>
 #include <ModelHighAPI_Tools.h>
@@ -99,6 +100,25 @@ void SketchAPI_Sketch::setValue(
   theConstraint->execute();
 }
 
+//--------------------------------------------------------------------------------------
+std::list<ModelHighAPI_Selection> SketchAPI_Sketch::selectFace() const
+{
+  std::list<ModelHighAPI_Selection> aSelectionList;
+
+  ResultConstructionPtr aResultConstruction =
+      std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(feature()->firstResult());
+  if (aResultConstruction.get() == NULL)
+    return aSelectionList;
+
+  for (int anIndex = 0; anIndex < aResultConstruction->facesNum(); ++anIndex) {
+    aSelectionList.push_back(
+        ModelHighAPI_Selection(aResultConstruction,
+                               aResultConstruction->face(anIndex)));
+  }
+
+  return aSelectionList;
+}
+
 //--------------------------------------------------------------------------------------
 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
                     const std::shared_ptr<GeomAPI_Ax3> & thePlane)
index 70ec19cb9baf2e9410a61a1964145d43c86e6803..fdbaca992816cf99f550f31ba8540dea09ed2ac0 100644 (file)
@@ -10,6 +10,8 @@
 //--------------------------------------------------------------------------------------
 #include "SketchAPI.h"
 
+#include <list>
+
 #include <SketchPlugin_Sketch.h>
 #include <SketchPlugin_SketchEntity.h>
 
@@ -155,6 +157,11 @@ public:
 
   // TODO(spo): setText. Is it necessary as setValue accepts text expressions?
 
+  // TODO(spo): rename to selectFaces() or faces() (or add faces() -> list to SWIG)
+  /// Select face
+  SKETCHAPI_EXPORT
+  std::list<ModelHighAPI_Selection> selectFace() const;
+
 protected:
   std::shared_ptr<ModelAPI_CompositeFeature> compositeFeature() const;