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()
1394 status = self.mesh.RemoveHypothesis(geom, hyp)
1397 ## Gets the list of hypotheses added on a geometry
1398 # @param geom a sub-shape of mesh geometry
1399 # @return the sequence of SMESH_Hypothesis
1400 # @ingroup l2_hypotheses
1401 def GetHypothesisList(self, geom):
1402 return self.mesh.GetHypothesisList( geom )
1404 ## Removes all global hypotheses
1405 # @ingroup l2_hypotheses
1406 def RemoveGlobalHypotheses(self):
1407 current_hyps = self.mesh.GetHypothesisList( self.geom )
1408 for hyp in current_hyps:
1409 self.mesh.RemoveHypothesis( self.geom, hyp )
1413 ## Exports the mesh in a file in MED format and chooses the \a version of MED format
1414 ## allowing to overwrite the file if it exists or add the exported data to its contents
1415 # @param f is the file name
1416 # @param auto_groups boolean parameter for creating/not creating
1417 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1418 # the typical use is auto_groups=false.
1419 # @param version MED format version(MED_V2_1 or MED_V2_2)
1420 # @param overwrite boolean parameter for overwriting/not overwriting the file
1421 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1422 # @ingroup l2_impexp
1423 def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1, meshPart=None):
1425 if isinstance( meshPart, list ):
1426 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1427 self.mesh.ExportPartToMED( meshPart, f, auto_groups, version, overwrite )
1429 self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
1431 ## Exports the mesh in a file in SAUV format
1432 # @param f is the file name
1433 # @param auto_groups boolean parameter for creating/not creating
1434 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1435 # the typical use is auto_groups=false.
1436 # @ingroup l2_impexp
1437 def ExportSAUV(self, f, auto_groups=0):
1438 self.mesh.ExportSAUV(f, auto_groups)
1440 ## Exports the mesh in a file in DAT format
1441 # @param f the file name
1442 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1443 # @ingroup l2_impexp
1444 def ExportDAT(self, f, meshPart=None):
1446 if isinstance( meshPart, list ):
1447 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1448 self.mesh.ExportPartToDAT( meshPart, f )
1450 self.mesh.ExportDAT(f)
1452 ## Exports the mesh in a file in UNV format
1453 # @param f the file name
1454 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1455 # @ingroup l2_impexp
1456 def ExportUNV(self, f, meshPart=None):
1458 if isinstance( meshPart, list ):
1459 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1460 self.mesh.ExportPartToUNV( meshPart, f )
1462 self.mesh.ExportUNV(f)
1464 ## Export the mesh in a file in STL format
1465 # @param f the file name
1466 # @param ascii defines the file encoding
1467 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1468 # @ingroup l2_impexp
1469 def ExportSTL(self, f, ascii=1, meshPart=None):
1471 if isinstance( meshPart, list ):
1472 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1473 self.mesh.ExportPartToSTL( meshPart, f, ascii )
1475 self.mesh.ExportSTL(f, ascii)
1477 ## Exports the mesh in a file in CGNS format
1478 # @param f is the file name
1479 # @param overwrite boolean parameter for overwriting/not overwriting the file
1480 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1481 # @ingroup l2_impexp
1482 def ExportCGNS(self, f, overwrite=1, meshPart=None):
1483 if isinstance( meshPart, list ):
1484 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1485 if isinstance( meshPart, Mesh ):
1486 meshPart = meshPart.mesh
1488 meshPart = self.mesh
1489 self.mesh.ExportCGNS(meshPart, f, overwrite)
1491 ## Exports the mesh in a file in GMF format
1492 # @param f is the file name
1493 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1494 # @ingroup l2_impexp
1495 def ExportGMF(self, f, meshPart=None):
1496 if isinstance( meshPart, list ):
1497 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1498 if isinstance( meshPart, Mesh ):
1499 meshPart = meshPart.mesh
1501 meshPart = self.mesh
1502 self.mesh.ExportGMF(meshPart, f, True)
1504 ## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead.
1505 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1506 ## allowing to overwrite the file if it exists or add the exported data to its contents
1507 # @param f the file name
1508 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1509 # @param opt boolean parameter for creating/not creating
1510 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1511 # @param overwrite boolean parameter for overwriting/not overwriting the file
1512 # @ingroup l2_impexp
1513 def ExportToMED(self, f, version, opt=0, overwrite=1):
1514 self.mesh.ExportToMEDX(f, opt, version, overwrite)
1516 # Operations with groups:
1517 # ----------------------
1519 ## Creates an empty mesh group
1520 # @param elementType the type of elements in the group
1521 # @param name the name of the mesh group
1522 # @return SMESH_Group
1523 # @ingroup l2_grps_create
1524 def CreateEmptyGroup(self, elementType, name):
1525 return self.mesh.CreateGroup(elementType, name)
1527 ## Creates a mesh group based on the geometric object \a grp
1528 # and gives a \a name, \n if this parameter is not defined
1529 # the name is the same as the geometric group name \n
1530 # Note: Works like GroupOnGeom().
1531 # @param grp a geometric group, a vertex, an edge, a face or a solid
1532 # @param name the name of the mesh group
1533 # @return SMESH_GroupOnGeom
1534 # @ingroup l2_grps_create
1535 def Group(self, grp, name=""):
1536 return self.GroupOnGeom(grp, name)
1538 ## Creates a mesh group based on the geometrical object \a grp
1539 # and gives a \a name, \n if this parameter is not defined
1540 # the name is the same as the geometrical group name
1541 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1542 # @param name the name of the mesh group
1543 # @param typ the type of elements in the group. If not set, it is
1544 # automatically detected by the type of the geometry
1545 # @return SMESH_GroupOnGeom
1546 # @ingroup l2_grps_create
1547 def GroupOnGeom(self, grp, name="", typ=None):
1548 AssureGeomPublished( self, grp, name )
1550 name = grp.GetName()
1552 typ = self._groupTypeFromShape( grp )
1553 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1555 ## Pivate method to get a type of group on geometry
1556 def _groupTypeFromShape( self, shape ):
1557 tgeo = str(shape.GetShapeType())
1558 if tgeo == "VERTEX":
1560 elif tgeo == "EDGE":
1562 elif tgeo == "FACE" or tgeo == "SHELL":
1564 elif tgeo == "SOLID" or tgeo == "COMPSOLID":
1566 elif tgeo == "COMPOUND":
1567 sub = self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHAPE"])
1569 raise ValueError,"_groupTypeFromShape(): empty geometric group or compound '%s'" % GetName(shape)
1570 return self._groupTypeFromShape( sub[0] )
1573 "_groupTypeFromShape(): invalid geometry '%s'" % GetName(shape)
1576 ## Creates a mesh group with given \a name based on the \a filter which
1577 ## is a special type of group dynamically updating it's contents during
1578 ## mesh modification
1579 # @param typ the type of elements in the group
1580 # @param name the name of the mesh group
1581 # @param filter the filter defining group contents
1582 # @return SMESH_GroupOnFilter
1583 # @ingroup l2_grps_create
1584 def GroupOnFilter(self, typ, name, filter):
1585 return self.mesh.CreateGroupFromFilter(typ, name, filter)
1587 ## Creates a mesh group by the given ids of elements
1588 # @param groupName the name of the mesh group
1589 # @param elementType the type of elements in the group
1590 # @param elemIDs the list of ids
1591 # @return SMESH_Group
1592 # @ingroup l2_grps_create
1593 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1594 group = self.mesh.CreateGroup(elementType, groupName)
1598 ## Creates a mesh group by the given conditions
1599 # @param groupName the name of the mesh group
1600 # @param elementType the type of elements in the group
1601 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1602 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1603 # @param Threshold the threshold value (range of id ids as string, shape, numeric)
1604 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1605 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
1606 # FT_LyingOnGeom, FT_CoplanarFaces criteria
1607 # @return SMESH_Group
1608 # @ingroup l2_grps_create
1612 CritType=FT_Undefined,
1615 UnaryOp=FT_Undefined,
1617 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Threshold, UnaryOp, FT_Undefined,Tolerance)
1618 group = self.MakeGroupByCriterion(groupName, aCriterion)
1621 ## Creates a mesh group by the given criterion
1622 # @param groupName the name of the mesh group
1623 # @param Criterion the instance of Criterion class
1624 # @return SMESH_Group
1625 # @ingroup l2_grps_create
1626 def MakeGroupByCriterion(self, groupName, Criterion):
1627 aFilterMgr = self.smeshpyD.CreateFilterManager()
1628 aFilter = aFilterMgr.CreateFilter()
1630 aCriteria.append(Criterion)
1631 aFilter.SetCriteria(aCriteria)
1632 group = self.MakeGroupByFilter(groupName, aFilter)
1633 aFilterMgr.UnRegister()
1636 ## Creates a mesh group by the given criteria (list of criteria)
1637 # @param groupName the name of the mesh group
1638 # @param theCriteria the list of criteria
1639 # @return SMESH_Group
1640 # @ingroup l2_grps_create
1641 def MakeGroupByCriteria(self, groupName, theCriteria):
1642 aFilterMgr = self.smeshpyD.CreateFilterManager()
1643 aFilter = aFilterMgr.CreateFilter()
1644 aFilter.SetCriteria(theCriteria)
1645 group = self.MakeGroupByFilter(groupName, aFilter)
1646 aFilterMgr.UnRegister()
1649 ## Creates a mesh group by the given filter
1650 # @param groupName the name of the mesh group
1651 # @param theFilter the instance of Filter class
1652 # @return SMESH_Group
1653 # @ingroup l2_grps_create
1654 def MakeGroupByFilter(self, groupName, theFilter):
1655 group = self.CreateEmptyGroup(theFilter.GetElementType(), groupName)
1656 theFilter.SetMesh( self.mesh )
1657 group.AddFrom( theFilter )
1661 # @ingroup l2_grps_delete
1662 def RemoveGroup(self, group):
1663 self.mesh.RemoveGroup(group)
1665 ## Removes a group with its contents
1666 # @ingroup l2_grps_delete
1667 def RemoveGroupWithContents(self, group):
1668 self.mesh.RemoveGroupWithContents(group)
1670 ## Gets the list of groups existing in the mesh
1671 # @return a sequence of SMESH_GroupBase
1672 # @ingroup l2_grps_create
1673 def GetGroups(self):
1674 return self.mesh.GetGroups()
1676 ## Gets the number of groups existing in the mesh
1677 # @return the quantity of groups as an integer value
1678 # @ingroup l2_grps_create
1680 return self.mesh.NbGroups()
1682 ## Gets the list of names of groups existing in the mesh
1683 # @return list of strings
1684 # @ingroup l2_grps_create
1685 def GetGroupNames(self):
1686 groups = self.GetGroups()
1688 for group in groups:
1689 names.append(group.GetName())
1692 ## Produces a union of two groups
1693 # A new group is created. All mesh elements that are
1694 # present in the initial groups are added to the new one
1695 # @return an instance of SMESH_Group
1696 # @ingroup l2_grps_operon
1697 def UnionGroups(self, group1, group2, name):
1698 return self.mesh.UnionGroups(group1, group2, name)
1700 ## Produces a union list of groups
1701 # New group is created. All mesh elements that are present in
1702 # initial groups are added to the new one
1703 # @return an instance of SMESH_Group
1704 # @ingroup l2_grps_operon
1705 def UnionListOfGroups(self, groups, name):
1706 return self.mesh.UnionListOfGroups(groups, name)
1708 ## Prodices an intersection of two groups
1709 # A new group is created. All mesh elements that are common
1710 # for the two initial groups are added to the new one.
1711 # @return an instance of SMESH_Group
1712 # @ingroup l2_grps_operon
1713 def IntersectGroups(self, group1, group2, name):
1714 return self.mesh.IntersectGroups(group1, group2, name)
1716 ## Produces an intersection of groups
1717 # New group is created. All mesh elements that are present in all
1718 # initial groups simultaneously are added to the new one
1719 # @return an instance of SMESH_Group
1720 # @ingroup l2_grps_operon
1721 def IntersectListOfGroups(self, groups, name):
1722 return self.mesh.IntersectListOfGroups(groups, name)
1724 ## Produces a cut of two groups
1725 # A new group is created. All mesh elements that are present in
1726 # the main group but are not present in the tool group are added to the new one
1727 # @return an instance of SMESH_Group
1728 # @ingroup l2_grps_operon
1729 def CutGroups(self, main_group, tool_group, name):
1730 return self.mesh.CutGroups(main_group, tool_group, name)
1732 ## Produces a cut of groups
1733 # A new group is created. All mesh elements that are present in main groups
1734 # but do not present in tool groups are added to the new one
1735 # @return an instance of SMESH_Group
1736 # @ingroup l2_grps_operon
1737 def CutListOfGroups(self, main_groups, tool_groups, name):
1738 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1740 ## Produces a group of elements of specified type using list of existing groups
1741 # A new group is created. System
1742 # 1) extracts all nodes on which groups elements are built
1743 # 2) combines all elements of specified dimension laying on these nodes
1744 # @return an instance of SMESH_Group
1745 # @ingroup l2_grps_operon
1746 def CreateDimGroup(self, groups, elem_type, name):
1747 return self.mesh.CreateDimGroup(groups, elem_type, name)
1750 ## Convert group on geom into standalone group
1751 # @ingroup l2_grps_delete
1752 def ConvertToStandalone(self, group):
1753 return self.mesh.ConvertToStandalone(group)
1755 # Get some info about mesh:
1756 # ------------------------
1758 ## Returns the log of nodes and elements added or removed
1759 # since the previous clear of the log.
1760 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1761 # @return list of log_block structures:
1766 # @ingroup l1_auxiliary
1767 def GetLog(self, clearAfterGet):
1768 return self.mesh.GetLog(clearAfterGet)
1770 ## Clears the log of nodes and elements added or removed since the previous
1771 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1772 # @ingroup l1_auxiliary
1774 self.mesh.ClearLog()
1776 ## Toggles auto color mode on the object.
1777 # @param theAutoColor the flag which toggles auto color mode.
1778 # @ingroup l1_auxiliary
1779 def SetAutoColor(self, theAutoColor):
1780 self.mesh.SetAutoColor(theAutoColor)
1782 ## Gets flag of object auto color mode.
1783 # @return True or False
1784 # @ingroup l1_auxiliary
1785 def GetAutoColor(self):
1786 return self.mesh.GetAutoColor()
1788 ## Gets the internal ID
1789 # @return integer value, which is the internal Id of the mesh
1790 # @ingroup l1_auxiliary
1792 return self.mesh.GetId()
1795 # @return integer value, which is the study Id of the mesh
1796 # @ingroup l1_auxiliary
1797 def GetStudyId(self):
1798 return self.mesh.GetStudyId()
1800 ## Checks the group names for duplications.
1801 # Consider the maximum group name length stored in MED file.
1802 # @return True or False
1803 # @ingroup l1_auxiliary
1804 def HasDuplicatedGroupNamesMED(self):
1805 return self.mesh.HasDuplicatedGroupNamesMED()
1807 ## Obtains the mesh editor tool
1808 # @return an instance of SMESH_MeshEditor
1809 # @ingroup l1_modifying
1810 def GetMeshEditor(self):
1813 ## Wrap a list of IDs of elements or nodes into SMESH_IDSource which
1814 # can be passed as argument to a method accepting mesh, group or sub-mesh
1815 # @return an instance of SMESH_IDSource
1816 # @ingroup l1_auxiliary
1817 def GetIDSource(self, ids, elemType):
1818 return self.editor.MakeIDSource(ids, elemType)
1821 # @return an instance of SALOME_MED::MESH
1822 # @ingroup l1_auxiliary
1823 def GetMEDMesh(self):
1824 return self.mesh.GetMEDMesh()
1827 # Get informations about mesh contents:
1828 # ------------------------------------
1830 ## Gets the mesh stattistic
1831 # @return dictionary type element - count of elements
1832 # @ingroup l1_meshinfo
1833 def GetMeshInfo(self, obj = None):
1834 if not obj: obj = self.mesh
1835 return self.smeshpyD.GetMeshInfo(obj)
1837 ## Returns the number of nodes in the mesh
1838 # @return an integer value
1839 # @ingroup l1_meshinfo
1841 return self.mesh.NbNodes()
1843 ## Returns the number of elements in the mesh
1844 # @return an integer value
1845 # @ingroup l1_meshinfo
1846 def NbElements(self):
1847 return self.mesh.NbElements()
1849 ## Returns the number of 0d elements in the mesh
1850 # @return an integer value
1851 # @ingroup l1_meshinfo
1852 def Nb0DElements(self):
1853 return self.mesh.Nb0DElements()
1855 ## Returns the number of ball discrete elements in the mesh
1856 # @return an integer value
1857 # @ingroup l1_meshinfo
1859 return self.mesh.NbBalls()
1861 ## Returns the number of edges in the mesh
1862 # @return an integer value
1863 # @ingroup l1_meshinfo
1865 return self.mesh.NbEdges()
1867 ## Returns the number of edges with the given order in the mesh
1868 # @param elementOrder the order of elements:
1869 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1870 # @return an integer value
1871 # @ingroup l1_meshinfo
1872 def NbEdgesOfOrder(self, elementOrder):
1873 return self.mesh.NbEdgesOfOrder(elementOrder)
1875 ## Returns the number of faces in the mesh
1876 # @return an integer value
1877 # @ingroup l1_meshinfo
1879 return self.mesh.NbFaces()
1881 ## Returns the number of faces with the given order in the mesh
1882 # @param elementOrder the order of elements:
1883 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1884 # @return an integer value
1885 # @ingroup l1_meshinfo
1886 def NbFacesOfOrder(self, elementOrder):
1887 return self.mesh.NbFacesOfOrder(elementOrder)
1889 ## Returns the number of triangles in the mesh
1890 # @return an integer value
1891 # @ingroup l1_meshinfo
1892 def NbTriangles(self):
1893 return self.mesh.NbTriangles()
1895 ## Returns the number of triangles with the given order in the mesh
1896 # @param elementOrder is the order of elements:
1897 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1898 # @return an integer value
1899 # @ingroup l1_meshinfo
1900 def NbTrianglesOfOrder(self, elementOrder):
1901 return self.mesh.NbTrianglesOfOrder(elementOrder)
1903 ## Returns the number of quadrangles in the mesh
1904 # @return an integer value
1905 # @ingroup l1_meshinfo
1906 def NbQuadrangles(self):
1907 return self.mesh.NbQuadrangles()
1909 ## Returns the number of quadrangles with the given order in the mesh
1910 # @param elementOrder the order of elements:
1911 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1912 # @return an integer value
1913 # @ingroup l1_meshinfo
1914 def NbQuadranglesOfOrder(self, elementOrder):
1915 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1917 ## Returns the number of biquadratic quadrangles in the mesh
1918 # @return an integer value
1919 # @ingroup l1_meshinfo
1920 def NbBiQuadQuadrangles(self):
1921 return self.mesh.NbBiQuadQuadrangles()
1923 ## Returns the number of polygons in the mesh
1924 # @return an integer value
1925 # @ingroup l1_meshinfo
1926 def NbPolygons(self):
1927 return self.mesh.NbPolygons()
1929 ## Returns the number of volumes in the mesh
1930 # @return an integer value
1931 # @ingroup l1_meshinfo
1932 def NbVolumes(self):
1933 return self.mesh.NbVolumes()
1935 ## Returns the number of volumes with the given order in the mesh
1936 # @param elementOrder the order of elements:
1937 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1938 # @return an integer value
1939 # @ingroup l1_meshinfo
1940 def NbVolumesOfOrder(self, elementOrder):
1941 return self.mesh.NbVolumesOfOrder(elementOrder)
1943 ## Returns the number of tetrahedrons in the mesh
1944 # @return an integer value
1945 # @ingroup l1_meshinfo
1947 return self.mesh.NbTetras()
1949 ## Returns the number of tetrahedrons with the given order in the mesh
1950 # @param elementOrder the order of elements:
1951 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1952 # @return an integer value
1953 # @ingroup l1_meshinfo
1954 def NbTetrasOfOrder(self, elementOrder):
1955 return self.mesh.NbTetrasOfOrder(elementOrder)
1957 ## Returns the number of hexahedrons in the mesh
1958 # @return an integer value
1959 # @ingroup l1_meshinfo
1961 return self.mesh.NbHexas()
1963 ## Returns the number of hexahedrons with the given order in the mesh
1964 # @param elementOrder the order of elements:
1965 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1966 # @return an integer value
1967 # @ingroup l1_meshinfo
1968 def NbHexasOfOrder(self, elementOrder):
1969 return self.mesh.NbHexasOfOrder(elementOrder)
1971 ## Returns the number of triquadratic hexahedrons in the mesh
1972 # @return an integer value
1973 # @ingroup l1_meshinfo
1974 def NbTriQuadraticHexas(self):
1975 return self.mesh.NbTriQuadraticHexas()
1977 ## Returns the number of pyramids in the mesh
1978 # @return an integer value
1979 # @ingroup l1_meshinfo
1980 def NbPyramids(self):
1981 return self.mesh.NbPyramids()
1983 ## Returns the number of pyramids with the given order in the mesh
1984 # @param elementOrder the order of elements:
1985 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1986 # @return an integer value
1987 # @ingroup l1_meshinfo
1988 def NbPyramidsOfOrder(self, elementOrder):
1989 return self.mesh.NbPyramidsOfOrder(elementOrder)
1991 ## Returns the number of prisms in the mesh
1992 # @return an integer value
1993 # @ingroup l1_meshinfo
1995 return self.mesh.NbPrisms()
1997 ## Returns the number of prisms with the given order in the mesh
1998 # @param elementOrder the order of elements:
1999 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2000 # @return an integer value
2001 # @ingroup l1_meshinfo
2002 def NbPrismsOfOrder(self, elementOrder):
2003 return self.mesh.NbPrismsOfOrder(elementOrder)
2005 ## Returns the number of hexagonal prisms in the mesh
2006 # @return an integer value
2007 # @ingroup l1_meshinfo
2008 def NbHexagonalPrisms(self):
2009 return self.mesh.NbHexagonalPrisms()
2011 ## Returns the number of polyhedrons in the mesh
2012 # @return an integer value
2013 # @ingroup l1_meshinfo
2014 def NbPolyhedrons(self):
2015 return self.mesh.NbPolyhedrons()
2017 ## Returns the number of submeshes in the mesh
2018 # @return an integer value
2019 # @ingroup l1_meshinfo
2020 def NbSubMesh(self):
2021 return self.mesh.NbSubMesh()
2023 ## Returns the list of mesh elements IDs
2024 # @return the list of integer values
2025 # @ingroup l1_meshinfo
2026 def GetElementsId(self):
2027 return self.mesh.GetElementsId()
2029 ## Returns the list of IDs of mesh elements with the given type
2030 # @param elementType the required type of elements (SMESH.NODE, SMESH.EDGE, SMESH.FACE or SMESH.VOLUME)
2031 # @return list of integer values
2032 # @ingroup l1_meshinfo
2033 def GetElementsByType(self, elementType):
2034 return self.mesh.GetElementsByType(elementType)
2036 ## Returns the list of mesh nodes IDs
2037 # @return the list of integer values
2038 # @ingroup l1_meshinfo
2039 def GetNodesId(self):
2040 return self.mesh.GetNodesId()
2042 # Get the information about mesh elements:
2043 # ------------------------------------
2045 ## Returns the type of mesh element
2046 # @return the value from SMESH::ElementType enumeration
2047 # @ingroup l1_meshinfo
2048 def GetElementType(self, id, iselem):
2049 return self.mesh.GetElementType(id, iselem)
2051 ## Returns the geometric type of mesh element
2052 # @return the value from SMESH::EntityType enumeration
2053 # @ingroup l1_meshinfo
2054 def GetElementGeomType(self, id):
2055 return self.mesh.GetElementGeomType(id)
2057 ## Returns the list of submesh elements IDs
2058 # @param Shape a geom object(sub-shape) IOR
2059 # Shape must be the sub-shape of a ShapeToMesh()
2060 # @return the list of integer values
2061 # @ingroup l1_meshinfo
2062 def GetSubMeshElementsId(self, Shape):
2063 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2064 ShapeID = Shape.GetSubShapeIndices()[0]
2067 return self.mesh.GetSubMeshElementsId(ShapeID)
2069 ## Returns the list of submesh nodes IDs
2070 # @param Shape a geom object(sub-shape) IOR
2071 # Shape must be the sub-shape of a ShapeToMesh()
2072 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
2073 # @return the list of integer values
2074 # @ingroup l1_meshinfo
2075 def GetSubMeshNodesId(self, Shape, all):
2076 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2077 ShapeID = self.geompyD.GetSubShapeID( self.geom, Shape )
2080 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2082 ## Returns type of elements on given shape
2083 # @param Shape a geom object(sub-shape) IOR
2084 # Shape must be a sub-shape of a ShapeToMesh()
2085 # @return element type
2086 # @ingroup l1_meshinfo
2087 def GetSubMeshElementType(self, Shape):
2088 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2089 ShapeID = Shape.GetSubShapeIndices()[0]
2092 return self.mesh.GetSubMeshElementType(ShapeID)
2094 ## Gets the mesh description
2095 # @return string value
2096 # @ingroup l1_meshinfo
2098 return self.mesh.Dump()
2101 # Get the information about nodes and elements of a mesh by its IDs:
2102 # -----------------------------------------------------------
2104 ## Gets XYZ coordinates of a node
2105 # \n If there is no nodes for the given ID - returns an empty list
2106 # @return a list of double precision values
2107 # @ingroup l1_meshinfo
2108 def GetNodeXYZ(self, id):
2109 return self.mesh.GetNodeXYZ(id)
2111 ## Returns list of IDs of inverse elements for the given node
2112 # \n If there is no node for the given ID - returns an empty list
2113 # @return a list of integer values
2114 # @ingroup l1_meshinfo
2115 def GetNodeInverseElements(self, id):
2116 return self.mesh.GetNodeInverseElements(id)
2118 ## @brief Returns the position of a node on the shape
2119 # @return SMESH::NodePosition
2120 # @ingroup l1_meshinfo
2121 def GetNodePosition(self,NodeID):
2122 return self.mesh.GetNodePosition(NodeID)
2124 ## @brief Returns the position of an element on the shape
2125 # @return SMESH::ElementPosition
2126 # @ingroup l1_meshinfo
2127 def GetElementPosition(self,ElemID):
2128 return self.mesh.GetElementPosition(ElemID)
2130 ## If the given element is a node, returns the ID of shape
2131 # \n If there is no node for the given ID - returns -1
2132 # @return an integer value
2133 # @ingroup l1_meshinfo
2134 def GetShapeID(self, id):
2135 return self.mesh.GetShapeID(id)
2137 ## Returns the ID of the result shape after
2138 # FindShape() from SMESH_MeshEditor for the given element
2139 # \n If there is no element for the given ID - returns -1
2140 # @return an integer value
2141 # @ingroup l1_meshinfo
2142 def GetShapeIDForElem(self,id):
2143 return self.mesh.GetShapeIDForElem(id)
2145 ## Returns the number of nodes for the given element
2146 # \n If there is no element for the given ID - returns -1
2147 # @return an integer value
2148 # @ingroup l1_meshinfo
2149 def GetElemNbNodes(self, id):
2150 return self.mesh.GetElemNbNodes(id)
2152 ## Returns the node ID the given index for the given element
2153 # \n If there is no element for the given ID - returns -1
2154 # \n If there is no node for the given index - returns -2
2155 # @return an integer value
2156 # @ingroup l1_meshinfo
2157 def GetElemNode(self, id, index):
2158 return self.mesh.GetElemNode(id, index)
2160 ## Returns the IDs of nodes of the given element
2161 # @return a list of integer values
2162 # @ingroup l1_meshinfo
2163 def GetElemNodes(self, id):
2164 return self.mesh.GetElemNodes(id)
2166 ## Returns true if the given node is the medium node in the given quadratic element
2167 # @ingroup l1_meshinfo
2168 def IsMediumNode(self, elementID, nodeID):
2169 return self.mesh.IsMediumNode(elementID, nodeID)
2171 ## Returns true if the given node is the medium node in one of quadratic elements
2172 # @ingroup l1_meshinfo
2173 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2174 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2176 ## Returns the number of edges for the given element
2177 # @ingroup l1_meshinfo
2178 def ElemNbEdges(self, id):
2179 return self.mesh.ElemNbEdges(id)
2181 ## Returns the number of faces for the given element
2182 # @ingroup l1_meshinfo
2183 def ElemNbFaces(self, id):
2184 return self.mesh.ElemNbFaces(id)
2186 ## Returns nodes of given face (counted from zero) for given volumic element.
2187 # @ingroup l1_meshinfo
2188 def GetElemFaceNodes(self,elemId, faceIndex):
2189 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2191 ## Returns an element based on all given nodes.
2192 # @ingroup l1_meshinfo
2193 def FindElementByNodes(self,nodes):
2194 return self.mesh.FindElementByNodes(nodes)
2196 ## Returns true if the given element is a polygon
2197 # @ingroup l1_meshinfo
2198 def IsPoly(self, id):
2199 return self.mesh.IsPoly(id)
2201 ## Returns true if the given element is quadratic
2202 # @ingroup l1_meshinfo
2203 def IsQuadratic(self, id):
2204 return self.mesh.IsQuadratic(id)
2206 ## Returns diameter of a ball discrete element or zero in case of an invalid \a id
2207 # @ingroup l1_meshinfo
2208 def GetBallDiameter(self, id):
2209 return self.mesh.GetBallDiameter(id)
2211 ## Returns XYZ coordinates of the barycenter of the given element
2212 # \n If there is no element for the given ID - returns an empty list
2213 # @return a list of three double values
2214 # @ingroup l1_meshinfo
2215 def BaryCenter(self, id):
2216 return self.mesh.BaryCenter(id)
2218 ## Passes mesh elements through the given filter and return IDs of fitting elements
2219 # @param theFilter SMESH_Filter
2220 # @return a list of ids
2221 # @ingroup l1_controls
2222 def GetIdsFromFilter(self, theFilter):
2223 theFilter.SetMesh( self.mesh )
2224 return theFilter.GetIDs()
2226 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
2227 # Returns a list of special structures (borders).
2228 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
2229 # @ingroup l1_controls
2230 def GetFreeBorders(self):
2231 aFilterMgr = self.smeshpyD.CreateFilterManager()
2232 aPredicate = aFilterMgr.CreateFreeEdges()
2233 aPredicate.SetMesh(self.mesh)
2234 aBorders = aPredicate.GetBorders()
2235 aFilterMgr.UnRegister()
2239 # Get mesh measurements information:
2240 # ------------------------------------
2242 ## Get minimum distance between two nodes, elements or distance to the origin
2243 # @param id1 first node/element id
2244 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2245 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2246 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2247 # @return minimum distance value
2248 # @sa GetMinDistance()
2249 def MinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2250 aMeasure = self.GetMinDistance(id1, id2, isElem1, isElem2)
2251 return aMeasure.value
2253 ## Get measure structure specifying minimum distance data between two objects
2254 # @param id1 first node/element id
2255 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2256 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2257 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2258 # @return Measure structure
2260 def GetMinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2262 id1 = self.editor.MakeIDSource([id1], SMESH.FACE)
2264 id1 = self.editor.MakeIDSource([id1], SMESH.NODE)
2267 id2 = self.editor.MakeIDSource([id2], SMESH.FACE)
2269 id2 = self.editor.MakeIDSource([id2], SMESH.NODE)
2274 aMeasurements = self.smeshpyD.CreateMeasurements()
2275 aMeasure = aMeasurements.MinDistance(id1, id2)
2276 aMeasurements.UnRegister()
2279 ## Get bounding box of the specified object(s)
2280 # @param objects single source object or list of source objects or list of nodes/elements IDs
2281 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2282 # @c False specifies that @a objects are nodes
2283 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
2284 # @sa GetBoundingBox()
2285 def BoundingBox(self, objects=None, isElem=False):
2286 result = self.GetBoundingBox(objects, isElem)
2290 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
2293 ## Get measure structure specifying bounding box data of the specified object(s)
2294 # @param IDs single source object or list of source objects or list of nodes/elements IDs
2295 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2296 # @c False specifies that @a objects are nodes
2297 # @return Measure structure
2299 def GetBoundingBox(self, IDs=None, isElem=False):
2302 elif isinstance(IDs, tuple):
2304 if not isinstance(IDs, list):
2306 if len(IDs) > 0 and isinstance(IDs[0], int):
2310 if isinstance(o, Mesh):
2311 srclist.append(o.mesh)
2312 elif hasattr(o, "_narrow"):
2313 src = o._narrow(SMESH.SMESH_IDSource)
2314 if src: srclist.append(src)
2316 elif isinstance(o, list):
2318 srclist.append(self.editor.MakeIDSource(o, SMESH.FACE))
2320 srclist.append(self.editor.MakeIDSource(o, SMESH.NODE))
2323 aMeasurements = self.smeshpyD.CreateMeasurements()
2324 aMeasure = aMeasurements.BoundingBox(srclist)
2325 aMeasurements.UnRegister()
2328 # Mesh edition (SMESH_MeshEditor functionality):
2329 # ---------------------------------------------
2331 ## Removes the elements from the mesh by ids
2332 # @param IDsOfElements is a list of ids of elements to remove
2333 # @return True or False
2334 # @ingroup l2_modif_del
2335 def RemoveElements(self, IDsOfElements):
2336 return self.editor.RemoveElements(IDsOfElements)
2338 ## Removes nodes from mesh by ids
2339 # @param IDsOfNodes is a list of ids of nodes to remove
2340 # @return True or False
2341 # @ingroup l2_modif_del
2342 def RemoveNodes(self, IDsOfNodes):
2343 return self.editor.RemoveNodes(IDsOfNodes)
2345 ## Removes all orphan (free) nodes from mesh
2346 # @return number of the removed nodes
2347 # @ingroup l2_modif_del
2348 def RemoveOrphanNodes(self):
2349 return self.editor.RemoveOrphanNodes()
2351 ## Add a node to the mesh by coordinates
2352 # @return Id of the new node
2353 # @ingroup l2_modif_add
2354 def AddNode(self, x, y, z):
2355 x,y,z,Parameters,hasVars = ParseParameters(x,y,z)
2356 if hasVars: self.mesh.SetParameters(Parameters)
2357 return self.editor.AddNode( x, y, z)
2359 ## Creates a 0D element on a node with given number.
2360 # @param IDOfNode the ID of node for creation of the element.
2361 # @return the Id of the new 0D element
2362 # @ingroup l2_modif_add
2363 def Add0DElement(self, IDOfNode):
2364 return self.editor.Add0DElement(IDOfNode)
2366 ## Create 0D elements on all nodes of the given elements except those
2367 # nodes on which a 0D element already exists.
2368 # @param theObject an object on whose nodes 0D elements will be created.
2369 # It can be mesh, sub-mesh, group, list of element IDs or a holder
2370 # of nodes IDs created by calling mesh.GetIDSource( nodes, SMESH.NODE )
2371 # @param theGroupName optional name of a group to add 0D elements created
2372 # and/or found on nodes of \a theObject.
2373 # @return an object (a new group or a temporary SMESH_IDSource) holding
2374 # IDs of new and/or found 0D elements. IDs of 0D elements
2375 # can be retrieved from the returned object by calling GetIDs()
2376 # @ingroup l2_modif_add
2377 def Add0DElementsToAllNodes(self, theObject, theGroupName=""):
2378 if isinstance( theObject, Mesh ):
2379 theObject = theObject.GetMesh()
2380 if isinstance( theObject, list ):
2381 theObject = self.GetIDSource( theObject, SMESH.ALL )
2382 return self.editor.Create0DElementsOnAllNodes( theObject, theGroupName )
2384 ## Creates a ball element on a node with given ID.
2385 # @param IDOfNode the ID of node for creation of the element.
2386 # @param diameter the bal diameter.
2387 # @return the Id of the new ball element
2388 # @ingroup l2_modif_add
2389 def AddBall(self, IDOfNode, diameter):
2390 return self.editor.AddBall( IDOfNode, diameter )
2392 ## Creates a linear or quadratic edge (this is determined
2393 # by the number of given nodes).
2394 # @param IDsOfNodes the list of node IDs for creation of the element.
2395 # The order of nodes in this list should correspond to the description
2396 # of MED. \n This description is located by the following link:
2397 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2398 # @return the Id of the new edge
2399 # @ingroup l2_modif_add
2400 def AddEdge(self, IDsOfNodes):
2401 return self.editor.AddEdge(IDsOfNodes)
2403 ## Creates a linear or quadratic face (this is determined
2404 # by the number of given nodes).
2405 # @param IDsOfNodes the list of node IDs for creation of the element.
2406 # The order of nodes in this list should correspond to the description
2407 # of MED. \n This description is located by the following link:
2408 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2409 # @return the Id of the new face
2410 # @ingroup l2_modif_add
2411 def AddFace(self, IDsOfNodes):
2412 return self.editor.AddFace(IDsOfNodes)
2414 ## Adds a polygonal face to the mesh by the list of node IDs
2415 # @param IdsOfNodes the list of node IDs for creation of the element.
2416 # @return the Id of the new face
2417 # @ingroup l2_modif_add
2418 def AddPolygonalFace(self, IdsOfNodes):
2419 return self.editor.AddPolygonalFace(IdsOfNodes)
2421 ## Creates both simple and quadratic volume (this is determined
2422 # by the number of given nodes).
2423 # @param IDsOfNodes the list of node IDs for creation of the element.
2424 # The order of nodes in this list should correspond to the description
2425 # of MED. \n This description is located by the following link:
2426 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2427 # @return the Id of the new volumic element
2428 # @ingroup l2_modif_add
2429 def AddVolume(self, IDsOfNodes):
2430 return self.editor.AddVolume(IDsOfNodes)
2432 ## Creates a volume of many faces, giving nodes for each face.
2433 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2434 # @param Quantities the list of integer values, Quantities[i]
2435 # gives the quantity of nodes in face number i.
2436 # @return the Id of the new volumic element
2437 # @ingroup l2_modif_add
2438 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2439 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2441 ## Creates a volume of many faces, giving the IDs of the existing faces.
2442 # @param IdsOfFaces the list of face IDs for volume creation.
2444 # Note: The created volume will refer only to the nodes
2445 # of the given faces, not to the faces themselves.
2446 # @return the Id of the new volumic element
2447 # @ingroup l2_modif_add
2448 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2449 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2452 ## @brief Binds a node to a vertex
2453 # @param NodeID a node ID
2454 # @param Vertex a vertex or vertex ID
2455 # @return True if succeed else raises an exception
2456 # @ingroup l2_modif_add
2457 def SetNodeOnVertex(self, NodeID, Vertex):
2458 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2459 VertexID = Vertex.GetSubShapeIndices()[0]
2463 self.editor.SetNodeOnVertex(NodeID, VertexID)
2464 except SALOME.SALOME_Exception, inst:
2465 raise ValueError, inst.details.text
2469 ## @brief Stores the node position on an edge
2470 # @param NodeID a node ID
2471 # @param Edge an edge or edge ID
2472 # @param paramOnEdge a parameter on the edge where the node is located
2473 # @return True if succeed else raises an exception
2474 # @ingroup l2_modif_add
2475 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2476 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2477 EdgeID = Edge.GetSubShapeIndices()[0]
2481 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2482 except SALOME.SALOME_Exception, inst:
2483 raise ValueError, inst.details.text
2486 ## @brief Stores node position on a face
2487 # @param NodeID a node ID
2488 # @param Face a face or face ID
2489 # @param u U parameter on the face where the node is located
2490 # @param v V parameter on the face where the node is located
2491 # @return True if succeed else raises an exception
2492 # @ingroup l2_modif_add
2493 def SetNodeOnFace(self, NodeID, Face, u, v):
2494 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2495 FaceID = Face.GetSubShapeIndices()[0]
2499 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2500 except SALOME.SALOME_Exception, inst:
2501 raise ValueError, inst.details.text
2504 ## @brief Binds a node to a solid
2505 # @param NodeID a node ID
2506 # @param Solid a solid or solid ID
2507 # @return True if succeed else raises an exception
2508 # @ingroup l2_modif_add
2509 def SetNodeInVolume(self, NodeID, Solid):
2510 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2511 SolidID = Solid.GetSubShapeIndices()[0]
2515 self.editor.SetNodeInVolume(NodeID, SolidID)
2516 except SALOME.SALOME_Exception, inst:
2517 raise ValueError, inst.details.text
2520 ## @brief Bind an element to a shape
2521 # @param ElementID an element ID
2522 # @param Shape a shape or shape ID
2523 # @return True if succeed else raises an exception
2524 # @ingroup l2_modif_add
2525 def SetMeshElementOnShape(self, ElementID, Shape):
2526 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2527 ShapeID = Shape.GetSubShapeIndices()[0]
2531 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2532 except SALOME.SALOME_Exception, inst:
2533 raise ValueError, inst.details.text
2537 ## Moves the node with the given id
2538 # @param NodeID the id of the node
2539 # @param x a new X coordinate
2540 # @param y a new Y coordinate
2541 # @param z a new Z coordinate
2542 # @return True if succeed else False
2543 # @ingroup l2_modif_movenode
2544 def MoveNode(self, NodeID, x, y, z):
2545 x,y,z,Parameters,hasVars = ParseParameters(x,y,z)
2546 if hasVars: self.mesh.SetParameters(Parameters)
2547 return self.editor.MoveNode(NodeID, x, y, z)
2549 ## Finds the node closest to a point and moves it to a point location
2550 # @param x the X coordinate of a point
2551 # @param y the Y coordinate of a point
2552 # @param z the Z coordinate of a point
2553 # @param NodeID if specified (>0), the node with this ID is moved,
2554 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2555 # @return the ID of a node
2556 # @ingroup l2_modif_throughp
2557 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2558 x,y,z,Parameters,hasVars = ParseParameters(x,y,z)
2559 if hasVars: self.mesh.SetParameters(Parameters)
2560 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2562 ## Finds the node closest to a point
2563 # @param x the X coordinate of a point
2564 # @param y the Y coordinate of a point
2565 # @param z the Z coordinate of a point
2566 # @return the ID of a node
2567 # @ingroup l2_modif_throughp
2568 def FindNodeClosestTo(self, x, y, z):
2569 #preview = self.mesh.GetMeshEditPreviewer()
2570 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2571 return self.editor.FindNodeClosestTo(x, y, z)
2573 ## Finds the elements where a point lays IN or ON
2574 # @param x the X coordinate of a point
2575 # @param y the Y coordinate of a point
2576 # @param z the Z coordinate of a point
2577 # @param elementType type of elements to find (SMESH.ALL type
2578 # means elements of any type excluding nodes, discrete and 0D elements)
2579 # @param meshPart a part of mesh (group, sub-mesh) to search within
2580 # @return list of IDs of found elements
2581 # @ingroup l2_modif_throughp
2582 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL, meshPart=None):
2584 return self.editor.FindAmongElementsByPoint( meshPart, x, y, z, elementType );
2586 return self.editor.FindElementsByPoint(x, y, z, elementType)
2588 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration:
2589 # 0-IN, 1-OUT, 2-ON, 3-UNKNOWN
2590 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2592 def GetPointState(self, x, y, z):
2593 return self.editor.GetPointState(x, y, z)
2595 ## Finds the node closest to a point and moves it to a point location
2596 # @param x the X coordinate of a point
2597 # @param y the Y coordinate of a point
2598 # @param z the Z coordinate of a point
2599 # @return the ID of a moved node
2600 # @ingroup l2_modif_throughp
2601 def MeshToPassThroughAPoint(self, x, y, z):
2602 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2604 ## Replaces two neighbour triangles sharing Node1-Node2 link
2605 # with the triangles built on the same 4 nodes but having other common link.
2606 # @param NodeID1 the ID of the first node
2607 # @param NodeID2 the ID of the second node
2608 # @return false if proper faces were not found
2609 # @ingroup l2_modif_invdiag
2610 def InverseDiag(self, NodeID1, NodeID2):
2611 return self.editor.InverseDiag(NodeID1, NodeID2)
2613 ## Replaces two neighbour triangles sharing Node1-Node2 link
2614 # with a quadrangle built on the same 4 nodes.
2615 # @param NodeID1 the ID of the first node
2616 # @param NodeID2 the ID of the second node
2617 # @return false if proper faces were not found
2618 # @ingroup l2_modif_unitetri
2619 def DeleteDiag(self, NodeID1, NodeID2):
2620 return self.editor.DeleteDiag(NodeID1, NodeID2)
2622 ## Reorients elements by ids
2623 # @param IDsOfElements if undefined reorients all mesh elements
2624 # @return True if succeed else False
2625 # @ingroup l2_modif_changori
2626 def Reorient(self, IDsOfElements=None):
2627 if IDsOfElements == None:
2628 IDsOfElements = self.GetElementsId()
2629 return self.editor.Reorient(IDsOfElements)
2631 ## Reorients all elements of the object
2632 # @param theObject mesh, submesh or group
2633 # @return True if succeed else False
2634 # @ingroup l2_modif_changori
2635 def ReorientObject(self, theObject):
2636 if ( isinstance( theObject, Mesh )):
2637 theObject = theObject.GetMesh()
2638 return self.editor.ReorientObject(theObject)
2640 ## Reorient faces contained in \a the2DObject.
2641 # @param the2DObject is a mesh, sub-mesh, group or list of IDs of 2D elements
2642 # @param theDirection is a desired direction of normal of \a theFace.
2643 # It can be either a GEOM vector or a list of coordinates [x,y,z].
2644 # @param theFaceOrPoint defines a face of \a the2DObject whose normal will be
2645 # compared with theDirection. It can be either ID of face or a point
2646 # by which the face will be found. The point can be given as either
2647 # a GEOM vertex or a list of point coordinates.
2648 # @return number of reoriented faces
2649 # @ingroup l2_modif_changori
2650 def Reorient2D(self, the2DObject, theDirection, theFaceOrPoint ):
2652 if isinstance( the2DObject, Mesh ):
2653 the2DObject = the2DObject.GetMesh()
2654 if isinstance( the2DObject, list ):
2655 the2DObject = self.GetIDSource( the2DObject, SMESH.FACE )
2656 # check theDirection
2657 if isinstance( theDirection, geompyDC.GEOM._objref_GEOM_Object):
2658 theDirection = self.smeshpyD.GetDirStruct( theDirection )
2659 if isinstance( theDirection, list ):
2660 theDirection = self.smeshpyD.MakeDirStruct( *theDirection )
2661 # prepare theFace and thePoint
2662 theFace = theFaceOrPoint
2663 thePoint = PointStruct(0,0,0)
2664 if isinstance( theFaceOrPoint, geompyDC.GEOM._objref_GEOM_Object):
2665 thePoint = self.smeshpyD.GetPointStruct( theFaceOrPoint )
2667 if isinstance( theFaceOrPoint, list ):
2668 thePoint = PointStruct( *theFaceOrPoint )
2670 if isinstance( theFaceOrPoint, PointStruct ):
2671 thePoint = theFaceOrPoint
2673 return self.editor.Reorient2D( the2DObject, theDirection, theFace, thePoint )
2675 ## Fuses the neighbouring triangles into quadrangles.
2676 # @param IDsOfElements The triangles to be fused,
2677 # @param theCriterion is a numerical functor, in terms of enum SMESH.FunctorType, used to
2678 # choose a neighbour to fuse with.
2679 # @param MaxAngle is the maximum angle between element normals at which the fusion
2680 # is still performed; theMaxAngle is mesured in radians.
2681 # Also it could be a name of variable which defines angle in degrees.
2682 # @return TRUE in case of success, FALSE otherwise.
2683 # @ingroup l2_modif_unitetri
2684 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2685 MaxAngle,Parameters,hasVars = ParseAngles(MaxAngle)
2686 self.mesh.SetParameters(Parameters)
2687 if not IDsOfElements:
2688 IDsOfElements = self.GetElementsId()
2689 Functor = self.smeshpyD.GetFunctor(theCriterion)
2690 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2692 ## Fuses the neighbouring triangles of the object into quadrangles
2693 # @param theObject is mesh, submesh or group
2694 # @param theCriterion is a numerical functor, in terms of enum SMESH.FunctorType, used to
2695 # choose a neighbour to fuse with.
2696 # @param MaxAngle a max angle between element normals at which the fusion
2697 # is still performed; theMaxAngle is mesured in radians.
2698 # @return TRUE in case of success, FALSE otherwise.
2699 # @ingroup l2_modif_unitetri
2700 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2701 MaxAngle,Parameters,hasVars = ParseAngles(MaxAngle)
2702 self.mesh.SetParameters(Parameters)
2703 if isinstance( theObject, Mesh ):
2704 theObject = theObject.GetMesh()
2705 Functor = self.smeshpyD.GetFunctor(theCriterion)
2706 return self.editor.TriToQuadObject(theObject, Functor, MaxAngle)
2708 ## Splits quadrangles into triangles.
2710 # @param IDsOfElements the faces to be splitted.
2711 # @param theCriterion is a numerical functor, in terms of enum SMESH.FunctorType, used to
2712 # choose a diagonal for splitting. If @a theCriterion is None, which is a default
2713 # value, then quadrangles will be split by the smallest diagonal.
2714 # @return TRUE in case of success, FALSE otherwise.
2715 # @ingroup l2_modif_cutquadr
2716 def QuadToTri (self, IDsOfElements, theCriterion = None):
2717 if IDsOfElements == []:
2718 IDsOfElements = self.GetElementsId()
2719 if theCriterion is None:
2720 theCriterion = FT_MaxElementLength2D
2721 Functor = self.smeshpyD.GetFunctor(theCriterion)
2722 return self.editor.QuadToTri(IDsOfElements, Functor)
2724 ## Splits quadrangles into triangles.
2725 # @param theObject the object from which the list of elements is taken,
2726 # this is mesh, submesh or group
2727 # @param theCriterion is a numerical functor, in terms of enum SMESH.FunctorType, used to
2728 # choose a diagonal for splitting. If @a theCriterion is None, which is a default
2729 # value, then quadrangles will be split by the smallest diagonal.
2730 # @return TRUE in case of success, FALSE otherwise.
2731 # @ingroup l2_modif_cutquadr
2732 def QuadToTriObject (self, theObject, theCriterion = None):
2733 if ( isinstance( theObject, Mesh )):
2734 theObject = theObject.GetMesh()
2735 if theCriterion is None:
2736 theCriterion = FT_MaxElementLength2D
2737 Functor = self.smeshpyD.GetFunctor(theCriterion)
2738 return self.editor.QuadToTriObject(theObject, Functor)
2740 ## Splits quadrangles into triangles.
2741 # @param IDsOfElements the faces to be splitted
2742 # @param Diag13 is used to choose a diagonal for splitting.
2743 # @return TRUE in case of success, FALSE otherwise.
2744 # @ingroup l2_modif_cutquadr
2745 def SplitQuad (self, IDsOfElements, Diag13):
2746 if IDsOfElements == []:
2747 IDsOfElements = self.GetElementsId()
2748 return self.editor.SplitQuad(IDsOfElements, Diag13)
2750 ## Splits quadrangles into triangles.
2751 # @param theObject the object from which the list of elements is taken,
2752 # this is mesh, submesh or group
2753 # @param Diag13 is used to choose a diagonal for splitting.
2754 # @return TRUE in case of success, FALSE otherwise.
2755 # @ingroup l2_modif_cutquadr
2756 def SplitQuadObject (self, theObject, Diag13):
2757 if ( isinstance( theObject, Mesh )):
2758 theObject = theObject.GetMesh()
2759 return self.editor.SplitQuadObject(theObject, Diag13)
2761 ## Finds a better splitting of the given quadrangle.
2762 # @param IDOfQuad the ID of the quadrangle to be splitted.
2763 # @param theCriterion is a numerical functor, in terms of enum SMESH.FunctorType, used to
2764 # choose a diagonal for splitting.
2765 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2766 # diagonal is better, 0 if error occurs.
2767 # @ingroup l2_modif_cutquadr
2768 def BestSplit (self, IDOfQuad, theCriterion):
2769 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2771 ## Splits volumic elements into tetrahedrons
2772 # @param elemIDs either list of elements or mesh or group or submesh
2773 # @param method flags passing splitting method: Hex_5Tet, Hex_6Tet, Hex_24Tet
2774 # Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc
2775 # @ingroup l2_modif_cutquadr
2776 def SplitVolumesIntoTetra(self, elemIDs, method=Hex_5Tet ):
2777 if isinstance( elemIDs, Mesh ):
2778 elemIDs = elemIDs.GetMesh()
2779 if ( isinstance( elemIDs, list )):
2780 elemIDs = self.editor.MakeIDSource(elemIDs, SMESH.VOLUME)
2781 self.editor.SplitVolumesIntoTetra(elemIDs, method)
2783 ## Splits quadrangle faces near triangular facets of volumes
2785 # @ingroup l1_auxiliary
2786 def SplitQuadsNearTriangularFacets(self):
2787 faces_array = self.GetElementsByType(SMESH.FACE)
2788 for face_id in faces_array:
2789 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2790 quad_nodes = self.mesh.GetElemNodes(face_id)
2791 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2792 isVolumeFound = False
2793 for node1_elem in node1_elems:
2794 if not isVolumeFound:
2795 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2796 nb_nodes = self.GetElemNbNodes(node1_elem)
2797 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2798 volume_elem = node1_elem
2799 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2800 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2801 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2802 isVolumeFound = True
2803 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2804 self.SplitQuad([face_id], False) # diagonal 2-4
2805 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2806 isVolumeFound = True
2807 self.SplitQuad([face_id], True) # diagonal 1-3
2808 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2809 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2810 isVolumeFound = True
2811 self.SplitQuad([face_id], True) # diagonal 1-3
2813 ## @brief Splits hexahedrons into tetrahedrons.
2815 # This operation uses pattern mapping functionality for splitting.
2816 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2817 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2818 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2819 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2820 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2821 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2822 # @return TRUE in case of success, FALSE otherwise.
2823 # @ingroup l1_auxiliary
2824 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2825 # Pattern: 5.---------.6
2830 # (0,0,1) 4.---------.7 * |
2837 # (0,0,0) 0.---------.3
2838 pattern_tetra = "!!! Nb of points: \n 8 \n\
2848 !!! Indices of points of 6 tetras: \n\
2856 pattern = self.smeshpyD.GetPattern()
2857 isDone = pattern.LoadFromFile(pattern_tetra)
2859 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2862 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2863 isDone = pattern.MakeMesh(self.mesh, False, False)
2864 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2866 # split quafrangle faces near triangular facets of volumes
2867 self.SplitQuadsNearTriangularFacets()
2871 ## @brief Split hexahedrons into prisms.
2873 # Uses the pattern mapping functionality for splitting.
2874 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2875 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2876 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2877 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2878 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2879 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2880 # @return TRUE in case of success, FALSE otherwise.
2881 # @ingroup l1_auxiliary
2882 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2883 # Pattern: 5.---------.6
2888 # (0,0,1) 4.---------.7 |
2895 # (0,0,0) 0.---------.3
2896 pattern_prism = "!!! Nb of points: \n 8 \n\
2906 !!! Indices of points of 2 prisms: \n\
2910 pattern = self.smeshpyD.GetPattern()
2911 isDone = pattern.LoadFromFile(pattern_prism)
2913 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2916 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2917 isDone = pattern.MakeMesh(self.mesh, False, False)
2918 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2920 # Splits quafrangle faces near triangular facets of volumes
2921 self.SplitQuadsNearTriangularFacets()
2925 ## Smoothes elements
2926 # @param IDsOfElements the list if ids of elements to smooth
2927 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2928 # Note that nodes built on edges and boundary nodes are always fixed.
2929 # @param MaxNbOfIterations the maximum number of iterations
2930 # @param MaxAspectRatio varies in range [1.0, inf]
2931 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2932 # @return TRUE in case of success, FALSE otherwise.
2933 # @ingroup l2_modif_smooth
2934 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2935 MaxNbOfIterations, MaxAspectRatio, Method):
2936 if IDsOfElements == []:
2937 IDsOfElements = self.GetElementsId()
2938 MaxNbOfIterations,MaxAspectRatio,Parameters,hasVars = ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2939 self.mesh.SetParameters(Parameters)
2940 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2941 MaxNbOfIterations, MaxAspectRatio, Method)
2943 ## Smoothes elements which belong to the given object
2944 # @param theObject the object to smooth
2945 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2946 # Note that nodes built on edges and boundary nodes are always fixed.
2947 # @param MaxNbOfIterations the maximum number of iterations
2948 # @param MaxAspectRatio varies in range [1.0, inf]
2949 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2950 # @return TRUE in case of success, FALSE otherwise.
2951 # @ingroup l2_modif_smooth
2952 def SmoothObject(self, theObject, IDsOfFixedNodes,
2953 MaxNbOfIterations, MaxAspectRatio, Method):
2954 if ( isinstance( theObject, Mesh )):
2955 theObject = theObject.GetMesh()
2956 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2957 MaxNbOfIterations, MaxAspectRatio, Method)
2959 ## Parametrically smoothes the given elements
2960 # @param IDsOfElements the list if ids of elements to smooth
2961 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2962 # Note that nodes built on edges and boundary nodes are always fixed.
2963 # @param MaxNbOfIterations the maximum number of iterations
2964 # @param MaxAspectRatio varies in range [1.0, inf]
2965 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2966 # @return TRUE in case of success, FALSE otherwise.
2967 # @ingroup l2_modif_smooth
2968 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2969 MaxNbOfIterations, MaxAspectRatio, Method):
2970 if IDsOfElements == []:
2971 IDsOfElements = self.GetElementsId()
2972 MaxNbOfIterations,MaxAspectRatio,Parameters,hasVars = ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2973 self.mesh.SetParameters(Parameters)
2974 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2975 MaxNbOfIterations, MaxAspectRatio, Method)
2977 ## Parametrically smoothes the elements which belong to the given object
2978 # @param theObject the object to smooth
2979 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2980 # Note that nodes built on edges and boundary nodes are always fixed.
2981 # @param MaxNbOfIterations the maximum number of iterations
2982 # @param MaxAspectRatio varies in range [1.0, inf]
2983 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2984 # @return TRUE in case of success, FALSE otherwise.
2985 # @ingroup l2_modif_smooth
2986 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2987 MaxNbOfIterations, MaxAspectRatio, Method):
2988 if ( isinstance( theObject, Mesh )):
2989 theObject = theObject.GetMesh()
2990 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2991 MaxNbOfIterations, MaxAspectRatio, Method)
2993 ## Converts the mesh to quadratic, deletes old elements, replacing
2994 # them with quadratic with the same id.
2995 # @param theForce3d new node creation method:
2996 # 0 - the medium node lies at the geometrical entity from which the mesh element is built
2997 # 1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element
2998 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
2999 # @ingroup l2_modif_tofromqu
3000 def ConvertToQuadratic(self, theForce3d, theSubMesh=None):
3002 self.editor.ConvertToQuadraticObject(theForce3d,theSubMesh)
3004 self.editor.ConvertToQuadratic(theForce3d)
3006 ## Converts the mesh from quadratic to ordinary,
3007 # deletes old quadratic elements, \n replacing
3008 # them with ordinary mesh elements with the same id.
3009 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
3010 # @ingroup l2_modif_tofromqu
3011 def ConvertFromQuadratic(self, theSubMesh=None):
3013 self.editor.ConvertFromQuadraticObject(theSubMesh)
3015 return self.editor.ConvertFromQuadratic()
3017 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
3018 # @return TRUE if operation has been completed successfully, FALSE otherwise
3019 # @ingroup l2_modif_edit
3020 def Make2DMeshFrom3D(self):
3021 return self.editor. Make2DMeshFrom3D()
3023 ## Creates missing boundary elements
3024 # @param elements - elements whose boundary is to be checked:
3025 # mesh, group, sub-mesh or list of elements
3026 # if elements is mesh, it must be the mesh whose MakeBoundaryMesh() is called
3027 # @param dimension - defines type of boundary elements to create:
3028 # SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D
3029 # SMESH.BND_1DFROM3D creates mesh edges on all borders of free facets of 3D cells
3030 # @param groupName - a name of group to store created boundary elements in,
3031 # "" means not to create the group
3032 # @param meshName - a name of new mesh to store created boundary elements in,
3033 # "" means not to create the new mesh
3034 # @param toCopyElements - if true, the checked elements will be copied into
3035 # the new mesh else only boundary elements will be copied into the new mesh
3036 # @param toCopyExistingBondary - if true, not only new but also pre-existing
3037 # boundary elements will be copied into the new mesh
3038 # @return tuple (mesh, group) where bondary elements were added to
3039 # @ingroup l2_modif_edit
3040 def MakeBoundaryMesh(self, elements, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3041 toCopyElements=False, toCopyExistingBondary=False):
3042 if isinstance( elements, Mesh ):
3043 elements = elements.GetMesh()
3044 if ( isinstance( elements, list )):
3045 elemType = SMESH.ALL
3046 if elements: elemType = self.GetElementType( elements[0], iselem=True)
3047 elements = self.editor.MakeIDSource(elements, elemType)
3048 mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName,
3049 toCopyElements,toCopyExistingBondary)
3050 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3054 # @brief Creates missing boundary elements around either the whole mesh or
3055 # groups of 2D elements
3056 # @param dimension - defines type of boundary elements to create
3057 # @param groupName - a name of group to store all boundary elements in,
3058 # "" means not to create the group
3059 # @param meshName - a name of a new mesh, which is a copy of the initial
3060 # mesh + created boundary elements; "" means not to create the new mesh
3061 # @param toCopyAll - if true, the whole initial mesh will be copied into
3062 # the new mesh else only boundary elements will be copied into the new mesh
3063 # @param groups - groups of 2D elements to make boundary around
3064 # @retval tuple( long, mesh, groups )
3065 # long - number of added boundary elements
3066 # mesh - the mesh where elements were added to
3067 # group - the group of boundary elements or None
3069 def MakeBoundaryElements(self, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3070 toCopyAll=False, groups=[]):
3071 nb, mesh, group = self.editor.MakeBoundaryElements(dimension,groupName,meshName,
3073 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3074 return nb, mesh, group
3076 ## Renumber mesh nodes
3077 # @ingroup l2_modif_renumber
3078 def RenumberNodes(self):
3079 self.editor.RenumberNodes()
3081 ## Renumber mesh elements
3082 # @ingroup l2_modif_renumber
3083 def RenumberElements(self):
3084 self.editor.RenumberElements()
3086 ## Generates new elements by rotation of the elements around the axis
3087 # @param IDsOfElements the list of ids of elements to sweep
3088 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3089 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
3090 # @param NbOfSteps the number of steps
3091 # @param Tolerance tolerance
3092 # @param MakeGroups forces the generation of new groups from existing ones
3093 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3094 # of all steps, else - size of each step
3095 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3096 # @ingroup l2_modif_extrurev
3097 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
3098 MakeGroups=False, TotalAngle=False):
3099 if IDsOfElements == []:
3100 IDsOfElements = self.GetElementsId()
3101 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3102 Axis = self.smeshpyD.GetAxisStruct(Axis)
3103 AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians)
3104 NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance)
3105 Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters
3106 self.mesh.SetParameters(Parameters)
3107 if TotalAngle and NbOfSteps:
3108 AngleInRadians /= NbOfSteps
3110 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
3111 AngleInRadians, NbOfSteps, Tolerance)
3112 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
3115 ## Generates new elements by rotation of the elements of object around the axis
3116 # @param theObject object which elements should be sweeped.
3117 # It can be a mesh, a sub mesh or a group.
3118 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3119 # @param AngleInRadians the angle of Rotation
3120 # @param NbOfSteps number of steps
3121 # @param Tolerance tolerance
3122 # @param MakeGroups forces the generation of new groups from existing ones
3123 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3124 # of all steps, else - size of each step
3125 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3126 # @ingroup l2_modif_extrurev
3127 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3128 MakeGroups=False, TotalAngle=False):
3129 if ( isinstance( theObject, Mesh )):
3130 theObject = theObject.GetMesh()
3131 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3132 Axis = self.smeshpyD.GetAxisStruct(Axis)
3133 AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians)
3134 NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance)
3135 Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters
3136 self.mesh.SetParameters(Parameters)
3137 if TotalAngle and NbOfSteps:
3138 AngleInRadians /= NbOfSteps
3140 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
3141 NbOfSteps, Tolerance)
3142 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3145 ## Generates new elements by rotation of the elements of object around the axis
3146 # @param theObject object which elements should be sweeped.
3147 # It can be a mesh, a sub mesh or a group.
3148 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3149 # @param AngleInRadians the angle of Rotation
3150 # @param NbOfSteps number of steps
3151 # @param Tolerance tolerance
3152 # @param MakeGroups forces the generation of new groups from existing ones
3153 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3154 # of all steps, else - size of each step
3155 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3156 # @ingroup l2_modif_extrurev
3157 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3158 MakeGroups=False, TotalAngle=False):
3159 if ( isinstance( theObject, Mesh )):
3160 theObject = theObject.GetMesh()
3161 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3162 Axis = self.smeshpyD.GetAxisStruct(Axis)
3163 AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians)
3164 NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance)
3165 Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters
3166 self.mesh.SetParameters(Parameters)
3167 if TotalAngle and NbOfSteps:
3168 AngleInRadians /= NbOfSteps
3170 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
3171 NbOfSteps, Tolerance)
3172 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3175 ## Generates new elements by rotation of the elements of object around the axis
3176 # @param theObject object which elements should be sweeped.
3177 # It can be a mesh, a sub mesh or a group.
3178 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3179 # @param AngleInRadians the angle of Rotation
3180 # @param NbOfSteps number of steps
3181 # @param Tolerance tolerance
3182 # @param MakeGroups forces the generation of new groups from existing ones
3183 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3184 # of all steps, else - size of each step
3185 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3186 # @ingroup l2_modif_extrurev
3187 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3188 MakeGroups=False, TotalAngle=False):
3189 if ( isinstance( theObject, Mesh )):
3190 theObject = theObject.GetMesh()
3191 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3192 Axis = self.smeshpyD.GetAxisStruct(Axis)
3193 AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians)
3194 NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance)
3195 Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters
3196 self.mesh.SetParameters(Parameters)
3197 if TotalAngle and NbOfSteps:
3198 AngleInRadians /= NbOfSteps
3200 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
3201 NbOfSteps, Tolerance)
3202 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3205 ## Generates new elements by extrusion of the elements with given ids
3206 # @param IDsOfElements the list of elements ids for extrusion
3207 # @param StepVector vector or DirStruct or 3 vector components, defining
3208 # the direction and value of extrusion for one step (the total extrusion
3209 # length will be NbOfSteps * ||StepVector||)
3210 # @param NbOfSteps the number of steps
3211 # @param MakeGroups forces the generation of new groups from existing ones
3212 # @param IsNodes is True if elements with given ids are nodes
3213 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3214 # @ingroup l2_modif_extrurev
3215 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False, IsNodes = False):
3216 if IDsOfElements == []:
3217 IDsOfElements = self.GetElementsId()
3218 if isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object):
3219 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3220 if isinstance( StepVector, list ):
3221 StepVector = self.smeshpyD.MakeDirStruct(*StepVector)
3222 NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
3223 Parameters = StepVector.PS.parameters + var_separator + Parameters
3224 self.mesh.SetParameters(Parameters)
3227 return self.editor.ExtrusionSweepMakeGroups0D(IDsOfElements, StepVector, NbOfSteps)
3229 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
3231 self.editor.ExtrusionSweep0D(IDsOfElements, StepVector, NbOfSteps)
3233 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
3236 ## Generates new elements by extrusion of the elements with given ids
3237 # @param IDsOfElements is ids of elements
3238 # @param StepVector vector or DirStruct or 3 vector components, defining
3239 # the direction and value of extrusion for one step (the total extrusion
3240 # length will be NbOfSteps * ||StepVector||)
3241 # @param NbOfSteps the number of steps
3242 # @param ExtrFlags sets flags for extrusion
3243 # @param SewTolerance uses for comparing locations of nodes if flag
3244 # EXTRUSION_FLAG_SEW is set
3245 # @param MakeGroups forces the generation of new groups from existing ones
3246 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3247 # @ingroup l2_modif_extrurev
3248 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
3249 ExtrFlags, SewTolerance, MakeGroups=False):
3250 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3251 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3252 if isinstance( StepVector, list ):
3253 StepVector = self.smeshpyD.MakeDirStruct(*StepVector)
3255 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
3256 ExtrFlags, SewTolerance)
3257 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
3258 ExtrFlags, SewTolerance)
3261 ## Generates new elements by extrusion of the elements which belong to the object
3262 # @param theObject the object which elements should be processed.
3263 # It can be a mesh, a sub mesh or a group.
3264 # @param StepVector vector or DirStruct or 3 vector components, defining
3265 # the direction and value of extrusion for one step (the total extrusion
3266 # length will be NbOfSteps * ||StepVector||)
3267 # @param NbOfSteps the number of steps
3268 # @param MakeGroups forces the generation of new groups from existing ones
3269 # @param IsNodes is True if elements which belong to the object are nodes
3270 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3271 # @ingroup l2_modif_extrurev
3272 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False, IsNodes=False):
3273 if ( isinstance( theObject, Mesh )):
3274 theObject = theObject.GetMesh()
3275 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3276 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3277 if isinstance( StepVector, list ):
3278 StepVector = self.smeshpyD.MakeDirStruct(*StepVector)
3279 NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
3280 Parameters = StepVector.PS.parameters + var_separator + Parameters
3281 self.mesh.SetParameters(Parameters)
3284 return self.editor.ExtrusionSweepObject0DMakeGroups(theObject, StepVector, NbOfSteps)
3286 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3288 self.editor.ExtrusionSweepObject0D(theObject, StepVector, NbOfSteps)
3290 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
3293 ## Generates new elements by extrusion of the elements which belong to the object
3294 # @param theObject object which elements should be processed.
3295 # It can be a mesh, a sub mesh or a group.
3296 # @param StepVector vector or DirStruct or 3 vector components, defining
3297 # the direction and value of extrusion for one step (the total extrusion
3298 # length will be NbOfSteps * ||StepVector||)
3299 # @param NbOfSteps the number of steps
3300 # @param MakeGroups to generate new groups from existing ones
3301 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3302 # @ingroup l2_modif_extrurev
3303 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3304 if ( isinstance( theObject, Mesh )):
3305 theObject = theObject.GetMesh()
3306 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3307 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3308 if isinstance( StepVector, list ):
3309 StepVector = self.smeshpyD.MakeDirStruct(*StepVector)
3310 NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
3311 Parameters = StepVector.PS.parameters + var_separator + Parameters
3312 self.mesh.SetParameters(Parameters)
3314 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3315 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3318 ## Generates new elements by extrusion of the elements which belong to the object
3319 # @param theObject object which elements should be processed.
3320 # It can be a mesh, a sub mesh or a group.
3321 # @param StepVector vector or DirStruct or 3 vector components, defining
3322 # the direction and value of extrusion for one step (the total extrusion
3323 # length will be NbOfSteps * ||StepVector||)
3324 # @param NbOfSteps the number of steps
3325 # @param MakeGroups forces the generation of new groups from existing ones
3326 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3327 # @ingroup l2_modif_extrurev
3328 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3329 if ( isinstance( theObject, Mesh )):
3330 theObject = theObject.GetMesh()
3331 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3332 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3333 if isinstance( StepVector, list ):
3334 StepVector = self.smeshpyD.MakeDirStruct(*StepVector)
3335 NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
3336 Parameters = StepVector.PS.parameters + var_separator + Parameters
3337 self.mesh.SetParameters(Parameters)
3339 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3340 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3345 ## Generates new elements by extrusion of the given elements
3346 # The path of extrusion must be a meshed edge.
3347 # @param Base mesh or group, or submesh, or list of ids of elements for extrusion
3348 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3349 # @param NodeStart the start node from Path. Defines the direction of extrusion
3350 # @param HasAngles allows the shape to be rotated around the path
3351 # to get the resulting mesh in a helical fashion
3352 # @param Angles list of angles in radians
3353 # @param LinearVariation forces the computation of rotation angles as linear
3354 # variation of the given Angles along path steps
3355 # @param HasRefPoint allows using the reference point
3356 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3357 # The User can specify any point as the Reference Point.
3358 # @param MakeGroups forces the generation of new groups from existing ones
3359 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3360 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3361 # only SMESH::Extrusion_Error otherwise
3362 # @ingroup l2_modif_extrurev
3363 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3364 HasAngles, Angles, LinearVariation,
3365 HasRefPoint, RefPoint, MakeGroups, ElemType):
3366 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3367 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3369 Angles,AnglesParameters,hasVars = ParseAngles(Angles)
3370 Parameters = AnglesParameters + var_separator + RefPoint.parameters
3371 self.mesh.SetParameters(Parameters)
3373 if (isinstance(Path, Mesh)): Path = Path.GetMesh()
3375 if isinstance(Base, list):
3377 if Base == []: IDsOfElements = self.GetElementsId()
3378 else: IDsOfElements = Base
3379 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3380 HasAngles, Angles, LinearVariation,
3381 HasRefPoint, RefPoint, MakeGroups, ElemType)
3383 if isinstance(Base, Mesh): Base = Base.GetMesh()
3384 if isinstance(Base, SMESH._objref_SMESH_Mesh) or isinstance(Base, SMESH._objref_SMESH_Group) or isinstance(Base, SMESH._objref_SMESH_subMesh):
3385 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3386 HasAngles, Angles, LinearVariation,
3387 HasRefPoint, RefPoint, MakeGroups, ElemType)
3389 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3392 ## Generates new elements by extrusion of the given elements
3393 # The path of extrusion must be a meshed edge.
3394 # @param IDsOfElements ids of elements
3395 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3396 # @param PathShape shape(edge) defines the sub-mesh for the path
3397 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3398 # @param HasAngles allows the shape to be rotated around the path
3399 # to get the resulting mesh in a helical fashion
3400 # @param Angles list of angles in radians
3401 # @param HasRefPoint allows using the reference point
3402 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3403 # The User can specify any point as the Reference Point.
3404 # @param MakeGroups forces the generation of new groups from existing ones
3405 # @param LinearVariation forces the computation of rotation angles as linear
3406 # variation of the given Angles along path steps
3407 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3408 # only SMESH::Extrusion_Error otherwise
3409 # @ingroup l2_modif_extrurev
3410 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3411 HasAngles, Angles, HasRefPoint, RefPoint,
3412 MakeGroups=False, LinearVariation=False):
3413 if IDsOfElements == []:
3414 IDsOfElements = self.GetElementsId()
3415 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3416 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3418 if ( isinstance( PathMesh, Mesh )):
3419 PathMesh = PathMesh.GetMesh()
3420 Angles,AnglesParameters,hasVars = ParseAngles(Angles)
3421 Parameters = AnglesParameters + var_separator + RefPoint.parameters
3422 self.mesh.SetParameters(Parameters)
3423 if HasAngles and Angles and LinearVariation:
3424 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3427 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3428 PathShape, NodeStart, HasAngles,
3429 Angles, HasRefPoint, RefPoint)
3430 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3431 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3433 ## Generates new elements by extrusion of the elements which belong to the object
3434 # The path of extrusion must be a meshed edge.
3435 # @param theObject the object which elements should be processed.
3436 # It can be a mesh, a sub mesh or a group.
3437 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3438 # @param PathShape shape(edge) defines the sub-mesh for the path
3439 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3440 # @param HasAngles allows the shape to be rotated around the path
3441 # to get the resulting mesh in a helical fashion
3442 # @param Angles list of angles
3443 # @param HasRefPoint allows using the reference point
3444 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3445 # The User can specify any point as the Reference Point.
3446 # @param MakeGroups forces the generation of new groups from existing ones
3447 # @param LinearVariation forces the computation of rotation angles as linear
3448 # variation of the given Angles along path steps
3449 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3450 # only SMESH::Extrusion_Error otherwise
3451 # @ingroup l2_modif_extrurev
3452 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3453 HasAngles, Angles, HasRefPoint, RefPoint,
3454 MakeGroups=False, LinearVariation=False):
3455 if ( isinstance( theObject, Mesh )):
3456 theObject = theObject.GetMesh()
3457 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3458 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3459 if ( isinstance( PathMesh, Mesh )):
3460 PathMesh = PathMesh.GetMesh()
3461 Angles,AnglesParameters,hasVars = ParseAngles(Angles)
3462 Parameters = AnglesParameters + var_separator + RefPoint.parameters
3463 self.mesh.SetParameters(Parameters)
3464 if HasAngles and Angles and LinearVariation:
3465 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3468 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3469 PathShape, NodeStart, HasAngles,
3470 Angles, HasRefPoint, RefPoint)
3471 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3472 NodeStart, HasAngles, Angles, HasRefPoint,
3475 ## Generates new elements by extrusion of the elements which belong to the object
3476 # The path of extrusion must be a meshed edge.
3477 # @param theObject the object which elements should be processed.
3478 # It can be a mesh, a sub mesh or a group.
3479 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3480 # @param PathShape shape(edge) defines the sub-mesh for the path
3481 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3482 # @param HasAngles allows the shape to be rotated around the path
3483 # to get the resulting mesh in a helical fashion
3484 # @param Angles list of angles
3485 # @param HasRefPoint allows using the reference point
3486 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3487 # The User can specify any point as the Reference Point.
3488 # @param MakeGroups forces the generation of new groups from existing ones
3489 # @param LinearVariation forces the computation of rotation angles as linear
3490 # variation of the given Angles along path steps
3491 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3492 # only SMESH::Extrusion_Error otherwise
3493 # @ingroup l2_modif_extrurev
3494 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3495 HasAngles, Angles, HasRefPoint, RefPoint,
3496 MakeGroups=False, LinearVariation=False):
3497 if ( isinstance( theObject, Mesh )):
3498 theObject = theObject.GetMesh()
3499 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3500 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3501 if ( isinstance( PathMesh, Mesh )):
3502 PathMesh = PathMesh.GetMesh()
3503 Angles,AnglesParameters,hasVars = ParseAngles(Angles)
3504 Parameters = AnglesParameters + var_separator + RefPoint.parameters
3505 self.mesh.SetParameters(Parameters)
3506 if HasAngles and Angles and LinearVariation:
3507 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3510 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3511 PathShape, NodeStart, HasAngles,
3512 Angles, HasRefPoint, RefPoint)
3513 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3514 NodeStart, HasAngles, Angles, HasRefPoint,
3517 ## Generates new elements by extrusion of the elements which belong to the object
3518 # The path of extrusion must be a meshed edge.
3519 # @param theObject the object which elements should be processed.
3520 # It can be a mesh, a sub mesh or a group.
3521 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3522 # @param PathShape shape(edge) defines the sub-mesh for the path
3523 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3524 # @param HasAngles allows the shape to be rotated around the path
3525 # to get the resulting mesh in a helical fashion
3526 # @param Angles list of angles
3527 # @param HasRefPoint allows using the reference point
3528 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3529 # The User can specify any point as the Reference Point.
3530 # @param MakeGroups forces the generation of new groups from existing ones
3531 # @param LinearVariation forces the computation of rotation angles as linear
3532 # variation of the given Angles along path steps
3533 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3534 # only SMESH::Extrusion_Error otherwise
3535 # @ingroup l2_modif_extrurev
3536 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3537 HasAngles, Angles, HasRefPoint, RefPoint,
3538 MakeGroups=False, LinearVariation=False):
3539 if ( isinstance( theObject, Mesh )):
3540 theObject = theObject.GetMesh()
3541 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3542 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3543 if ( isinstance( PathMesh, Mesh )):
3544 PathMesh = PathMesh.GetMesh()
3545 Angles,AnglesParameters,hasVars = ParseAngles(Angles)
3546 Parameters = AnglesParameters + var_separator + RefPoint.parameters
3547 self.mesh.SetParameters(Parameters)
3548 if HasAngles and Angles and LinearVariation:
3549 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3552 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3553 PathShape, NodeStart, HasAngles,
3554 Angles, HasRefPoint, RefPoint)
3555 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3556 NodeStart, HasAngles, Angles, HasRefPoint,
3559 ## Creates a symmetrical copy of mesh elements
3560 # @param IDsOfElements list of elements ids
3561 # @param Mirror is AxisStruct or geom object(point, line, plane)
3562 # @param theMirrorType is POINT, AXIS or PLANE
3563 # If the Mirror is a geom object this parameter is unnecessary
3564 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3565 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3566 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3567 # @ingroup l2_modif_trsf
3568 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3569 if IDsOfElements == []:
3570 IDsOfElements = self.GetElementsId()
3571 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3572 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3573 self.mesh.SetParameters(Mirror.parameters)
3574 if Copy and MakeGroups:
3575 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3576 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3579 ## Creates a new mesh by a symmetrical copy of mesh elements
3580 # @param IDsOfElements the list of elements ids
3581 # @param Mirror is AxisStruct or geom object (point, line, plane)
3582 # @param theMirrorType is POINT, AXIS or PLANE
3583 # If the Mirror is a geom object this parameter is unnecessary
3584 # @param MakeGroups to generate new groups from existing ones
3585 # @param NewMeshName a name of the new mesh to create
3586 # @return instance of Mesh class
3587 # @ingroup l2_modif_trsf
3588 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3589 if IDsOfElements == []:
3590 IDsOfElements = self.GetElementsId()
3591 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3592 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3593 self.mesh.SetParameters(Mirror.parameters)
3594 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3595 MakeGroups, NewMeshName)
3596 return Mesh(self.smeshpyD,self.geompyD,mesh)
3598 ## Creates a symmetrical copy of the object
3599 # @param theObject mesh, submesh or group
3600 # @param Mirror AxisStruct or geom object (point, line, plane)
3601 # @param theMirrorType is POINT, AXIS or PLANE
3602 # If the Mirror is a geom object this parameter is unnecessary
3603 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3604 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3605 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3606 # @ingroup l2_modif_trsf
3607 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3608 if ( isinstance( theObject, Mesh )):
3609 theObject = theObject.GetMesh()
3610 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3611 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3612 self.mesh.SetParameters(Mirror.parameters)
3613 if Copy and MakeGroups:
3614 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3615 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3618 ## Creates a new mesh by a symmetrical copy of the object
3619 # @param theObject mesh, submesh or group
3620 # @param Mirror AxisStruct or geom object (point, line, plane)
3621 # @param theMirrorType POINT, AXIS or PLANE
3622 # If the Mirror is a geom object this parameter is unnecessary
3623 # @param MakeGroups forces the generation of new groups from existing ones
3624 # @param NewMeshName the name of the new mesh to create
3625 # @return instance of Mesh class
3626 # @ingroup l2_modif_trsf
3627 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3628 if ( isinstance( theObject, Mesh )):
3629 theObject = theObject.GetMesh()
3630 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3631 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3632 self.mesh.SetParameters(Mirror.parameters)
3633 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3634 MakeGroups, NewMeshName)
3635 return Mesh( self.smeshpyD,self.geompyD,mesh )
3637 ## Translates the elements
3638 # @param IDsOfElements list of elements ids
3639 # @param Vector the direction of translation (DirStruct or vector)
3640 # @param Copy allows copying the translated elements
3641 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3642 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3643 # @ingroup l2_modif_trsf
3644 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3645 if IDsOfElements == []:
3646 IDsOfElements = self.GetElementsId()
3647 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3648 Vector = self.smeshpyD.GetDirStruct(Vector)
3649 self.mesh.SetParameters(Vector.PS.parameters)
3650 if Copy and MakeGroups:
3651 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3652 self.editor.Translate(IDsOfElements, Vector, Copy)
3655 ## Creates a new mesh of translated elements
3656 # @param IDsOfElements list of elements ids
3657 # @param Vector the direction of translation (DirStruct or vector)
3658 # @param MakeGroups forces the generation of new groups from existing ones
3659 # @param NewMeshName the name of the newly created mesh
3660 # @return instance of Mesh class
3661 # @ingroup l2_modif_trsf
3662 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3663 if IDsOfElements == []:
3664 IDsOfElements = self.GetElementsId()
3665 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3666 Vector = self.smeshpyD.GetDirStruct(Vector)
3667 self.mesh.SetParameters(Vector.PS.parameters)
3668 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3669 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3671 ## Translates the object
3672 # @param theObject the object to translate (mesh, submesh, or group)
3673 # @param Vector direction of translation (DirStruct or geom vector)
3674 # @param Copy allows copying the translated elements
3675 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3676 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3677 # @ingroup l2_modif_trsf
3678 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3679 if ( isinstance( theObject, Mesh )):
3680 theObject = theObject.GetMesh()
3681 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3682 Vector = self.smeshpyD.GetDirStruct(Vector)
3683 self.mesh.SetParameters(Vector.PS.parameters)
3684 if Copy and MakeGroups:
3685 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3686 self.editor.TranslateObject(theObject, Vector, Copy)
3689 ## Creates a new mesh from the translated object
3690 # @param theObject the object to translate (mesh, submesh, or group)
3691 # @param Vector the direction of translation (DirStruct or geom vector)
3692 # @param MakeGroups forces the generation of new groups from existing ones
3693 # @param NewMeshName the name of the newly created mesh
3694 # @return instance of Mesh class
3695 # @ingroup l2_modif_trsf
3696 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3697 if (isinstance(theObject, Mesh)):
3698 theObject = theObject.GetMesh()
3699 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3700 Vector = self.smeshpyD.GetDirStruct(Vector)
3701 self.mesh.SetParameters(Vector.PS.parameters)
3702 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3703 return Mesh( self.smeshpyD, self.geompyD, mesh )
3707 ## Scales the object
3708 # @param theObject - the object to translate (mesh, submesh, or group)
3709 # @param thePoint - base point for scale
3710 # @param theScaleFact - list of 1-3 scale factors for axises
3711 # @param Copy - allows copying the translated elements
3712 # @param MakeGroups - forces the generation of new groups from existing
3714 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3715 # empty list otherwise
3716 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3717 if ( isinstance( theObject, Mesh )):
3718 theObject = theObject.GetMesh()
3719 if ( isinstance( theObject, list )):
3720 theObject = self.GetIDSource(theObject, SMESH.ALL)
3721 if ( isinstance( theScaleFact, float )):
3722 theScaleFact = [theScaleFact]
3723 if ( isinstance( theScaleFact, int )):
3724 theScaleFact = [ float(theScaleFact)]
3726 self.mesh.SetParameters(thePoint.parameters)
3728 if Copy and MakeGroups:
3729 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3730 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3733 ## Creates a new mesh from the translated object
3734 # @param theObject - the object to translate (mesh, submesh, or group)
3735 # @param thePoint - base point for scale
3736 # @param theScaleFact - list of 1-3 scale factors for axises
3737 # @param MakeGroups - forces the generation of new groups from existing ones
3738 # @param NewMeshName - the name of the newly created mesh
3739 # @return instance of Mesh class
3740 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3741 if (isinstance(theObject, Mesh)):
3742 theObject = theObject.GetMesh()
3743 if ( isinstance( theObject, list )):
3744 theObject = self.GetIDSource(theObject,SMESH.ALL)
3745 if ( isinstance( theScaleFact, float )):
3746 theScaleFact = [theScaleFact]
3747 if ( isinstance( theScaleFact, int )):
3748 theScaleFact = [ float(theScaleFact)]
3750 self.mesh.SetParameters(thePoint.parameters)
3751 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3752 MakeGroups, NewMeshName)
3753 return Mesh( self.smeshpyD, self.geompyD, mesh )
3757 ## Rotates the elements
3758 # @param IDsOfElements list of elements ids
3759 # @param Axis the axis of rotation (AxisStruct or geom line)
3760 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3761 # @param Copy allows copying the rotated elements
3762 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3763 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3764 # @ingroup l2_modif_trsf
3765 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3766 if IDsOfElements == []:
3767 IDsOfElements = self.GetElementsId()
3768 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3769 Axis = self.smeshpyD.GetAxisStruct(Axis)
3770 AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians)
3771 Parameters = Axis.parameters + var_separator + Parameters
3772 self.mesh.SetParameters(Parameters)
3773 if Copy and MakeGroups:
3774 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3775 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3778 ## Creates a new mesh of rotated elements
3779 # @param IDsOfElements list of element ids
3780 # @param Axis the axis of rotation (AxisStruct or geom line)
3781 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3782 # @param MakeGroups forces the generation of new groups from existing ones
3783 # @param NewMeshName the name of the newly created mesh
3784 # @return instance of Mesh class
3785 # @ingroup l2_modif_trsf
3786 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3787 if IDsOfElements == []:
3788 IDsOfElements = self.GetElementsId()
3789 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3790 Axis = self.smeshpyD.GetAxisStruct(Axis)
3791 AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians)
3792 Parameters = Axis.parameters + var_separator + Parameters
3793 self.mesh.SetParameters(Parameters)
3794 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3795 MakeGroups, NewMeshName)
3796 return Mesh( self.smeshpyD, self.geompyD, mesh )
3798 ## Rotates the object
3799 # @param theObject the object to rotate( mesh, submesh, or group)
3800 # @param Axis the axis of rotation (AxisStruct or geom line)
3801 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3802 # @param Copy allows copying the rotated elements
3803 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3804 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3805 # @ingroup l2_modif_trsf
3806 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3807 if (isinstance(theObject, Mesh)):
3808 theObject = theObject.GetMesh()
3809 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3810 Axis = self.smeshpyD.GetAxisStruct(Axis)
3811 AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians)
3812 Parameters = Axis.parameters + ":" + Parameters
3813 self.mesh.SetParameters(Parameters)
3814 if Copy and MakeGroups:
3815 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3816 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3819 ## Creates a new mesh from the rotated object
3820 # @param theObject the object to rotate (mesh, submesh, or group)
3821 # @param Axis the axis of rotation (AxisStruct or geom line)
3822 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3823 # @param MakeGroups forces the generation of new groups from existing ones
3824 # @param NewMeshName the name of the newly created mesh
3825 # @return instance of Mesh class
3826 # @ingroup l2_modif_trsf
3827 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3828 if (isinstance( theObject, Mesh )):
3829 theObject = theObject.GetMesh()
3830 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3831 Axis = self.smeshpyD.GetAxisStruct(Axis)
3832 AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians)
3833 Parameters = Axis.parameters + ":" + Parameters
3834 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3835 MakeGroups, NewMeshName)
3836 self.mesh.SetParameters(Parameters)
3837 return Mesh( self.smeshpyD, self.geompyD, mesh )
3839 ## Finds groups of ajacent nodes within Tolerance.
3840 # @param Tolerance the value of tolerance
3841 # @return the list of groups of nodes
3842 # @ingroup l2_modif_trsf
3843 def FindCoincidentNodes (self, Tolerance):
3844 return self.editor.FindCoincidentNodes(Tolerance)
3846 ## Finds groups of ajacent nodes within Tolerance.
3847 # @param Tolerance the value of tolerance
3848 # @param SubMeshOrGroup SubMesh or Group
3849 # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
3850 # @return the list of groups of nodes
3851 # @ingroup l2_modif_trsf
3852 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
3853 if (isinstance( SubMeshOrGroup, Mesh )):
3854 SubMeshOrGroup = SubMeshOrGroup.GetMesh()
3855 if not isinstance( exceptNodes, list):
3856 exceptNodes = [ exceptNodes ]
3857 if exceptNodes and isinstance( exceptNodes[0], int):
3858 exceptNodes = [ self.GetIDSource( exceptNodes, SMESH.NODE)]
3859 return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes)
3862 # @param GroupsOfNodes the list of groups of nodes
3863 # @ingroup l2_modif_trsf
3864 def MergeNodes (self, GroupsOfNodes):
3865 self.editor.MergeNodes(GroupsOfNodes)
3867 ## Finds the elements built on the same nodes.
3868 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3869 # @return a list of groups of equal elements
3870 # @ingroup l2_modif_trsf
3871 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3872 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3873 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3874 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3876 ## Merges elements in each given group.
3877 # @param GroupsOfElementsID groups of elements for merging
3878 # @ingroup l2_modif_trsf
3879 def MergeElements(self, GroupsOfElementsID):
3880 self.editor.MergeElements(GroupsOfElementsID)
3882 ## Leaves one element and removes all other elements built on the same nodes.
3883 # @ingroup l2_modif_trsf
3884 def MergeEqualElements(self):
3885 self.editor.MergeEqualElements()
3887 ## Sews free borders
3888 # @return SMESH::Sew_Error
3889 # @ingroup l2_modif_trsf
3890 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3891 FirstNodeID2, SecondNodeID2, LastNodeID2,
3892 CreatePolygons, CreatePolyedrs):
3893 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3894 FirstNodeID2, SecondNodeID2, LastNodeID2,
3895 CreatePolygons, CreatePolyedrs)
3897 ## Sews conform free borders
3898 # @return SMESH::Sew_Error
3899 # @ingroup l2_modif_trsf
3900 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3901 FirstNodeID2, SecondNodeID2):
3902 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3903 FirstNodeID2, SecondNodeID2)
3905 ## Sews border to side
3906 # @return SMESH::Sew_Error
3907 # @ingroup l2_modif_trsf
3908 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3909 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3910 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3911 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3913 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3914 # merged with the nodes of elements of Side2.
3915 # The number of elements in theSide1 and in theSide2 must be
3916 # equal and they should have similar nodal connectivity.
3917 # The nodes to merge should belong to side borders and
3918 # the first node should be linked to the second.
3919 # @return SMESH::Sew_Error
3920 # @ingroup l2_modif_trsf
3921 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3922 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3923 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3924 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3925 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3926 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3928 ## Sets new nodes for the given element.
3929 # @param ide the element id
3930 # @param newIDs nodes ids
3931 # @return If the number of nodes does not correspond to the type of element - returns false
3932 # @ingroup l2_modif_edit
3933 def ChangeElemNodes(self, ide, newIDs):
3934 return self.editor.ChangeElemNodes(ide, newIDs)
3936 ## If during the last operation of MeshEditor some nodes were
3937 # created, this method returns the list of their IDs, \n
3938 # if new nodes were not created - returns empty list
3939 # @return the list of integer values (can be empty)
3940 # @ingroup l1_auxiliary
3941 def GetLastCreatedNodes(self):
3942 return self.editor.GetLastCreatedNodes()
3944 ## If during the last operation of MeshEditor some elements were
3945 # created this method returns the list of their IDs, \n
3946 # if new elements were not created - returns empty list
3947 # @return the list of integer values (can be empty)
3948 # @ingroup l1_auxiliary
3949 def GetLastCreatedElems(self):
3950 return self.editor.GetLastCreatedElems()
3952 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3953 # @param theNodes identifiers of nodes to be doubled
3954 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
3955 # nodes. If list of element identifiers is empty then nodes are doubled but
3956 # they not assigned to elements
3957 # @return TRUE if operation has been completed successfully, FALSE otherwise
3958 # @ingroup l2_modif_edit
3959 def DoubleNodes(self, theNodes, theModifiedElems):
3960 return self.editor.DoubleNodes(theNodes, theModifiedElems)
3962 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3963 # This method provided for convenience works as DoubleNodes() described above.
3964 # @param theNodeId identifiers of node to be doubled
3965 # @param theModifiedElems identifiers of elements to be updated
3966 # @return TRUE if operation has been completed successfully, FALSE otherwise
3967 # @ingroup l2_modif_edit
3968 def DoubleNode(self, theNodeId, theModifiedElems):
3969 return self.editor.DoubleNode(theNodeId, theModifiedElems)
3971 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3972 # This method provided for convenience works as DoubleNodes() described above.
3973 # @param theNodes group of nodes to be doubled
3974 # @param theModifiedElems group of elements to be updated.
3975 # @param theMakeGroup forces the generation of a group containing new nodes.
3976 # @return TRUE or a created group if operation has been completed successfully,
3977 # FALSE or None otherwise
3978 # @ingroup l2_modif_edit
3979 def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
3981 return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
3982 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3984 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3985 # This method provided for convenience works as DoubleNodes() described above.
3986 # @param theNodes list of groups of nodes to be doubled
3987 # @param theModifiedElems list of groups of elements to be updated.
3988 # @param theMakeGroup forces the generation of a group containing new nodes.
3989 # @return TRUE if operation has been completed successfully, FALSE otherwise
3990 # @ingroup l2_modif_edit
3991 def DoubleNodeGroups(self, theNodes, theModifiedElems, theMakeGroup=False):
3993 return self.editor.DoubleNodeGroupsNew(theNodes, theModifiedElems)
3994 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3996 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3997 # @param theElems - the list of elements (edges or faces) to be replicated
3998 # The nodes for duplication could be found from these elements
3999 # @param theNodesNot - list of nodes to NOT replicate
4000 # @param theAffectedElems - the list of elements (cells and edges) to which the
4001 # replicated nodes should be associated to.
4002 # @return TRUE if operation has been completed successfully, FALSE otherwise
4003 # @ingroup l2_modif_edit
4004 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
4005 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
4007 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4008 # @param theElems - the list of elements (edges or faces) to be replicated
4009 # The nodes for duplication could be found from these elements
4010 # @param theNodesNot - list of nodes to NOT replicate
4011 # @param theShape - shape to detect affected elements (element which geometric center
4012 # located on or inside shape).
4013 # The replicated nodes should be associated to affected elements.
4014 # @return TRUE if operation has been completed successfully, FALSE otherwise
4015 # @ingroup l2_modif_edit
4016 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
4017 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
4019 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4020 # This method provided for convenience works as DoubleNodes() described above.
4021 # @param theElems - group of of elements (edges or faces) to be replicated
4022 # @param theNodesNot - group of nodes not to replicated
4023 # @param theAffectedElems - group of elements to which the replicated nodes
4024 # should be associated to.
4025 # @param theMakeGroup forces the generation of a group containing new elements.
4026 # @param theMakeNodeGroup forces the generation of a group containing new nodes.
4027 # @return TRUE or created groups (one or two) if operation has been completed successfully,
4028 # FALSE or None otherwise
4029 # @ingroup l2_modif_edit
4030 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems,
4031 theMakeGroup=False, theMakeNodeGroup=False):
4032 if theMakeGroup or theMakeNodeGroup:
4033 twoGroups = self.editor.DoubleNodeElemGroup2New(theElems, theNodesNot,
4035 theMakeGroup, theMakeNodeGroup)
4036 if theMakeGroup and theMakeNodeGroup:
4039 return twoGroups[ int(theMakeNodeGroup) ]
4040 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
4042 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4043 # This method provided for convenience works as DoubleNodes() described above.
4044 # @param theElems - group of of elements (edges or faces) to be replicated
4045 # @param theNodesNot - group of nodes not to replicated
4046 # @param theShape - shape to detect affected elements (element which geometric center
4047 # located on or inside shape).
4048 # The replicated nodes should be associated to affected elements.
4049 # @ingroup l2_modif_edit
4050 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
4051 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
4053 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4054 # This method provided for convenience works as DoubleNodes() described above.
4055 # @param theElems - list of groups of elements (edges or faces) to be replicated
4056 # @param theNodesNot - list of groups of nodes not to replicated
4057 # @param theAffectedElems - group of elements to which the replicated nodes
4058 # should be associated to.
4059 # @param theMakeGroup forces the generation of a group containing new elements.
4060 # @param theMakeNodeGroup forces the generation of a group containing new nodes.
4061 # @return TRUE or created groups (one or two) if operation has been completed successfully,
4062 # FALSE or None otherwise
4063 # @ingroup l2_modif_edit
4064 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems,
4065 theMakeGroup=False, theMakeNodeGroup=False):
4066 if theMakeGroup or theMakeNodeGroup:
4067 twoGroups = self.editor.DoubleNodeElemGroups2New(theElems, theNodesNot,
4069 theMakeGroup, theMakeNodeGroup)
4070 if theMakeGroup and theMakeNodeGroup:
4073 return twoGroups[ int(theMakeNodeGroup) ]
4074 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
4076 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4077 # This method provided for convenience works as DoubleNodes() described above.
4078 # @param theElems - list of groups of elements (edges or faces) to be replicated
4079 # @param theNodesNot - list of groups of nodes not to replicated
4080 # @param theShape - shape to detect affected elements (element which geometric center
4081 # located on or inside shape).
4082 # The replicated nodes should be associated to affected elements.
4083 # @return TRUE if operation has been completed successfully, FALSE otherwise
4084 # @ingroup l2_modif_edit
4085 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
4086 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
4088 ## Identify the elements that will be affected by node duplication (actual duplication is not performed.
4089 # This method is the first step of DoubleNodeElemGroupsInRegion.
4090 # @param theElems - list of groups of elements (edges or faces) to be replicated
4091 # @param theNodesNot - list of groups of nodes not to replicated
4092 # @param theShape - shape to detect affected elements (element which geometric center
4093 # located on or inside shape).
4094 # The replicated nodes should be associated to affected elements.
4095 # @return groups of affected elements
4096 # @ingroup l2_modif_edit
4097 def AffectedElemGroupsInRegion(self, theElems, theNodesNot, theShape):
4098 return self.editor.AffectedElemGroupsInRegion(theElems, theNodesNot, theShape)
4100 ## Double nodes on shared faces between groups of volumes and create flat elements on demand.
4101 # The list of groups must describe a partition of the mesh volumes.
4102 # The nodes of the internal faces at the boundaries of the groups are doubled.
4103 # In option, the internal faces are replaced by flat elements.
4104 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4105 # @param theDomains - list of groups of volumes
4106 # @param createJointElems - if TRUE, create the elements
4107 # @return TRUE if operation has been completed successfully, FALSE otherwise
4108 def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems ):
4109 return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems )
4111 ## Double nodes on some external faces and create flat elements.
4112 # Flat elements are mainly used by some types of mechanic calculations.
4114 # Each group of the list must be constituted of faces.
4115 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4116 # @param theGroupsOfFaces - list of groups of faces
4117 # @return TRUE if operation has been completed successfully, FALSE otherwise
4118 def CreateFlatElementsOnFacesGroups(self, theGroupsOfFaces ):
4119 return self.editor.CreateFlatElementsOnFacesGroups( theGroupsOfFaces )
4121 ## identify all the elements around a geom shape, get the faces delimiting the hole
4123 def CreateHoleSkin(self, radius, theShape, groupName, theNodesCoords):
4124 return self.editor.CreateHoleSkin( radius, theShape, groupName, theNodesCoords )
4126 def _getFunctor(self, funcType ):
4127 fn = self.functors[ funcType._v ]
4129 fn = self.smeshpyD.GetFunctor(funcType)
4130 fn.SetMesh(self.mesh)
4131 self.functors[ funcType._v ] = fn
4134 def _valueFromFunctor(self, funcType, elemId):
4135 fn = self._getFunctor( funcType )
4136 if fn.GetElementType() == self.GetElementType(elemId, True):
4137 val = fn.GetValue(elemId)
4142 ## Get length of 1D element.
4143 # @param elemId mesh element ID
4144 # @return element's length value
4145 # @ingroup l1_measurements
4146 def GetLength(self, elemId):
4147 return self._valueFromFunctor(SMESH.FT_Length, elemId)
4149 ## Get area of 2D element.
4150 # @param elemId mesh element ID
4151 # @return element's area value
4152 # @ingroup l1_measurements
4153 def GetArea(self, elemId):
4154 return self._valueFromFunctor(SMESH.FT_Area, elemId)
4156 ## Get volume of 3D element.
4157 # @param elemId mesh element ID
4158 # @return element's volume value
4159 # @ingroup l1_measurements
4160 def GetVolume(self, elemId):
4161 return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
4163 ## Get maximum element length.
4164 # @param elemId mesh element ID
4165 # @return element's maximum length value
4166 # @ingroup l1_measurements
4167 def GetMaxElementLength(self, elemId):
4168 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4169 ftype = SMESH.FT_MaxElementLength3D
4171 ftype = SMESH.FT_MaxElementLength2D
4172 return self._valueFromFunctor(ftype, elemId)
4174 ## Get aspect ratio of 2D or 3D element.
4175 # @param elemId mesh element ID
4176 # @return element's aspect ratio value
4177 # @ingroup l1_measurements
4178 def GetAspectRatio(self, elemId):
4179 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4180 ftype = SMESH.FT_AspectRatio3D
4182 ftype = SMESH.FT_AspectRatio
4183 return self._valueFromFunctor(ftype, elemId)
4185 ## Get warping angle of 2D element.
4186 # @param elemId mesh element ID
4187 # @return element's warping angle value
4188 # @ingroup l1_measurements
4189 def GetWarping(self, elemId):
4190 return self._valueFromFunctor(SMESH.FT_Warping, elemId)
4192 ## Get minimum angle of 2D element.
4193 # @param elemId mesh element ID
4194 # @return element's minimum angle value
4195 # @ingroup l1_measurements
4196 def GetMinimumAngle(self, elemId):
4197 return self._valueFromFunctor(SMESH.FT_MinimumAngle, elemId)
4199 ## Get taper of 2D element.
4200 # @param elemId mesh element ID
4201 # @return element's taper value
4202 # @ingroup l1_measurements
4203 def GetTaper(self, elemId):
4204 return self._valueFromFunctor(SMESH.FT_Taper, elemId)
4206 ## Get skew of 2D element.
4207 # @param elemId mesh element ID
4208 # @return element's skew value
4209 # @ingroup l1_measurements
4210 def GetSkew(self, elemId):
4211 return self._valueFromFunctor(SMESH.FT_Skew, elemId)
4213 pass # end of Mesh class
4215 ## Helper class for wrapping of SMESH.SMESH_Pattern CORBA class
4217 class Pattern(SMESH._objref_SMESH_Pattern):
4219 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
4220 decrFun = lambda i: i-1
4221 theNodeIndexOnKeyPoint1,Parameters,hasVars = ParseParameters(theNodeIndexOnKeyPoint1, decrFun)
4222 theMesh.SetParameters(Parameters)
4223 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
4225 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
4226 decrFun = lambda i: i-1
4227 theNode000Index,theNode001Index,Parameters,hasVars = ParseParameters(theNode000Index,theNode001Index, decrFun)
4228 theMesh.SetParameters(Parameters)
4229 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
4231 # Registering the new proxy for Pattern
4232 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)
4234 ## Private class used to bind methods creating algorithms to the class Mesh
4239 self.defaultAlgoType = ""
4240 self.algoTypeToClass = {}
4242 # Stores a python class of algorithm
4243 def add(self, algoClass):
4244 if type( algoClass ).__name__ == 'classobj' and \
4245 hasattr( algoClass, "algoType"):
4246 self.algoTypeToClass[ algoClass.algoType ] = algoClass
4247 if not self.defaultAlgoType and \
4248 hasattr( algoClass, "isDefault") and algoClass.isDefault:
4249 self.defaultAlgoType = algoClass.algoType
4250 #print "Add",algoClass.algoType, "dflt",self.defaultAlgoType
4252 # creates a copy of self and assign mesh to the copy
4253 def copy(self, mesh):
4254 other = algoCreator()
4255 other.defaultAlgoType = self.defaultAlgoType
4256 other.algoTypeToClass = self.algoTypeToClass
4260 # creates an instance of algorithm
4261 def __call__(self,algo="",geom=0,*args):
4262 algoType = self.defaultAlgoType
4263 for arg in args + (algo,geom):
4264 if isinstance( arg, geompyDC.GEOM._objref_GEOM_Object ):
4266 if isinstance( arg, str ) and arg:
4268 if not algoType and self.algoTypeToClass:
4269 algoType = self.algoTypeToClass.keys()[0]
4270 if self.algoTypeToClass.has_key( algoType ):
4271 #print "Create algo",algoType
4272 return self.algoTypeToClass[ algoType ]( self.mesh, geom )
4273 raise RuntimeError, "No class found for algo type %s" % algoType
4276 # Private class used to substitute and store variable parameters of hypotheses.
4278 class hypMethodWrapper:
4279 def __init__(self, hyp, method):
4281 self.method = method
4282 #print "REBIND:", method.__name__
4285 # call a method of hypothesis with calling SetVarParameter() before
4286 def __call__(self,*args):
4288 return self.method( self.hyp, *args ) # hypothesis method with no args
4290 #print "MethWrapper.__call__",self.method.__name__, args
4292 parsed = ParseParameters(*args) # replace variables with their values
4293 self.hyp.SetVarParameter( parsed[-2], self.method.__name__ )
4294 result = self.method( self.hyp, *parsed[:-2] ) # call hypothesis method
4295 except omniORB.CORBA.BAD_PARAM: # raised by hypothesis method call
4296 # maybe there is a replaced string arg which is not variable
4297 result = self.method( self.hyp, *args )
4298 except ValueError, detail: # raised by ParseParameters()
4300 result = self.method( self.hyp, *args )
4301 except omniORB.CORBA.BAD_PARAM:
4302 raise ValueError, detail # wrong variable name