1 # Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 # Author : Francis KLOSS, OCC
24 # Python API for SALOME %Mesh module
26 ## @defgroup l1_auxiliary Auxiliary methods and structures
27 ## @defgroup l1_creating Creating meshes
29 ## @defgroup l2_impexp Importing and exporting meshes
30 ## @defgroup l2_construct Constructing meshes
31 ## @defgroup l2_algorithms Defining Algorithms
33 ## @defgroup l3_algos_basic Basic meshing algorithms
34 ## @defgroup l3_algos_proj Projection Algorithms
35 ## @defgroup l3_algos_radialp Radial Prism
36 ## @defgroup l3_algos_segmarv Segments around Vertex
37 ## @defgroup l3_algos_3dextr 3D extrusion meshing algorithm
40 ## @defgroup l2_hypotheses Defining hypotheses
42 ## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
43 ## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
44 ## @defgroup l3_hypos_maxvol Max Element Volume hypothesis
45 ## @defgroup l3_hypos_quad Quadrangle Parameters hypothesis
46 ## @defgroup l3_hypos_additi Additional Hypotheses
49 ## @defgroup l2_submeshes Constructing submeshes
50 ## @defgroup l2_compounds Building Compounds
51 ## @defgroup l2_editing Editing Meshes
54 ## @defgroup l1_meshinfo Mesh Information
55 ## @defgroup l1_controls Quality controls and Filtering
56 ## @defgroup l1_grouping Grouping elements
58 ## @defgroup l2_grps_create Creating groups
59 ## @defgroup l2_grps_edit Editing groups
60 ## @defgroup l2_grps_operon Using operations on groups
61 ## @defgroup l2_grps_delete Deleting Groups
64 ## @defgroup l1_modifying Modifying meshes
66 ## @defgroup l2_modif_add Adding nodes and elements
67 ## @defgroup l2_modif_del Removing nodes and elements
68 ## @defgroup l2_modif_edit Modifying nodes and elements
69 ## @defgroup l2_modif_renumber Renumbering nodes and elements
70 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
71 ## @defgroup l2_modif_movenode Moving nodes
72 ## @defgroup l2_modif_throughp Mesh through point
73 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
74 ## @defgroup l2_modif_unitetri Uniting triangles
75 ## @defgroup l2_modif_changori Changing orientation of elements
76 ## @defgroup l2_modif_cutquadr Cutting quadrangles
77 ## @defgroup l2_modif_smooth Smoothing
78 ## @defgroup l2_modif_extrurev Extrusion and Revolution
79 ## @defgroup l2_modif_patterns Pattern mapping
80 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
83 ## @defgroup l1_measurements Measurements
88 import SMESH # This is necessary for back compatibility
90 from smesh_algorithm import Mesh_Algorithm
95 ## @addtogroup l1_auxiliary
98 # MirrorType enumeration
99 POINT = SMESH_MeshEditor.POINT
100 AXIS = SMESH_MeshEditor.AXIS
101 PLANE = SMESH_MeshEditor.PLANE
103 # Smooth_Method enumeration
104 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
105 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
107 PrecisionConfusion = 1e-07
109 # TopAbs_State enumeration
110 [TopAbs_IN, TopAbs_OUT, TopAbs_ON, TopAbs_UNKNOWN] = range(4)
112 # Methods of splitting a hexahedron into tetrahedra
113 Hex_5Tet, Hex_6Tet, Hex_24Tet = 1, 2, 3
115 ## Converts an angle from degrees to radians
116 def DegreesToRadians(AngleInDegrees):
118 return AngleInDegrees * pi / 180.0
120 import salome_notebook
121 notebook = salome_notebook.notebook
122 # Salome notebook variable separator
125 ## Return list of variable values from salome notebook.
126 # The last argument, if is callable, is used to modify values got from notebook
127 def ParseParameters(*args):
132 if args and callable( args[-1] ):
133 args, varModifFun = args[:-1], args[-1]
134 for parameter in args:
136 Parameters += str(parameter) + var_separator
138 if isinstance(parameter,str):
139 # check if there is an inexistent variable name
140 if not notebook.isVariable(parameter):
141 raise ValueError, "Variable with name '" + parameter + "' doesn't exist!!!"
142 parameter = notebook.get(parameter)
145 parameter = varModifFun(parameter)
148 Result.append(parameter)
151 Parameters = Parameters[:-1]
152 Result.append( Parameters )
153 Result.append( hasVariables )
156 # Parse parameters converting variables to radians
157 def ParseAngles(*args):
158 return ParseParameters( *( args + (DegreesToRadians, )))
160 # Substitute PointStruct.__init__() to create SMESH.PointStruct using notebook variables.
161 # Parameters are stored in PointStruct.parameters attribute
162 def __initPointStruct(point,*args):
163 point.x, point.y, point.z, point.parameters,hasVars = ParseParameters(*args)
165 SMESH.PointStruct.__init__ = __initPointStruct
167 # Substitute AxisStruct.__init__() to create SMESH.AxisStruct using notebook variables.
168 # Parameters are stored in AxisStruct.parameters attribute
169 def __initAxisStruct(ax,*args):
170 ax.x, ax.y, ax.z, ax.vx, ax.vy, ax.vz, ax.parameters,hasVars = ParseParameters(*args)
172 SMESH.AxisStruct.__init__ = __initAxisStruct
175 def IsEqual(val1, val2, tol=PrecisionConfusion):
176 if abs(val1 - val2) < tol:
186 if isinstance(obj, SALOMEDS._objref_SObject):
190 ior = salome.orb.object_to_string(obj)
195 studies = salome.myStudyManager.GetOpenStudies()
196 for sname in studies:
197 s = salome.myStudyManager.GetStudyByName(sname)
199 sobj = s.FindObjectIOR(ior)
200 if not sobj: continue
201 return sobj.GetName()
202 if hasattr(obj, "GetName"):
203 # unknown CORBA object, having GetName() method
206 # unknown CORBA object, no GetName() method
209 if hasattr(obj, "GetName"):
210 # unknown non-CORBA object, having GetName() method
213 raise RuntimeError, "Null or invalid object"
215 ## Prints error message if a hypothesis was not assigned.
216 def TreatHypoStatus(status, hypName, geomName, isAlgo):
218 hypType = "algorithm"
220 hypType = "hypothesis"
222 if status == HYP_UNKNOWN_FATAL :
223 reason = "for unknown reason"
224 elif status == HYP_INCOMPATIBLE :
225 reason = "this hypothesis mismatches the algorithm"
226 elif status == HYP_NOTCONFORM :
227 reason = "a non-conform mesh would be built"
228 elif status == HYP_ALREADY_EXIST :
229 if isAlgo: return # it does not influence anything
230 reason = hypType + " of the same dimension is already assigned to this shape"
231 elif status == HYP_BAD_DIM :
232 reason = hypType + " mismatches the shape"
233 elif status == HYP_CONCURENT :
234 reason = "there are concurrent hypotheses on sub-shapes"
235 elif status == HYP_BAD_SUBSHAPE :
236 reason = "the shape is neither the main one, nor its sub-shape, nor a valid group"
237 elif status == HYP_BAD_GEOMETRY:
238 reason = "geometry mismatches the expectation of the algorithm"
239 elif status == HYP_HIDDEN_ALGO:
240 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
241 elif status == HYP_HIDING_ALGO:
242 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
243 elif status == HYP_NEED_SHAPE:
244 reason = "Algorithm can't work without shape"
247 hypName = '"' + hypName + '"'
248 geomName= '"' + geomName+ '"'
249 if status < HYP_UNKNOWN_FATAL and not geomName =='""':
250 print hypName, "was assigned to", geomName,"but", reason
251 elif not geomName == '""':
252 print hypName, "was not assigned to",geomName,":", reason
254 print hypName, "was not assigned:", reason
257 ## Private method. Add geom (sub-shape of the main shape) into the study if not yet there
258 def AssureGeomPublished(mesh, geom, name=''):
259 if not isinstance( geom, geompyDC.GEOM._objref_GEOM_Object ):
261 if not geom.GetStudyEntry() and \
262 mesh.smeshpyD.GetCurrentStudy():
264 studyID = mesh.smeshpyD.GetCurrentStudy()._get_StudyId()
265 if studyID != mesh.geompyD.myStudyId:
266 mesh.geompyD.init_geom( mesh.smeshpyD.GetCurrentStudy())
268 if not name and geom.GetShapeType() != geompyDC.GEOM.COMPOUND:
269 # for all groups SubShapeName() returns "Compound_-1"
270 name = mesh.geompyD.SubShapeName(geom, mesh.geom)
272 name = "%s_%s"%(geom.GetShapeType(), id(geom)%10000)
274 mesh.geompyD.addToStudyInFather( mesh.geom, geom, name )
277 ## Return the first vertex of a geomertical edge by ignoring orienation
278 def FirstVertexOnCurve(edge):
279 from geompy import SubShapeAll, ShapeType, KindOfShape, PointCoordinates
280 vv = SubShapeAll( edge, ShapeType["VERTEX"])
282 raise TypeError, "Given object has no vertices"
283 if len( vv ) == 1: return vv[0]
284 info = KindOfShape(edge)
285 xyz = info[1:4] # coords of the first vertex
286 xyz1 = PointCoordinates( vv[0] )
287 xyz2 = PointCoordinates( vv[1] )
290 dist1 += abs( xyz[i] - xyz1[i] )
291 dist2 += abs( xyz[i] - xyz2[i] )
297 # end of l1_auxiliary
300 # All methods of this class are accessible directly from the smesh.py package.
301 class smeshDC(SMESH._objref_SMESH_Gen):
303 ## Dump component to the Python script
304 # This method overrides IDL function to allow default values for the parameters.
305 def DumpPython(self, theStudy, theIsPublished=True, theIsMultiFile=True):
306 return SMESH._objref_SMESH_Gen.DumpPython(self, theStudy, theIsPublished, theIsMultiFile)
308 ## Set mode of DumpPython(), \a historical or \a snapshot.
309 # In the \a historical mode, the Python Dump script includes all commands
310 # performed by SMESH engine. In the \a snapshot mode, commands
311 # relating to objects removed from the Study are excluded from the script
312 # as well as commands not influencing the current state of meshes
313 def SetDumpPythonHistorical(self, isHistorical):
314 if isHistorical: val = "true"
316 SMESH._objref_SMESH_Gen.SetOption(self, "historical_python_dump", val)
318 ## Sets the current study and Geometry component
319 # @ingroup l1_auxiliary
320 def init_smesh(self,theStudy,geompyD):
321 self.SetCurrentStudy(theStudy,geompyD)
323 ## Creates an empty Mesh. This mesh can have an underlying geometry.
324 # @param obj the Geometrical object on which the mesh is built. If not defined,
325 # the mesh will have no underlying geometry.
326 # @param name the name for the new mesh.
327 # @return an instance of Mesh class.
328 # @ingroup l2_construct
329 def Mesh(self, obj=0, name=0):
330 if isinstance(obj,str):
332 return Mesh(self,self.geompyD,obj,name)
334 ## Returns a long value from enumeration
335 # @ingroup l1_controls
336 def EnumToLong(self,theItem):
339 ## Returns a string representation of the color.
340 # To be used with filters.
341 # @param c color value (SALOMEDS.Color)
342 # @ingroup l1_controls
343 def ColorToString(self,c):
345 if isinstance(c, SALOMEDS.Color):
346 val = "%s;%s;%s" % (c.R, c.G, c.B)
347 elif isinstance(c, str):
350 raise ValueError, "Color value should be of string or SALOMEDS.Color type"
353 ## Gets PointStruct from vertex
354 # @param theVertex a GEOM object(vertex)
355 # @return SMESH.PointStruct
356 # @ingroup l1_auxiliary
357 def GetPointStruct(self,theVertex):
358 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
359 return PointStruct(x,y,z)
361 ## Gets DirStruct from vector
362 # @param theVector a GEOM object(vector)
363 # @return SMESH.DirStruct
364 # @ingroup l1_auxiliary
365 def GetDirStruct(self,theVector):
366 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
367 if(len(vertices) != 2):
368 print "Error: vector object is incorrect."
370 p1 = self.geompyD.PointCoordinates(vertices[0])
371 p2 = self.geompyD.PointCoordinates(vertices[1])
372 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
373 dirst = DirStruct(pnt)
376 ## Makes DirStruct from a triplet
377 # @param x,y,z vector components
378 # @return SMESH.DirStruct
379 # @ingroup l1_auxiliary
380 def MakeDirStruct(self,x,y,z):
381 pnt = PointStruct(x,y,z)
382 return DirStruct(pnt)
384 ## Get AxisStruct from object
385 # @param theObj a GEOM object (line or plane)
386 # @return SMESH.AxisStruct
387 # @ingroup l1_auxiliary
388 def GetAxisStruct(self,theObj):
389 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
391 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
392 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
393 vertex1 = self.geompyD.PointCoordinates(vertex1)
394 vertex2 = self.geompyD.PointCoordinates(vertex2)
395 vertex3 = self.geompyD.PointCoordinates(vertex3)
396 vertex4 = self.geompyD.PointCoordinates(vertex4)
397 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
398 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
399 normal = [ v1[1]*v2[2]-v2[1]*v1[2], v1[2]*v2[0]-v2[2]*v1[0], v1[0]*v2[1]-v2[0]*v1[1] ]
400 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
402 elif len(edges) == 1:
403 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
404 p1 = self.geompyD.PointCoordinates( vertex1 )
405 p2 = self.geompyD.PointCoordinates( vertex2 )
406 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
410 # From SMESH_Gen interface:
411 # ------------------------
413 ## Sets the given name to the object
414 # @param obj the object to rename
415 # @param name a new object name
416 # @ingroup l1_auxiliary
417 def SetName(self, obj, name):
418 if isinstance( obj, Mesh ):
420 elif isinstance( obj, Mesh_Algorithm ):
421 obj = obj.GetAlgorithm()
422 ior = salome.orb.object_to_string(obj)
423 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
425 ## Sets the current mode
426 # @ingroup l1_auxiliary
427 def SetEmbeddedMode( self,theMode ):
428 #self.SetEmbeddedMode(theMode)
429 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
431 ## Gets the current mode
432 # @ingroup l1_auxiliary
433 def IsEmbeddedMode(self):
434 #return self.IsEmbeddedMode()
435 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
437 ## Sets the current study
438 # @ingroup l1_auxiliary
439 def SetCurrentStudy( self, theStudy, geompyD = None ):
440 #self.SetCurrentStudy(theStudy)
443 geompyD = geompy.geom
446 self.SetGeomEngine(geompyD)
447 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
450 notebook = salome_notebook.NoteBook( theStudy )
452 notebook = salome_notebook.NoteBook( salome_notebook.PseudoStudyForNoteBook() )
454 ## Gets the current study
455 # @ingroup l1_auxiliary
456 def GetCurrentStudy(self):
457 #return self.GetCurrentStudy()
458 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
460 ## Creates a Mesh object importing data from the given UNV file
461 # @return an instance of Mesh class
463 def CreateMeshesFromUNV( self,theFileName ):
464 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
465 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
468 ## Creates a Mesh object(s) importing data from the given MED file
469 # @return a list of Mesh class instances
471 def CreateMeshesFromMED( self,theFileName ):
472 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
474 for iMesh in range(len(aSmeshMeshes)) :
475 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
476 aMeshes.append(aMesh)
477 return aMeshes, aStatus
479 ## Creates a Mesh object(s) importing data from the given SAUV file
480 # @return a list of Mesh class instances
482 def CreateMeshesFromSAUV( self,theFileName ):
483 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromSAUV(self,theFileName)
485 for iMesh in range(len(aSmeshMeshes)) :
486 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
487 aMeshes.append(aMesh)
488 return aMeshes, aStatus
490 ## Creates a Mesh object importing data from the given STL file
491 # @return an instance of Mesh class
493 def CreateMeshesFromSTL( self, theFileName ):
494 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
495 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
498 ## Creates Mesh objects importing data from the given CGNS file
499 # @return an instance of Mesh class
501 def CreateMeshesFromCGNS( self, theFileName ):
502 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromCGNS(self,theFileName)
504 for iMesh in range(len(aSmeshMeshes)) :
505 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
506 aMeshes.append(aMesh)
507 return aMeshes, aStatus
509 ## Creates a Mesh object importing data from the given GMF file
510 # @return [ an instance of Mesh class, SMESH::ComputeError ]
512 def CreateMeshesFromGMF( self, theFileName ):
513 aSmeshMesh, error = SMESH._objref_SMESH_Gen.CreateMeshesFromGMF(self,
516 if error.comment: print "*** CreateMeshesFromGMF() errors:\n", error.comment
517 return Mesh(self, self.geompyD, aSmeshMesh), error
519 ## Concatenate the given meshes into one mesh.
520 # @return an instance of Mesh class
521 # @param meshes the meshes to combine into one mesh
522 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
523 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
524 # @param mergeTolerance tolerance for merging nodes
525 # @param allGroups forces creation of groups of all elements
526 # @param name name of a new mesh
527 def Concatenate( self, meshes, uniteIdenticalGroups,
528 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False,
530 if not meshes: return None
531 for i,m in enumerate(meshes):
532 if isinstance(m, Mesh):
533 meshes[i] = m.GetMesh()
534 mergeTolerance,Parameters,hasVars = ParseParameters(mergeTolerance)
535 meshes[0].SetParameters(Parameters)
537 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
538 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
540 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
541 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
542 aMesh = Mesh(self, self.geompyD, aSmeshMesh, name=name)
545 ## Create a mesh by copying a part of another mesh.
546 # @param meshPart a part of mesh to copy, either a Mesh, a sub-mesh or a group;
547 # to copy nodes or elements not contained in any mesh object,
548 # pass result of Mesh.GetIDSource( list_of_ids, type ) as meshPart
549 # @param meshName a name of the new mesh
550 # @param toCopyGroups to create in the new mesh groups the copied elements belongs to
551 # @param toKeepIDs to preserve IDs of the copied elements or not
552 # @return an instance of Mesh class
553 def CopyMesh( self, meshPart, meshName, toCopyGroups=False, toKeepIDs=False):
554 if (isinstance( meshPart, Mesh )):
555 meshPart = meshPart.GetMesh()
556 mesh = SMESH._objref_SMESH_Gen.CopyMesh( self,meshPart,meshName,toCopyGroups,toKeepIDs )
557 return Mesh(self, self.geompyD, mesh)
559 ## From SMESH_Gen interface
560 # @return the list of integer values
561 # @ingroup l1_auxiliary
562 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
563 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
565 ## From SMESH_Gen interface. Creates a pattern
566 # @return an instance of SMESH_Pattern
568 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
569 # @ingroup l2_modif_patterns
570 def GetPattern(self):
571 return SMESH._objref_SMESH_Gen.GetPattern(self)
573 ## Sets number of segments per diagonal of boundary box of geometry by which
574 # default segment length of appropriate 1D hypotheses is defined.
575 # Default value is 10
576 # @ingroup l1_auxiliary
577 def SetBoundaryBoxSegmentation(self, nbSegments):
578 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
580 # Filtering. Auxiliary functions:
581 # ------------------------------
583 ## Creates an empty criterion
584 # @return SMESH.Filter.Criterion
585 # @ingroup l1_controls
586 def GetEmptyCriterion(self):
587 Type = self.EnumToLong(FT_Undefined)
588 Compare = self.EnumToLong(FT_Undefined)
592 UnaryOp = self.EnumToLong(FT_Undefined)
593 BinaryOp = self.EnumToLong(FT_Undefined)
596 Precision = -1 ##@1e-07
597 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
598 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
600 ## Creates a criterion by the given parameters
601 # \n Criterion structures allow to define complex filters by combining them with logical operations (AND / OR) (see example below)
602 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
603 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
604 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
605 # @param Threshold the threshold value (range of ids as string, shape, numeric)
606 # @param UnaryOp FT_LogicalNOT or FT_Undefined
607 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
608 # FT_Undefined (must be for the last criterion of all criteria)
609 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
610 # FT_LyingOnGeom, FT_CoplanarFaces criteria
611 # @return SMESH.Filter.Criterion
613 # <a href="../tui_filters_page.html#combining_filters">Example of Criteria usage</a>
614 # @ingroup l1_controls
615 def GetCriterion(self,elementType,
617 Compare = FT_EqualTo,
619 UnaryOp=FT_Undefined,
620 BinaryOp=FT_Undefined,
622 if not CritType in SMESH.FunctorType._items:
623 raise TypeError, "CritType should be of SMESH.FunctorType"
624 aCriterion = self.GetEmptyCriterion()
625 aCriterion.TypeOfElement = elementType
626 aCriterion.Type = self.EnumToLong(CritType)
627 aCriterion.Tolerance = Tolerance
629 aThreshold = Threshold
631 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
632 aCriterion.Compare = self.EnumToLong(Compare)
633 elif Compare == "=" or Compare == "==":
634 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
636 aCriterion.Compare = self.EnumToLong(FT_LessThan)
638 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
639 elif Compare != FT_Undefined:
640 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
643 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
644 FT_BelongToCylinder, FT_LyingOnGeom]:
645 # Checks that Threshold is GEOM object
646 if isinstance(aThreshold, geompyDC.GEOM._objref_GEOM_Object):
647 aCriterion.ThresholdStr = GetName(aThreshold)
648 aCriterion.ThresholdID = aThreshold.GetStudyEntry()
649 if not aCriterion.ThresholdID:
650 name = aCriterion.ThresholdStr
652 name = "%s_%s"%(aThreshold.GetShapeType(), id(aThreshold)%10000)
653 aCriterion.ThresholdID = self.geompyD.addToStudy( aThreshold, name )
654 #raise RuntimeError, "Threshold shape must be published"
656 print "Error: The Threshold should be a shape."
658 if isinstance(UnaryOp,float):
659 aCriterion.Tolerance = UnaryOp
660 UnaryOp = FT_Undefined
662 elif CritType == FT_RangeOfIds:
663 # Checks that Threshold is string
664 if isinstance(aThreshold, str):
665 aCriterion.ThresholdStr = aThreshold
667 print "Error: The Threshold should be a string."
669 elif CritType == FT_CoplanarFaces:
670 # Checks the Threshold
671 if isinstance(aThreshold, int):
672 aCriterion.ThresholdID = str(aThreshold)
673 elif isinstance(aThreshold, str):
676 raise ValueError, "Invalid ID of mesh face: '%s'"%aThreshold
677 aCriterion.ThresholdID = aThreshold
680 "The Threshold should be an ID of mesh face and not '%s'"%aThreshold
681 elif CritType == FT_ElemGeomType:
682 # Checks the Threshold
684 aCriterion.Threshold = self.EnumToLong(aThreshold)
685 assert( aThreshold in SMESH.GeometryType._items )
687 if isinstance(aThreshold, int):
688 aCriterion.Threshold = aThreshold
690 print "Error: The Threshold should be an integer or SMESH.GeometryType."
694 elif CritType == FT_GroupColor:
695 # Checks the Threshold
697 aCriterion.ThresholdStr = self.ColorToString(aThreshold)
699 print "Error: The threshold value should be of SALOMEDS.Color type"
702 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_FreeNodes, FT_FreeFaces,
703 FT_LinearOrQuadratic, FT_BadOrientedVolume,
704 FT_BareBorderFace, FT_BareBorderVolume,
705 FT_OverConstrainedFace, FT_OverConstrainedVolume,
706 FT_EqualNodes,FT_EqualEdges,FT_EqualFaces,FT_EqualVolumes ]:
707 # At this point the Threshold is unnecessary
708 if aThreshold == FT_LogicalNOT:
709 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
710 elif aThreshold in [FT_LogicalAND, FT_LogicalOR]:
711 aCriterion.BinaryOp = aThreshold
715 aThreshold = float(aThreshold)
716 aCriterion.Threshold = aThreshold
718 print "Error: The Threshold should be a number."
721 if Threshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
722 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
724 if Threshold in [FT_LogicalAND, FT_LogicalOR]:
725 aCriterion.BinaryOp = self.EnumToLong(Threshold)
727 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
728 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
730 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
731 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
735 ## Creates a filter with the given parameters
736 # @param elementType the type of elements in the group
737 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
738 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
739 # @param Threshold the threshold value (range of id ids as string, shape, numeric)
740 # @param UnaryOp FT_LogicalNOT or FT_Undefined
741 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
742 # FT_LyingOnGeom, FT_CoplanarFaces and FT_EqualNodes criteria
743 # @return SMESH_Filter
745 # <a href="../tui_filters_page.html#tui_filters">Example of Filters usage</a>
746 # @ingroup l1_controls
747 def GetFilter(self,elementType,
748 CritType=FT_Undefined,
751 UnaryOp=FT_Undefined,
753 aCriterion = self.GetCriterion(elementType, CritType, Compare, Threshold, UnaryOp, FT_Undefined,Tolerance)
754 aFilterMgr = self.CreateFilterManager()
755 aFilter = aFilterMgr.CreateFilter()
757 aCriteria.append(aCriterion)
758 aFilter.SetCriteria(aCriteria)
759 aFilterMgr.UnRegister()
762 ## Creates a filter from criteria
763 # @param criteria a list of criteria
764 # @return SMESH_Filter
766 # <a href="../tui_filters_page.html#tui_filters">Example of Filters usage</a>
767 # @ingroup l1_controls
768 def GetFilterFromCriteria(self,criteria):
769 aFilterMgr = self.CreateFilterManager()
770 aFilter = aFilterMgr.CreateFilter()
771 aFilter.SetCriteria(criteria)
772 aFilterMgr.UnRegister()
775 ## Creates a numerical functor by its type
776 # @param theCriterion FT_...; functor type
777 # @return SMESH_NumericalFunctor
778 # @ingroup l1_controls
779 def GetFunctor(self,theCriterion):
780 if isinstance( theCriterion, SMESH._objref_NumericalFunctor ):
782 aFilterMgr = self.CreateFilterManager()
784 if theCriterion == FT_AspectRatio:
785 functor = aFilterMgr.CreateAspectRatio()
786 elif theCriterion == FT_AspectRatio3D:
787 functor = aFilterMgr.CreateAspectRatio3D()
788 elif theCriterion == FT_Warping:
789 functor = aFilterMgr.CreateWarping()
790 elif theCriterion == FT_MinimumAngle:
791 functor = aFilterMgr.CreateMinimumAngle()
792 elif theCriterion == FT_Taper:
793 functor = aFilterMgr.CreateTaper()
794 elif theCriterion == FT_Skew:
795 functor = aFilterMgr.CreateSkew()
796 elif theCriterion == FT_Area:
797 functor = aFilterMgr.CreateArea()
798 elif theCriterion == FT_Volume3D:
799 functor = aFilterMgr.CreateVolume3D()
800 elif theCriterion == FT_MaxElementLength2D:
801 functor = aFilterMgr.CreateMaxElementLength2D()
802 elif theCriterion == FT_MaxElementLength3D:
803 functor = aFilterMgr.CreateMaxElementLength3D()
804 elif theCriterion == FT_MultiConnection:
805 functor = aFilterMgr.CreateMultiConnection()
806 elif theCriterion == FT_MultiConnection2D:
807 functor = aFilterMgr.CreateMultiConnection2D()
808 elif theCriterion == FT_Length:
809 functor = aFilterMgr.CreateLength()
810 elif theCriterion == FT_Length2D:
811 functor = aFilterMgr.CreateLength2D()
813 print "Error: given parameter is not numerical functor type."
814 aFilterMgr.UnRegister()
817 ## Creates hypothesis
818 # @param theHType mesh hypothesis type (string)
819 # @param theLibName mesh plug-in library name
820 # @return created hypothesis instance
821 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
822 hyp = SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
824 if isinstance( hyp, SMESH._objref_SMESH_Algo ):
827 # wrap hypothesis methods
828 #print "HYPOTHESIS", theHType
829 for meth_name in dir( hyp.__class__ ):
830 if not meth_name.startswith("Get") and \
831 not meth_name in dir ( SMESH._objref_SMESH_Hypothesis ):
832 method = getattr ( hyp.__class__, meth_name )
834 setattr( hyp, meth_name, hypMethodWrapper( hyp, method ))
838 ## Gets the mesh statistic
839 # @return dictionary "element type" - "count of elements"
840 # @ingroup l1_meshinfo
841 def GetMeshInfo(self, obj):
842 if isinstance( obj, Mesh ):
845 if hasattr(obj, "GetMeshInfo"):
846 values = obj.GetMeshInfo()
847 for i in range(SMESH.Entity_Last._v):
848 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
852 ## Get minimum distance between two objects
854 # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
855 # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
857 # @param src1 first source object
858 # @param src2 second source object
859 # @param id1 node/element id from the first source
860 # @param id2 node/element id from the second (or first) source
861 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
862 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
863 # @return minimum distance value
864 # @sa GetMinDistance()
865 # @ingroup l1_measurements
866 def MinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
867 result = self.GetMinDistance(src1, src2, id1, id2, isElem1, isElem2)
871 result = result.value
874 ## Get measure structure specifying minimum distance data between two objects
876 # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
877 # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
879 # @param src1 first source object
880 # @param src2 second source object
881 # @param id1 node/element id from the first source
882 # @param id2 node/element id from the second (or first) source
883 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
884 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
885 # @return Measure structure or None if input data is invalid
887 # @ingroup l1_measurements
888 def GetMinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
889 if isinstance(src1, Mesh): src1 = src1.mesh
890 if isinstance(src2, Mesh): src2 = src2.mesh
891 if src2 is None and id2 != 0: src2 = src1
892 if not hasattr(src1, "_narrow"): return None
893 src1 = src1._narrow(SMESH.SMESH_IDSource)
894 if not src1: return None
897 e = m.GetMeshEditor()
899 src1 = e.MakeIDSource([id1], SMESH.FACE)
901 src1 = e.MakeIDSource([id1], SMESH.NODE)
903 if hasattr(src2, "_narrow"):
904 src2 = src2._narrow(SMESH.SMESH_IDSource)
905 if src2 and id2 != 0:
907 e = m.GetMeshEditor()
909 src2 = e.MakeIDSource([id2], SMESH.FACE)
911 src2 = e.MakeIDSource([id2], SMESH.NODE)
914 aMeasurements = self.CreateMeasurements()
915 result = aMeasurements.MinDistance(src1, src2)
916 aMeasurements.UnRegister()
919 ## Get bounding box of the specified object(s)
920 # @param objects single source object or list of source objects
921 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
922 # @sa GetBoundingBox()
923 # @ingroup l1_measurements
924 def BoundingBox(self, objects):
925 result = self.GetBoundingBox(objects)
929 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
932 ## Get measure structure specifying bounding box data of the specified object(s)
933 # @param objects single source object or list of source objects
934 # @return Measure structure
936 # @ingroup l1_measurements
937 def GetBoundingBox(self, objects):
938 if isinstance(objects, tuple):
939 objects = list(objects)
940 if not isinstance(objects, list):
944 if isinstance(o, Mesh):
945 srclist.append(o.mesh)
946 elif hasattr(o, "_narrow"):
947 src = o._narrow(SMESH.SMESH_IDSource)
948 if src: srclist.append(src)
951 aMeasurements = self.CreateMeasurements()
952 result = aMeasurements.BoundingBox(srclist)
953 aMeasurements.UnRegister()
957 #Registering the new proxy for SMESH_Gen
958 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
964 ## This class allows defining and managing a mesh.
965 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
966 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
967 # new nodes and elements and by changing the existing entities), to get information
968 # about a mesh and to export a mesh into different formats.
977 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
978 # sets the GUI name of this mesh to \a name.
979 # @param smeshpyD an instance of smeshDC class
980 # @param geompyD an instance of geompyDC class
981 # @param obj Shape to be meshed or SMESH_Mesh object
982 # @param name Study name of the mesh
983 # @ingroup l2_construct
984 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
985 self.smeshpyD=smeshpyD
991 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
993 # publish geom of mesh (issue 0021122)
994 if not self.geom.GetStudyEntry() and smeshpyD.GetCurrentStudy():
996 studyID = smeshpyD.GetCurrentStudy()._get_StudyId()
997 if studyID != geompyD.myStudyId:
998 geompyD.init_geom( smeshpyD.GetCurrentStudy())
1003 geo_name = "%s_%s_for_meshing"%(self.geom.GetShapeType(), id(self.geom)%100)
1004 geompyD.addToStudy( self.geom, geo_name )
1005 self.mesh = self.smeshpyD.CreateMesh(self.geom)
1007 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
1010 self.mesh = self.smeshpyD.CreateEmptyMesh()
1012 self.smeshpyD.SetName(self.mesh, name)
1013 elif obj != 0 and objHasName:
1014 self.smeshpyD.SetName(self.mesh, GetName(obj))
1017 self.geom = self.mesh.GetShapeToMesh()
1019 self.editor = self.mesh.GetMeshEditor()
1020 self.functors = [None] * SMESH.FT_Undefined._v
1022 # set self to algoCreator's
1023 for attrName in dir(self):
1024 attr = getattr( self, attrName )
1025 if isinstance( attr, algoCreator ):
1026 setattr( self, attrName, attr.copy( self ))
1028 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
1029 # @param theMesh a SMESH_Mesh object
1030 # @ingroup l2_construct
1031 def SetMesh(self, theMesh):
1032 if self.mesh: self.mesh.UnRegister()
1035 self.mesh.Register()
1036 self.geom = self.mesh.GetShapeToMesh()
1038 ## Returns the mesh, that is an instance of SMESH_Mesh interface
1039 # @return a SMESH_Mesh object
1040 # @ingroup l2_construct
1044 ## Gets the name of the mesh
1045 # @return the name of the mesh as a string
1046 # @ingroup l2_construct
1048 name = GetName(self.GetMesh())
1051 ## Sets a name to the mesh
1052 # @param name a new name of the mesh
1053 # @ingroup l2_construct
1054 def SetName(self, name):
1055 self.smeshpyD.SetName(self.GetMesh(), name)
1057 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
1058 # The subMesh object gives access to the IDs of nodes and elements.
1059 # @param geom a geometrical object (shape)
1060 # @param name a name for the submesh
1061 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
1062 # @ingroup l2_submeshes
1063 def GetSubMesh(self, geom, name):
1064 AssureGeomPublished( self, geom, name )
1065 submesh = self.mesh.GetSubMesh( geom, name )
1068 ## Returns the shape associated to the mesh
1069 # @return a GEOM_Object
1070 # @ingroup l2_construct
1074 ## Associates the given shape to the mesh (entails the recreation of the mesh)
1075 # @param geom the shape to be meshed (GEOM_Object)
1076 # @ingroup l2_construct
1077 def SetShape(self, geom):
1078 self.mesh = self.smeshpyD.CreateMesh(geom)
1080 ## Loads mesh from the study after opening the study
1084 ## Returns true if the hypotheses are defined well
1085 # @param theSubObject a sub-shape of a mesh shape
1086 # @return True or False
1087 # @ingroup l2_construct
1088 def IsReadyToCompute(self, theSubObject):
1089 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
1091 ## Returns errors of hypotheses definition.
1092 # The list of errors is empty if everything is OK.
1093 # @param theSubObject a sub-shape of a mesh shape
1094 # @return a list of errors
1095 # @ingroup l2_construct
1096 def GetAlgoState(self, theSubObject):
1097 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
1099 ## Returns a geometrical object on which the given element was built.
1100 # The returned geometrical object, if not nil, is either found in the
1101 # study or published by this method with the given name
1102 # @param theElementID the id of the mesh element
1103 # @param theGeomName the user-defined name of the geometrical object
1104 # @return GEOM::GEOM_Object instance
1105 # @ingroup l2_construct
1106 def GetGeometryByMeshElement(self, theElementID, theGeomName):
1107 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
1109 ## Returns the mesh dimension depending on the dimension of the underlying shape
1110 # @return mesh dimension as an integer value [0,3]
1111 # @ingroup l1_auxiliary
1112 def MeshDimension(self):
1113 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
1114 if len( shells ) > 0 :
1116 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
1118 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
1124 ## Evaluates size of prospective mesh on a shape
1125 # @return a list where i-th element is a number of elements of i-th SMESH.EntityType
1126 # To know predicted number of e.g. edges, inquire it this way
1127 # Evaluate()[ EnumToLong( Entity_Edge )]
1128 def Evaluate(self, geom=0):
1129 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1131 geom = self.mesh.GetShapeToMesh()
1134 return self.smeshpyD.Evaluate(self.mesh, geom)
1137 ## Computes the mesh and returns the status of the computation
1138 # @param geom geomtrical shape on which mesh data should be computed
1139 # @param discardModifs if True and the mesh has been edited since
1140 # a last total re-compute and that may prevent successful partial re-compute,
1141 # then the mesh is cleaned before Compute()
1142 # @return True or False
1143 # @ingroup l2_construct
1144 def Compute(self, geom=0, discardModifs=False):
1145 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1147 geom = self.mesh.GetShapeToMesh()
1152 if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693
1154 ok = self.smeshpyD.Compute(self.mesh, geom)
1155 except SALOME.SALOME_Exception, ex:
1156 print "Mesh computation failed, exception caught:"
1157 print " ", ex.details.text
1160 print "Mesh computation failed, exception caught:"
1161 traceback.print_exc()
1165 # Treat compute errors
1166 computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
1167 for err in computeErrors:
1169 if self.mesh.HasShapeToMesh():
1171 mainIOR = salome.orb.object_to_string(geom)
1172 for sname in salome.myStudyManager.GetOpenStudies():
1173 s = salome.myStudyManager.GetStudyByName(sname)
1175 mainSO = s.FindObjectIOR(mainIOR)
1176 if not mainSO: continue
1177 if err.subShapeID == 1:
1178 shapeText = ' on "%s"' % mainSO.GetName()
1179 subIt = s.NewChildIterator(mainSO)
1181 subSO = subIt.Value()
1183 obj = subSO.GetObject()
1184 if not obj: continue
1185 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
1187 ids = go.GetSubShapeIndices()
1188 if len(ids) == 1 and ids[0] == err.subShapeID:
1189 shapeText = ' on "%s"' % subSO.GetName()
1192 shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
1194 shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID)
1196 shapeText = " on subshape #%s" % (err.subShapeID)
1198 shapeText = " on subshape #%s" % (err.subShapeID)
1200 stdErrors = ["OK", #COMPERR_OK
1201 "Invalid input mesh", #COMPERR_BAD_INPUT_MESH
1202 "std::exception", #COMPERR_STD_EXCEPTION
1203 "OCC exception", #COMPERR_OCC_EXCEPTION
1204 "..", #COMPERR_SLM_EXCEPTION
1205 "Unknown exception", #COMPERR_EXCEPTION
1206 "Memory allocation problem", #COMPERR_MEMORY_PB
1207 "Algorithm failed", #COMPERR_ALGO_FAILED
1208 "Unexpected geometry", #COMPERR_BAD_SHAPE
1209 "Warning", #COMPERR_WARNING
1210 "Computation cancelled",#COMPERR_CANCELED
1211 "No mesh on sub-shape"] #COMPERR_NO_MESH_ON_SHAPE
1213 if err.code < len(stdErrors): errText = stdErrors[err.code]
1215 errText = "code %s" % -err.code
1216 if errText: errText += ". "
1217 errText += err.comment
1218 if allReasons != "":allReasons += "\n"
1219 allReasons += '- "%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
1223 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1225 if err.isGlobalAlgo:
1233 reason = '%s %sD algorithm is missing' % (glob, dim)
1234 elif err.state == HYP_MISSING:
1235 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1236 % (glob, dim, name, dim))
1237 elif err.state == HYP_NOTCONFORM:
1238 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1239 elif err.state == HYP_BAD_PARAMETER:
1240 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1241 % ( glob, dim, name ))
1242 elif err.state == HYP_BAD_GEOMETRY:
1243 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1244 'geometry' % ( glob, dim, name ))
1245 elif err.state == HYP_HIDDEN_ALGO:
1246 reason = ('%s %sD algorithm "%s" is ignored due to presence of a %s '
1247 'algorithm of upper dimension generating %sD mesh'
1248 % ( glob, dim, name, glob, dim ))
1250 reason = ("For unknown reason. "
1251 "Developer, revise Mesh.Compute() implementation in smeshDC.py!")
1253 if allReasons != "":allReasons += "\n"
1254 allReasons += "- " + reason
1256 if not ok or allReasons != "":
1257 msg = '"' + GetName(self.mesh) + '"'
1258 if ok: msg += " has been computed with warnings"
1259 else: msg += " has not been computed"
1260 if allReasons != "": msg += ":"
1265 if salome.sg.hasDesktop() and self.mesh.GetStudyId() >= 0:
1266 smeshgui = salome.ImportComponentGUI("SMESH")
1267 smeshgui.Init(self.mesh.GetStudyId())
1268 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1269 salome.sg.updateObjBrowser(1)
1273 ## Return submesh objects list in meshing order
1274 # @return list of list of submesh objects
1275 # @ingroup l2_construct
1276 def GetMeshOrder(self):
1277 return self.mesh.GetMeshOrder()
1279 ## Return submesh objects list in meshing order
1280 # @return list of list of submesh objects
1281 # @ingroup l2_construct
1282 def SetMeshOrder(self, submeshes):
1283 return self.mesh.SetMeshOrder(submeshes)
1285 ## Removes all nodes and elements
1286 # @ingroup l2_construct
1289 if ( salome.sg.hasDesktop() and
1290 salome.myStudyManager.GetStudyByID( self.mesh.GetStudyId() )):
1291 smeshgui = salome.ImportComponentGUI("SMESH")
1292 smeshgui.Init(self.mesh.GetStudyId())
1293 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1294 salome.sg.updateObjBrowser(1)
1296 ## Removes all nodes and elements of indicated shape
1297 # @ingroup l2_construct
1298 def ClearSubMesh(self, geomId):
1299 self.mesh.ClearSubMesh(geomId)
1300 if salome.sg.hasDesktop():
1301 smeshgui = salome.ImportComponentGUI("SMESH")
1302 smeshgui.Init(self.mesh.GetStudyId())
1303 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1304 salome.sg.updateObjBrowser(1)
1306 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1307 # @param fineness [0.0,1.0] defines mesh fineness
1308 # @return True or False
1309 # @ingroup l3_algos_basic
1310 def AutomaticTetrahedralization(self, fineness=0):
1311 dim = self.MeshDimension()
1313 self.RemoveGlobalHypotheses()
1314 self.Segment().AutomaticLength(fineness)
1316 self.Triangle().LengthFromEdges()
1319 from NETGENPluginDC import NETGEN
1320 self.Tetrahedron(NETGEN)
1322 return self.Compute()
1324 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1325 # @param fineness [0.0, 1.0] defines mesh fineness
1326 # @return True or False
1327 # @ingroup l3_algos_basic
1328 def AutomaticHexahedralization(self, fineness=0):
1329 dim = self.MeshDimension()
1330 # assign the hypotheses
1331 self.RemoveGlobalHypotheses()
1332 self.Segment().AutomaticLength(fineness)
1339 return self.Compute()
1341 ## Assigns a hypothesis
1342 # @param hyp a hypothesis to assign
1343 # @param geom a subhape of mesh geometry
1344 # @return SMESH.Hypothesis_Status
1345 # @ingroup l2_hypotheses
1346 def AddHypothesis(self, hyp, geom=0):
1347 if isinstance( hyp, Mesh_Algorithm ):
1348 hyp = hyp.GetAlgorithm()
1353 geom = self.mesh.GetShapeToMesh()
1355 AssureGeomPublished( self, geom, "shape for %s" % hyp.GetName())
1356 status = self.mesh.AddHypothesis(geom, hyp)
1357 isAlgo = hyp._narrow( SMESH_Algo )
1358 hyp_name = GetName( hyp )
1361 geom_name = GetName( geom )
1362 TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1365 ## Return True if an algorithm of hypothesis is assigned to a given shape
1366 # @param hyp a hypothesis to check
1367 # @param geom a subhape of mesh geometry
1368 # @return True of False
1369 # @ingroup l2_hypotheses
1370 def IsUsedHypothesis(self, hyp, geom):
1371 if not hyp or not geom:
1373 if isinstance( hyp, Mesh_Algorithm ):
1374 hyp = hyp.GetAlgorithm()
1376 hyps = self.GetHypothesisList(geom)
1378 if h.GetId() == hyp.GetId():
1382 ## Unassigns a hypothesis
1383 # @param hyp a hypothesis to unassign
1384 # @param geom a sub-shape of mesh geometry
1385 # @return SMESH.Hypothesis_Status
1386 # @ingroup l2_hypotheses
1387 def RemoveHypothesis(self, hyp, geom=0):
1388 if isinstance( hyp, Mesh_Algorithm ):
1389 hyp = hyp.GetAlgorithm()
1395 if self.IsUsedHypothesis( hyp, shape ):
1396 return self.mesh.RemoveHypothesis(shape, hyp)
1397 hypName = GetName( hyp )
1398 geoName = GetName( shape )
1399 print "WARNING: RemoveHypothesis() failed as '%s' is not assigned to '%s' shape" % ( hypName, geoName )
1402 ## Gets the list of hypotheses added on a geometry
1403 # @param geom a sub-shape of mesh geometry
1404 # @return the sequence of SMESH_Hypothesis
1405 # @ingroup l2_hypotheses
1406 def GetHypothesisList(self, geom):
1407 return self.mesh.GetHypothesisList( geom )
1409 ## Removes all global hypotheses
1410 # @ingroup l2_hypotheses
1411 def RemoveGlobalHypotheses(self):
1412 current_hyps = self.mesh.GetHypothesisList( self.geom )
1413 for hyp in current_hyps:
1414 self.mesh.RemoveHypothesis( self.geom, hyp )
1418 ## Exports the mesh in a file in MED format and chooses the \a version of MED format
1419 ## allowing to overwrite the file if it exists or add the exported data to its contents
1420 # @param f is the file name
1421 # @param auto_groups boolean parameter for creating/not creating
1422 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1423 # the typical use is auto_groups=false.
1424 # @param version MED format version(MED_V2_1 or MED_V2_2)
1425 # @param overwrite boolean parameter for overwriting/not overwriting the file
1426 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1427 # @ingroup l2_impexp
1428 def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1, meshPart=None):
1430 if isinstance( meshPart, list ):
1431 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1432 self.mesh.ExportPartToMED( meshPart, f, auto_groups, version, overwrite )
1434 self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
1436 ## Exports the mesh in a file in SAUV format
1437 # @param f is the file name
1438 # @param auto_groups boolean parameter for creating/not creating
1439 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1440 # the typical use is auto_groups=false.
1441 # @ingroup l2_impexp
1442 def ExportSAUV(self, f, auto_groups=0):
1443 self.mesh.ExportSAUV(f, auto_groups)
1445 ## Exports the mesh in a file in DAT format
1446 # @param f the file name
1447 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1448 # @ingroup l2_impexp
1449 def ExportDAT(self, f, meshPart=None):
1451 if isinstance( meshPart, list ):
1452 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1453 self.mesh.ExportPartToDAT( meshPart, f )
1455 self.mesh.ExportDAT(f)
1457 ## Exports the mesh in a file in UNV format
1458 # @param f the file name
1459 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1460 # @ingroup l2_impexp
1461 def ExportUNV(self, f, meshPart=None):
1463 if isinstance( meshPart, list ):
1464 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1465 self.mesh.ExportPartToUNV( meshPart, f )
1467 self.mesh.ExportUNV(f)
1469 ## Export the mesh in a file in STL format
1470 # @param f the file name
1471 # @param ascii defines the file encoding
1472 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1473 # @ingroup l2_impexp
1474 def ExportSTL(self, f, ascii=1, meshPart=None):
1476 if isinstance( meshPart, list ):
1477 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1478 self.mesh.ExportPartToSTL( meshPart, f, ascii )
1480 self.mesh.ExportSTL(f, ascii)
1482 ## Exports the mesh in a file in CGNS format
1483 # @param f is the file name
1484 # @param overwrite boolean parameter for overwriting/not overwriting the file
1485 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1486 # @ingroup l2_impexp
1487 def ExportCGNS(self, f, overwrite=1, meshPart=None):
1488 if isinstance( meshPart, list ):
1489 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1490 if isinstance( meshPart, Mesh ):
1491 meshPart = meshPart.mesh
1493 meshPart = self.mesh
1494 self.mesh.ExportCGNS(meshPart, f, overwrite)
1496 ## Exports the mesh in a file in GMF format
1497 # @param f is the file name
1498 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1499 # @ingroup l2_impexp
1500 def ExportGMF(self, f, meshPart=None):
1501 if isinstance( meshPart, list ):
1502 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1503 if isinstance( meshPart, Mesh ):
1504 meshPart = meshPart.mesh
1506 meshPart = self.mesh
1507 self.mesh.ExportGMF(meshPart, f, True)
1509 ## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead.
1510 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1511 ## allowing to overwrite the file if it exists or add the exported data to its contents
1512 # @param f the file name
1513 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1514 # @param opt boolean parameter for creating/not creating
1515 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1516 # @param overwrite boolean parameter for overwriting/not overwriting the file
1517 # @ingroup l2_impexp
1518 def ExportToMED(self, f, version, opt=0, overwrite=1):
1519 self.mesh.ExportToMEDX(f, opt, version, overwrite)
1521 # Operations with groups:
1522 # ----------------------
1524 ## Creates an empty mesh group
1525 # @param elementType the type of elements in the group
1526 # @param name the name of the mesh group
1527 # @return SMESH_Group
1528 # @ingroup l2_grps_create
1529 def CreateEmptyGroup(self, elementType, name):
1530 return self.mesh.CreateGroup(elementType, name)
1532 ## Creates a mesh group based on the geometric object \a grp
1533 # and gives a \a name, \n if this parameter is not defined
1534 # the name is the same as the geometric group name \n
1535 # Note: Works like GroupOnGeom().
1536 # @param grp a geometric group, a vertex, an edge, a face or a solid
1537 # @param name the name of the mesh group
1538 # @return SMESH_GroupOnGeom
1539 # @ingroup l2_grps_create
1540 def Group(self, grp, name=""):
1541 return self.GroupOnGeom(grp, name)
1543 ## Creates a mesh group based on the geometrical object \a grp
1544 # and gives a \a name, \n if this parameter is not defined
1545 # the name is the same as the geometrical group name
1546 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1547 # @param name the name of the mesh group
1548 # @param typ the type of elements in the group. If not set, it is
1549 # automatically detected by the type of the geometry
1550 # @return SMESH_GroupOnGeom
1551 # @ingroup l2_grps_create
1552 def GroupOnGeom(self, grp, name="", typ=None):
1553 AssureGeomPublished( self, grp, name )
1555 name = grp.GetName()
1557 typ = self._groupTypeFromShape( grp )
1558 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1560 ## Pivate method to get a type of group on geometry
1561 def _groupTypeFromShape( self, shape ):
1562 tgeo = str(shape.GetShapeType())
1563 if tgeo == "VERTEX":
1565 elif tgeo == "EDGE":
1567 elif tgeo == "FACE" or tgeo == "SHELL":
1569 elif tgeo == "SOLID" or tgeo == "COMPSOLID":
1571 elif tgeo == "COMPOUND":
1572 sub = self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHAPE"])
1574 raise ValueError,"_groupTypeFromShape(): empty geometric group or compound '%s'" % GetName(shape)
1575 return self._groupTypeFromShape( sub[0] )
1578 "_groupTypeFromShape(): invalid geometry '%s'" % GetName(shape)
1581 ## Creates a mesh group with given \a name based on the \a filter which
1582 ## is a special type of group dynamically updating it's contents during
1583 ## mesh modification
1584 # @param typ the type of elements in the group
1585 # @param name the name of the mesh group
1586 # @param filter the filter defining group contents
1587 # @return SMESH_GroupOnFilter
1588 # @ingroup l2_grps_create
1589 def GroupOnFilter(self, typ, name, filter):
1590 return self.mesh.CreateGroupFromFilter(typ, name, filter)
1592 ## Creates a mesh group by the given ids of elements
1593 # @param groupName the name of the mesh group
1594 # @param elementType the type of elements in the group
1595 # @param elemIDs the list of ids
1596 # @return SMESH_Group
1597 # @ingroup l2_grps_create
1598 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1599 group = self.mesh.CreateGroup(elementType, groupName)
1603 ## Creates a mesh group by the given conditions
1604 # @param groupName the name of the mesh group
1605 # @param elementType the type of elements in the group
1606 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1607 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1608 # @param Threshold the threshold value (range of id ids as string, shape, numeric)
1609 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1610 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
1611 # FT_LyingOnGeom, FT_CoplanarFaces criteria
1612 # @return SMESH_Group
1613 # @ingroup l2_grps_create
1617 CritType=FT_Undefined,
1620 UnaryOp=FT_Undefined,
1622 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Threshold, UnaryOp, FT_Undefined,Tolerance)
1623 group = self.MakeGroupByCriterion(groupName, aCriterion)
1626 ## Creates a mesh group by the given criterion
1627 # @param groupName the name of the mesh group
1628 # @param Criterion the instance of Criterion class
1629 # @return SMESH_Group
1630 # @ingroup l2_grps_create
1631 def MakeGroupByCriterion(self, groupName, Criterion):
1632 aFilterMgr = self.smeshpyD.CreateFilterManager()
1633 aFilter = aFilterMgr.CreateFilter()
1635 aCriteria.append(Criterion)
1636 aFilter.SetCriteria(aCriteria)
1637 group = self.MakeGroupByFilter(groupName, aFilter)
1638 aFilterMgr.UnRegister()
1641 ## Creates a mesh group by the given criteria (list of criteria)
1642 # @param groupName the name of the mesh group
1643 # @param theCriteria the list of criteria
1644 # @return SMESH_Group
1645 # @ingroup l2_grps_create
1646 def MakeGroupByCriteria(self, groupName, theCriteria):
1647 aFilterMgr = self.smeshpyD.CreateFilterManager()
1648 aFilter = aFilterMgr.CreateFilter()
1649 aFilter.SetCriteria(theCriteria)
1650 group = self.MakeGroupByFilter(groupName, aFilter)
1651 aFilterMgr.UnRegister()
1654 ## Creates a mesh group by the given filter
1655 # @param groupName the name of the mesh group
1656 # @param theFilter the instance of Filter class
1657 # @return SMESH_Group
1658 # @ingroup l2_grps_create
1659 def MakeGroupByFilter(self, groupName, theFilter):
1660 group = self.CreateEmptyGroup(theFilter.GetElementType(), groupName)
1661 theFilter.SetMesh( self.mesh )
1662 group.AddFrom( theFilter )
1666 # @ingroup l2_grps_delete
1667 def RemoveGroup(self, group):
1668 self.mesh.RemoveGroup(group)
1670 ## Removes a group with its contents
1671 # @ingroup l2_grps_delete
1672 def RemoveGroupWithContents(self, group):
1673 self.mesh.RemoveGroupWithContents(group)
1675 ## Gets the list of groups existing in the mesh
1676 # @return a sequence of SMESH_GroupBase
1677 # @ingroup l2_grps_create
1678 def GetGroups(self):
1679 return self.mesh.GetGroups()
1681 ## Gets the number of groups existing in the mesh
1682 # @return the quantity of groups as an integer value
1683 # @ingroup l2_grps_create
1685 return self.mesh.NbGroups()
1687 ## Gets the list of names of groups existing in the mesh
1688 # @return list of strings
1689 # @ingroup l2_grps_create
1690 def GetGroupNames(self):
1691 groups = self.GetGroups()
1693 for group in groups:
1694 names.append(group.GetName())
1697 ## Produces a union of two groups
1698 # A new group is created. All mesh elements that are
1699 # present in the initial groups are added to the new one
1700 # @return an instance of SMESH_Group
1701 # @ingroup l2_grps_operon
1702 def UnionGroups(self, group1, group2, name):
1703 return self.mesh.UnionGroups(group1, group2, name)
1705 ## Produces a union list of groups
1706 # New group is created. All mesh elements that are present in
1707 # initial groups are added to the new one
1708 # @return an instance of SMESH_Group
1709 # @ingroup l2_grps_operon
1710 def UnionListOfGroups(self, groups, name):
1711 return self.mesh.UnionListOfGroups(groups, name)
1713 ## Prodices an intersection of two groups
1714 # A new group is created. All mesh elements that are common
1715 # for the two initial groups are added to the new one.
1716 # @return an instance of SMESH_Group
1717 # @ingroup l2_grps_operon
1718 def IntersectGroups(self, group1, group2, name):
1719 return self.mesh.IntersectGroups(group1, group2, name)
1721 ## Produces an intersection of groups
1722 # New group is created. All mesh elements that are present in all
1723 # initial groups simultaneously are added to the new one
1724 # @return an instance of SMESH_Group
1725 # @ingroup l2_grps_operon
1726 def IntersectListOfGroups(self, groups, name):
1727 return self.mesh.IntersectListOfGroups(groups, name)
1729 ## Produces a cut of two groups
1730 # A new group is created. All mesh elements that are present in
1731 # the main group but are not present in the tool group are added to the new one
1732 # @return an instance of SMESH_Group
1733 # @ingroup l2_grps_operon
1734 def CutGroups(self, main_group, tool_group, name):
1735 return self.mesh.CutGroups(main_group, tool_group, name)
1737 ## Produces a cut of groups
1738 # A new group is created. All mesh elements that are present in main groups
1739 # but do not present in tool groups are added to the new one
1740 # @return an instance of SMESH_Group
1741 # @ingroup l2_grps_operon
1742 def CutListOfGroups(self, main_groups, tool_groups, name):
1743 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1745 ## Produces a group of elements of specified type using list of existing groups
1746 # A new group is created. System
1747 # 1) extracts all nodes on which groups elements are built
1748 # 2) combines all elements of specified dimension laying on these nodes
1749 # @return an instance of SMESH_Group
1750 # @ingroup l2_grps_operon
1751 def CreateDimGroup(self, groups, elem_type, name):
1752 return self.mesh.CreateDimGroup(groups, elem_type, name)
1755 ## Convert group on geom into standalone group
1756 # @ingroup l2_grps_delete
1757 def ConvertToStandalone(self, group):
1758 return self.mesh.ConvertToStandalone(group)
1760 # Get some info about mesh:
1761 # ------------------------
1763 ## Returns the log of nodes and elements added or removed
1764 # since the previous clear of the log.
1765 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1766 # @return list of log_block structures:
1771 # @ingroup l1_auxiliary
1772 def GetLog(self, clearAfterGet):
1773 return self.mesh.GetLog(clearAfterGet)
1775 ## Clears the log of nodes and elements added or removed since the previous
1776 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1777 # @ingroup l1_auxiliary
1779 self.mesh.ClearLog()
1781 ## Toggles auto color mode on the object.
1782 # @param theAutoColor the flag which toggles auto color mode.
1783 # @ingroup l1_auxiliary
1784 def SetAutoColor(self, theAutoColor):
1785 self.mesh.SetAutoColor(theAutoColor)
1787 ## Gets flag of object auto color mode.
1788 # @return True or False
1789 # @ingroup l1_auxiliary
1790 def GetAutoColor(self):
1791 return self.mesh.GetAutoColor()
1793 ## Gets the internal ID
1794 # @return integer value, which is the internal Id of the mesh
1795 # @ingroup l1_auxiliary
1797 return self.mesh.GetId()
1800 # @return integer value, which is the study Id of the mesh
1801 # @ingroup l1_auxiliary
1802 def GetStudyId(self):
1803 return self.mesh.GetStudyId()
1805 ## Checks the group names for duplications.
1806 # Consider the maximum group name length stored in MED file.
1807 # @return True or False
1808 # @ingroup l1_auxiliary
1809 def HasDuplicatedGroupNamesMED(self):
1810 return self.mesh.HasDuplicatedGroupNamesMED()
1812 ## Obtains the mesh editor tool
1813 # @return an instance of SMESH_MeshEditor
1814 # @ingroup l1_modifying
1815 def GetMeshEditor(self):
1818 ## Wrap a list of IDs of elements or nodes into SMESH_IDSource which
1819 # can be passed as argument to a method accepting mesh, group or sub-mesh
1820 # @return an instance of SMESH_IDSource
1821 # @ingroup l1_auxiliary
1822 def GetIDSource(self, ids, elemType):
1823 return self.editor.MakeIDSource(ids, elemType)
1826 # @return an instance of SALOME_MED::MESH
1827 # @ingroup l1_auxiliary
1828 def GetMEDMesh(self):
1829 return self.mesh.GetMEDMesh()
1832 # Get informations about mesh contents:
1833 # ------------------------------------
1835 ## Gets the mesh stattistic
1836 # @return dictionary type element - count of elements
1837 # @ingroup l1_meshinfo
1838 def GetMeshInfo(self, obj = None):
1839 if not obj: obj = self.mesh
1840 return self.smeshpyD.GetMeshInfo(obj)
1842 ## Returns the number of nodes in the mesh
1843 # @return an integer value
1844 # @ingroup l1_meshinfo
1846 return self.mesh.NbNodes()
1848 ## Returns the number of elements in the mesh
1849 # @return an integer value
1850 # @ingroup l1_meshinfo
1851 def NbElements(self):
1852 return self.mesh.NbElements()
1854 ## Returns the number of 0d elements in the mesh
1855 # @return an integer value
1856 # @ingroup l1_meshinfo
1857 def Nb0DElements(self):
1858 return self.mesh.Nb0DElements()
1860 ## Returns the number of ball discrete elements in the mesh
1861 # @return an integer value
1862 # @ingroup l1_meshinfo
1864 return self.mesh.NbBalls()
1866 ## Returns the number of edges in the mesh
1867 # @return an integer value
1868 # @ingroup l1_meshinfo
1870 return self.mesh.NbEdges()
1872 ## Returns the number of edges with the given order in the mesh
1873 # @param elementOrder the order of elements:
1874 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1875 # @return an integer value
1876 # @ingroup l1_meshinfo
1877 def NbEdgesOfOrder(self, elementOrder):
1878 return self.mesh.NbEdgesOfOrder(elementOrder)
1880 ## Returns the number of faces in the mesh
1881 # @return an integer value
1882 # @ingroup l1_meshinfo
1884 return self.mesh.NbFaces()
1886 ## Returns the number of faces with the given order in the mesh
1887 # @param elementOrder the order of elements:
1888 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1889 # @return an integer value
1890 # @ingroup l1_meshinfo
1891 def NbFacesOfOrder(self, elementOrder):
1892 return self.mesh.NbFacesOfOrder(elementOrder)
1894 ## Returns the number of triangles in the mesh
1895 # @return an integer value
1896 # @ingroup l1_meshinfo
1897 def NbTriangles(self):
1898 return self.mesh.NbTriangles()
1900 ## Returns the number of triangles with the given order in the mesh
1901 # @param elementOrder is the order of elements:
1902 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1903 # @return an integer value
1904 # @ingroup l1_meshinfo
1905 def NbTrianglesOfOrder(self, elementOrder):
1906 return self.mesh.NbTrianglesOfOrder(elementOrder)
1908 ## Returns the number of quadrangles in the mesh
1909 # @return an integer value
1910 # @ingroup l1_meshinfo
1911 def NbQuadrangles(self):
1912 return self.mesh.NbQuadrangles()
1914 ## Returns the number of quadrangles with the given order in the mesh
1915 # @param elementOrder the order of elements:
1916 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1917 # @return an integer value
1918 # @ingroup l1_meshinfo
1919 def NbQuadranglesOfOrder(self, elementOrder):
1920 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1922 ## Returns the number of biquadratic quadrangles in the mesh
1923 # @return an integer value
1924 # @ingroup l1_meshinfo
1925 def NbBiQuadQuadrangles(self):
1926 return self.mesh.NbBiQuadQuadrangles()
1928 ## Returns the number of polygons in the mesh
1929 # @return an integer value
1930 # @ingroup l1_meshinfo
1931 def NbPolygons(self):
1932 return self.mesh.NbPolygons()
1934 ## Returns the number of volumes in the mesh
1935 # @return an integer value
1936 # @ingroup l1_meshinfo
1937 def NbVolumes(self):
1938 return self.mesh.NbVolumes()
1940 ## Returns the number of volumes with the given order in the mesh
1941 # @param elementOrder the order of elements:
1942 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1943 # @return an integer value
1944 # @ingroup l1_meshinfo
1945 def NbVolumesOfOrder(self, elementOrder):
1946 return self.mesh.NbVolumesOfOrder(elementOrder)
1948 ## Returns the number of tetrahedrons in the mesh
1949 # @return an integer value
1950 # @ingroup l1_meshinfo
1952 return self.mesh.NbTetras()
1954 ## Returns the number of tetrahedrons with the given order in the mesh
1955 # @param elementOrder the order of elements:
1956 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1957 # @return an integer value
1958 # @ingroup l1_meshinfo
1959 def NbTetrasOfOrder(self, elementOrder):
1960 return self.mesh.NbTetrasOfOrder(elementOrder)
1962 ## Returns the number of hexahedrons in the mesh
1963 # @return an integer value
1964 # @ingroup l1_meshinfo
1966 return self.mesh.NbHexas()
1968 ## Returns the number of hexahedrons with the given order in the mesh
1969 # @param elementOrder the order of elements:
1970 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1971 # @return an integer value
1972 # @ingroup l1_meshinfo
1973 def NbHexasOfOrder(self, elementOrder):
1974 return self.mesh.NbHexasOfOrder(elementOrder)
1976 ## Returns the number of triquadratic hexahedrons in the mesh
1977 # @return an integer value
1978 # @ingroup l1_meshinfo
1979 def NbTriQuadraticHexas(self):
1980 return self.mesh.NbTriQuadraticHexas()
1982 ## Returns the number of pyramids in the mesh
1983 # @return an integer value
1984 # @ingroup l1_meshinfo
1985 def NbPyramids(self):
1986 return self.mesh.NbPyramids()
1988 ## Returns the number of pyramids with the given order in the mesh
1989 # @param elementOrder the order of elements:
1990 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1991 # @return an integer value
1992 # @ingroup l1_meshinfo
1993 def NbPyramidsOfOrder(self, elementOrder):
1994 return self.mesh.NbPyramidsOfOrder(elementOrder)
1996 ## Returns the number of prisms in the mesh
1997 # @return an integer value
1998 # @ingroup l1_meshinfo
2000 return self.mesh.NbPrisms()
2002 ## Returns the number of prisms with the given order in the mesh
2003 # @param elementOrder the order of elements:
2004 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2005 # @return an integer value
2006 # @ingroup l1_meshinfo
2007 def NbPrismsOfOrder(self, elementOrder):
2008 return self.mesh.NbPrismsOfOrder(elementOrder)
2010 ## Returns the number of hexagonal prisms in the mesh
2011 # @return an integer value
2012 # @ingroup l1_meshinfo
2013 def NbHexagonalPrisms(self):
2014 return self.mesh.NbHexagonalPrisms()
2016 ## Returns the number of polyhedrons in the mesh
2017 # @return an integer value
2018 # @ingroup l1_meshinfo
2019 def NbPolyhedrons(self):
2020 return self.mesh.NbPolyhedrons()
2022 ## Returns the number of submeshes in the mesh
2023 # @return an integer value
2024 # @ingroup l1_meshinfo
2025 def NbSubMesh(self):
2026 return self.mesh.NbSubMesh()
2028 ## Returns the list of mesh elements IDs
2029 # @return the list of integer values
2030 # @ingroup l1_meshinfo
2031 def GetElementsId(self):
2032 return self.mesh.GetElementsId()
2034 ## Returns the list of IDs of mesh elements with the given type
2035 # @param elementType the required type of elements (SMESH.NODE, SMESH.EDGE, SMESH.FACE or SMESH.VOLUME)
2036 # @return list of integer values
2037 # @ingroup l1_meshinfo
2038 def GetElementsByType(self, elementType):
2039 return self.mesh.GetElementsByType(elementType)
2041 ## Returns the list of mesh nodes IDs
2042 # @return the list of integer values
2043 # @ingroup l1_meshinfo
2044 def GetNodesId(self):
2045 return self.mesh.GetNodesId()
2047 # Get the information about mesh elements:
2048 # ------------------------------------
2050 ## Returns the type of mesh element
2051 # @return the value from SMESH::ElementType enumeration
2052 # @ingroup l1_meshinfo
2053 def GetElementType(self, id, iselem):
2054 return self.mesh.GetElementType(id, iselem)
2056 ## Returns the geometric type of mesh element
2057 # @return the value from SMESH::EntityType enumeration
2058 # @ingroup l1_meshinfo
2059 def GetElementGeomType(self, id):
2060 return self.mesh.GetElementGeomType(id)
2062 ## Returns the list of submesh elements IDs
2063 # @param Shape a geom object(sub-shape) IOR
2064 # Shape must be the sub-shape of a ShapeToMesh()
2065 # @return the list of integer values
2066 # @ingroup l1_meshinfo
2067 def GetSubMeshElementsId(self, Shape):
2068 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2069 ShapeID = Shape.GetSubShapeIndices()[0]
2072 return self.mesh.GetSubMeshElementsId(ShapeID)
2074 ## Returns the list of submesh nodes IDs
2075 # @param Shape a geom object(sub-shape) IOR
2076 # Shape must be the sub-shape of a ShapeToMesh()
2077 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
2078 # @return the list of integer values
2079 # @ingroup l1_meshinfo
2080 def GetSubMeshNodesId(self, Shape, all):
2081 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2082 ShapeID = self.geompyD.GetSubShapeID( self.geom, Shape )
2085 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2087 ## Returns type of elements on given shape
2088 # @param Shape a geom object(sub-shape) IOR
2089 # Shape must be a sub-shape of a ShapeToMesh()
2090 # @return element type
2091 # @ingroup l1_meshinfo
2092 def GetSubMeshElementType(self, Shape):
2093 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2094 ShapeID = Shape.GetSubShapeIndices()[0]
2097 return self.mesh.GetSubMeshElementType(ShapeID)
2099 ## Gets the mesh description
2100 # @return string value
2101 # @ingroup l1_meshinfo
2103 return self.mesh.Dump()
2106 # Get the information about nodes and elements of a mesh by its IDs:
2107 # -----------------------------------------------------------
2109 ## Gets XYZ coordinates of a node
2110 # \n If there is no nodes for the given ID - returns an empty list
2111 # @return a list of double precision values
2112 # @ingroup l1_meshinfo
2113 def GetNodeXYZ(self, id):
2114 return self.mesh.GetNodeXYZ(id)
2116 ## Returns list of IDs of inverse elements for the given node
2117 # \n If there is no node for the given ID - returns an empty list
2118 # @return a list of integer values
2119 # @ingroup l1_meshinfo
2120 def GetNodeInverseElements(self, id):
2121 return self.mesh.GetNodeInverseElements(id)
2123 ## @brief Returns the position of a node on the shape
2124 # @return SMESH::NodePosition
2125 # @ingroup l1_meshinfo
2126 def GetNodePosition(self,NodeID):
2127 return self.mesh.GetNodePosition(NodeID)
2129 ## @brief Returns the position of an element on the shape
2130 # @return SMESH::ElementPosition
2131 # @ingroup l1_meshinfo
2132 def GetElementPosition(self,ElemID):
2133 return self.mesh.GetElementPosition(ElemID)
2135 ## If the given element is a node, returns the ID of shape
2136 # \n If there is no node for the given ID - returns -1
2137 # @return an integer value
2138 # @ingroup l1_meshinfo
2139 def GetShapeID(self, id):
2140 return self.mesh.GetShapeID(id)
2142 ## Returns the ID of the result shape after
2143 # FindShape() from SMESH_MeshEditor for the given element
2144 # \n If there is no element for the given ID - returns -1
2145 # @return an integer value
2146 # @ingroup l1_meshinfo
2147 def GetShapeIDForElem(self,id):
2148 return self.mesh.GetShapeIDForElem(id)
2150 ## Returns the number of nodes for the given element
2151 # \n If there is no element for the given ID - returns -1
2152 # @return an integer value
2153 # @ingroup l1_meshinfo
2154 def GetElemNbNodes(self, id):
2155 return self.mesh.GetElemNbNodes(id)
2157 ## Returns the node ID the given index for the given element
2158 # \n If there is no element for the given ID - returns -1
2159 # \n If there is no node for the given index - returns -2
2160 # @return an integer value
2161 # @ingroup l1_meshinfo
2162 def GetElemNode(self, id, index):
2163 return self.mesh.GetElemNode(id, index)
2165 ## Returns the IDs of nodes of the given element
2166 # @return a list of integer values
2167 # @ingroup l1_meshinfo
2168 def GetElemNodes(self, id):
2169 return self.mesh.GetElemNodes(id)
2171 ## Returns true if the given node is the medium node in the given quadratic element
2172 # @ingroup l1_meshinfo
2173 def IsMediumNode(self, elementID, nodeID):
2174 return self.mesh.IsMediumNode(elementID, nodeID)
2176 ## Returns true if the given node is the medium node in one of quadratic elements
2177 # @ingroup l1_meshinfo
2178 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2179 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2181 ## Returns the number of edges for the given element
2182 # @ingroup l1_meshinfo
2183 def ElemNbEdges(self, id):
2184 return self.mesh.ElemNbEdges(id)
2186 ## Returns the number of faces for the given element
2187 # @ingroup l1_meshinfo
2188 def ElemNbFaces(self, id):
2189 return self.mesh.ElemNbFaces(id)
2191 ## Returns nodes of given face (counted from zero) for given volumic element.
2192 # @ingroup l1_meshinfo
2193 def GetElemFaceNodes(self,elemId, faceIndex):
2194 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2196 ## Returns an element based on all given nodes.
2197 # @ingroup l1_meshinfo
2198 def FindElementByNodes(self,nodes):
2199 return self.mesh.FindElementByNodes(nodes)
2201 ## Returns true if the given element is a polygon
2202 # @ingroup l1_meshinfo
2203 def IsPoly(self, id):
2204 return self.mesh.IsPoly(id)
2206 ## Returns true if the given element is quadratic
2207 # @ingroup l1_meshinfo
2208 def IsQuadratic(self, id):
2209 return self.mesh.IsQuadratic(id)
2211 ## Returns diameter of a ball discrete element or zero in case of an invalid \a id
2212 # @ingroup l1_meshinfo
2213 def GetBallDiameter(self, id):
2214 return self.mesh.GetBallDiameter(id)
2216 ## Returns XYZ coordinates of the barycenter of the given element
2217 # \n If there is no element for the given ID - returns an empty list
2218 # @return a list of three double values
2219 # @ingroup l1_meshinfo
2220 def BaryCenter(self, id):
2221 return self.mesh.BaryCenter(id)
2223 ## Passes mesh elements through the given filter and return IDs of fitting elements
2224 # @param theFilter SMESH_Filter
2225 # @return a list of ids
2226 # @ingroup l1_controls
2227 def GetIdsFromFilter(self, theFilter):
2228 theFilter.SetMesh( self.mesh )
2229 return theFilter.GetIDs()
2231 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
2232 # Returns a list of special structures (borders).
2233 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
2234 # @ingroup l1_controls
2235 def GetFreeBorders(self):
2236 aFilterMgr = self.smeshpyD.CreateFilterManager()
2237 aPredicate = aFilterMgr.CreateFreeEdges()
2238 aPredicate.SetMesh(self.mesh)
2239 aBorders = aPredicate.GetBorders()
2240 aFilterMgr.UnRegister()
2244 # Get mesh measurements information:
2245 # ------------------------------------
2247 ## Get minimum distance between two nodes, elements or distance to the origin
2248 # @param id1 first node/element id
2249 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2250 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2251 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2252 # @return minimum distance value
2253 # @sa GetMinDistance()
2254 def MinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2255 aMeasure = self.GetMinDistance(id1, id2, isElem1, isElem2)
2256 return aMeasure.value
2258 ## Get measure structure specifying minimum distance data between two objects
2259 # @param id1 first node/element id
2260 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2261 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2262 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2263 # @return Measure structure
2265 def GetMinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2267 id1 = self.editor.MakeIDSource([id1], SMESH.FACE)
2269 id1 = self.editor.MakeIDSource([id1], SMESH.NODE)
2272 id2 = self.editor.MakeIDSource([id2], SMESH.FACE)
2274 id2 = self.editor.MakeIDSource([id2], SMESH.NODE)
2279 aMeasurements = self.smeshpyD.CreateMeasurements()
2280 aMeasure = aMeasurements.MinDistance(id1, id2)
2281 aMeasurements.UnRegister()
2284 ## Get bounding box of the specified object(s)
2285 # @param objects single source object or list of source objects or list of nodes/elements IDs
2286 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2287 # @c False specifies that @a objects are nodes
2288 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
2289 # @sa GetBoundingBox()
2290 def BoundingBox(self, objects=None, isElem=False):
2291 result = self.GetBoundingBox(objects, isElem)
2295 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
2298 ## Get measure structure specifying bounding box data of the specified object(s)
2299 # @param IDs single source object or list of source objects or list of nodes/elements IDs
2300 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2301 # @c False specifies that @a objects are nodes
2302 # @return Measure structure
2304 def GetBoundingBox(self, IDs=None, isElem=False):
2307 elif isinstance(IDs, tuple):
2309 if not isinstance(IDs, list):
2311 if len(IDs) > 0 and isinstance(IDs[0], int):
2315 if isinstance(o, Mesh):
2316 srclist.append(o.mesh)
2317 elif hasattr(o, "_narrow"):
2318 src = o._narrow(SMESH.SMESH_IDSource)
2319 if src: srclist.append(src)
2321 elif isinstance(o, list):
2323 srclist.append(self.editor.MakeIDSource(o, SMESH.FACE))
2325 srclist.append(self.editor.MakeIDSource(o, SMESH.NODE))
2328 aMeasurements = self.smeshpyD.CreateMeasurements()
2329 aMeasure = aMeasurements.BoundingBox(srclist)
2330 aMeasurements.UnRegister()
2333 # Mesh edition (SMESH_MeshEditor functionality):
2334 # ---------------------------------------------
2336 ## Removes the elements from the mesh by ids
2337 # @param IDsOfElements is a list of ids of elements to remove
2338 # @return True or False
2339 # @ingroup l2_modif_del
2340 def RemoveElements(self, IDsOfElements):
2341 return self.editor.RemoveElements(IDsOfElements)
2343 ## Removes nodes from mesh by ids
2344 # @param IDsOfNodes is a list of ids of nodes to remove
2345 # @return True or False
2346 # @ingroup l2_modif_del
2347 def RemoveNodes(self, IDsOfNodes):
2348 return self.editor.RemoveNodes(IDsOfNodes)
2350 ## Removes all orphan (free) nodes from mesh
2351 # @return number of the removed nodes
2352 # @ingroup l2_modif_del
2353 def RemoveOrphanNodes(self):
2354 return self.editor.RemoveOrphanNodes()
2356 ## Add a node to the mesh by coordinates
2357 # @return Id of the new node
2358 # @ingroup l2_modif_add
2359 def AddNode(self, x, y, z):
2360 x,y,z,Parameters,hasVars = ParseParameters(x,y,z)
2361 if hasVars: self.mesh.SetParameters(Parameters)
2362 return self.editor.AddNode( x, y, z)
2364 ## Creates a 0D element on a node with given number.
2365 # @param IDOfNode the ID of node for creation of the element.
2366 # @return the Id of the new 0D element
2367 # @ingroup l2_modif_add
2368 def Add0DElement(self, IDOfNode):
2369 return self.editor.Add0DElement(IDOfNode)
2371 ## Create 0D elements on all nodes of the given elements except those
2372 # nodes on which a 0D element already exists.
2373 # @param theObject an object on whose nodes 0D elements will be created.
2374 # It can be mesh, sub-mesh, group, list of element IDs or a holder
2375 # of nodes IDs created by calling mesh.GetIDSource( nodes, SMESH.NODE )
2376 # @param theGroupName optional name of a group to add 0D elements created
2377 # and/or found on nodes of \a theObject.
2378 # @return an object (a new group or a temporary SMESH_IDSource) holding
2379 # IDs of new and/or found 0D elements. IDs of 0D elements
2380 # can be retrieved from the returned object by calling GetIDs()
2381 # @ingroup l2_modif_add
2382 def Add0DElementsToAllNodes(self, theObject, theGroupName=""):
2383 if isinstance( theObject, Mesh ):
2384 theObject = theObject.GetMesh()
2385 if isinstance( theObject, list ):
2386 theObject = self.GetIDSource( theObject, SMESH.ALL )
2387 return self.editor.Create0DElementsOnAllNodes( theObject, theGroupName )
2389 ## Creates a ball element on a node with given ID.
2390 # @param IDOfNode the ID of node for creation of the element.
2391 # @param diameter the bal diameter.
2392 # @return the Id of the new ball element
2393 # @ingroup l2_modif_add
2394 def AddBall(self, IDOfNode, diameter):
2395 return self.editor.AddBall( IDOfNode, diameter )
2397 ## Creates a linear or quadratic edge (this is determined
2398 # by the number of given nodes).
2399 # @param IDsOfNodes the list of node IDs for creation of the element.
2400 # The order of nodes in this list should correspond to the description
2401 # of MED. \n This description is located by the following link:
2402 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2403 # @return the Id of the new edge
2404 # @ingroup l2_modif_add
2405 def AddEdge(self, IDsOfNodes):
2406 return self.editor.AddEdge(IDsOfNodes)
2408 ## Creates a linear or quadratic face (this is determined
2409 # by the number of given nodes).
2410 # @param IDsOfNodes the list of node IDs for creation of the element.
2411 # The order of nodes in this list should correspond to the description
2412 # of MED. \n This description is located by the following link:
2413 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2414 # @return the Id of the new face
2415 # @ingroup l2_modif_add
2416 def AddFace(self, IDsOfNodes):
2417 return self.editor.AddFace(IDsOfNodes)
2419 ## Adds a polygonal face to the mesh by the list of node IDs
2420 # @param IdsOfNodes the list of node IDs for creation of the element.
2421 # @return the Id of the new face
2422 # @ingroup l2_modif_add
2423 def AddPolygonalFace(self, IdsOfNodes):
2424 return self.editor.AddPolygonalFace(IdsOfNodes)
2426 ## Creates both simple and quadratic volume (this is determined
2427 # by the number of given nodes).
2428 # @param IDsOfNodes the list of node IDs for creation of the element.
2429 # The order of nodes in this list should correspond to the description
2430 # of MED. \n This description is located by the following link:
2431 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2432 # @return the Id of the new volumic element
2433 # @ingroup l2_modif_add
2434 def AddVolume(self, IDsOfNodes):
2435 return self.editor.AddVolume(IDsOfNodes)
2437 ## Creates a volume of many faces, giving nodes for each face.
2438 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2439 # @param Quantities the list of integer values, Quantities[i]
2440 # gives the quantity of nodes in face number i.
2441 # @return the Id of the new volumic element
2442 # @ingroup l2_modif_add
2443 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2444 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2446 ## Creates a volume of many faces, giving the IDs of the existing faces.
2447 # @param IdsOfFaces the list of face IDs for volume creation.
2449 # Note: The created volume will refer only to the nodes
2450 # of the given faces, not to the faces themselves.
2451 # @return the Id of the new volumic element
2452 # @ingroup l2_modif_add
2453 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2454 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2457 ## @brief Binds a node to a vertex
2458 # @param NodeID a node ID
2459 # @param Vertex a vertex or vertex ID
2460 # @return True if succeed else raises an exception
2461 # @ingroup l2_modif_add
2462 def SetNodeOnVertex(self, NodeID, Vertex):
2463 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2464 VertexID = Vertex.GetSubShapeIndices()[0]
2468 self.editor.SetNodeOnVertex(NodeID, VertexID)
2469 except SALOME.SALOME_Exception, inst:
2470 raise ValueError, inst.details.text
2474 ## @brief Stores the node position on an edge
2475 # @param NodeID a node ID
2476 # @param Edge an edge or edge ID
2477 # @param paramOnEdge a parameter on the edge where the node is located
2478 # @return True if succeed else raises an exception
2479 # @ingroup l2_modif_add
2480 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2481 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2482 EdgeID = Edge.GetSubShapeIndices()[0]
2486 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2487 except SALOME.SALOME_Exception, inst:
2488 raise ValueError, inst.details.text
2491 ## @brief Stores node position on a face
2492 # @param NodeID a node ID
2493 # @param Face a face or face ID
2494 # @param u U parameter on the face where the node is located
2495 # @param v V parameter on the face where the node is located
2496 # @return True if succeed else raises an exception
2497 # @ingroup l2_modif_add
2498 def SetNodeOnFace(self, NodeID, Face, u, v):
2499 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2500 FaceID = Face.GetSubShapeIndices()[0]
2504 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2505 except SALOME.SALOME_Exception, inst:
2506 raise ValueError, inst.details.text
2509 ## @brief Binds a node to a solid
2510 # @param NodeID a node ID
2511 # @param Solid a solid or solid ID
2512 # @return True if succeed else raises an exception
2513 # @ingroup l2_modif_add
2514 def SetNodeInVolume(self, NodeID, Solid):
2515 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2516 SolidID = Solid.GetSubShapeIndices()[0]
2520 self.editor.SetNodeInVolume(NodeID, SolidID)
2521 except SALOME.SALOME_Exception, inst:
2522 raise ValueError, inst.details.text
2525 ## @brief Bind an element to a shape
2526 # @param ElementID an element ID
2527 # @param Shape a shape or shape ID
2528 # @return True if succeed else raises an exception
2529 # @ingroup l2_modif_add
2530 def SetMeshElementOnShape(self, ElementID, Shape):
2531 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2532 ShapeID = Shape.GetSubShapeIndices()[0]
2536 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2537 except SALOME.SALOME_Exception, inst:
2538 raise ValueError, inst.details.text
2542 ## Moves the node with the given id
2543 # @param NodeID the id of the node
2544 # @param x a new X coordinate
2545 # @param y a new Y coordinate
2546 # @param z a new Z coordinate
2547 # @return True if succeed else False
2548 # @ingroup l2_modif_movenode
2549 def MoveNode(self, NodeID, x, y, z):
2550 x,y,z,Parameters,hasVars = ParseParameters(x,y,z)
2551 if hasVars: self.mesh.SetParameters(Parameters)
2552 return self.editor.MoveNode(NodeID, x, y, z)
2554 ## Finds the node closest to a point and moves it to a point location
2555 # @param x the X coordinate of a point
2556 # @param y the Y coordinate of a point
2557 # @param z the Z coordinate of a point
2558 # @param NodeID if specified (>0), the node with this ID is moved,
2559 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2560 # @return the ID of a node
2561 # @ingroup l2_modif_throughp
2562 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2563 x,y,z,Parameters,hasVars = ParseParameters(x,y,z)
2564 if hasVars: self.mesh.SetParameters(Parameters)
2565 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2567 ## Finds the node closest to a point
2568 # @param x the X coordinate of a point
2569 # @param y the Y coordinate of a point
2570 # @param z the Z coordinate of a point
2571 # @return the ID of a node
2572 # @ingroup l2_modif_throughp
2573 def FindNodeClosestTo(self, x, y, z):
2574 #preview = self.mesh.GetMeshEditPreviewer()
2575 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2576 return self.editor.FindNodeClosestTo(x, y, z)
2578 ## Finds the elements where a point lays IN or ON
2579 # @param x the X coordinate of a point
2580 # @param y the Y coordinate of a point
2581 # @param z the Z coordinate of a point
2582 # @param elementType type of elements to find (SMESH.ALL type
2583 # means elements of any type excluding nodes, discrete and 0D elements)
2584 # @param meshPart a part of mesh (group, sub-mesh) to search within
2585 # @return list of IDs of found elements
2586 # @ingroup l2_modif_throughp
2587 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL, meshPart=None):
2589 return self.editor.FindAmongElementsByPoint( meshPart, x, y, z, elementType );
2591 return self.editor.FindElementsByPoint(x, y, z, elementType)
2593 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration:
2594 # 0-IN, 1-OUT, 2-ON, 3-UNKNOWN
2595 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2597 def GetPointState(self, x, y, z):
2598 return self.editor.GetPointState(x, y, z)
2600 ## Finds the node closest to a point and moves it to a point location
2601 # @param x the X coordinate of a point
2602 # @param y the Y coordinate of a point
2603 # @param z the Z coordinate of a point
2604 # @return the ID of a moved node
2605 # @ingroup l2_modif_throughp
2606 def MeshToPassThroughAPoint(self, x, y, z):
2607 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2609 ## Replaces two neighbour triangles sharing Node1-Node2 link
2610 # with the triangles built on the same 4 nodes but having other common link.
2611 # @param NodeID1 the ID of the first node
2612 # @param NodeID2 the ID of the second node
2613 # @return false if proper faces were not found
2614 # @ingroup l2_modif_invdiag
2615 def InverseDiag(self, NodeID1, NodeID2):
2616 return self.editor.InverseDiag(NodeID1, NodeID2)
2618 ## Replaces two neighbour triangles sharing Node1-Node2 link
2619 # with a quadrangle built on the same 4 nodes.
2620 # @param NodeID1 the ID of the first node
2621 # @param NodeID2 the ID of the second node
2622 # @return false if proper faces were not found
2623 # @ingroup l2_modif_unitetri
2624 def DeleteDiag(self, NodeID1, NodeID2):
2625 return self.editor.DeleteDiag(NodeID1, NodeID2)
2627 ## Reorients elements by ids
2628 # @param IDsOfElements if undefined reorients all mesh elements
2629 # @return True if succeed else False
2630 # @ingroup l2_modif_changori
2631 def Reorient(self, IDsOfElements=None):
2632 if IDsOfElements == None:
2633 IDsOfElements = self.GetElementsId()
2634 return self.editor.Reorient(IDsOfElements)
2636 ## Reorients all elements of the object
2637 # @param theObject mesh, submesh or group
2638 # @return True if succeed else False
2639 # @ingroup l2_modif_changori
2640 def ReorientObject(self, theObject):
2641 if ( isinstance( theObject, Mesh )):
2642 theObject = theObject.GetMesh()
2643 return self.editor.ReorientObject(theObject)
2645 ## Reorient faces contained in \a the2DObject.
2646 # @param the2DObject is a mesh, sub-mesh, group or list of IDs of 2D elements
2647 # @param theDirection is a desired direction of normal of \a theFace.
2648 # It can be either a GEOM vector or a list of coordinates [x,y,z].
2649 # @param theFaceOrPoint defines a face of \a the2DObject whose normal will be
2650 # compared with theDirection. It can be either ID of face or a point
2651 # by which the face will be found. The point can be given as either
2652 # a GEOM vertex or a list of point coordinates.
2653 # @return number of reoriented faces
2654 # @ingroup l2_modif_changori
2655 def Reorient2D(self, the2DObject, theDirection, theFaceOrPoint ):
2657 if isinstance( the2DObject, Mesh ):
2658 the2DObject = the2DObject.GetMesh()
2659 if isinstance( the2DObject, list ):
2660 the2DObject = self.GetIDSource( the2DObject, SMESH.FACE )
2661 # check theDirection
2662 if isinstance( theDirection, geompyDC.GEOM._objref_GEOM_Object):
2663 theDirection = self.smeshpyD.GetDirStruct( theDirection )
2664 if isinstance( theDirection, list ):
2665 theDirection = self.smeshpyD.MakeDirStruct( *theDirection )
2666 # prepare theFace and thePoint
2667 theFace = theFaceOrPoint
2668 thePoint = PointStruct(0,0,0)
2669 if isinstance( theFaceOrPoint, geompyDC.GEOM._objref_GEOM_Object):
2670 thePoint = self.smeshpyD.GetPointStruct( theFaceOrPoint )
2672 if isinstance( theFaceOrPoint, list ):
2673 thePoint = PointStruct( *theFaceOrPoint )
2675 if isinstance( theFaceOrPoint, PointStruct ):
2676 thePoint = theFaceOrPoint
2678 return self.editor.Reorient2D( the2DObject, theDirection, theFace, thePoint )
2680 ## Fuses the neighbouring triangles into quadrangles.
2681 # @param IDsOfElements The triangles to be fused,
2682 # @param theCriterion is a numerical functor, in terms of enum SMESH.FunctorType, used to
2683 # choose a neighbour to fuse with.
2684 # @param MaxAngle is the maximum angle between element normals at which the fusion
2685 # is still performed; theMaxAngle is mesured in radians.
2686 # Also it could be a name of variable which defines angle in degrees.
2687 # @return TRUE in case of success, FALSE otherwise.
2688 # @ingroup l2_modif_unitetri
2689 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2690 MaxAngle,Parameters,hasVars = ParseAngles(MaxAngle)
2691 self.mesh.SetParameters(Parameters)
2692 if not IDsOfElements:
2693 IDsOfElements = self.GetElementsId()
2694 Functor = self.smeshpyD.GetFunctor(theCriterion)
2695 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2697 ## Fuses the neighbouring triangles of the object into quadrangles
2698 # @param theObject is mesh, submesh or group
2699 # @param theCriterion is a numerical functor, in terms of enum SMESH.FunctorType, used to
2700 # choose a neighbour to fuse with.
2701 # @param MaxAngle a max angle between element normals at which the fusion
2702 # is still performed; theMaxAngle is mesured in radians.
2703 # @return TRUE in case of success, FALSE otherwise.
2704 # @ingroup l2_modif_unitetri
2705 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2706 MaxAngle,Parameters,hasVars = ParseAngles(MaxAngle)
2707 self.mesh.SetParameters(Parameters)
2708 if isinstance( theObject, Mesh ):
2709 theObject = theObject.GetMesh()
2710 Functor = self.smeshpyD.GetFunctor(theCriterion)
2711 return self.editor.TriToQuadObject(theObject, Functor, MaxAngle)
2713 ## Splits quadrangles into triangles.
2715 # @param IDsOfElements the faces to be splitted.
2716 # @param theCriterion is a numerical functor, in terms of enum SMESH.FunctorType, used to
2717 # choose a diagonal for splitting. If @a theCriterion is None, which is a default
2718 # value, then quadrangles will be split by the smallest diagonal.
2719 # @return TRUE in case of success, FALSE otherwise.
2720 # @ingroup l2_modif_cutquadr
2721 def QuadToTri (self, IDsOfElements, theCriterion = None):
2722 if IDsOfElements == []:
2723 IDsOfElements = self.GetElementsId()
2724 if theCriterion is None:
2725 theCriterion = FT_MaxElementLength2D
2726 Functor = self.smeshpyD.GetFunctor(theCriterion)
2727 return self.editor.QuadToTri(IDsOfElements, Functor)
2729 ## Splits quadrangles into triangles.
2730 # @param theObject the object from which the list of elements is taken,
2731 # this is mesh, submesh or group
2732 # @param theCriterion is a numerical functor, in terms of enum SMESH.FunctorType, used to
2733 # choose a diagonal for splitting. If @a theCriterion is None, which is a default
2734 # value, then quadrangles will be split by the smallest diagonal.
2735 # @return TRUE in case of success, FALSE otherwise.
2736 # @ingroup l2_modif_cutquadr
2737 def QuadToTriObject (self, theObject, theCriterion = None):
2738 if ( isinstance( theObject, Mesh )):
2739 theObject = theObject.GetMesh()
2740 if theCriterion is None:
2741 theCriterion = FT_MaxElementLength2D
2742 Functor = self.smeshpyD.GetFunctor(theCriterion)
2743 return self.editor.QuadToTriObject(theObject, Functor)
2745 ## Splits quadrangles into triangles.
2746 # @param IDsOfElements the faces to be splitted
2747 # @param Diag13 is used to choose a diagonal for splitting.
2748 # @return TRUE in case of success, FALSE otherwise.
2749 # @ingroup l2_modif_cutquadr
2750 def SplitQuad (self, IDsOfElements, Diag13):
2751 if IDsOfElements == []:
2752 IDsOfElements = self.GetElementsId()
2753 return self.editor.SplitQuad(IDsOfElements, Diag13)
2755 ## Splits quadrangles into triangles.
2756 # @param theObject the object from which the list of elements is taken,
2757 # this is mesh, submesh or group
2758 # @param Diag13 is used to choose a diagonal for splitting.
2759 # @return TRUE in case of success, FALSE otherwise.
2760 # @ingroup l2_modif_cutquadr
2761 def SplitQuadObject (self, theObject, Diag13):
2762 if ( isinstance( theObject, Mesh )):
2763 theObject = theObject.GetMesh()
2764 return self.editor.SplitQuadObject(theObject, Diag13)
2766 ## Finds a better splitting of the given quadrangle.
2767 # @param IDOfQuad the ID of the quadrangle to be splitted.
2768 # @param theCriterion is a numerical functor, in terms of enum SMESH.FunctorType, used to
2769 # choose a diagonal for splitting.
2770 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2771 # diagonal is better, 0 if error occurs.
2772 # @ingroup l2_modif_cutquadr
2773 def BestSplit (self, IDOfQuad, theCriterion):
2774 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2776 ## Splits volumic elements into tetrahedrons
2777 # @param elemIDs either list of elements or mesh or group or submesh
2778 # @param method flags passing splitting method: Hex_5Tet, Hex_6Tet, Hex_24Tet
2779 # Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc
2780 # @ingroup l2_modif_cutquadr
2781 def SplitVolumesIntoTetra(self, elemIDs, method=Hex_5Tet ):
2782 if isinstance( elemIDs, Mesh ):
2783 elemIDs = elemIDs.GetMesh()
2784 if ( isinstance( elemIDs, list )):
2785 elemIDs = self.editor.MakeIDSource(elemIDs, SMESH.VOLUME)
2786 self.editor.SplitVolumesIntoTetra(elemIDs, method)
2788 ## Splits quadrangle faces near triangular facets of volumes
2790 # @ingroup l1_auxiliary
2791 def SplitQuadsNearTriangularFacets(self):
2792 faces_array = self.GetElementsByType(SMESH.FACE)
2793 for face_id in faces_array:
2794 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2795 quad_nodes = self.mesh.GetElemNodes(face_id)
2796 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2797 isVolumeFound = False
2798 for node1_elem in node1_elems:
2799 if not isVolumeFound:
2800 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2801 nb_nodes = self.GetElemNbNodes(node1_elem)
2802 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2803 volume_elem = node1_elem
2804 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2805 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2806 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2807 isVolumeFound = True
2808 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2809 self.SplitQuad([face_id], False) # diagonal 2-4
2810 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2811 isVolumeFound = True
2812 self.SplitQuad([face_id], True) # diagonal 1-3
2813 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2814 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2815 isVolumeFound = True
2816 self.SplitQuad([face_id], True) # diagonal 1-3
2818 ## @brief Splits hexahedrons into tetrahedrons.
2820 # This operation uses pattern mapping functionality for splitting.
2821 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2822 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2823 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2824 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2825 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2826 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2827 # @return TRUE in case of success, FALSE otherwise.
2828 # @ingroup l1_auxiliary
2829 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2830 # Pattern: 5.---------.6
2835 # (0,0,1) 4.---------.7 * |
2842 # (0,0,0) 0.---------.3
2843 pattern_tetra = "!!! Nb of points: \n 8 \n\
2853 !!! Indices of points of 6 tetras: \n\
2861 pattern = self.smeshpyD.GetPattern()
2862 isDone = pattern.LoadFromFile(pattern_tetra)
2864 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2867 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2868 isDone = pattern.MakeMesh(self.mesh, False, False)
2869 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2871 # split quafrangle faces near triangular facets of volumes
2872 self.SplitQuadsNearTriangularFacets()
2876 ## @brief Split hexahedrons into prisms.
2878 # Uses the pattern mapping functionality for splitting.
2879 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2880 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2881 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2882 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2883 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2884 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2885 # @return TRUE in case of success, FALSE otherwise.
2886 # @ingroup l1_auxiliary
2887 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2888 # Pattern: 5.---------.6
2893 # (0,0,1) 4.---------.7 |
2900 # (0,0,0) 0.---------.3
2901 pattern_prism = "!!! Nb of points: \n 8 \n\
2911 !!! Indices of points of 2 prisms: \n\
2915 pattern = self.smeshpyD.GetPattern()
2916 isDone = pattern.LoadFromFile(pattern_prism)
2918 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2921 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2922 isDone = pattern.MakeMesh(self.mesh, False, False)
2923 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2925 # Splits quafrangle faces near triangular facets of volumes
2926 self.SplitQuadsNearTriangularFacets()
2930 ## Smoothes elements
2931 # @param IDsOfElements the list if ids of elements to smooth
2932 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2933 # Note that nodes built on edges and boundary nodes are always fixed.
2934 # @param MaxNbOfIterations the maximum number of iterations
2935 # @param MaxAspectRatio varies in range [1.0, inf]
2936 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2937 # @return TRUE in case of success, FALSE otherwise.
2938 # @ingroup l2_modif_smooth
2939 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2940 MaxNbOfIterations, MaxAspectRatio, Method):
2941 if IDsOfElements == []:
2942 IDsOfElements = self.GetElementsId()
2943 MaxNbOfIterations,MaxAspectRatio,Parameters,hasVars = ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2944 self.mesh.SetParameters(Parameters)
2945 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2946 MaxNbOfIterations, MaxAspectRatio, Method)
2948 ## Smoothes elements which belong to the given object
2949 # @param theObject the object to smooth
2950 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2951 # Note that nodes built on edges and boundary nodes are always fixed.
2952 # @param MaxNbOfIterations the maximum number of iterations
2953 # @param MaxAspectRatio varies in range [1.0, inf]
2954 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2955 # @return TRUE in case of success, FALSE otherwise.
2956 # @ingroup l2_modif_smooth
2957 def SmoothObject(self, theObject, IDsOfFixedNodes,
2958 MaxNbOfIterations, MaxAspectRatio, Method):
2959 if ( isinstance( theObject, Mesh )):
2960 theObject = theObject.GetMesh()
2961 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2962 MaxNbOfIterations, MaxAspectRatio, Method)
2964 ## Parametrically smoothes the given elements
2965 # @param IDsOfElements the list if ids of elements to smooth
2966 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2967 # Note that nodes built on edges and boundary nodes are always fixed.
2968 # @param MaxNbOfIterations the maximum number of iterations
2969 # @param MaxAspectRatio varies in range [1.0, inf]
2970 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2971 # @return TRUE in case of success, FALSE otherwise.
2972 # @ingroup l2_modif_smooth
2973 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2974 MaxNbOfIterations, MaxAspectRatio, Method):
2975 if IDsOfElements == []:
2976 IDsOfElements = self.GetElementsId()
2977 MaxNbOfIterations,MaxAspectRatio,Parameters,hasVars = ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2978 self.mesh.SetParameters(Parameters)
2979 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2980 MaxNbOfIterations, MaxAspectRatio, Method)
2982 ## Parametrically smoothes the elements which belong to the given object
2983 # @param theObject the object to smooth
2984 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2985 # Note that nodes built on edges and boundary nodes are always fixed.
2986 # @param MaxNbOfIterations the maximum number of iterations
2987 # @param MaxAspectRatio varies in range [1.0, inf]
2988 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2989 # @return TRUE in case of success, FALSE otherwise.
2990 # @ingroup l2_modif_smooth
2991 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2992 MaxNbOfIterations, MaxAspectRatio, Method):
2993 if ( isinstance( theObject, Mesh )):
2994 theObject = theObject.GetMesh()
2995 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2996 MaxNbOfIterations, MaxAspectRatio, Method)
2998 ## Converts the mesh to quadratic, deletes old elements, replacing
2999 # them with quadratic with the same id.
3000 # @param theForce3d new node creation method:
3001 # 0 - the medium node lies at the geometrical entity from which the mesh element is built
3002 # 1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element
3003 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
3004 # @ingroup l2_modif_tofromqu
3005 def ConvertToQuadratic(self, theForce3d, theSubMesh=None):
3007 self.editor.ConvertToQuadraticObject(theForce3d,theSubMesh)
3009 self.editor.ConvertToQuadratic(theForce3d)
3011 ## Converts the mesh from quadratic to ordinary,
3012 # deletes old quadratic elements, \n replacing
3013 # them with ordinary mesh elements with the same id.
3014 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
3015 # @ingroup l2_modif_tofromqu
3016 def ConvertFromQuadratic(self, theSubMesh=None):
3018 self.editor.ConvertFromQuadraticObject(theSubMesh)
3020 return self.editor.ConvertFromQuadratic()
3022 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
3023 # @return TRUE if operation has been completed successfully, FALSE otherwise
3024 # @ingroup l2_modif_edit
3025 def Make2DMeshFrom3D(self):
3026 return self.editor. Make2DMeshFrom3D()
3028 ## Creates missing boundary elements
3029 # @param elements - elements whose boundary is to be checked:
3030 # mesh, group, sub-mesh or list of elements
3031 # if elements is mesh, it must be the mesh whose MakeBoundaryMesh() is called
3032 # @param dimension - defines type of boundary elements to create:
3033 # SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D
3034 # SMESH.BND_1DFROM3D creates mesh edges on all borders of free facets of 3D cells
3035 # @param groupName - a name of group to store created boundary elements in,
3036 # "" means not to create the group
3037 # @param meshName - a name of new mesh to store created boundary elements in,
3038 # "" means not to create the new mesh
3039 # @param toCopyElements - if true, the checked elements will be copied into
3040 # the new mesh else only boundary elements will be copied into the new mesh
3041 # @param toCopyExistingBondary - if true, not only new but also pre-existing
3042 # boundary elements will be copied into the new mesh
3043 # @return tuple (mesh, group) where bondary elements were added to
3044 # @ingroup l2_modif_edit
3045 def MakeBoundaryMesh(self, elements, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3046 toCopyElements=False, toCopyExistingBondary=False):
3047 if isinstance( elements, Mesh ):
3048 elements = elements.GetMesh()
3049 if ( isinstance( elements, list )):
3050 elemType = SMESH.ALL
3051 if elements: elemType = self.GetElementType( elements[0], iselem=True)
3052 elements = self.editor.MakeIDSource(elements, elemType)
3053 mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName,
3054 toCopyElements,toCopyExistingBondary)
3055 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3059 # @brief Creates missing boundary elements around either the whole mesh or
3060 # groups of 2D elements
3061 # @param dimension - defines type of boundary elements to create
3062 # @param groupName - a name of group to store all boundary elements in,
3063 # "" means not to create the group
3064 # @param meshName - a name of a new mesh, which is a copy of the initial
3065 # mesh + created boundary elements; "" means not to create the new mesh
3066 # @param toCopyAll - if true, the whole initial mesh will be copied into
3067 # the new mesh else only boundary elements will be copied into the new mesh
3068 # @param groups - groups of 2D elements to make boundary around
3069 # @retval tuple( long, mesh, groups )
3070 # long - number of added boundary elements
3071 # mesh - the mesh where elements were added to
3072 # group - the group of boundary elements or None
3074 def MakeBoundaryElements(self, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3075 toCopyAll=False, groups=[]):
3076 nb, mesh, group = self.editor.MakeBoundaryElements(dimension,groupName,meshName,
3078 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3079 return nb, mesh, group
3081 ## Renumber mesh nodes
3082 # @ingroup l2_modif_renumber
3083 def RenumberNodes(self):
3084 self.editor.RenumberNodes()
3086 ## Renumber mesh elements
3087 # @ingroup l2_modif_renumber
3088 def RenumberElements(self):
3089 self.editor.RenumberElements()
3091 ## Generates new elements by rotation of the elements around the axis
3092 # @param IDsOfElements the list of ids of elements to sweep
3093 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3094 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
3095 # @param NbOfSteps the number of steps
3096 # @param Tolerance tolerance
3097 # @param MakeGroups forces the generation of new groups from existing ones
3098 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3099 # of all steps, else - size of each step
3100 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3101 # @ingroup l2_modif_extrurev
3102 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
3103 MakeGroups=False, TotalAngle=False):
3104 if IDsOfElements == []:
3105 IDsOfElements = self.GetElementsId()
3106 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3107 Axis = self.smeshpyD.GetAxisStruct(Axis)
3108 AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians)
3109 NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance)
3110 Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters
3111 self.mesh.SetParameters(Parameters)
3112 if TotalAngle and NbOfSteps:
3113 AngleInRadians /= NbOfSteps
3115 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
3116 AngleInRadians, NbOfSteps, Tolerance)
3117 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
3120 ## Generates new elements by rotation of the elements of object around the axis
3121 # @param theObject object which elements should be sweeped.
3122 # It can be a mesh, a sub mesh or a group.
3123 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3124 # @param AngleInRadians the angle of Rotation
3125 # @param NbOfSteps number of steps
3126 # @param Tolerance tolerance
3127 # @param MakeGroups forces the generation of new groups from existing ones
3128 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3129 # of all steps, else - size of each step
3130 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3131 # @ingroup l2_modif_extrurev
3132 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3133 MakeGroups=False, TotalAngle=False):
3134 if ( isinstance( theObject, Mesh )):
3135 theObject = theObject.GetMesh()
3136 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3137 Axis = self.smeshpyD.GetAxisStruct(Axis)
3138 AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians)
3139 NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance)
3140 Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters
3141 self.mesh.SetParameters(Parameters)
3142 if TotalAngle and NbOfSteps:
3143 AngleInRadians /= NbOfSteps
3145 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
3146 NbOfSteps, Tolerance)
3147 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3150 ## Generates new elements by rotation of the elements of object around the axis
3151 # @param theObject object which elements should be sweeped.
3152 # It can be a mesh, a sub mesh or a group.
3153 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3154 # @param AngleInRadians the angle of Rotation
3155 # @param NbOfSteps number of steps
3156 # @param Tolerance tolerance
3157 # @param MakeGroups forces the generation of new groups from existing ones
3158 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3159 # of all steps, else - size of each step
3160 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3161 # @ingroup l2_modif_extrurev
3162 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3163 MakeGroups=False, TotalAngle=False):
3164 if ( isinstance( theObject, Mesh )):
3165 theObject = theObject.GetMesh()
3166 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3167 Axis = self.smeshpyD.GetAxisStruct(Axis)
3168 AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians)
3169 NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance)
3170 Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters
3171 self.mesh.SetParameters(Parameters)
3172 if TotalAngle and NbOfSteps:
3173 AngleInRadians /= NbOfSteps
3175 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
3176 NbOfSteps, Tolerance)
3177 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3180 ## Generates new elements by rotation of the elements of object around the axis
3181 # @param theObject object which elements should be sweeped.
3182 # It can be a mesh, a sub mesh or a group.
3183 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3184 # @param AngleInRadians the angle of Rotation
3185 # @param NbOfSteps number of steps
3186 # @param Tolerance tolerance
3187 # @param MakeGroups forces the generation of new groups from existing ones
3188 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3189 # of all steps, else - size of each step
3190 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3191 # @ingroup l2_modif_extrurev
3192 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3193 MakeGroups=False, TotalAngle=False):
3194 if ( isinstance( theObject, Mesh )):
3195 theObject = theObject.GetMesh()
3196 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3197 Axis = self.smeshpyD.GetAxisStruct(Axis)
3198 AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians)
3199 NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance)
3200 Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters
3201 self.mesh.SetParameters(Parameters)
3202 if TotalAngle and NbOfSteps:
3203 AngleInRadians /= NbOfSteps
3205 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
3206 NbOfSteps, Tolerance)
3207 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3210 ## Generates new elements by extrusion of the elements with given ids
3211 # @param IDsOfElements the list of elements ids for extrusion
3212 # @param StepVector vector or DirStruct or 3 vector components, defining
3213 # the direction and value of extrusion for one step (the total extrusion
3214 # length will be NbOfSteps * ||StepVector||)
3215 # @param NbOfSteps the number of steps
3216 # @param MakeGroups forces the generation of new groups from existing ones
3217 # @param IsNodes is True if elements with given ids are nodes
3218 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3219 # @ingroup l2_modif_extrurev
3220 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False, IsNodes = False):
3221 if IDsOfElements == []:
3222 IDsOfElements = self.GetElementsId()
3223 if isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object):
3224 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3225 if isinstance( StepVector, list ):
3226 StepVector = self.smeshpyD.MakeDirStruct(*StepVector)
3227 NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
3228 Parameters = StepVector.PS.parameters + var_separator + Parameters
3229 self.mesh.SetParameters(Parameters)
3232 return self.editor.ExtrusionSweepMakeGroups0D(IDsOfElements, StepVector, NbOfSteps)
3234 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
3236 self.editor.ExtrusionSweep0D(IDsOfElements, StepVector, NbOfSteps)
3238 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
3241 ## Generates new elements by extrusion of the elements with given ids
3242 # @param IDsOfElements is ids of elements
3243 # @param StepVector vector or DirStruct or 3 vector components, defining
3244 # the direction and value of extrusion for one step (the total extrusion
3245 # length will be NbOfSteps * ||StepVector||)
3246 # @param NbOfSteps the number of steps
3247 # @param ExtrFlags sets flags for extrusion
3248 # @param SewTolerance uses for comparing locations of nodes if flag
3249 # EXTRUSION_FLAG_SEW is set
3250 # @param MakeGroups forces the generation of new groups from existing ones
3251 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3252 # @ingroup l2_modif_extrurev
3253 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
3254 ExtrFlags, SewTolerance, MakeGroups=False):
3255 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3256 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3257 if isinstance( StepVector, list ):
3258 StepVector = self.smeshpyD.MakeDirStruct(*StepVector)
3260 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
3261 ExtrFlags, SewTolerance)
3262 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
3263 ExtrFlags, SewTolerance)
3266 ## Generates new elements by extrusion of the elements which belong to the object
3267 # @param theObject the object which elements should be processed.
3268 # It can be a mesh, a sub mesh or a group.
3269 # @param StepVector vector or DirStruct or 3 vector components, defining
3270 # the direction and value of extrusion for one step (the total extrusion
3271 # length will be NbOfSteps * ||StepVector||)
3272 # @param NbOfSteps the number of steps
3273 # @param MakeGroups forces the generation of new groups from existing ones
3274 # @param IsNodes is True if elements which belong to the object are nodes
3275 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3276 # @ingroup l2_modif_extrurev
3277 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False, IsNodes=False):
3278 if ( isinstance( theObject, Mesh )):
3279 theObject = theObject.GetMesh()
3280 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3281 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3282 if isinstance( StepVector, list ):
3283 StepVector = self.smeshpyD.MakeDirStruct(*StepVector)
3284 NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
3285 Parameters = StepVector.PS.parameters + var_separator + Parameters
3286 self.mesh.SetParameters(Parameters)
3289 return self.editor.ExtrusionSweepObject0DMakeGroups(theObject, StepVector, NbOfSteps)
3291 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3293 self.editor.ExtrusionSweepObject0D(theObject, StepVector, NbOfSteps)
3295 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
3298 ## Generates new elements by extrusion of the elements which belong to the object
3299 # @param theObject object which elements should be processed.
3300 # It can be a mesh, a sub mesh or a group.
3301 # @param StepVector vector or DirStruct or 3 vector components, defining
3302 # the direction and value of extrusion for one step (the total extrusion
3303 # length will be NbOfSteps * ||StepVector||)
3304 # @param NbOfSteps the number of steps
3305 # @param MakeGroups to generate new groups from existing ones
3306 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3307 # @ingroup l2_modif_extrurev
3308 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3309 if ( isinstance( theObject, Mesh )):
3310 theObject = theObject.GetMesh()
3311 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3312 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3313 if isinstance( StepVector, list ):
3314 StepVector = self.smeshpyD.MakeDirStruct(*StepVector)
3315 NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
3316 Parameters = StepVector.PS.parameters + var_separator + Parameters
3317 self.mesh.SetParameters(Parameters)
3319 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3320 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3323 ## Generates new elements by extrusion of the elements which belong to the object
3324 # @param theObject object which elements should be processed.
3325 # It can be a mesh, a sub mesh or a group.
3326 # @param StepVector vector or DirStruct or 3 vector components, defining
3327 # the direction and value of extrusion for one step (the total extrusion
3328 # length will be NbOfSteps * ||StepVector||)
3329 # @param NbOfSteps the number of steps
3330 # @param MakeGroups forces the generation of new groups from existing ones
3331 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3332 # @ingroup l2_modif_extrurev
3333 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3334 if ( isinstance( theObject, Mesh )):
3335 theObject = theObject.GetMesh()
3336 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3337 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3338 if isinstance( StepVector, list ):
3339 StepVector = self.smeshpyD.MakeDirStruct(*StepVector)
3340 NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
3341 Parameters = StepVector.PS.parameters + var_separator + Parameters
3342 self.mesh.SetParameters(Parameters)
3344 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3345 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3350 ## Generates new elements by extrusion of the given elements
3351 # The path of extrusion must be a meshed edge.
3352 # @param Base mesh or group, or submesh, or list of ids of elements for extrusion
3353 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3354 # @param NodeStart the start node from Path. Defines the direction of extrusion
3355 # @param HasAngles allows the shape to be rotated around the path
3356 # to get the resulting mesh in a helical fashion
3357 # @param Angles list of angles in radians
3358 # @param LinearVariation forces the computation of rotation angles as linear
3359 # variation of the given Angles along path steps
3360 # @param HasRefPoint allows using the reference point
3361 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3362 # The User can specify any point as the Reference Point.
3363 # @param MakeGroups forces the generation of new groups from existing ones
3364 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3365 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3366 # only SMESH::Extrusion_Error otherwise
3367 # @ingroup l2_modif_extrurev
3368 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3369 HasAngles, Angles, LinearVariation,
3370 HasRefPoint, RefPoint, MakeGroups, ElemType):
3371 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3372 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3374 Angles,AnglesParameters,hasVars = ParseAngles(Angles)
3375 Parameters = AnglesParameters + var_separator + RefPoint.parameters
3376 self.mesh.SetParameters(Parameters)
3378 if (isinstance(Path, Mesh)): Path = Path.GetMesh()
3380 if isinstance(Base, list):
3382 if Base == []: IDsOfElements = self.GetElementsId()
3383 else: IDsOfElements = Base
3384 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3385 HasAngles, Angles, LinearVariation,
3386 HasRefPoint, RefPoint, MakeGroups, ElemType)
3388 if isinstance(Base, Mesh): Base = Base.GetMesh()
3389 if isinstance(Base, SMESH._objref_SMESH_Mesh) or isinstance(Base, SMESH._objref_SMESH_Group) or isinstance(Base, SMESH._objref_SMESH_subMesh):
3390 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3391 HasAngles, Angles, LinearVariation,
3392 HasRefPoint, RefPoint, MakeGroups, ElemType)
3394 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3397 ## Generates new elements by extrusion of the given elements
3398 # The path of extrusion must be a meshed edge.
3399 # @param IDsOfElements ids of elements
3400 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3401 # @param PathShape shape(edge) defines the sub-mesh for the path
3402 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3403 # @param HasAngles allows the shape to be rotated around the path
3404 # to get the resulting mesh in a helical fashion
3405 # @param Angles list of angles in radians
3406 # @param HasRefPoint allows using the reference point
3407 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3408 # The User can specify any point as the Reference Point.
3409 # @param MakeGroups forces the generation of new groups from existing ones
3410 # @param LinearVariation forces the computation of rotation angles as linear
3411 # variation of the given Angles along path steps
3412 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3413 # only SMESH::Extrusion_Error otherwise
3414 # @ingroup l2_modif_extrurev
3415 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3416 HasAngles, Angles, HasRefPoint, RefPoint,
3417 MakeGroups=False, LinearVariation=False):
3418 if IDsOfElements == []:
3419 IDsOfElements = self.GetElementsId()
3420 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3421 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3423 if ( isinstance( PathMesh, Mesh )):
3424 PathMesh = PathMesh.GetMesh()
3425 Angles,AnglesParameters,hasVars = ParseAngles(Angles)
3426 Parameters = AnglesParameters + var_separator + RefPoint.parameters
3427 self.mesh.SetParameters(Parameters)
3428 if HasAngles and Angles and LinearVariation:
3429 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3432 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3433 PathShape, NodeStart, HasAngles,
3434 Angles, HasRefPoint, RefPoint)
3435 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3436 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3438 ## Generates new elements by extrusion of the elements which belong to the object
3439 # The path of extrusion must be a meshed edge.
3440 # @param theObject the object which elements should be processed.
3441 # It can be a mesh, a sub mesh or a group.
3442 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3443 # @param PathShape shape(edge) defines the sub-mesh for the path
3444 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3445 # @param HasAngles allows the shape to be rotated around the path
3446 # to get the resulting mesh in a helical fashion
3447 # @param Angles list of angles
3448 # @param HasRefPoint allows using the reference point
3449 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3450 # The User can specify any point as the Reference Point.
3451 # @param MakeGroups forces the generation of new groups from existing ones
3452 # @param LinearVariation forces the computation of rotation angles as linear
3453 # variation of the given Angles along path steps
3454 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3455 # only SMESH::Extrusion_Error otherwise
3456 # @ingroup l2_modif_extrurev
3457 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3458 HasAngles, Angles, HasRefPoint, RefPoint,
3459 MakeGroups=False, LinearVariation=False):
3460 if ( isinstance( theObject, Mesh )):
3461 theObject = theObject.GetMesh()
3462 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3463 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3464 if ( isinstance( PathMesh, Mesh )):
3465 PathMesh = PathMesh.GetMesh()
3466 Angles,AnglesParameters,hasVars = ParseAngles(Angles)
3467 Parameters = AnglesParameters + var_separator + RefPoint.parameters
3468 self.mesh.SetParameters(Parameters)
3469 if HasAngles and Angles and LinearVariation:
3470 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3473 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3474 PathShape, NodeStart, HasAngles,
3475 Angles, HasRefPoint, RefPoint)
3476 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3477 NodeStart, HasAngles, Angles, HasRefPoint,
3480 ## Generates new elements by extrusion of the elements which belong to the object
3481 # The path of extrusion must be a meshed edge.
3482 # @param theObject the object which elements should be processed.
3483 # It can be a mesh, a sub mesh or a group.
3484 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3485 # @param PathShape shape(edge) defines the sub-mesh for the path
3486 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3487 # @param HasAngles allows the shape to be rotated around the path
3488 # to get the resulting mesh in a helical fashion
3489 # @param Angles list of angles
3490 # @param HasRefPoint allows using the reference point
3491 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3492 # The User can specify any point as the Reference Point.
3493 # @param MakeGroups forces the generation of new groups from existing ones
3494 # @param LinearVariation forces the computation of rotation angles as linear
3495 # variation of the given Angles along path steps
3496 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3497 # only SMESH::Extrusion_Error otherwise
3498 # @ingroup l2_modif_extrurev
3499 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3500 HasAngles, Angles, HasRefPoint, RefPoint,
3501 MakeGroups=False, LinearVariation=False):
3502 if ( isinstance( theObject, Mesh )):
3503 theObject = theObject.GetMesh()
3504 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3505 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3506 if ( isinstance( PathMesh, Mesh )):
3507 PathMesh = PathMesh.GetMesh()
3508 Angles,AnglesParameters,hasVars = ParseAngles(Angles)
3509 Parameters = AnglesParameters + var_separator + RefPoint.parameters
3510 self.mesh.SetParameters(Parameters)
3511 if HasAngles and Angles and LinearVariation:
3512 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3515 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3516 PathShape, NodeStart, HasAngles,
3517 Angles, HasRefPoint, RefPoint)
3518 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3519 NodeStart, HasAngles, Angles, HasRefPoint,
3522 ## Generates new elements by extrusion of the elements which belong to the object
3523 # The path of extrusion must be a meshed edge.
3524 # @param theObject the object which elements should be processed.
3525 # It can be a mesh, a sub mesh or a group.
3526 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3527 # @param PathShape shape(edge) defines the sub-mesh for the path
3528 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3529 # @param HasAngles allows the shape to be rotated around the path
3530 # to get the resulting mesh in a helical fashion
3531 # @param Angles list of angles
3532 # @param HasRefPoint allows using the reference point
3533 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3534 # The User can specify any point as the Reference Point.
3535 # @param MakeGroups forces the generation of new groups from existing ones
3536 # @param LinearVariation forces the computation of rotation angles as linear
3537 # variation of the given Angles along path steps
3538 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3539 # only SMESH::Extrusion_Error otherwise
3540 # @ingroup l2_modif_extrurev
3541 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3542 HasAngles, Angles, HasRefPoint, RefPoint,
3543 MakeGroups=False, LinearVariation=False):
3544 if ( isinstance( theObject, Mesh )):
3545 theObject = theObject.GetMesh()
3546 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3547 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3548 if ( isinstance( PathMesh, Mesh )):
3549 PathMesh = PathMesh.GetMesh()
3550 Angles,AnglesParameters,hasVars = ParseAngles(Angles)
3551 Parameters = AnglesParameters + var_separator + RefPoint.parameters
3552 self.mesh.SetParameters(Parameters)
3553 if HasAngles and Angles and LinearVariation:
3554 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3557 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3558 PathShape, NodeStart, HasAngles,
3559 Angles, HasRefPoint, RefPoint)
3560 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3561 NodeStart, HasAngles, Angles, HasRefPoint,
3564 ## Creates a symmetrical copy of mesh elements
3565 # @param IDsOfElements list of elements ids
3566 # @param Mirror is AxisStruct or geom object(point, line, plane)
3567 # @param theMirrorType is POINT, AXIS or PLANE
3568 # If the Mirror is a geom object this parameter is unnecessary
3569 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3570 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3571 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3572 # @ingroup l2_modif_trsf
3573 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3574 if IDsOfElements == []:
3575 IDsOfElements = self.GetElementsId()
3576 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3577 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3578 self.mesh.SetParameters(Mirror.parameters)
3579 if Copy and MakeGroups:
3580 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3581 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3584 ## Creates a new mesh by a symmetrical copy of mesh elements
3585 # @param IDsOfElements the list of elements ids
3586 # @param Mirror is AxisStruct or geom object (point, line, plane)
3587 # @param theMirrorType is POINT, AXIS or PLANE
3588 # If the Mirror is a geom object this parameter is unnecessary
3589 # @param MakeGroups to generate new groups from existing ones
3590 # @param NewMeshName a name of the new mesh to create
3591 # @return instance of Mesh class
3592 # @ingroup l2_modif_trsf
3593 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3594 if IDsOfElements == []:
3595 IDsOfElements = self.GetElementsId()
3596 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3597 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3598 self.mesh.SetParameters(Mirror.parameters)
3599 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3600 MakeGroups, NewMeshName)
3601 return Mesh(self.smeshpyD,self.geompyD,mesh)
3603 ## Creates a symmetrical copy of the object
3604 # @param theObject mesh, submesh or group
3605 # @param Mirror AxisStruct or geom object (point, line, plane)
3606 # @param theMirrorType is POINT, AXIS or PLANE
3607 # If the Mirror is a geom object this parameter is unnecessary
3608 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3609 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3610 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3611 # @ingroup l2_modif_trsf
3612 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3613 if ( isinstance( theObject, Mesh )):
3614 theObject = theObject.GetMesh()
3615 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3616 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3617 self.mesh.SetParameters(Mirror.parameters)
3618 if Copy and MakeGroups:
3619 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3620 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3623 ## Creates a new mesh by a symmetrical copy of the object
3624 # @param theObject mesh, submesh or group
3625 # @param Mirror AxisStruct or geom object (point, line, plane)
3626 # @param theMirrorType POINT, AXIS or PLANE
3627 # If the Mirror is a geom object this parameter is unnecessary
3628 # @param MakeGroups forces the generation of new groups from existing ones
3629 # @param NewMeshName the name of the new mesh to create
3630 # @return instance of Mesh class
3631 # @ingroup l2_modif_trsf
3632 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3633 if ( isinstance( theObject, Mesh )):
3634 theObject = theObject.GetMesh()
3635 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3636 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3637 self.mesh.SetParameters(Mirror.parameters)
3638 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3639 MakeGroups, NewMeshName)
3640 return Mesh( self.smeshpyD,self.geompyD,mesh )
3642 ## Translates the elements
3643 # @param IDsOfElements list of elements ids
3644 # @param Vector the direction of translation (DirStruct or vector)
3645 # @param Copy allows copying the translated elements
3646 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3647 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3648 # @ingroup l2_modif_trsf
3649 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3650 if IDsOfElements == []:
3651 IDsOfElements = self.GetElementsId()
3652 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3653 Vector = self.smeshpyD.GetDirStruct(Vector)
3654 self.mesh.SetParameters(Vector.PS.parameters)
3655 if Copy and MakeGroups:
3656 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3657 self.editor.Translate(IDsOfElements, Vector, Copy)
3660 ## Creates a new mesh of translated elements
3661 # @param IDsOfElements list of elements ids
3662 # @param Vector the direction of translation (DirStruct or vector)
3663 # @param MakeGroups forces the generation of new groups from existing ones
3664 # @param NewMeshName the name of the newly created mesh
3665 # @return instance of Mesh class
3666 # @ingroup l2_modif_trsf
3667 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3668 if IDsOfElements == []:
3669 IDsOfElements = self.GetElementsId()
3670 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3671 Vector = self.smeshpyD.GetDirStruct(Vector)
3672 self.mesh.SetParameters(Vector.PS.parameters)
3673 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3674 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3676 ## Translates the object
3677 # @param theObject the object to translate (mesh, submesh, or group)
3678 # @param Vector direction of translation (DirStruct or geom vector)
3679 # @param Copy allows copying the translated elements
3680 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3681 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3682 # @ingroup l2_modif_trsf
3683 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3684 if ( isinstance( theObject, Mesh )):
3685 theObject = theObject.GetMesh()
3686 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3687 Vector = self.smeshpyD.GetDirStruct(Vector)
3688 self.mesh.SetParameters(Vector.PS.parameters)
3689 if Copy and MakeGroups:
3690 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3691 self.editor.TranslateObject(theObject, Vector, Copy)
3694 ## Creates a new mesh from the translated object
3695 # @param theObject the object to translate (mesh, submesh, or group)
3696 # @param Vector the direction of translation (DirStruct or geom vector)
3697 # @param MakeGroups forces the generation of new groups from existing ones
3698 # @param NewMeshName the name of the newly created mesh
3699 # @return instance of Mesh class
3700 # @ingroup l2_modif_trsf
3701 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3702 if (isinstance(theObject, Mesh)):
3703 theObject = theObject.GetMesh()
3704 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3705 Vector = self.smeshpyD.GetDirStruct(Vector)
3706 self.mesh.SetParameters(Vector.PS.parameters)
3707 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3708 return Mesh( self.smeshpyD, self.geompyD, mesh )
3712 ## Scales the object
3713 # @param theObject - the object to translate (mesh, submesh, or group)
3714 # @param thePoint - base point for scale
3715 # @param theScaleFact - list of 1-3 scale factors for axises
3716 # @param Copy - allows copying the translated elements
3717 # @param MakeGroups - forces the generation of new groups from existing
3719 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3720 # empty list otherwise
3721 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3722 if ( isinstance( theObject, Mesh )):
3723 theObject = theObject.GetMesh()
3724 if ( isinstance( theObject, list )):
3725 theObject = self.GetIDSource(theObject, SMESH.ALL)
3726 if ( isinstance( theScaleFact, float )):
3727 theScaleFact = [theScaleFact]
3728 if ( isinstance( theScaleFact, int )):
3729 theScaleFact = [ float(theScaleFact)]
3731 self.mesh.SetParameters(thePoint.parameters)
3733 if Copy and MakeGroups:
3734 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3735 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3738 ## Creates a new mesh from the translated object
3739 # @param theObject - the object to translate (mesh, submesh, or group)
3740 # @param thePoint - base point for scale
3741 # @param theScaleFact - list of 1-3 scale factors for axises
3742 # @param MakeGroups - forces the generation of new groups from existing ones
3743 # @param NewMeshName - the name of the newly created mesh
3744 # @return instance of Mesh class
3745 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3746 if (isinstance(theObject, Mesh)):
3747 theObject = theObject.GetMesh()
3748 if ( isinstance( theObject, list )):
3749 theObject = self.GetIDSource(theObject,SMESH.ALL)
3750 if ( isinstance( theScaleFact, float )):
3751 theScaleFact = [theScaleFact]
3752 if ( isinstance( theScaleFact, int )):
3753 theScaleFact = [ float(theScaleFact)]
3755 self.mesh.SetParameters(thePoint.parameters)
3756 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3757 MakeGroups, NewMeshName)
3758 return Mesh( self.smeshpyD, self.geompyD, mesh )
3762 ## Rotates the elements
3763 # @param IDsOfElements list of elements ids
3764 # @param Axis the axis of rotation (AxisStruct or geom line)
3765 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3766 # @param Copy allows copying the rotated elements
3767 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3768 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3769 # @ingroup l2_modif_trsf
3770 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3771 if IDsOfElements == []:
3772 IDsOfElements = self.GetElementsId()
3773 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3774 Axis = self.smeshpyD.GetAxisStruct(Axis)
3775 AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians)
3776 Parameters = Axis.parameters + var_separator + Parameters
3777 self.mesh.SetParameters(Parameters)
3778 if Copy and MakeGroups:
3779 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3780 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3783 ## Creates a new mesh of rotated elements
3784 # @param IDsOfElements list of element ids
3785 # @param Axis the axis of rotation (AxisStruct or geom line)
3786 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3787 # @param MakeGroups forces the generation of new groups from existing ones
3788 # @param NewMeshName the name of the newly created mesh
3789 # @return instance of Mesh class
3790 # @ingroup l2_modif_trsf
3791 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3792 if IDsOfElements == []:
3793 IDsOfElements = self.GetElementsId()
3794 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3795 Axis = self.smeshpyD.GetAxisStruct(Axis)
3796 AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians)
3797 Parameters = Axis.parameters + var_separator + Parameters
3798 self.mesh.SetParameters(Parameters)
3799 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3800 MakeGroups, NewMeshName)
3801 return Mesh( self.smeshpyD, self.geompyD, mesh )
3803 ## Rotates the object
3804 # @param theObject the object to rotate( mesh, submesh, or group)
3805 # @param Axis the axis of rotation (AxisStruct or geom line)
3806 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3807 # @param Copy allows copying the rotated elements
3808 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3809 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3810 # @ingroup l2_modif_trsf
3811 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3812 if (isinstance(theObject, Mesh)):
3813 theObject = theObject.GetMesh()
3814 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3815 Axis = self.smeshpyD.GetAxisStruct(Axis)
3816 AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians)
3817 Parameters = Axis.parameters + ":" + Parameters
3818 self.mesh.SetParameters(Parameters)
3819 if Copy and MakeGroups:
3820 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3821 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3824 ## Creates a new mesh from the rotated object
3825 # @param theObject the object to rotate (mesh, submesh, or group)
3826 # @param Axis the axis of rotation (AxisStruct or geom line)
3827 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3828 # @param MakeGroups forces the generation of new groups from existing ones
3829 # @param NewMeshName the name of the newly created mesh
3830 # @return instance of Mesh class
3831 # @ingroup l2_modif_trsf
3832 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3833 if (isinstance( theObject, Mesh )):
3834 theObject = theObject.GetMesh()
3835 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3836 Axis = self.smeshpyD.GetAxisStruct(Axis)
3837 AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians)
3838 Parameters = Axis.parameters + ":" + Parameters
3839 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3840 MakeGroups, NewMeshName)
3841 self.mesh.SetParameters(Parameters)
3842 return Mesh( self.smeshpyD, self.geompyD, mesh )
3844 ## Finds groups of ajacent nodes within Tolerance.
3845 # @param Tolerance the value of tolerance
3846 # @return the list of groups of nodes
3847 # @ingroup l2_modif_trsf
3848 def FindCoincidentNodes (self, Tolerance):
3849 return self.editor.FindCoincidentNodes(Tolerance)
3851 ## Finds groups of ajacent nodes within Tolerance.
3852 # @param Tolerance the value of tolerance
3853 # @param SubMeshOrGroup SubMesh or Group
3854 # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
3855 # @return the list of groups of nodes
3856 # @ingroup l2_modif_trsf
3857 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
3858 if (isinstance( SubMeshOrGroup, Mesh )):
3859 SubMeshOrGroup = SubMeshOrGroup.GetMesh()
3860 if not isinstance( exceptNodes, list):
3861 exceptNodes = [ exceptNodes ]
3862 if exceptNodes and isinstance( exceptNodes[0], int):
3863 exceptNodes = [ self.GetIDSource( exceptNodes, SMESH.NODE)]
3864 return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes)
3867 # @param GroupsOfNodes the list of groups of nodes
3868 # @ingroup l2_modif_trsf
3869 def MergeNodes (self, GroupsOfNodes):
3870 self.editor.MergeNodes(GroupsOfNodes)
3872 ## Finds the elements built on the same nodes.
3873 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3874 # @return a list of groups of equal elements
3875 # @ingroup l2_modif_trsf
3876 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3877 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3878 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3879 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3881 ## Merges elements in each given group.
3882 # @param GroupsOfElementsID groups of elements for merging
3883 # @ingroup l2_modif_trsf
3884 def MergeElements(self, GroupsOfElementsID):
3885 self.editor.MergeElements(GroupsOfElementsID)
3887 ## Leaves one element and removes all other elements built on the same nodes.
3888 # @ingroup l2_modif_trsf
3889 def MergeEqualElements(self):
3890 self.editor.MergeEqualElements()
3892 ## Sews free borders
3893 # @return SMESH::Sew_Error
3894 # @ingroup l2_modif_trsf
3895 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3896 FirstNodeID2, SecondNodeID2, LastNodeID2,
3897 CreatePolygons, CreatePolyedrs):
3898 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3899 FirstNodeID2, SecondNodeID2, LastNodeID2,
3900 CreatePolygons, CreatePolyedrs)
3902 ## Sews conform free borders
3903 # @return SMESH::Sew_Error
3904 # @ingroup l2_modif_trsf
3905 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3906 FirstNodeID2, SecondNodeID2):
3907 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3908 FirstNodeID2, SecondNodeID2)
3910 ## Sews border to side
3911 # @return SMESH::Sew_Error
3912 # @ingroup l2_modif_trsf
3913 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3914 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3915 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3916 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3918 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3919 # merged with the nodes of elements of Side2.
3920 # The number of elements in theSide1 and in theSide2 must be
3921 # equal and they should have similar nodal connectivity.
3922 # The nodes to merge should belong to side borders and
3923 # the first node should be linked to the second.
3924 # @return SMESH::Sew_Error
3925 # @ingroup l2_modif_trsf
3926 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3927 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3928 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3929 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3930 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3931 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3933 ## Sets new nodes for the given element.
3934 # @param ide the element id
3935 # @param newIDs nodes ids
3936 # @return If the number of nodes does not correspond to the type of element - returns false
3937 # @ingroup l2_modif_edit
3938 def ChangeElemNodes(self, ide, newIDs):
3939 return self.editor.ChangeElemNodes(ide, newIDs)
3941 ## If during the last operation of MeshEditor some nodes were
3942 # created, this method returns the list of their IDs, \n
3943 # if new nodes were not created - returns empty list
3944 # @return the list of integer values (can be empty)
3945 # @ingroup l1_auxiliary
3946 def GetLastCreatedNodes(self):
3947 return self.editor.GetLastCreatedNodes()
3949 ## If during the last operation of MeshEditor some elements were
3950 # created this method returns the list of their IDs, \n
3951 # if new elements were not created - returns empty list
3952 # @return the list of integer values (can be empty)
3953 # @ingroup l1_auxiliary
3954 def GetLastCreatedElems(self):
3955 return self.editor.GetLastCreatedElems()
3957 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3958 # @param theNodes identifiers of nodes to be doubled
3959 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
3960 # nodes. If list of element identifiers is empty then nodes are doubled but
3961 # they not assigned to elements
3962 # @return TRUE if operation has been completed successfully, FALSE otherwise
3963 # @ingroup l2_modif_edit
3964 def DoubleNodes(self, theNodes, theModifiedElems):
3965 return self.editor.DoubleNodes(theNodes, theModifiedElems)
3967 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3968 # This method provided for convenience works as DoubleNodes() described above.
3969 # @param theNodeId identifiers of node to be doubled
3970 # @param theModifiedElems identifiers of elements to be updated
3971 # @return TRUE if operation has been completed successfully, FALSE otherwise
3972 # @ingroup l2_modif_edit
3973 def DoubleNode(self, theNodeId, theModifiedElems):
3974 return self.editor.DoubleNode(theNodeId, theModifiedElems)
3976 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3977 # This method provided for convenience works as DoubleNodes() described above.
3978 # @param theNodes group of nodes to be doubled
3979 # @param theModifiedElems group of elements to be updated.
3980 # @param theMakeGroup forces the generation of a group containing new nodes.
3981 # @return TRUE or a created group if operation has been completed successfully,
3982 # FALSE or None otherwise
3983 # @ingroup l2_modif_edit
3984 def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
3986 return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
3987 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3989 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3990 # This method provided for convenience works as DoubleNodes() described above.
3991 # @param theNodes list of groups of nodes to be doubled
3992 # @param theModifiedElems list of groups of elements to be updated.
3993 # @param theMakeGroup forces the generation of a group containing new nodes.
3994 # @return TRUE if operation has been completed successfully, FALSE otherwise
3995 # @ingroup l2_modif_edit
3996 def DoubleNodeGroups(self, theNodes, theModifiedElems, theMakeGroup=False):
3998 return self.editor.DoubleNodeGroupsNew(theNodes, theModifiedElems)
3999 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
4001 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4002 # @param theElems - the list of elements (edges or faces) to be replicated
4003 # The nodes for duplication could be found from these elements
4004 # @param theNodesNot - list of nodes to NOT replicate
4005 # @param theAffectedElems - the list of elements (cells and edges) to which the
4006 # replicated nodes should be associated to.
4007 # @return TRUE if operation has been completed successfully, FALSE otherwise
4008 # @ingroup l2_modif_edit
4009 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
4010 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
4012 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4013 # @param theElems - the list of elements (edges or faces) to be replicated
4014 # The nodes for duplication could be found from these elements
4015 # @param theNodesNot - list of nodes to NOT replicate
4016 # @param theShape - shape to detect affected elements (element which geometric center
4017 # located on or inside shape).
4018 # The replicated nodes should be associated to affected elements.
4019 # @return TRUE if operation has been completed successfully, FALSE otherwise
4020 # @ingroup l2_modif_edit
4021 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
4022 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
4024 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4025 # This method provided for convenience works as DoubleNodes() described above.
4026 # @param theElems - group of of elements (edges or faces) to be replicated
4027 # @param theNodesNot - group of nodes not to replicated
4028 # @param theAffectedElems - group of elements to which the replicated nodes
4029 # should be associated to.
4030 # @param theMakeGroup forces the generation of a group containing new elements.
4031 # @param theMakeNodeGroup forces the generation of a group containing new nodes.
4032 # @return TRUE or created groups (one or two) if operation has been completed successfully,
4033 # FALSE or None otherwise
4034 # @ingroup l2_modif_edit
4035 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems,
4036 theMakeGroup=False, theMakeNodeGroup=False):
4037 if theMakeGroup or theMakeNodeGroup:
4038 twoGroups = self.editor.DoubleNodeElemGroup2New(theElems, theNodesNot,
4040 theMakeGroup, theMakeNodeGroup)
4041 if theMakeGroup and theMakeNodeGroup:
4044 return twoGroups[ int(theMakeNodeGroup) ]
4045 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
4047 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4048 # This method provided for convenience works as DoubleNodes() described above.
4049 # @param theElems - group of of elements (edges or faces) to be replicated
4050 # @param theNodesNot - group of nodes not to replicated
4051 # @param theShape - shape to detect affected elements (element which geometric center
4052 # located on or inside shape).
4053 # The replicated nodes should be associated to affected elements.
4054 # @ingroup l2_modif_edit
4055 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
4056 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
4058 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4059 # This method provided for convenience works as DoubleNodes() described above.
4060 # @param theElems - list of groups of elements (edges or faces) to be replicated
4061 # @param theNodesNot - list of groups of nodes not to replicated
4062 # @param theAffectedElems - group of elements to which the replicated nodes
4063 # should be associated to.
4064 # @param theMakeGroup forces the generation of a group containing new elements.
4065 # @param theMakeNodeGroup forces the generation of a group containing new nodes.
4066 # @return TRUE or created groups (one or two) if operation has been completed successfully,
4067 # FALSE or None otherwise
4068 # @ingroup l2_modif_edit
4069 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems,
4070 theMakeGroup=False, theMakeNodeGroup=False):
4071 if theMakeGroup or theMakeNodeGroup:
4072 twoGroups = self.editor.DoubleNodeElemGroups2New(theElems, theNodesNot,
4074 theMakeGroup, theMakeNodeGroup)
4075 if theMakeGroup and theMakeNodeGroup:
4078 return twoGroups[ int(theMakeNodeGroup) ]
4079 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
4081 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4082 # This method provided for convenience works as DoubleNodes() described above.
4083 # @param theElems - list of groups of elements (edges or faces) to be replicated
4084 # @param theNodesNot - list of groups of nodes not to replicated
4085 # @param theShape - shape to detect affected elements (element which geometric center
4086 # located on or inside shape).
4087 # The replicated nodes should be associated to affected elements.
4088 # @return TRUE if operation has been completed successfully, FALSE otherwise
4089 # @ingroup l2_modif_edit
4090 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
4091 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
4093 ## Identify the elements that will be affected by node duplication (actual duplication is not performed.
4094 # This method is the first step of DoubleNodeElemGroupsInRegion.
4095 # @param theElems - list of groups of elements (edges or faces) to be replicated
4096 # @param theNodesNot - list of groups of nodes not to replicated
4097 # @param theShape - shape to detect affected elements (element which geometric center
4098 # located on or inside shape).
4099 # The replicated nodes should be associated to affected elements.
4100 # @return groups of affected elements
4101 # @ingroup l2_modif_edit
4102 def AffectedElemGroupsInRegion(self, theElems, theNodesNot, theShape):
4103 return self.editor.AffectedElemGroupsInRegion(theElems, theNodesNot, theShape)
4105 ## Double nodes on shared faces between groups of volumes and create flat elements on demand.
4106 # The list of groups must describe a partition of the mesh volumes.
4107 # The nodes of the internal faces at the boundaries of the groups are doubled.
4108 # In option, the internal faces are replaced by flat elements.
4109 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4110 # @param theDomains - list of groups of volumes
4111 # @param createJointElems - if TRUE, create the elements
4112 # @return TRUE if operation has been completed successfully, FALSE otherwise
4113 def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems ):
4114 return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems )
4116 ## Double nodes on some external faces and create flat elements.
4117 # Flat elements are mainly used by some types of mechanic calculations.
4119 # Each group of the list must be constituted of faces.
4120 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4121 # @param theGroupsOfFaces - list of groups of faces
4122 # @return TRUE if operation has been completed successfully, FALSE otherwise
4123 def CreateFlatElementsOnFacesGroups(self, theGroupsOfFaces ):
4124 return self.editor.CreateFlatElementsOnFacesGroups( theGroupsOfFaces )
4126 ## identify all the elements around a geom shape, get the faces delimiting the hole
4128 def CreateHoleSkin(self, radius, theShape, groupName, theNodesCoords):
4129 return self.editor.CreateHoleSkin( radius, theShape, groupName, theNodesCoords )
4131 def _getFunctor(self, funcType ):
4132 fn = self.functors[ funcType._v ]
4134 fn = self.smeshpyD.GetFunctor(funcType)
4135 fn.SetMesh(self.mesh)
4136 self.functors[ funcType._v ] = fn
4139 def _valueFromFunctor(self, funcType, elemId):
4140 fn = self._getFunctor( funcType )
4141 if fn.GetElementType() == self.GetElementType(elemId, True):
4142 val = fn.GetValue(elemId)
4147 ## Get length of 1D element.
4148 # @param elemId mesh element ID
4149 # @return element's length value
4150 # @ingroup l1_measurements
4151 def GetLength(self, elemId):
4152 return self._valueFromFunctor(SMESH.FT_Length, elemId)
4154 ## Get area of 2D element.
4155 # @param elemId mesh element ID
4156 # @return element's area value
4157 # @ingroup l1_measurements
4158 def GetArea(self, elemId):
4159 return self._valueFromFunctor(SMESH.FT_Area, elemId)
4161 ## Get volume of 3D element.
4162 # @param elemId mesh element ID
4163 # @return element's volume value
4164 # @ingroup l1_measurements
4165 def GetVolume(self, elemId):
4166 return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
4168 ## Get maximum element length.
4169 # @param elemId mesh element ID
4170 # @return element's maximum length value
4171 # @ingroup l1_measurements
4172 def GetMaxElementLength(self, elemId):
4173 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4174 ftype = SMESH.FT_MaxElementLength3D
4176 ftype = SMESH.FT_MaxElementLength2D
4177 return self._valueFromFunctor(ftype, elemId)
4179 ## Get aspect ratio of 2D or 3D element.
4180 # @param elemId mesh element ID
4181 # @return element's aspect ratio value
4182 # @ingroup l1_measurements
4183 def GetAspectRatio(self, elemId):
4184 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4185 ftype = SMESH.FT_AspectRatio3D
4187 ftype = SMESH.FT_AspectRatio
4188 return self._valueFromFunctor(ftype, elemId)
4190 ## Get warping angle of 2D element.
4191 # @param elemId mesh element ID
4192 # @return element's warping angle value
4193 # @ingroup l1_measurements
4194 def GetWarping(self, elemId):
4195 return self._valueFromFunctor(SMESH.FT_Warping, elemId)
4197 ## Get minimum angle of 2D element.
4198 # @param elemId mesh element ID
4199 # @return element's minimum angle value
4200 # @ingroup l1_measurements
4201 def GetMinimumAngle(self, elemId):
4202 return self._valueFromFunctor(SMESH.FT_MinimumAngle, elemId)
4204 ## Get taper of 2D element.
4205 # @param elemId mesh element ID
4206 # @return element's taper value
4207 # @ingroup l1_measurements
4208 def GetTaper(self, elemId):
4209 return self._valueFromFunctor(SMESH.FT_Taper, elemId)
4211 ## Get skew of 2D element.
4212 # @param elemId mesh element ID
4213 # @return element's skew value
4214 # @ingroup l1_measurements
4215 def GetSkew(self, elemId):
4216 return self._valueFromFunctor(SMESH.FT_Skew, elemId)
4218 pass # end of Mesh class
4220 ## Helper class for wrapping of SMESH.SMESH_Pattern CORBA class
4222 class Pattern(SMESH._objref_SMESH_Pattern):
4224 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
4225 decrFun = lambda i: i-1
4226 theNodeIndexOnKeyPoint1,Parameters,hasVars = ParseParameters(theNodeIndexOnKeyPoint1, decrFun)
4227 theMesh.SetParameters(Parameters)
4228 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
4230 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
4231 decrFun = lambda i: i-1
4232 theNode000Index,theNode001Index,Parameters,hasVars = ParseParameters(theNode000Index,theNode001Index, decrFun)
4233 theMesh.SetParameters(Parameters)
4234 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
4236 # Registering the new proxy for Pattern
4237 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)
4239 ## Private class used to bind methods creating algorithms to the class Mesh
4244 self.defaultAlgoType = ""
4245 self.algoTypeToClass = {}
4247 # Stores a python class of algorithm
4248 def add(self, algoClass):
4249 if type( algoClass ).__name__ == 'classobj' and \
4250 hasattr( algoClass, "algoType"):
4251 self.algoTypeToClass[ algoClass.algoType ] = algoClass
4252 if not self.defaultAlgoType and \
4253 hasattr( algoClass, "isDefault") and algoClass.isDefault:
4254 self.defaultAlgoType = algoClass.algoType
4255 #print "Add",algoClass.algoType, "dflt",self.defaultAlgoType
4257 # creates a copy of self and assign mesh to the copy
4258 def copy(self, mesh):
4259 other = algoCreator()
4260 other.defaultAlgoType = self.defaultAlgoType
4261 other.algoTypeToClass = self.algoTypeToClass
4265 # creates an instance of algorithm
4266 def __call__(self,algo="",geom=0,*args):
4267 algoType = self.defaultAlgoType
4268 for arg in args + (algo,geom):
4269 if isinstance( arg, geompyDC.GEOM._objref_GEOM_Object ):
4271 if isinstance( arg, str ) and arg:
4273 if not algoType and self.algoTypeToClass:
4274 algoType = self.algoTypeToClass.keys()[0]
4275 if self.algoTypeToClass.has_key( algoType ):
4276 #print "Create algo",algoType
4277 return self.algoTypeToClass[ algoType ]( self.mesh, geom )
4278 raise RuntimeError, "No class found for algo type %s" % algoType
4281 # Private class used to substitute and store variable parameters of hypotheses.
4283 class hypMethodWrapper:
4284 def __init__(self, hyp, method):
4286 self.method = method
4287 #print "REBIND:", method.__name__
4290 # call a method of hypothesis with calling SetVarParameter() before
4291 def __call__(self,*args):
4293 return self.method( self.hyp, *args ) # hypothesis method with no args
4295 #print "MethWrapper.__call__",self.method.__name__, args
4297 parsed = ParseParameters(*args) # replace variables with their values
4298 self.hyp.SetVarParameter( parsed[-2], self.method.__name__ )
4299 result = self.method( self.hyp, *parsed[:-2] ) # call hypothesis method
4300 except omniORB.CORBA.BAD_PARAM: # raised by hypothesis method call
4301 # maybe there is a replaced string arg which is not variable
4302 result = self.method( self.hyp, *args )
4303 except ValueError, detail: # raised by ParseParameters()
4305 result = self.method( self.hyp, *args )
4306 except omniORB.CORBA.BAD_PARAM:
4307 raise ValueError, detail # wrong variable name