Salome HOME
Initial support of publication of shapes
authormpv <mpv@opencascade.com>
Tue, 10 Dec 2019 14:39:15 +0000 (17:39 +0300)
committermpv <mpv@opencascade.com>
Tue, 10 Dec 2019 14:39:15 +0000 (17:39 +0300)
idl/SHAPERSTUDY_Gen.idl
src/PY/SHAPERSTUDY.py
src/PY/SHAPERSTUDY_Object.py
src/PY/SHAPERSTUDY_utils.py
src/SWIG/StudyData_Swig.i
src/StudyData/StudyData_Object.cpp
src/StudyData/StudyData_Object.h

index e5a3d563a18a7e3e1ec9dc885e99146a35f820e8..de63919c48c153b94c267369e7b91ae234d43268 100644 (file)
 
 module SHAPERSTUDY_ORB
 {
+
+interface SHAPER_Object     : GEOM::GEOM_Object
+{
+  void SetShapeByStream(in string theStream);
+};
+
 interface Gen : GEOM::GEOM_Gen
 {
+  /*!
+   *  \brief Creates a SHAPERSTUDY_Object to interact with SHAPER
+   */
+  SHAPER_Object CreateShape();
 };
 
 interface IShapesOperations : GEOM::GEOM_IShapesOperations
@@ -53,10 +63,6 @@ interface BaseObject        : GEOM::GEOM_BaseObject
 {
 };
 
-interface SHAPER_Object     : GEOM::GEOM_Object
-{
-};
-
 interface Field             : GEOM::GEOM_Field
 {
 };
index 6730fb26d813267a0ac46da5acd2a01db8baf8fd..b01781a138dbfe34693cbf0e282b87c33ee4e548 100644 (file)
@@ -25,6 +25,8 @@ import SALOME_ComponentPy
 import SALOME_DriverPy
 import SALOMEDS
 from SHAPERSTUDY_utils import findOrCreateComponent, moduleName, getStudy, getORB
+import salome
+import SHAPERSTUDY_Object
 
 __entry2IOR__ = {}
 
@@ -51,11 +53,11 @@ class SHAPERSTUDY(SHAPERSTUDY_ORB__POA.Gen,
         #
         pass
 
-    def publish( self, theShaperObj ):
+    def CreateShape( self ):
         """
-        Publish GEOM_Object corresponding to a given SHAPER object
+        Creates a SHAPERSTUDY_Object to interact with SHAPER
         """
-        return SHAPERSTUDY_Object()
+        return SHAPERSTUDY_Object.SHAPERSTUDY_Object()._this()
 
     def AddInStudy( self, theObject, theName, theFather ):
         """
@@ -63,8 +65,17 @@ class SHAPERSTUDY(SHAPERSTUDY_ORB__POA.Gen,
         if theFather is not NULL the object is placed under theFather's SObject.
         Returns a SObject where theObject is placed
         """
-        so = SALOMEDS.SALOMEDS_SObject()
-        return so
+        aStudy = getStudy()
+        aBuilder = aStudy.NewBuilder()
+        if not theFather:
+          theFather = findOrCreateComponent()
+        aResultSO = aBuilder.NewObject(theFather);
+        aResultSO.SetAttrString("AttributeName", theName)
+        if theObject:
+          anIOR = salome.orb.object_to_string(theObject)
+          aResultSO.SetAttrString("AttributeIOR", anIOR)
+
+        return aResultSO
 
     def AddSubShape( theMainShape, theIndices ):
         """
@@ -124,7 +135,8 @@ class SHAPERSTUDY(SHAPERSTUDY_ORB__POA.Gen,
         Parameters:
             theStudyEntry is an entry of the Object in the study
         """
-        return ""
+        print("My Test")
+        return "test"
 
 
     def Save( self, component, URL, isMultiFile ):
@@ -265,27 +277,3 @@ class SHAPERSTUDY(SHAPERSTUDY_ORB__POA.Gen,
         Adds to the group all the given shapes. No errors, if some shapes are already included.
         """
         return GetIGroupOperations().UnionList( theGroup, theSubShapes )
-
-    def addToStudy( self, aShape, aName ):
-        """
-        Publish in study aShape with name aName
-        """
-        try:
-            so = self.AddInStudy(aShape, aName, None )
-            if so and aName: so.SetAttrString("AttributeName", aName)
-        except:
-            print("addToStudyInFather() failed")
-            return ""
-        return so.GetStudyEntry()
-
-    def addToStudyInFather(self, aFather, aShape, aName):
-        """
-        Publish in study aShape with name aName as sub-object of previously published aFather
-        """
-        try:
-            so = self.AddInStudy(aShape, aName, aFather )
-            if so and aName: so.SetAttrString("AttributeName", aName)
-        except:
-            print("addToStudyInFather() failed")
-            return ""
-        return so.GetStudyEntry()
index 46eb7f121cca4e9e918900ba0c6ba5d0dd028261..4a8f4000c9b81d25082e2e1f9018b75bc2a8b3ba 100644 (file)
@@ -129,4 +129,10 @@ class SHAPERSTUDY_Object(SHAPERSTUDY_ORB__POA.SHAPER_Object):
         """
         return ;
 
+    def SetShapeByStream(self, theStream):
+        """
+        Sets geometric shape content of the object as a byte stream in BRep format
+        """
+        return ;
+
     pass
index 1ef1a0326d2eafe5ac1dc63638a59485fc13fc40..0cf33c64d038fe2718d1a8732cd1bedbb86c5bc5 100644 (file)
@@ -146,7 +146,7 @@ def getEngineIOR():
 ###
 def findOrCreateComponent():
     study = getStudy()
-    father =study.FindComponent( moduleName() )
+    father = study.FindComponent( moduleName() )
     if father is None:
         builder = study.NewBuilder()
         father = builder.NewComponent( moduleName() )
index f74d9d1cf282a54618abe7a82a6f332c21d08f9d..93ce542622df8fdfcb471115184c742f2c941f5d 100644 (file)
@@ -5,3 +5,5 @@
 %{
 #include "StudyData_Object.h"
 %}
+
+%include "StudyData_Object.h"
index 31e466802c4e9ba7afba6096194e7165a2cfa39b..13e22ddcb389213986aabb675ac4e02289528c81 100644 (file)
 #include <BRep_Builder.hxx>
 #include <BRepTools.hxx>
 
-StudyData_Object::StudyData_Object(SALOMEDS::TMPFile_var theFile)
+StudyData_Object::StudyData_Object(const std::string theFile)
 {
-  int sizebuf = theFile->length();
-  char* aBuf;
-  aBuf = (char*)&theFile[0];
-  std::istringstream streamBrep(aBuf);
+  std::istringstream streamBrep(theFile.c_str());
   BRep_Builder aBuilder;
   BRepTools::Read(myShape, streamBrep, aBuilder);
 }
index 55e786656083a40bcc43e17bf92d9bfd1b71c686..d04d3504ab4675a0c53ddd4c10b16935ad56dd6b 100644 (file)
@@ -30,7 +30,7 @@
 class StudyData_Object
 {
 public:
-  StudyData_Object(SALOMEDS::TMPFile_var theFile);
+  Standard_EXPORT StudyData_Object(const std::string theFile);
 
 
 private: