Salome HOME
Compilation SALOME on Windows
[modules/geom.git] / src / GEOM_SWIG / geomBuilder.py
index eba62b74c55172d8683dcc2bbb6f3e8485bcbac5..2e71559e60db1b62644c34bf52755c7257a5b4b0 100644 (file)
 ## - Sub-shapes are automatically published as child items of the parent main shape in the study if main
 ##   shape was also published before. Otherwise, sub-shapes are published as top-level objects.
 ## - Not that some functions of \ref geomBuilder.geomBuilder "geomBuilder" class do not have
-##   @theName parameter (and, thus, do not support automatic publication).
+##   \a theName parameter (and, thus, do not support automatic publication).
 ##   For example, some transformation operations like
 ##   \ref geomBuilder.geomBuilder.TranslateDXDYDZ() "TranslateDXDYDZ()".
 ##   Refer to the documentation to check if some function has such possibility.
@@ -459,6 +459,18 @@ class info:
     CLOSED   = 1
     UNCLOSED = 2
 
+##! Private class used to bind calls of plugin operations to geomBuilder
+class PluginOperation:
+  def __init__(self, operation, function):
+    self.operation = operation
+    self.function = function
+    pass
+
+  def __call__(self, *args):
+    res = self.function(self.operation, *args)
+    RaiseIfFailed(self.function.__name__, self.operation)
+    return res
+
 # Warning: geom is a singleton
 geom = None
 engine = None
@@ -684,9 +696,28 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             self.MeasuOp  = self.GetIMeasureOperations  (self.myStudyId)
             self.BlocksOp = self.GetIBlocksOperations   (self.myStudyId)
             self.GroupOp  = self.GetIGroupOperations    (self.myStudyId)
-            self.AdvOp    = self.GetIAdvancedOperations (self.myStudyId)
+            #self.AdvOp    = self.GetIAdvancedOperations (self.myStudyId)
+            self.AdvOp    = self.GetPluginOperations (self.myStudyId, "AdvancedEngine")
+            # set GEOM as root in the use case tree
+            self.myUseCaseBuilder = self.myStudy.GetUseCaseBuilder()
+            self.myUseCaseBuilder.SetRootCurrent()
+            self.myUseCaseBuilder.Append(self.father)
             pass
 
+        def GetPluginOperations(self, studyID, libraryName):
+            op = GEOM._objref_GEOM_Gen.GetPluginOperations(self, studyID, libraryName)
+            if op:
+                # bind methods of operations to self
+                methods = op.__class__.__dict__['__methods__']
+                avoid_methods = self.BasicOp.__class__.__dict__['__methods__']
+                for meth_name in methods:
+                    if not meth_name in avoid_methods: # avoid basic methods
+                        function = getattr(op.__class__, meth_name)
+                        if callable(function):
+                            #self.__dict__[meth_name] = self.__PluginOperation(op, function)
+                            self.__dict__[meth_name] = PluginOperation(op, function)
+            return op
+
         ## Enable / disable results auto-publishing
         # 
         #  The automatic publishing is managed in the following way:
@@ -5468,7 +5499,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             return ListObj
 
         ## Obtain a compound of sub-shapes of <VAR>aShape</VAR>,
-        #  selected by they indices in list of all sub-shapes of type <VAR>aType</VAR>.
+        #  selected by their indices in list of all sub-shapes of type <VAR>aType</VAR>.
         #  Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type]
         #  @param aShape Shape to get sub-shape of.
         #  @param ListOfInd List of sub-shapes indices.
@@ -5483,7 +5514,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
         def SubShape(self, aShape, aType, ListOfInd, theName=None):
             """
             Obtain a compound of sub-shapes of aShape,
-            selected by they indices in list of all sub-shapes of type aType.
+            selected by their indices in list of all sub-shapes of type aType.
             Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type]
             
             Parameters:
@@ -5996,6 +6027,36 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             self._autoPublish(anObj, theName, "sewed")
             return anObj
 
+        ## Rebuild the topology of theCompound of solids by removing
+        #  of the faces that are shared by several solids.
+        #  @param theCompound Shape to be processed.
+        #  @param theName Object name; when specified, this parameter is used
+        #         for result publication in the study. Otherwise, if automatic
+        #         publication is switched on, default value is used for result name.
+        #
+        #  @return New GEOM.GEOM_Object, containing processed shape.
+        #
+        #  @ref tui_remove_webs "Example"
+        def RemoveInternalFaces (self, theCompound, theName=None):
+            """
+            Rebuild the topology of theCompound of solids by removing
+            of the faces that are shared by several solids.
+
+            Parameters:
+                theCompound Shape to be processed.
+                theName Object name; when specified, this parameter is used
+                        for result publication in the study. Otherwise, if automatic
+                        publication is switched on, default value is used for result name.
+
+            Returns:
+                New GEOM.GEOM_Object, containing processed shape.
+            """
+            # Example: see GEOM_TestHealing.py
+            anObj = self.HealOp.RemoveInternalFaces(theCompound)
+            RaiseIfFailed("RemoveInternalFaces", self.HealOp)
+            self._autoPublish(anObj, theName, "removeWebs")
+            return anObj
+
         ## Remove internal wires and edges from the given object (face).
         #  @param theObject Shape to be processed.
         #  @param theWires Indices of wires to be removed, if EMPTY then the method
@@ -9565,6 +9626,17 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
                 pass
             return aDict
 
+        def GetCreationInformation(self, theShape):
+            info = theShape.GetCreationInformation()
+            # operationName
+            opName = info.operationName
+            if not opName: opName = "no info available"
+            res = "Operation: " + opName
+            # parameters
+            for parVal in info.params:
+                res += " \n %s = %s" % ( parVal.name, parVal.value )
+            return res
+
         ## Get a point, situated at the centre of mass of theShape.
         #  @param theShape Shape to define centre of mass of.
         #  @param theName Object name; when specified, this parameter is used
@@ -11385,10 +11457,8 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
 
         ## Cut of lists of groups.
         #  New group is created. It will contain only entities
-        #  which are present in groups listed in theGList1 but 
-        #  are not present in groups from theGList2.
-        #  @param theGList1 is a list of GEOM groups to include elements of.
-        #  @param theGList2 is a list of GEOM groups to exclude elements of.
+        #  which are present in groups listed in theGList.
+        #  @param theGList is a list of GEOM groups to include elements of.
         #  @param theName Object name; when specified, this parameter is used
         #         for result publication in the study. Otherwise, if automatic
         #         publication is switched on, default value is used for result name.
@@ -11400,12 +11470,10 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             """
             Cut of lists of groups.
             New group is created. It will contain only entities
-            which are present in groups listed in theGList1 but 
-            are not present in groups from theGList2.
+            which are present in groups listed in theGList.
 
             Parameters:
-                theGList1 is a list of GEOM groups to include elements of.
-                theGList2 is a list of GEOM groups to exclude elements of.
+                theGList is a list of GEOM groups to include elements of.
                 theName Object name; when specified, this parameter is used
                         for result publication in the study. Otherwise, if automatic
                         publication is switched on, default value is used for result name.
@@ -12190,6 +12258,16 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             self._autoPublish(anObj, theName, "dividedCylinder")
             return anObj
 
+        ## Create a surface from a cloud of points
+        #  @param thelPoints list of points
+        #  @return New GEOM_Object, containing the created shape.
+        #
+        #  @ref tui_creation_smoothingsurface "Example"
+        def MakeSmoothingSurface(self, thelPoints):
+            anObj = self.AdvOp.MakeSmoothingSurface(thelPoints)
+            RaiseIfFailed("MakeSmoothingSurface", self.AdvOp)
+            return anObj
+
         #@@ insert new functions before this line @@ do not remove this line @@#
 
         # end of l4_advanced
@@ -12328,6 +12406,54 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             RaiseIfFailed("AddTexture", self.InsertOp)
             return ID
 
+        ## Creates a new folder object. It is a container for any GEOM objects.
+        #  @param Name name of the container
+        #  @param Father parent object. If None, 
+        #         folder under 'Geometry' root object will be created.
+        #  @return a new created folder
+        def NewFolder(self, Name, Father=None):
+            """
+            Create a new folder object. It is an auxiliary container for any GEOM objects.
+            
+            Parameters:
+                Name name of the container
+                Father parent object. If None, 
+                folder under 'Geometry' root object will be created.
+            
+            Returns:
+                a new created folder
+            """
+            if not Father: Father = self.father
+            return self.CreateFolder(Name, Father)
+
+        ## Move object to the specified folder
+        #  @param Object object to move
+        #  @param Folder target folder
+        def PutToFolder(self, Object, Folder):
+            """
+            Move object to the specified folder
+            
+            Parameters:
+                Object object to move
+                Folder target folder
+            """
+            self.MoveToFolder(Object, Folder)
+            pass
+
+        ## Move list of objects to the specified folder
+        #  @param ListOfSO list of objects to move
+        #  @param Folder target folder
+        def PutListToFolder(self, ListOfSO, Folder):
+            """
+            Move list of objects to the specified folder
+            
+            Parameters:
+                ListOfSO list of objects to move
+                Folder target folder
+            """
+            self.MoveListToFolder(ListOfSO, Folder)
+            pass
+
 import omniORB
 # Register the new proxy for GEOM_Gen
 omniORB.registerObjref(GEOM._objref_GEOM_Gen._NP_RepositoryId, geomBuilder)