Salome HOME
Make SHAPEr STUDY fields exported in SMESH into MED file
authormpv <mpv@opencascade.com>
Thu, 16 Jan 2020 16:56:05 +0000 (19:56 +0300)
committermpv <mpv@opencascade.com>
Thu, 16 Jan 2020 16:56:16 +0000 (19:56 +0300)
idl/SHAPERSTUDY_Gen.idl
src/PY/SHAPERSTUDY.py
src/PY/SHAPERSTUDY_IOperations.py
src/PY/SHAPERSTUDY_Object.py

index efc6b7ceee0bce1ed6b0defbbdeb341b8657cbc9..eb0a6d9b8a5fff4eabd80ae23164aff69945be80 100644 (file)
@@ -115,7 +115,7 @@ interface IGroupOperations  : GEOM::GEOM_IGroupOperations
   SHAPER_Group FindGroup(in SHAPER_Object theOwner, in string theEntry);
 };
 
-interface SHAPER_Field             : SHAPER_Group
+interface SHAPER_Field             : GEOM::GEOM_Field
 {
   /*!
   *  \brief Sets the type of values in the field
@@ -131,6 +131,55 @@ interface SHAPER_Field             : SHAPER_Group
   *  \brief Sets the names of components
   */
   void SetComponents( in GEOM::string_array theComponents );
+  /*!
+  *  \brief Erases all steps of this field
+  */
+  void ClearFieldSteps();
+
+  /*!
+  *  \brief Appends a step data to this field
+  */
+  void AddFieldStep( in long theStampID, in long theStepID, in GEOM::ListOfDouble theValues);
+
+
+  /*!
+  *  \brief Sets what is returned in the GEOM_IGroupOperations::GetType
+  */
+  void SetSelectionType(in long theType);
+  /*!
+  *  \brief Returns the type of the selected sub-shapes
+  */
+  long GetSelectionType();
+  /*!
+  *  \brief Sets what is returned in the GEOM_IGroupOperations::GetObjects
+  */
+  void SetSelection(in GEOM::ListOfLong theSelection);
+  /*!
+  *  \brief Returns the selected sub-shapes indices
+  */
+  GEOM::ListOfLong GetSelection();
+
+
+  /*!
+  *  \brief Sets the internal entry of the object, common for all objects in SHAPER-STUDY
+  */
+  void SetEntry( in string theInternalEntry );
+  /*!
+  *  \brief Sets SObject of this object (when it is published)
+  */
+  void SetSO( in SALOMEDS::SObject theInternalEntry );
+  /*!
+  *  \brief Returns SObject of this object
+  */
+  SALOMEDS::SObject GetSO();
+  /*!
+  *  \brief Returns true if shape is already dead
+  */
+  boolean IsDead();
+  /*!
+  *  \brief Makes the dead-copy of the shape and returns it
+  */
+  SHAPER_Object MakeDead();
 
 };
 
@@ -143,18 +192,13 @@ interface IFieldOperations  : GEOM::GEOM_IFieldOperations
   /*!
   *  \brief Creates a field of theMainShape.
   */
-  SHAPER_Field CreateFieldByType(
-    in GEOM::GEOM_Object theMainShape, in long theShapeType);
+  SHAPER_Field CreateFieldByType(in GEOM::GEOM_Object theMainShape, in long theShapeType);
 };
 
 interface IMeasureOperations  : GEOM::GEOM_IMeasureOperations
 {
 };
 
-interface SHAPER_FieldStep         : GEOM::GEOM_FieldStep
-{
-};
-
 interface SHAPER_DoubleFieldStep   : GEOM::GEOM_DoubleFieldStep
 {
 };
index 4f26ea701bcf333829e7c8d9b71ee77913fd3bda..d689200b3e55547dbc377aae08d7797141506d0d 100644 (file)
@@ -261,7 +261,7 @@ class SHAPERSTUDY(SHAPERSTUDY_ORB__POA.Gen,
             anObj = None
             if anId.startswith('group'): # group object
               anObj = SHAPERSTUDY_Object.SHAPERSTUDY_Group()
-              if len(aNewShapeStream):
+              if len(aSub):
                 anObj.SetSelection([int(anI) for anI in aSub.split(' ')])
               anObj.SetSelectionType(int(aNewShapeStream))
             else: # shape object by BRep in the stream: set old first then new
index 1f878d771c6572e9419602de08cf1f28b9fe23c5..aad76b9265ec077293b6e21122bb4f2c46709a7e 100644 (file)
@@ -50,7 +50,10 @@ class SHAPERSTUDY_IShapesOperations(SHAPERSTUDY_ORB__POA.IShapesOperations,
         """
         aList = self.myop.GetAllSubShapesIDs(theShape.getShape(), theShapeType, isSorted)
         self.done = not aList.empty()
-        return aList
+        aResult = []
+        for i in aList:
+          aResult.append(i)
+        return aResult
 
     def GetSharedShapes( self, theShape1, theShape2, theShapeType ):
         """
@@ -63,7 +66,10 @@ class SHAPERSTUDY_IShapesOperations(SHAPERSTUDY_ORB__POA.IShapesOperations,
         """
         aList = self.myop.GetSharedShapes(theShape1.getShape(), theShape2.getShape(), theShapeType)
         self.done = not aList.empty()
-        return aList
+        aResult = []
+        for i in aList:
+          aResult.append(i)
+        return aResult
 
     def GetSubShapeIndex( self, theMainShape, theSubShape ):
         """
@@ -216,10 +222,11 @@ class SHAPERSTUDY_IFieldOperations(SHAPERSTUDY_ORB__POA.IFieldOperations):
         aStudy = getStudy()
         anIter = aStudy.NewChildIterator(theOwner.GetSO())
         while anIter.More():
-          aFieldObj = anIter.Value().GetObject()
-          if aFieldObj:
-            if aFieldObj.GetEntry() == theEntry:
-              return aFieldObj
+          if len(anIter.Value().GetIOR()):
+            aFieldObj = anIter.Value().GetObject()
+            if aFieldObj:
+              if aFieldObj.GetEntry() == theEntry:
+                return aFieldObj
           anIter.Next()
         return None # not found
 
@@ -235,6 +242,7 @@ class SHAPERSTUDY_IFieldOperations(SHAPERSTUDY_ORB__POA.IFieldOperations):
           aFieldObj = anIter.Value().GetObject()
           if aFieldObj and isinstance(aFieldObj, SHAPERSTUDY_ORB._objref_SHAPER_Field):
             aResList.append(aFieldObj)
+          anIter.Next()
         return aResList
 
     pass
index b441acd71f9ce23f75396aff6901383df729d7cd..1621cba439fe328d7553aa6332b0797691ed62c9 100644 (file)
@@ -63,7 +63,7 @@ class SHAPERSTUDY_GenericObject:
 class SHAPERSTUDY_Object(SHAPERSTUDY_ORB__POA.SHAPER_Object,
                          SHAPERSTUDY_GenericObject):
     """
-    Construct an instance of SHAPERSTUDY Object.
+    Constructs an instance of SHAPERSTUDY Object.
     """
     def __init__ ( self, *args):
         self.SO = None
@@ -266,7 +266,8 @@ class SHAPERSTUDY_Object(SHAPERSTUDY_ORB__POA.SHAPER_Object,
               aDeadGroup.SetSelection(aGroup.GetSelection())
               aDeadGroupSO = aBuilder.NewObject(aDeadSO)
               aDeadGroup.SetSO(aDeadGroupSO)
-              aDeadGroupSO.SetAttrString("AttributeName", aGroupSO.GetName() + " (" + str(anIndex) + ")")
+              # 15.01.20 groups and fields names stays the same
+              #aDeadGroupSO.SetAttrString("AttributeName", aGroupSO.GetName() + " (" + str(anIndex) + ")")
               aDeadGroupObj = aDeadGroup._this()
               anIOR = salome.orb.object_to_string(aDeadGroupObj)
               aDeadGroupSO.SetAttrString("AttributeIOR", anIOR)
@@ -286,7 +287,7 @@ class SHAPERSTUDY_Object(SHAPERSTUDY_ORB__POA.SHAPER_Object,
 
 class SHAPERSTUDY_Group(SHAPERSTUDY_ORB__POA.SHAPER_Group, SHAPERSTUDY_Object):
     """
-    Construct an instance of SHAPERSTUDY Group
+    Constructs an instance of SHAPERSTUDY Group
     """
     def __init__ ( self, *args):
         self.seltype = None
@@ -345,7 +346,7 @@ class SHAPERSTUDY_Group(SHAPERSTUDY_ORB__POA.SHAPER_Group, SHAPERSTUDY_Object):
 
 class SHAPERSTUDY_Field(SHAPERSTUDY_ORB__POA.SHAPER_Field, SHAPERSTUDY_Group):
     """
-    Construct an instance of SHAPERSTUDY Field (inherits selection from a Group object)
+    Constructs an instance of SHAPERSTUDY Field (inherits selection from a Group object)
     """
     def __init__ ( self, *args):
         self.seltype = None
@@ -358,6 +359,7 @@ class SHAPERSTUDY_Field(SHAPERSTUDY_ORB__POA.SHAPER_Field, SHAPERSTUDY_Group):
         self.steps = [] # list of long
         self.components = [] # string array, names of the components
         self.name = None # name, string
+        self.fieldsteps = {} # FieldSteps objects identified by step ID
         pass
 
     def SetValuesType( self, theType ):
@@ -380,6 +382,12 @@ class SHAPERSTUDY_Field(SHAPERSTUDY_ORB__POA.SHAPER_Field, SHAPERSTUDY_Group):
         return GEOM.FDT_String
       return None # unknown case
 
+    def GetShape ( self ):
+      """
+      Returns the shape the field lies on
+      """
+      return super().GetMainShape()
+
     def SetSteps( self, theSteps ):
       self.steps = theSteps
 
@@ -393,7 +401,7 @@ class SHAPERSTUDY_Field(SHAPERSTUDY_ORB__POA.SHAPER_Field, SHAPERSTUDY_Group):
       return self.components
 
     def GetDimension( self ):
-      aShapeType = SHAPERSTUDY_Group.GetSelectionType()
+      aShapeType = super().GetSelectionType()
       if aShapeType == 8:
         return -1 # whole part
       elif aShapeType == 7:
@@ -406,7 +414,111 @@ class SHAPERSTUDY_Field(SHAPERSTUDY_ORB__POA.SHAPER_Field, SHAPERSTUDY_Group):
         return 3 # solid
       return None # unknown case
 
-    def GetShape( self ):
-      return SHAPERSTUDY_Group.getShape()
+    def ClearFieldSteps( self ):
+       self.fieldsteps = {}
+
+    def AddFieldStep( self, theStampID, theStepID, theValues):
+      aFieldStep = None
+      if self.valtype == 0:
+        aFieldStep = SHAPER_BoolFieldStep()
+      elif self.valtype == 1:
+        aFieldStep = SHAPER_IntFieldStep()
+      elif self.valtype == 2:
+        aFieldStep = SHAPER_DoubleFieldStep()
+      
+      aFieldStep.SetStep(theStampID, theStepID, theValues)
+      self.fieldsteps[theStepID] = aFieldStep._this()
+
+    def GetStep( self, theStepID ):
+       return self.fieldsteps[theStepID]
+
+    pass
+
+class SHAPER_FieldStep:
+    """
+    Base class for all step-classes
+    """
+    def __init__ ( self, *args):
+        self.stamp = None  # long, ID of stamp
+        self.step = None   # long, ID of step
+        self.values = None # array of values of the needed type
+
+    """
+    Defines all parameters of the step
+    """
+    def SetStep( self, theStamp, theStep, theValues ):
+        self.stamp = theStamp
+        self.step = theStep
+        self.values = theValues
+     
+    """
+    Returns stamp ID
+    """
+    def GetStamp( self ):
+        return self.stamp
+    """
+    Returns step ID
+    """
+    def GetID( self ):
+        return self.step
+    """
+    Returns a name of a sub-shape if the sub-shape is published in the study
+    """
+    def GetSubShape(self, theSubID):
+        # the SHAPER study does not support sub-shapes for now
+        return ""
+        
+
+class SHAPER_DoubleFieldStep(SHAPERSTUDY_ORB__POA.SHAPER_DoubleFieldStep, SHAPER_FieldStep):
+    """
+    Constructs an instance of SHAPERSTUDY Field step of type Double
+    """
+    def __init__ ( self, *args):
+        pass
+
+    """
+    Returns values as an array of the needed type
+    """
+    def GetValues( self ):
+        aResult = [] # to make any type of result, create a corba-type
+        for i in self.values:
+          aResult.append(float(i))
+        return aResult
+
+    pass
+
+class SHAPER_IntFieldStep(SHAPERSTUDY_ORB__POA.SHAPER_IntFieldStep, SHAPER_FieldStep):
+    """
+    Constructs an instance of SHAPERSTUDY Field step of type Double
+    """
+    def __init__ ( self, *args):
+        pass
+
+    """
+    Returns values as an array of the needed type
+    """
+    def GetValues( self ):
+        aResult = [] # to make any type of result, create a corba-type
+        for i in self.values:
+          aResult.append(int(i))
+        return aResult
+
+    pass
+
+class SHAPER_BoolFieldStep(SHAPERSTUDY_ORB__POA.SHAPER_BoolFieldStep, SHAPER_FieldStep):
+    """
+    Constructs an instance of SHAPERSTUDY Field step of type Double
+    """
+    def __init__ ( self, *args):
+        pass
+
+    """
+    Returns values as an array of the needed type
+    """
+    def GetValues( self ):
+        aResult = [] # to make any type of result, create a corba-type
+        for i in self.values:
+          aResult.append(int(i))
+        return aResult
 
     pass