Salome HOME
23305: [EDF 10301] Extrusion with scaling
[modules/smesh.git] / src / SMESH_SWIG / smeshBuilder.py
index 6e39264b1a79aa8ea6eae2288d84950d09c69212..b4da6ea8e8495ff4ba537f1d8a372ec09e680303 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -1504,6 +1504,12 @@ class Mesh:
             pass
         return ok
 
+    ## Return a list of error messages (SMESH.ComputeError) of the last Compute()
+    def GetComputeErrors(self, shape=0 ):
+        if shape == 0:
+            shape = self.mesh.GetShapeToMesh()
+        return self.smeshpyD.GetComputeErrors( self.mesh, shape )
+
     ## Return a name of a sub-shape by its ID
     #  @param subShapeID a unique ID of a sub-shape
     #  @return a string describing the sub-shape; possible variants:
@@ -1592,13 +1598,13 @@ class Mesh:
         return groups
 
     ## Return sub-mesh objects list in meshing order
-    #  @return list of list of sub-meshes
+    #  @return list of lists of sub-meshes
     #  @ingroup l2_construct
     def GetMeshOrder(self):
         return self.mesh.GetMeshOrder()
 
     ## Set order in which concurrent sub-meshes sould be meshed
-    #  @param submeshes list of sub-meshes
+    #  @param submeshes list of lists of sub-meshes
     #  @ingroup l2_construct
     def SetMeshOrder(self, submeshes):
         return self.mesh.SetMeshOrder(submeshes)
@@ -3814,17 +3820,27 @@ class Mesh:
                                          NbOfSteps, Tolerance, MakeGroups, TotalAngle)
 
     ## Generates new elements by extrusion of the given elements and nodes
-    #  @param nodes nodes to extrude: a list including ids, groups, sub-meshes or a mesh
-    #  @param edges edges to extrude: a list including ids, groups, sub-meshes or a mesh
-    #  @param faces faces to extrude: a list including ids, groups, sub-meshes or a mesh
+    #  @param nodes nodes to extrude: a list including ids, groups, sub-meshes or a mesh
+    #  @param edges edges to extrude: a list including ids, groups, sub-meshes or a mesh
+    #  @param faces faces to extrude: a list including ids, groups, sub-meshes or a mesh
     #  @param StepVector vector or DirStruct or 3 vector components, defining
     #         the direction and value of extrusion for one step (the total extrusion
     #         length will be NbOfSteps * ||StepVector||)
     #  @param NbOfSteps the number of steps
     #  @param MakeGroups forces the generation of new groups from existing ones
+    #  @param scaleFactors optional scale factors to apply during extrusion
+    #  @param linearVariation if @c True, scaleFactors are spread over all @a scaleFactors,
+    #         else scaleFactors[i] is applied to nodes at the i-th extrusion step
+    #  @param basePoint optional scaling center; if not provided, a gravity center of
+    #         nodes and elements being extruded is used as the scaling center.
+    #         It can be either
+    #         - a list of tree components of the point or
+    #         - a node ID or
+    #         - a GEOM point
     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
     #  @ingroup l2_modif_extrurev
-    def ExtrusionSweepObjects(self, nodes, edges, faces, StepVector, NbOfSteps, MakeGroups=False):
+    def ExtrusionSweepObjects(self, nodes, edges, faces, StepVector, NbOfSteps, MakeGroups=False,
+                              scaleFactors=[], linearVariation=False, basePoint=[] ):
         unRegister = genObjUnRegister()
         nodes = self._getIdSourceList( nodes, SMESH.NODE, unRegister )
         edges = self._getIdSourceList( edges, SMESH.EDGE, unRegister )
@@ -3835,12 +3851,22 @@ class Mesh:
         if isinstance( StepVector, list ):
             StepVector = self.smeshpyD.MakeDirStruct(*StepVector)
 
+        if isinstance( basePoint, int):
+            xyz = self.GetNodeXYZ( basePoint )
+            if not xyz:
+                raise RuntimeError, "Invalid node ID: %s" % basePoint
+            basePoint = xyz
+        if isinstance( basePoint, geomBuilder.GEOM._objref_GEOM_Object ):
+            basePoint = self.geompyD.PointCoordinates( basePoint )
+
         NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
         Parameters = StepVector.PS.parameters + var_separator + Parameters
         self.mesh.SetParameters(Parameters)
 
         return self.editor.ExtrusionSweepObjects( nodes, edges, faces,
-                                                  StepVector, NbOfSteps, MakeGroups)
+                                                  StepVector, NbOfSteps,
+                                                  scaleFactors, linearVariation, basePoint,
+                                                  MakeGroups)
 
 
     ## Generates new elements by extrusion of the elements with given ids