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
28 ## @defgroup l1_auxiliary Auxiliary methods and structures
29 ## @defgroup l1_creating Creating meshes
31 ## @defgroup l2_impexp Importing and exporting meshes
32 ## @defgroup l2_construct Constructing meshes
33 ## @defgroup l2_algorithms Defining Algorithms
35 ## @defgroup l3_algos_basic Basic meshing algorithms
36 ## @defgroup l3_algos_proj Projection Algorithms
37 ## @defgroup l3_algos_radialp Radial Prism
38 ## @defgroup l3_algos_segmarv Segments around Vertex
39 ## @defgroup l3_algos_3dextr 3D extrusion meshing algorithm
42 ## @defgroup l2_hypotheses Defining hypotheses
44 ## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
45 ## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
46 ## @defgroup l3_hypos_maxvol Max Element Volume hypothesis
47 ## @defgroup l3_hypos_quad Quadrangle Parameters hypothesis
48 ## @defgroup l3_hypos_additi Additional Hypotheses
51 ## @defgroup l2_submeshes Constructing submeshes
52 ## @defgroup l2_compounds Building Compounds
53 ## @defgroup l2_editing Editing Meshes
56 ## @defgroup l1_meshinfo Mesh Information
57 ## @defgroup l1_controls Quality controls and Filtering
58 ## @defgroup l1_grouping Grouping elements
60 ## @defgroup l2_grps_create Creating groups
61 ## @defgroup l2_grps_edit Editing groups
62 ## @defgroup l2_grps_operon Using operations on groups
63 ## @defgroup l2_grps_delete Deleting Groups
66 ## @defgroup l1_modifying Modifying meshes
68 ## @defgroup l2_modif_add Adding nodes and elements
69 ## @defgroup l2_modif_del Removing nodes and elements
70 ## @defgroup l2_modif_edit Modifying nodes and elements
71 ## @defgroup l2_modif_renumber Renumbering nodes and elements
72 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
73 ## @defgroup l2_modif_movenode Moving nodes
74 ## @defgroup l2_modif_throughp Mesh through point
75 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
76 ## @defgroup l2_modif_unitetri Uniting triangles
77 ## @defgroup l2_modif_changori Changing orientation of elements
78 ## @defgroup l2_modif_cutquadr Cutting quadrangles
79 ## @defgroup l2_modif_smooth Smoothing
80 ## @defgroup l2_modif_extrurev Extrusion and Revolution
81 ## @defgroup l2_modif_patterns Pattern mapping
82 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
85 ## @defgroup l1_measurements Measurements
90 import SMESH # This is necessary for back compatibility
96 ## @addtogroup l1_auxiliary
99 # MirrorType enumeration
100 POINT = SMESH_MeshEditor.POINT
101 AXIS = SMESH_MeshEditor.AXIS
102 PLANE = SMESH_MeshEditor.PLANE
104 # Smooth_Method enumeration
105 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
106 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
108 PrecisionConfusion = 1e-07
110 # TopAbs_State enumeration
111 [TopAbs_IN, TopAbs_OUT, TopAbs_ON, TopAbs_UNKNOWN] = range(4)
113 # Methods of splitting a hexahedron into tetrahedra
114 Hex_5Tet, Hex_6Tet, Hex_24Tet = 1, 2, 3
116 ## Converts an angle from degrees to radians
117 def DegreesToRadians(AngleInDegrees):
119 return AngleInDegrees * pi / 180.0
121 import salome_notebook
122 notebook = salome_notebook.notebook
123 # Salome notebook variable separator
126 ## Return list of variable values from salome notebook.
127 # The last argument, if is callable, is used to modify values got from notebook
128 def ParseParameters(*args):
133 if args and callable( args[-1] ):
134 args, varModifFun = args[:-1], args[-1]
135 for parameter in args:
137 Parameters += str(parameter) + var_separator
139 if isinstance(parameter,str):
140 # check if there is an inexistent variable name
141 if not notebook.isVariable(parameter):
142 raise ValueError, "Variable with name '" + parameter + "' doesn't exist!!!"
143 parameter = notebook.get(parameter)
146 parameter = varModifFun(parameter)
149 Result.append(parameter)
152 Parameters = Parameters[:-1]
153 Result.append( Parameters )
154 Result.append( hasVariables )
157 # Parse parameters converting variables to radians
158 def ParseAngles(*args):
159 return ParseParameters( *( args + (DegreesToRadians, )))
161 # Substitute PointStruct.__init__() to create SMESH.PointStruct using notebook variables.
162 # Parameters are stored in PointStruct.parameters attribute
163 def __initPointStruct(point,*args):
164 point.x, point.y, point.z, point.parameters,hasVars = ParseParameters(*args)
166 SMESH.PointStruct.__init__ = __initPointStruct
168 # Substitute AxisStruct.__init__() to create SMESH.AxisStruct using notebook variables.
169 # Parameters are stored in AxisStruct.parameters attribute
170 def __initAxisStruct(ax,*args):
171 ax.x, ax.y, ax.z, ax.vx, ax.vy, ax.vz, ax.parameters,hasVars = ParseParameters(*args)
173 SMESH.AxisStruct.__init__ = __initAxisStruct
176 def IsEqual(val1, val2, tol=PrecisionConfusion):
177 if abs(val1 - val2) < tol:
187 if isinstance(obj, SALOMEDS._objref_SObject):
190 ior = salome.orb.object_to_string(obj)
193 studies = salome.myStudyManager.GetOpenStudies()
194 for sname in studies:
195 s = salome.myStudyManager.GetStudyByName(sname)
197 sobj = s.FindObjectIOR(ior)
198 if not sobj: continue
199 return sobj.GetName()
200 if hasattr(obj, "GetName"):
201 # unknown CORBA object, having GetName() method
204 # unknown CORBA object, no GetName() method
207 if hasattr(obj, "GetName"):
208 # unknown non-CORBA object, having GetName() method
211 raise RuntimeError, "Null or invalid object"
213 ## Prints error message if a hypothesis was not assigned.
214 def TreatHypoStatus(status, hypName, geomName, isAlgo):
216 hypType = "algorithm"
218 hypType = "hypothesis"
220 if status == HYP_UNKNOWN_FATAL :
221 reason = "for unknown reason"
222 elif status == HYP_INCOMPATIBLE :
223 reason = "this hypothesis mismatches the algorithm"
224 elif status == HYP_NOTCONFORM :
225 reason = "a non-conform mesh would be built"
226 elif status == HYP_ALREADY_EXIST :
227 if isAlgo: return # it does not influence anything
228 reason = hypType + " of the same dimension is already assigned to this shape"
229 elif status == HYP_BAD_DIM :
230 reason = hypType + " mismatches the shape"
231 elif status == HYP_CONCURENT :
232 reason = "there are concurrent hypotheses on sub-shapes"
233 elif status == HYP_BAD_SUBSHAPE :
234 reason = "the shape is neither the main one, nor its sub-shape, nor a valid group"
235 elif status == HYP_BAD_GEOMETRY:
236 reason = "geometry mismatches the expectation of the algorithm"
237 elif status == HYP_HIDDEN_ALGO:
238 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
239 elif status == HYP_HIDING_ALGO:
240 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
241 elif status == HYP_NEED_SHAPE:
242 reason = "Algorithm can't work without shape"
245 hypName = '"' + hypName + '"'
246 geomName= '"' + geomName+ '"'
247 if status < HYP_UNKNOWN_FATAL and not geomName =='""':
248 print hypName, "was assigned to", geomName,"but", reason
249 elif not geomName == '""':
250 print hypName, "was not assigned to",geomName,":", reason
252 print hypName, "was not assigned:", reason
255 ## Private method. Add geom (sub-shape of the main shape) into the study if not yet there
256 def AssureGeomPublished(mesh, geom, name=''):
257 if not isinstance( geom, geompyDC.GEOM._objref_GEOM_Object ):
259 if not geom.IsSame( mesh.geom ) and \
260 not geom.GetStudyEntry() and \
261 mesh.smeshpyD.GetCurrentStudy():
263 studyID = mesh.smeshpyD.GetCurrentStudy()._get_StudyId()
264 if studyID != mesh.geompyD.myStudyId:
265 mesh.geompyD.init_geom( mesh.smeshpyD.GetCurrentStudy())
267 if not name and geom.GetShapeType() != geompyDC.GEOM.COMPOUND:
268 # for all groups SubShapeName() returns "Compound_-1"
269 name = mesh.geompyD.SubShapeName(geom, mesh.geom)
271 name = "%s_%s"%(geom.GetShapeType(), id(geom)%10000)
273 mesh.geompyD.addToStudyInFather( mesh.geom, geom, name )
276 ## Return the first vertex of a geomertical edge by ignoring orienation
277 def FirstVertexOnCurve(edge):
278 from geompy import SubShapeAll, ShapeType, KindOfShape, PointCoordinates
279 vv = SubShapeAll( edge, ShapeType["VERTEX"])
281 raise TypeError, "Given object has no vertices"
282 if len( vv ) == 1: return vv[0]
283 info = KindOfShape(edge)
284 xyz = info[1:4] # coords of the first vertex
285 xyz1 = PointCoordinates( vv[0] )
286 xyz2 = PointCoordinates( vv[1] )
289 dist1 += abs( xyz[i] - xyz1[i] )
290 dist2 += abs( xyz[i] - xyz2[i] )
296 # end of l1_auxiliary
299 # All methods of this class are accessible directly from the smesh.py package.
300 class smeshDC(SMESH._objref_SMESH_Gen):
302 ## Dump component to the Python script
303 # This method overrides IDL function to allow default values for the parameters.
304 def DumpPython(self, theStudy, theIsPublished=True, theIsMultiFile=True):
305 return SMESH._objref_SMESH_Gen.DumpPython(self, theStudy, theIsPublished, theIsMultiFile)
307 ## Set mode of DumpPython(), \a historical or \a snapshot.
308 # In the \a historical mode, the Python Dump script includes all commands
309 # performed by SMESH engine. In the \a snapshot mode, commands
310 # relating to objects removed from the Study are excluded from the script
311 # as well as commands not influencing the current state of meshes
312 def SetDumpPythonHistorical(self, isHistorical):
313 if isHistorical: val = "true"
315 SMESH._objref_SMESH_Gen.SetOption(self, "historical_python_dump", val)
317 ## Sets the current study and Geometry component
318 # @ingroup l1_auxiliary
319 def init_smesh(self,theStudy,geompyD):
320 self.SetCurrentStudy(theStudy,geompyD)
322 ## Creates an empty Mesh. This mesh can have an underlying geometry.
323 # @param obj the Geometrical object on which the mesh is built. If not defined,
324 # the mesh will have no underlying geometry.
325 # @param name the name for the new mesh.
326 # @return an instance of Mesh class.
327 # @ingroup l2_construct
328 def Mesh(self, obj=0, name=0):
329 if isinstance(obj,str):
331 return Mesh(self,self.geompyD,obj,name)
333 ## Returns a long value from enumeration
334 # Should be used for SMESH.FunctorType 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 ## Concatenate the given meshes into one mesh.
510 # @return an instance of Mesh class
511 # @param meshes the meshes to combine into one mesh
512 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
513 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
514 # @param mergeTolerance tolerance for merging nodes
515 # @param allGroups forces creation of groups of all elements
516 def Concatenate( self, meshes, uniteIdenticalGroups,
517 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
518 if not meshes: return None
519 for i,m in enumerate(meshes):
520 if isinstance(m, Mesh):
521 meshes[i] = m.GetMesh()
522 mergeTolerance,Parameters,hasVars = ParseParameters(mergeTolerance)
523 meshes[0].SetParameters(Parameters)
525 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
526 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
528 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
529 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
530 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
533 ## Create a mesh by copying a part of another mesh.
534 # @param meshPart a part of mesh to copy, either a Mesh, a sub-mesh or a group;
535 # to copy nodes or elements not contained in any mesh object,
536 # pass result of Mesh.GetIDSource( list_of_ids, type ) as meshPart
537 # @param meshName a name of the new mesh
538 # @param toCopyGroups to create in the new mesh groups the copied elements belongs to
539 # @param toKeepIDs to preserve IDs of the copied elements or not
540 # @return an instance of Mesh class
541 def CopyMesh( self, meshPart, meshName, toCopyGroups=False, toKeepIDs=False):
542 if (isinstance( meshPart, Mesh )):
543 meshPart = meshPart.GetMesh()
544 mesh = SMESH._objref_SMESH_Gen.CopyMesh( self,meshPart,meshName,toCopyGroups,toKeepIDs )
545 return Mesh(self, self.geompyD, mesh)
547 ## From SMESH_Gen interface
548 # @return the list of integer values
549 # @ingroup l1_auxiliary
550 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
551 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
553 ## From SMESH_Gen interface. Creates a pattern
554 # @return an instance of SMESH_Pattern
556 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
557 # @ingroup l2_modif_patterns
558 def GetPattern(self):
559 return SMESH._objref_SMESH_Gen.GetPattern(self)
561 ## Sets number of segments per diagonal of boundary box of geometry by which
562 # default segment length of appropriate 1D hypotheses is defined.
563 # Default value is 10
564 # @ingroup l1_auxiliary
565 def SetBoundaryBoxSegmentation(self, nbSegments):
566 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
568 # Filtering. Auxiliary functions:
569 # ------------------------------
571 ## Creates an empty criterion
572 # @return SMESH.Filter.Criterion
573 # @ingroup l1_controls
574 def GetEmptyCriterion(self):
575 Type = self.EnumToLong(FT_Undefined)
576 Compare = self.EnumToLong(FT_Undefined)
580 UnaryOp = self.EnumToLong(FT_Undefined)
581 BinaryOp = self.EnumToLong(FT_Undefined)
584 Precision = -1 ##@1e-07
585 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
586 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
588 ## Creates a criterion by the given parameters
589 # \n Criterion structures allow to define complex filters by combining them with logical operations (AND / OR) (see example below)
590 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
591 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
592 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
593 # @param Threshold the threshold value (range of ids as string, shape, numeric)
594 # @param UnaryOp FT_LogicalNOT or FT_Undefined
595 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
596 # FT_Undefined (must be for the last criterion of all criteria)
597 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
598 # FT_LyingOnGeom, FT_CoplanarFaces criteria
599 # @return SMESH.Filter.Criterion
601 # <a href="../tui_filters_page.html#combining_filters">Example of Criteria usage</a>
602 # @ingroup l1_controls
603 def GetCriterion(self,elementType,
605 Compare = FT_EqualTo,
607 UnaryOp=FT_Undefined,
608 BinaryOp=FT_Undefined,
610 if not CritType in SMESH.FunctorType._items:
611 raise TypeError, "CritType should be of SMESH.FunctorType"
612 aCriterion = self.GetEmptyCriterion()
613 aCriterion.TypeOfElement = elementType
614 aCriterion.Type = self.EnumToLong(CritType)
615 aCriterion.Tolerance = Tolerance
617 aThreshold = Threshold
619 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
620 aCriterion.Compare = self.EnumToLong(Compare)
621 elif Compare == "=" or Compare == "==":
622 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
624 aCriterion.Compare = self.EnumToLong(FT_LessThan)
626 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
627 elif Compare != FT_Undefined:
628 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
631 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
632 FT_BelongToCylinder, FT_LyingOnGeom]:
633 # Checks the Threshold
634 if isinstance(aThreshold, geompyDC.GEOM._objref_GEOM_Object):
635 aCriterion.ThresholdStr = GetName(aThreshold)
636 aCriterion.ThresholdID = salome.ObjectToID(aThreshold)
638 print "Error: The Threshold should be a shape."
640 if isinstance(UnaryOp,float):
641 aCriterion.Tolerance = UnaryOp
642 UnaryOp = FT_Undefined
644 elif CritType == FT_RangeOfIds:
645 # Checks the Threshold
646 if isinstance(aThreshold, str):
647 aCriterion.ThresholdStr = aThreshold
649 print "Error: The Threshold should be a string."
651 elif CritType == FT_CoplanarFaces:
652 # Checks the Threshold
653 if isinstance(aThreshold, int):
654 aCriterion.ThresholdID = "%s"%aThreshold
655 elif isinstance(aThreshold, str):
658 raise ValueError, "Invalid ID of mesh face: '%s'"%aThreshold
659 aCriterion.ThresholdID = aThreshold
662 "The Threshold should be an ID of mesh face and not '%s'"%aThreshold
663 elif CritType == FT_ElemGeomType:
664 # Checks the Threshold
666 aCriterion.Threshold = self.EnumToLong(aThreshold)
667 assert( aThreshold in SMESH.GeometryType._items )
669 if isinstance(aThreshold, int):
670 aCriterion.Threshold = aThreshold
672 print "Error: The Threshold should be an integer or SMESH.GeometryType."
676 elif CritType == FT_GroupColor:
677 # Checks the Threshold
679 aCriterion.ThresholdStr = self.ColorToString(aThreshold)
681 print "Error: The threshold value should be of SALOMEDS.Color type"
684 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_FreeNodes, FT_FreeFaces,
685 FT_LinearOrQuadratic, FT_BadOrientedVolume,
686 FT_BareBorderFace, FT_BareBorderVolume,
687 FT_OverConstrainedFace, FT_OverConstrainedVolume,
688 FT_EqualNodes,FT_EqualEdges,FT_EqualFaces,FT_EqualVolumes ]:
689 # At this point the Threshold is unnecessary
690 if aThreshold == FT_LogicalNOT:
691 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
692 elif aThreshold in [FT_LogicalAND, FT_LogicalOR]:
693 aCriterion.BinaryOp = aThreshold
697 aThreshold = float(aThreshold)
698 aCriterion.Threshold = aThreshold
700 print "Error: The Threshold should be a number."
703 if Threshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
704 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
706 if Threshold in [FT_LogicalAND, FT_LogicalOR]:
707 aCriterion.BinaryOp = self.EnumToLong(Threshold)
709 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
710 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
712 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
713 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
717 ## Creates a filter with the given parameters
718 # @param elementType the type of elements in the group
719 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
720 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
721 # @param Threshold the threshold value (range of id ids as string, shape, numeric)
722 # @param UnaryOp FT_LogicalNOT or FT_Undefined
723 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
724 # FT_LyingOnGeom, FT_CoplanarFaces and FT_EqualNodes criteria
725 # @return SMESH_Filter
727 # <a href="../tui_filters_page.html#tui_filters">Example of Filters usage</a>
728 # @ingroup l1_controls
729 def GetFilter(self,elementType,
730 CritType=FT_Undefined,
733 UnaryOp=FT_Undefined,
735 aCriterion = self.GetCriterion(elementType, CritType, Compare, Threshold, UnaryOp, FT_Undefined,Tolerance)
736 aFilterMgr = self.CreateFilterManager()
737 aFilter = aFilterMgr.CreateFilter()
739 aCriteria.append(aCriterion)
740 aFilter.SetCriteria(aCriteria)
741 aFilterMgr.UnRegister()
744 ## Creates a filter from criteria
745 # @param criteria a list of criteria
746 # @return SMESH_Filter
748 # <a href="../tui_filters_page.html#tui_filters">Example of Filters usage</a>
749 # @ingroup l1_controls
750 def GetFilterFromCriteria(self,criteria):
751 aFilterMgr = self.CreateFilterManager()
752 aFilter = aFilterMgr.CreateFilter()
753 aFilter.SetCriteria(criteria)
754 aFilterMgr.UnRegister()
757 ## Creates a numerical functor by its type
758 # @param theCriterion FT_...; functor type
759 # @return SMESH_NumericalFunctor
760 # @ingroup l1_controls
761 def GetFunctor(self,theCriterion):
762 aFilterMgr = self.CreateFilterManager()
763 if theCriterion == FT_AspectRatio:
764 return aFilterMgr.CreateAspectRatio()
765 elif theCriterion == FT_AspectRatio3D:
766 return aFilterMgr.CreateAspectRatio3D()
767 elif theCriterion == FT_Warping:
768 return aFilterMgr.CreateWarping()
769 elif theCriterion == FT_MinimumAngle:
770 return aFilterMgr.CreateMinimumAngle()
771 elif theCriterion == FT_Taper:
772 return aFilterMgr.CreateTaper()
773 elif theCriterion == FT_Skew:
774 return aFilterMgr.CreateSkew()
775 elif theCriterion == FT_Area:
776 return aFilterMgr.CreateArea()
777 elif theCriterion == FT_Volume3D:
778 return aFilterMgr.CreateVolume3D()
779 elif theCriterion == FT_MaxElementLength2D:
780 return aFilterMgr.CreateMaxElementLength2D()
781 elif theCriterion == FT_MaxElementLength3D:
782 return aFilterMgr.CreateMaxElementLength3D()
783 elif theCriterion == FT_MultiConnection:
784 return aFilterMgr.CreateMultiConnection()
785 elif theCriterion == FT_MultiConnection2D:
786 return aFilterMgr.CreateMultiConnection2D()
787 elif theCriterion == FT_Length:
788 return aFilterMgr.CreateLength()
789 elif theCriterion == FT_Length2D:
790 return aFilterMgr.CreateLength2D()
792 print "Error: given parameter is not numerical functor type."
794 ## Creates hypothesis
795 # @param theHType mesh hypothesis type (string)
796 # @param theLibName mesh plug-in library name
797 # @return created hypothesis instance
798 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
799 hyp = SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
801 if isinstance( hyp, SMESH._objref_SMESH_Algo ):
804 # wrap hypothesis methods
805 #print "HYPOTHESIS", theHType
806 for meth_name in dir( hyp.__class__ ):
807 if not meth_name.startswith("Get") and \
808 not meth_name in dir ( SMESH._objref_SMESH_Hypothesis ):
809 method = getattr ( hyp.__class__, meth_name )
811 setattr( hyp, meth_name, hypMethodWrapper( hyp, method ))
815 ## Gets the mesh statistic
816 # @return dictionary "element type" - "count of elements"
817 # @ingroup l1_meshinfo
818 def GetMeshInfo(self, obj):
819 if isinstance( obj, Mesh ):
822 if hasattr(obj, "GetMeshInfo"):
823 values = obj.GetMeshInfo()
824 for i in range(SMESH.Entity_Last._v):
825 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
829 ## Get minimum distance between two objects
831 # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
832 # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
834 # @param src1 first source object
835 # @param src2 second source object
836 # @param id1 node/element id from the first source
837 # @param id2 node/element id from the second (or first) source
838 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
839 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
840 # @return minimum distance value
841 # @sa GetMinDistance()
842 # @ingroup l1_measurements
843 def MinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
844 result = self.GetMinDistance(src1, src2, id1, id2, isElem1, isElem2)
848 result = result.value
851 ## Get measure structure specifying minimum distance data between two objects
853 # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
854 # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
856 # @param src1 first source object
857 # @param src2 second source object
858 # @param id1 node/element id from the first source
859 # @param id2 node/element id from the second (or first) source
860 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
861 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
862 # @return Measure structure or None if input data is invalid
864 # @ingroup l1_measurements
865 def GetMinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
866 if isinstance(src1, Mesh): src1 = src1.mesh
867 if isinstance(src2, Mesh): src2 = src2.mesh
868 if src2 is None and id2 != 0: src2 = src1
869 if not hasattr(src1, "_narrow"): return None
870 src1 = src1._narrow(SMESH.SMESH_IDSource)
871 if not src1: return None
874 e = m.GetMeshEditor()
876 src1 = e.MakeIDSource([id1], SMESH.FACE)
878 src1 = e.MakeIDSource([id1], SMESH.NODE)
880 if hasattr(src2, "_narrow"):
881 src2 = src2._narrow(SMESH.SMESH_IDSource)
882 if src2 and id2 != 0:
884 e = m.GetMeshEditor()
886 src2 = e.MakeIDSource([id2], SMESH.FACE)
888 src2 = e.MakeIDSource([id2], SMESH.NODE)
891 aMeasurements = self.CreateMeasurements()
892 result = aMeasurements.MinDistance(src1, src2)
893 aMeasurements.UnRegister()
896 ## Get bounding box of the specified object(s)
897 # @param objects single source object or list of source objects
898 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
899 # @sa GetBoundingBox()
900 # @ingroup l1_measurements
901 def BoundingBox(self, objects):
902 result = self.GetBoundingBox(objects)
906 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
909 ## Get measure structure specifying bounding box data of the specified object(s)
910 # @param objects single source object or list of source objects
911 # @return Measure structure
913 # @ingroup l1_measurements
914 def GetBoundingBox(self, objects):
915 if isinstance(objects, tuple):
916 objects = list(objects)
917 if not isinstance(objects, list):
921 if isinstance(o, Mesh):
922 srclist.append(o.mesh)
923 elif hasattr(o, "_narrow"):
924 src = o._narrow(SMESH.SMESH_IDSource)
925 if src: srclist.append(src)
928 aMeasurements = self.CreateMeasurements()
929 result = aMeasurements.BoundingBox(srclist)
930 aMeasurements.UnRegister()
934 #Registering the new proxy for SMESH_Gen
935 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
941 ## This class allows defining and managing a mesh.
942 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
943 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
944 # new nodes and elements and by changing the existing entities), to get information
945 # about a mesh and to export a mesh into different formats.
954 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
955 # sets the GUI name of this mesh to \a name.
956 # @param smeshpyD an instance of smeshDC class
957 # @param geompyD an instance of geompyDC class
958 # @param obj Shape to be meshed or SMESH_Mesh object
959 # @param name Study name of the mesh
960 # @ingroup l2_construct
961 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
962 self.smeshpyD=smeshpyD
967 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
969 # publish geom of mesh (issue 0021122)
970 if not self.geom.GetStudyEntry() and smeshpyD.GetCurrentStudy():
971 studyID = smeshpyD.GetCurrentStudy()._get_StudyId()
972 if studyID != geompyD.myStudyId:
973 geompyD.init_geom( smeshpyD.GetCurrentStudy())
975 geo_name = "%s_%s"%(self.geom.GetShapeType(), id(self.geom)%100)
976 geompyD.addToStudy( self.geom, geo_name )
977 self.mesh = self.smeshpyD.CreateMesh(self.geom)
979 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
982 self.mesh = self.smeshpyD.CreateEmptyMesh()
984 self.smeshpyD.SetName(self.mesh, name)
986 self.smeshpyD.SetName(self.mesh, GetName(obj))
989 self.geom = self.mesh.GetShapeToMesh()
991 self.editor = self.mesh.GetMeshEditor()
993 # set self to algoCreator's
994 for attrName in dir(self):
995 attr = getattr( self, attrName )
996 if isinstance( attr, algoCreator ):
997 setattr( self, attrName, attr.copy( self ))
999 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
1000 # @param theMesh a SMESH_Mesh object
1001 # @ingroup l2_construct
1002 def SetMesh(self, theMesh):
1004 self.geom = self.mesh.GetShapeToMesh()
1006 ## Returns the mesh, that is an instance of SMESH_Mesh interface
1007 # @return a SMESH_Mesh object
1008 # @ingroup l2_construct
1012 ## Gets the name of the mesh
1013 # @return the name of the mesh as a string
1014 # @ingroup l2_construct
1016 name = GetName(self.GetMesh())
1019 ## Sets a name to the mesh
1020 # @param name a new name of the mesh
1021 # @ingroup l2_construct
1022 def SetName(self, name):
1023 self.smeshpyD.SetName(self.GetMesh(), name)
1025 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
1026 # The subMesh object gives access to the IDs of nodes and elements.
1027 # @param geom a geometrical object (shape)
1028 # @param name a name for the submesh
1029 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
1030 # @ingroup l2_submeshes
1031 def GetSubMesh(self, geom, name):
1032 AssureGeomPublished( self, geom, name )
1033 submesh = self.mesh.GetSubMesh( geom, name )
1036 ## Returns the shape associated to the mesh
1037 # @return a GEOM_Object
1038 # @ingroup l2_construct
1042 ## Associates the given shape to the mesh (entails the recreation of the mesh)
1043 # @param geom the shape to be meshed (GEOM_Object)
1044 # @ingroup l2_construct
1045 def SetShape(self, geom):
1046 self.mesh = self.smeshpyD.CreateMesh(geom)
1048 ## Loads mesh from the study after opening the study
1052 ## Returns true if the hypotheses are defined well
1053 # @param theSubObject a sub-shape of a mesh shape
1054 # @return True or False
1055 # @ingroup l2_construct
1056 def IsReadyToCompute(self, theSubObject):
1057 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
1059 ## Returns errors of hypotheses definition.
1060 # The list of errors is empty if everything is OK.
1061 # @param theSubObject a sub-shape of a mesh shape
1062 # @return a list of errors
1063 # @ingroup l2_construct
1064 def GetAlgoState(self, theSubObject):
1065 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
1067 ## Returns a geometrical object on which the given element was built.
1068 # The returned geometrical object, if not nil, is either found in the
1069 # study or published by this method with the given name
1070 # @param theElementID the id of the mesh element
1071 # @param theGeomName the user-defined name of the geometrical object
1072 # @return GEOM::GEOM_Object instance
1073 # @ingroup l2_construct
1074 def GetGeometryByMeshElement(self, theElementID, theGeomName):
1075 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
1077 ## Returns the mesh dimension depending on the dimension of the underlying shape
1078 # @return mesh dimension as an integer value [0,3]
1079 # @ingroup l1_auxiliary
1080 def MeshDimension(self):
1081 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
1082 if len( shells ) > 0 :
1084 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
1086 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
1092 ## Evaluates size of prospective mesh on a shape
1093 # @return a list where i-th element is a number of elements of i-th SMESH.EntityType
1094 # To know predicted number of e.g. edges, inquire it this way
1095 # Evaluate()[ EnumToLong( Entity_Edge )]
1096 def Evaluate(self, geom=0):
1097 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1099 geom = self.mesh.GetShapeToMesh()
1102 return self.smeshpyD.Evaluate(self.mesh, geom)
1105 ## Computes the mesh and returns the status of the computation
1106 # @param geom geomtrical shape on which mesh data should be computed
1107 # @param discardModifs if True and the mesh has been edited since
1108 # a last total re-compute and that may prevent successful partial re-compute,
1109 # then the mesh is cleaned before Compute()
1110 # @return True or False
1111 # @ingroup l2_construct
1112 def Compute(self, geom=0, discardModifs=False):
1113 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1115 geom = self.mesh.GetShapeToMesh()
1120 if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693
1122 ok = self.smeshpyD.Compute(self.mesh, geom)
1123 except SALOME.SALOME_Exception, ex:
1124 print "Mesh computation failed, exception caught:"
1125 print " ", ex.details.text
1128 print "Mesh computation failed, exception caught:"
1129 traceback.print_exc()
1133 # Treat compute errors
1134 computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
1135 for err in computeErrors:
1137 if self.mesh.HasShapeToMesh():
1139 mainIOR = salome.orb.object_to_string(geom)
1140 for sname in salome.myStudyManager.GetOpenStudies():
1141 s = salome.myStudyManager.GetStudyByName(sname)
1143 mainSO = s.FindObjectIOR(mainIOR)
1144 if not mainSO: continue
1145 if err.subShapeID == 1:
1146 shapeText = ' on "%s"' % mainSO.GetName()
1147 subIt = s.NewChildIterator(mainSO)
1149 subSO = subIt.Value()
1151 obj = subSO.GetObject()
1152 if not obj: continue
1153 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
1155 ids = go.GetSubShapeIndices()
1156 if len(ids) == 1 and ids[0] == err.subShapeID:
1157 shapeText = ' on "%s"' % subSO.GetName()
1160 shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
1162 shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID)
1164 shapeText = " on subshape #%s" % (err.subShapeID)
1166 shapeText = " on subshape #%s" % (err.subShapeID)
1168 stdErrors = ["OK", #COMPERR_OK
1169 "Invalid input mesh", #COMPERR_BAD_INPUT_MESH
1170 "std::exception", #COMPERR_STD_EXCEPTION
1171 "OCC exception", #COMPERR_OCC_EXCEPTION
1172 "SALOME exception", #COMPERR_SLM_EXCEPTION
1173 "Unknown exception", #COMPERR_EXCEPTION
1174 "Memory allocation problem", #COMPERR_MEMORY_PB
1175 "Algorithm failed", #COMPERR_ALGO_FAILED
1176 "Unexpected geometry"]#COMPERR_BAD_SHAPE
1178 if err.code < len(stdErrors): errText = stdErrors[err.code]
1180 errText = "code %s" % -err.code
1181 if errText: errText += ". "
1182 errText += err.comment
1183 if allReasons != "":allReasons += "\n"
1184 allReasons += '- "%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
1188 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1190 if err.isGlobalAlgo:
1198 reason = '%s %sD algorithm is missing' % (glob, dim)
1199 elif err.state == HYP_MISSING:
1200 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1201 % (glob, dim, name, dim))
1202 elif err.state == HYP_NOTCONFORM:
1203 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1204 elif err.state == HYP_BAD_PARAMETER:
1205 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1206 % ( glob, dim, name ))
1207 elif err.state == HYP_BAD_GEOMETRY:
1208 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1209 'geometry' % ( glob, dim, name ))
1211 reason = "For unknown reason."+\
1212 " Revise Mesh.Compute() implementation in smeshDC.py!"
1214 if allReasons != "":allReasons += "\n"
1215 allReasons += "- " + reason
1217 if not ok or allReasons != "":
1218 msg = '"' + GetName(self.mesh) + '"'
1219 if ok: msg += " has been computed with warnings"
1220 else: msg += " has not been computed"
1221 if allReasons != "": msg += ":"
1226 if salome.sg.hasDesktop() and self.mesh.GetStudyId() >= 0:
1227 smeshgui = salome.ImportComponentGUI("SMESH")
1228 smeshgui.Init(self.mesh.GetStudyId())
1229 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1230 salome.sg.updateObjBrowser(1)
1234 ## Return submesh objects list in meshing order
1235 # @return list of list of submesh objects
1236 # @ingroup l2_construct
1237 def GetMeshOrder(self):
1238 return self.mesh.GetMeshOrder()
1240 ## Return submesh objects list in meshing order
1241 # @return list of list of submesh objects
1242 # @ingroup l2_construct
1243 def SetMeshOrder(self, submeshes):
1244 return self.mesh.SetMeshOrder(submeshes)
1246 ## Removes all nodes and elements
1247 # @ingroup l2_construct
1250 if salome.sg.hasDesktop():
1251 smeshgui = salome.ImportComponentGUI("SMESH")
1252 smeshgui.Init(self.mesh.GetStudyId())
1253 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1254 salome.sg.updateObjBrowser(1)
1256 ## Removes all nodes and elements of indicated shape
1257 # @ingroup l2_construct
1258 def ClearSubMesh(self, geomId):
1259 self.mesh.ClearSubMesh(geomId)
1260 if salome.sg.hasDesktop():
1261 smeshgui = salome.ImportComponentGUI("SMESH")
1262 smeshgui.Init(self.mesh.GetStudyId())
1263 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1264 salome.sg.updateObjBrowser(1)
1266 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1267 # @param fineness [0.0,1.0] defines mesh fineness
1268 # @return True or False
1269 # @ingroup l3_algos_basic
1270 def AutomaticTetrahedralization(self, fineness=0):
1271 dim = self.MeshDimension()
1273 self.RemoveGlobalHypotheses()
1274 self.Segment().AutomaticLength(fineness)
1276 self.Triangle().LengthFromEdges()
1279 from NETGENPluginDC import NETGEN
1280 self.Tetrahedron(NETGEN)
1282 return self.Compute()
1284 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1285 # @param fineness [0.0, 1.0] defines mesh fineness
1286 # @return True or False
1287 # @ingroup l3_algos_basic
1288 def AutomaticHexahedralization(self, fineness=0):
1289 dim = self.MeshDimension()
1290 # assign the hypotheses
1291 self.RemoveGlobalHypotheses()
1292 self.Segment().AutomaticLength(fineness)
1299 return self.Compute()
1301 ## Assigns a hypothesis
1302 # @param hyp a hypothesis to assign
1303 # @param geom a subhape of mesh geometry
1304 # @return SMESH.Hypothesis_Status
1305 # @ingroup l2_hypotheses
1306 def AddHypothesis(self, hyp, geom=0):
1307 if isinstance( hyp, Mesh_Algorithm ):
1308 hyp = hyp.GetAlgorithm()
1313 geom = self.mesh.GetShapeToMesh()
1315 status = self.mesh.AddHypothesis(geom, hyp)
1316 isAlgo = hyp._narrow( SMESH_Algo )
1317 hyp_name = GetName( hyp )
1320 geom_name = GetName( geom )
1321 TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1324 ## Return True if an algorithm of hypothesis is assigned to a given shape
1325 # @param hyp a hypothesis to check
1326 # @param geom a subhape of mesh geometry
1327 # @return True of False
1328 # @ingroup l2_hypotheses
1329 def IsUsedHypothesis(self, hyp, geom):
1330 if not hyp or not geom:
1332 if isinstance( hyp, Mesh_Algorithm ):
1333 hyp = hyp.GetAlgorithm()
1335 hyps = self.GetHypothesisList(geom)
1337 if h.GetId() == hyp.GetId():
1341 ## Unassigns a hypothesis
1342 # @param hyp a hypothesis to unassign
1343 # @param geom a sub-shape of mesh geometry
1344 # @return SMESH.Hypothesis_Status
1345 # @ingroup l2_hypotheses
1346 def RemoveHypothesis(self, hyp, geom=0):
1347 if isinstance( hyp, Mesh_Algorithm ):
1348 hyp = hyp.GetAlgorithm()
1353 status = self.mesh.RemoveHypothesis(geom, hyp)
1356 ## Gets the list of hypotheses added on a geometry
1357 # @param geom a sub-shape of mesh geometry
1358 # @return the sequence of SMESH_Hypothesis
1359 # @ingroup l2_hypotheses
1360 def GetHypothesisList(self, geom):
1361 return self.mesh.GetHypothesisList( geom )
1363 ## Removes all global hypotheses
1364 # @ingroup l2_hypotheses
1365 def RemoveGlobalHypotheses(self):
1366 current_hyps = self.mesh.GetHypothesisList( self.geom )
1367 for hyp in current_hyps:
1368 self.mesh.RemoveHypothesis( self.geom, hyp )
1372 ## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead.
1373 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1374 ## allowing to overwrite the file if it exists or add the exported data to its contents
1375 # @param f the file name
1376 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1377 # @param opt boolean parameter for creating/not creating
1378 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1379 # @param overwrite boolean parameter for overwriting/not overwriting the file
1380 # @ingroup l2_impexp
1381 def ExportToMED(self, f, version, opt=0, overwrite=1):
1382 self.mesh.ExportToMEDX(f, opt, version, overwrite)
1384 ## Exports the mesh in a file in MED format and chooses the \a version of MED format
1385 ## allowing to overwrite the file if it exists or add the exported data to its contents
1386 # @param f is the file name
1387 # @param auto_groups boolean parameter for creating/not creating
1388 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1389 # the typical use is auto_groups=false.
1390 # @param version MED format version(MED_V2_1 or MED_V2_2)
1391 # @param overwrite boolean parameter for overwriting/not overwriting the file
1392 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1393 # @ingroup l2_impexp
1394 def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1, meshPart=None):
1396 if isinstance( meshPart, list ):
1397 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1398 self.mesh.ExportPartToMED( meshPart, f, auto_groups, version, overwrite )
1400 self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
1402 ## Exports the mesh in a file in SAUV format
1403 # @param f is the file name
1404 # @param auto_groups boolean parameter for creating/not creating
1405 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1406 # the typical use is auto_groups=false.
1407 # @ingroup l2_impexp
1408 def ExportSAUV(self, f, auto_groups=0):
1409 self.mesh.ExportSAUV(f, auto_groups)
1411 ## Exports the mesh in a file in DAT format
1412 # @param f the file name
1413 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1414 # @ingroup l2_impexp
1415 def ExportDAT(self, f, meshPart=None):
1417 if isinstance( meshPart, list ):
1418 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1419 self.mesh.ExportPartToDAT( meshPart, f )
1421 self.mesh.ExportDAT(f)
1423 ## Exports the mesh in a file in UNV format
1424 # @param f the file name
1425 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1426 # @ingroup l2_impexp
1427 def ExportUNV(self, f, meshPart=None):
1429 if isinstance( meshPart, list ):
1430 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1431 self.mesh.ExportPartToUNV( meshPart, f )
1433 self.mesh.ExportUNV(f)
1435 ## Export the mesh in a file in STL format
1436 # @param f the file name
1437 # @param ascii defines the file encoding
1438 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1439 # @ingroup l2_impexp
1440 def ExportSTL(self, f, ascii=1, meshPart=None):
1442 if isinstance( meshPart, list ):
1443 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1444 self.mesh.ExportPartToSTL( meshPart, f, ascii )
1446 self.mesh.ExportSTL(f, ascii)
1448 ## Exports the mesh in a file in CGNS format
1449 # @param f is the file name
1450 # @param overwrite boolean parameter for overwriting/not overwriting the file
1451 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1452 # @ingroup l2_impexp
1453 def ExportCGNS(self, f, overwrite=1, meshPart=None):
1454 if isinstance( meshPart, list ):
1455 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1456 if isinstance( meshPart, Mesh ):
1457 meshPart = meshPart.mesh
1459 meshPart = self.mesh
1460 self.mesh.ExportCGNS(meshPart, f, overwrite)
1462 # Operations with groups:
1463 # ----------------------
1465 ## Creates an empty mesh group
1466 # @param elementType the type of elements in the group
1467 # @param name the name of the mesh group
1468 # @return SMESH_Group
1469 # @ingroup l2_grps_create
1470 def CreateEmptyGroup(self, elementType, name):
1471 return self.mesh.CreateGroup(elementType, name)
1473 ## Creates a mesh group based on the geometric object \a grp
1474 # and gives a \a name, \n if this parameter is not defined
1475 # the name is the same as the geometric group name \n
1476 # Note: Works like GroupOnGeom().
1477 # @param grp a geometric group, a vertex, an edge, a face or a solid
1478 # @param name the name of the mesh group
1479 # @return SMESH_GroupOnGeom
1480 # @ingroup l2_grps_create
1481 def Group(self, grp, name=""):
1482 return self.GroupOnGeom(grp, name)
1484 ## Creates a mesh group based on the geometrical object \a grp
1485 # and gives a \a name, \n if this parameter is not defined
1486 # the name is the same as the geometrical group name
1487 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1488 # @param name the name of the mesh group
1489 # @param typ the type of elements in the group. If not set, it is
1490 # automatically detected by the type of the geometry
1491 # @return SMESH_GroupOnGeom
1492 # @ingroup l2_grps_create
1493 def GroupOnGeom(self, grp, name="", typ=None):
1494 AssureGeomPublished( self, grp, name )
1496 name = grp.GetName()
1498 typ = self._groupTypeFromShape( grp )
1499 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1501 ## Pivate method to get a type of group on geometry
1502 def _groupTypeFromShape( self, shape ):
1503 tgeo = str(shape.GetShapeType())
1504 if tgeo == "VERTEX":
1506 elif tgeo == "EDGE":
1508 elif tgeo == "FACE" or tgeo == "SHELL":
1510 elif tgeo == "SOLID" or tgeo == "COMPSOLID":
1512 elif tgeo == "COMPOUND":
1513 sub = self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHAPE"])
1515 raise ValueError,"_groupTypeFromShape(): empty geometric group or compound '%s'" % GetName(shape)
1516 return self._groupTypeFromShape( sub[0] )
1519 "_groupTypeFromShape(): invalid geometry '%s'" % GetName(shape)
1522 ## Creates a mesh group with given \a name based on the \a filter which
1523 ## is a special type of group dynamically updating it's contents during
1524 ## mesh modification
1525 # @param typ the type of elements in the group
1526 # @param name the name of the mesh group
1527 # @param filter the filter defining group contents
1528 # @return SMESH_GroupOnFilter
1529 # @ingroup l2_grps_create
1530 def GroupOnFilter(self, typ, name, filter):
1531 return self.mesh.CreateGroupFromFilter(typ, name, filter)
1533 ## Creates a mesh group by the given ids of elements
1534 # @param groupName the name of the mesh group
1535 # @param elementType the type of elements in the group
1536 # @param elemIDs the list of ids
1537 # @return SMESH_Group
1538 # @ingroup l2_grps_create
1539 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1540 group = self.mesh.CreateGroup(elementType, groupName)
1544 ## Creates a mesh group by the given conditions
1545 # @param groupName the name of the mesh group
1546 # @param elementType the type of elements in the group
1547 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1548 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1549 # @param Threshold the threshold value (range of id ids as string, shape, numeric)
1550 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1551 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
1552 # FT_LyingOnGeom, FT_CoplanarFaces criteria
1553 # @return SMESH_Group
1554 # @ingroup l2_grps_create
1558 CritType=FT_Undefined,
1561 UnaryOp=FT_Undefined,
1563 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Threshold, UnaryOp, FT_Undefined,Tolerance)
1564 group = self.MakeGroupByCriterion(groupName, aCriterion)
1567 ## Creates a mesh group by the given criterion
1568 # @param groupName the name of the mesh group
1569 # @param Criterion the instance of Criterion class
1570 # @return SMESH_Group
1571 # @ingroup l2_grps_create
1572 def MakeGroupByCriterion(self, groupName, Criterion):
1573 aFilterMgr = self.smeshpyD.CreateFilterManager()
1574 aFilter = aFilterMgr.CreateFilter()
1576 aCriteria.append(Criterion)
1577 aFilter.SetCriteria(aCriteria)
1578 group = self.MakeGroupByFilter(groupName, aFilter)
1579 aFilterMgr.UnRegister()
1582 ## Creates a mesh group by the given criteria (list of criteria)
1583 # @param groupName the name of the mesh group
1584 # @param theCriteria the list of criteria
1585 # @return SMESH_Group
1586 # @ingroup l2_grps_create
1587 def MakeGroupByCriteria(self, groupName, theCriteria):
1588 aFilterMgr = self.smeshpyD.CreateFilterManager()
1589 aFilter = aFilterMgr.CreateFilter()
1590 aFilter.SetCriteria(theCriteria)
1591 group = self.MakeGroupByFilter(groupName, aFilter)
1592 aFilterMgr.UnRegister()
1595 ## Creates a mesh group by the given filter
1596 # @param groupName the name of the mesh group
1597 # @param theFilter the instance of Filter class
1598 # @return SMESH_Group
1599 # @ingroup l2_grps_create
1600 def MakeGroupByFilter(self, groupName, theFilter):
1601 group = self.CreateEmptyGroup(theFilter.GetElementType(), groupName)
1602 theFilter.SetMesh( self.mesh )
1603 group.AddFrom( theFilter )
1606 ## Passes mesh elements through the given filter and return IDs of fitting elements
1607 # @param theFilter SMESH_Filter
1608 # @return a list of ids
1609 # @ingroup l1_controls
1610 def GetIdsFromFilter(self, theFilter):
1611 theFilter.SetMesh( self.mesh )
1612 return theFilter.GetIDs()
1614 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1615 # Returns a list of special structures (borders).
1616 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1617 # @ingroup l1_controls
1618 def GetFreeBorders(self):
1619 aFilterMgr = self.smeshpyD.CreateFilterManager()
1620 aPredicate = aFilterMgr.CreateFreeEdges()
1621 aPredicate.SetMesh(self.mesh)
1622 aBorders = aPredicate.GetBorders()
1623 aFilterMgr.UnRegister()
1627 # @ingroup l2_grps_delete
1628 def RemoveGroup(self, group):
1629 self.mesh.RemoveGroup(group)
1631 ## Removes a group with its contents
1632 # @ingroup l2_grps_delete
1633 def RemoveGroupWithContents(self, group):
1634 self.mesh.RemoveGroupWithContents(group)
1636 ## Gets the list of groups existing in the mesh
1637 # @return a sequence of SMESH_GroupBase
1638 # @ingroup l2_grps_create
1639 def GetGroups(self):
1640 return self.mesh.GetGroups()
1642 ## Gets the number of groups existing in the mesh
1643 # @return the quantity of groups as an integer value
1644 # @ingroup l2_grps_create
1646 return self.mesh.NbGroups()
1648 ## Gets the list of names of groups existing in the mesh
1649 # @return list of strings
1650 # @ingroup l2_grps_create
1651 def GetGroupNames(self):
1652 groups = self.GetGroups()
1654 for group in groups:
1655 names.append(group.GetName())
1658 ## Produces a union of two groups
1659 # A new group is created. All mesh elements that are
1660 # present in the initial groups are added to the new one
1661 # @return an instance of SMESH_Group
1662 # @ingroup l2_grps_operon
1663 def UnionGroups(self, group1, group2, name):
1664 return self.mesh.UnionGroups(group1, group2, name)
1666 ## Produces a union list of groups
1667 # New group is created. All mesh elements that are present in
1668 # initial groups are added to the new one
1669 # @return an instance of SMESH_Group
1670 # @ingroup l2_grps_operon
1671 def UnionListOfGroups(self, groups, name):
1672 return self.mesh.UnionListOfGroups(groups, name)
1674 ## Prodices an intersection of two groups
1675 # A new group is created. All mesh elements that are common
1676 # for the two initial groups are added to the new one.
1677 # @return an instance of SMESH_Group
1678 # @ingroup l2_grps_operon
1679 def IntersectGroups(self, group1, group2, name):
1680 return self.mesh.IntersectGroups(group1, group2, name)
1682 ## Produces an intersection of groups
1683 # New group is created. All mesh elements that are present in all
1684 # initial groups simultaneously are added to the new one
1685 # @return an instance of SMESH_Group
1686 # @ingroup l2_grps_operon
1687 def IntersectListOfGroups(self, groups, name):
1688 return self.mesh.IntersectListOfGroups(groups, name)
1690 ## Produces a cut of two groups
1691 # A new group is created. All mesh elements that are present in
1692 # the main group but are not present in the tool group are added to the new one
1693 # @return an instance of SMESH_Group
1694 # @ingroup l2_grps_operon
1695 def CutGroups(self, main_group, tool_group, name):
1696 return self.mesh.CutGroups(main_group, tool_group, name)
1698 ## Produces a cut of groups
1699 # A new group is created. All mesh elements that are present in main groups
1700 # but do not present in tool groups are added to the new one
1701 # @return an instance of SMESH_Group
1702 # @ingroup l2_grps_operon
1703 def CutListOfGroups(self, main_groups, tool_groups, name):
1704 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1706 ## Produces a group of elements of specified type using list of existing groups
1707 # A new group is created. System
1708 # 1) extracts all nodes on which groups elements are built
1709 # 2) combines all elements of specified dimension laying on these nodes
1710 # @return an instance of SMESH_Group
1711 # @ingroup l2_grps_operon
1712 def CreateDimGroup(self, groups, elem_type, name):
1713 return self.mesh.CreateDimGroup(groups, elem_type, name)
1716 ## Convert group on geom into standalone group
1717 # @ingroup l2_grps_delete
1718 def ConvertToStandalone(self, group):
1719 return self.mesh.ConvertToStandalone(group)
1721 # Get some info about mesh:
1722 # ------------------------
1724 ## Returns the log of nodes and elements added or removed
1725 # since the previous clear of the log.
1726 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1727 # @return list of log_block structures:
1732 # @ingroup l1_auxiliary
1733 def GetLog(self, clearAfterGet):
1734 return self.mesh.GetLog(clearAfterGet)
1736 ## Clears the log of nodes and elements added or removed since the previous
1737 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1738 # @ingroup l1_auxiliary
1740 self.mesh.ClearLog()
1742 ## Toggles auto color mode on the object.
1743 # @param theAutoColor the flag which toggles auto color mode.
1744 # @ingroup l1_auxiliary
1745 def SetAutoColor(self, theAutoColor):
1746 self.mesh.SetAutoColor(theAutoColor)
1748 ## Gets flag of object auto color mode.
1749 # @return True or False
1750 # @ingroup l1_auxiliary
1751 def GetAutoColor(self):
1752 return self.mesh.GetAutoColor()
1754 ## Gets the internal ID
1755 # @return integer value, which is the internal Id of the mesh
1756 # @ingroup l1_auxiliary
1758 return self.mesh.GetId()
1761 # @return integer value, which is the study Id of the mesh
1762 # @ingroup l1_auxiliary
1763 def GetStudyId(self):
1764 return self.mesh.GetStudyId()
1766 ## Checks the group names for duplications.
1767 # Consider the maximum group name length stored in MED file.
1768 # @return True or False
1769 # @ingroup l1_auxiliary
1770 def HasDuplicatedGroupNamesMED(self):
1771 return self.mesh.HasDuplicatedGroupNamesMED()
1773 ## Obtains the mesh editor tool
1774 # @return an instance of SMESH_MeshEditor
1775 # @ingroup l1_modifying
1776 def GetMeshEditor(self):
1777 return self.mesh.GetMeshEditor()
1779 ## Wrap a list of IDs of elements or nodes into SMESH_IDSource which
1780 # can be passed as argument to accepting mesh, group or sub-mesh
1781 # @return an instance of SMESH_IDSource
1782 # @ingroup l1_auxiliary
1783 def GetIDSource(self, ids, elemType):
1784 return self.GetMeshEditor().MakeIDSource(ids, elemType)
1787 # @return an instance of SALOME_MED::MESH
1788 # @ingroup l1_auxiliary
1789 def GetMEDMesh(self):
1790 return self.mesh.GetMEDMesh()
1793 # Get informations about mesh contents:
1794 # ------------------------------------
1796 ## Gets the mesh stattistic
1797 # @return dictionary type element - count of elements
1798 # @ingroup l1_meshinfo
1799 def GetMeshInfo(self, obj = None):
1800 if not obj: obj = self.mesh
1801 return self.smeshpyD.GetMeshInfo(obj)
1803 ## Returns the number of nodes in the mesh
1804 # @return an integer value
1805 # @ingroup l1_meshinfo
1807 return self.mesh.NbNodes()
1809 ## Returns the number of elements in the mesh
1810 # @return an integer value
1811 # @ingroup l1_meshinfo
1812 def NbElements(self):
1813 return self.mesh.NbElements()
1815 ## Returns the number of 0d elements in the mesh
1816 # @return an integer value
1817 # @ingroup l1_meshinfo
1818 def Nb0DElements(self):
1819 return self.mesh.Nb0DElements()
1821 ## Returns the number of edges in the mesh
1822 # @return an integer value
1823 # @ingroup l1_meshinfo
1825 return self.mesh.NbEdges()
1827 ## Returns the number of edges with the given order in the mesh
1828 # @param elementOrder the order of elements:
1829 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1830 # @return an integer value
1831 # @ingroup l1_meshinfo
1832 def NbEdgesOfOrder(self, elementOrder):
1833 return self.mesh.NbEdgesOfOrder(elementOrder)
1835 ## Returns the number of faces in the mesh
1836 # @return an integer value
1837 # @ingroup l1_meshinfo
1839 return self.mesh.NbFaces()
1841 ## Returns the number of faces with the given order in the mesh
1842 # @param elementOrder the order of elements:
1843 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1844 # @return an integer value
1845 # @ingroup l1_meshinfo
1846 def NbFacesOfOrder(self, elementOrder):
1847 return self.mesh.NbFacesOfOrder(elementOrder)
1849 ## Returns the number of triangles in the mesh
1850 # @return an integer value
1851 # @ingroup l1_meshinfo
1852 def NbTriangles(self):
1853 return self.mesh.NbTriangles()
1855 ## Returns the number of triangles with the given order in the mesh
1856 # @param elementOrder is the order of elements:
1857 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1858 # @return an integer value
1859 # @ingroup l1_meshinfo
1860 def NbTrianglesOfOrder(self, elementOrder):
1861 return self.mesh.NbTrianglesOfOrder(elementOrder)
1863 ## Returns the number of quadrangles in the mesh
1864 # @return an integer value
1865 # @ingroup l1_meshinfo
1866 def NbQuadrangles(self):
1867 return self.mesh.NbQuadrangles()
1869 ## Returns the number of quadrangles with the given order in the mesh
1870 # @param elementOrder the order of elements:
1871 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1872 # @return an integer value
1873 # @ingroup l1_meshinfo
1874 def NbQuadranglesOfOrder(self, elementOrder):
1875 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1877 ## Returns the number of biquadratic quadrangles in the mesh
1878 # @return an integer value
1879 # @ingroup l1_meshinfo
1880 def NbBiQuadQuadrangles(self):
1881 return self.mesh.NbBiQuadQuadrangles()
1883 ## Returns the number of polygons in the mesh
1884 # @return an integer value
1885 # @ingroup l1_meshinfo
1886 def NbPolygons(self):
1887 return self.mesh.NbPolygons()
1889 ## Returns the number of volumes in the mesh
1890 # @return an integer value
1891 # @ingroup l1_meshinfo
1892 def NbVolumes(self):
1893 return self.mesh.NbVolumes()
1895 ## Returns the number of volumes with the given order in the mesh
1896 # @param elementOrder the order of elements:
1897 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1898 # @return an integer value
1899 # @ingroup l1_meshinfo
1900 def NbVolumesOfOrder(self, elementOrder):
1901 return self.mesh.NbVolumesOfOrder(elementOrder)
1903 ## Returns the number of tetrahedrons in the mesh
1904 # @return an integer value
1905 # @ingroup l1_meshinfo
1907 return self.mesh.NbTetras()
1909 ## Returns the number of tetrahedrons 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 NbTetrasOfOrder(self, elementOrder):
1915 return self.mesh.NbTetrasOfOrder(elementOrder)
1917 ## Returns the number of hexahedrons in the mesh
1918 # @return an integer value
1919 # @ingroup l1_meshinfo
1921 return self.mesh.NbHexas()
1923 ## Returns the number of hexahedrons with the given order in the mesh
1924 # @param elementOrder the order of elements:
1925 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1926 # @return an integer value
1927 # @ingroup l1_meshinfo
1928 def NbHexasOfOrder(self, elementOrder):
1929 return self.mesh.NbHexasOfOrder(elementOrder)
1931 ## Returns the number of triquadratic hexahedrons in the mesh
1932 # @return an integer value
1933 # @ingroup l1_meshinfo
1934 def NbTriQuadraticHexas(self):
1935 return self.mesh.NbTriQuadraticHexas()
1937 ## Returns the number of pyramids in the mesh
1938 # @return an integer value
1939 # @ingroup l1_meshinfo
1940 def NbPyramids(self):
1941 return self.mesh.NbPyramids()
1943 ## Returns the number of pyramids with the given order in the mesh
1944 # @param elementOrder the order of elements:
1945 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1946 # @return an integer value
1947 # @ingroup l1_meshinfo
1948 def NbPyramidsOfOrder(self, elementOrder):
1949 return self.mesh.NbPyramidsOfOrder(elementOrder)
1951 ## Returns the number of prisms in the mesh
1952 # @return an integer value
1953 # @ingroup l1_meshinfo
1955 return self.mesh.NbPrisms()
1957 ## Returns the number of prisms with the given order in the mesh
1958 # @param elementOrder the order of elements:
1959 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1960 # @return an integer value
1961 # @ingroup l1_meshinfo
1962 def NbPrismsOfOrder(self, elementOrder):
1963 return self.mesh.NbPrismsOfOrder(elementOrder)
1965 ## Returns the number of hexagonal prisms in the mesh
1966 # @return an integer value
1967 # @ingroup l1_meshinfo
1968 def NbHexagonalPrisms(self):
1969 return self.mesh.NbHexagonalPrisms()
1971 ## Returns the number of polyhedrons in the mesh
1972 # @return an integer value
1973 # @ingroup l1_meshinfo
1974 def NbPolyhedrons(self):
1975 return self.mesh.NbPolyhedrons()
1977 ## Returns the number of submeshes in the mesh
1978 # @return an integer value
1979 # @ingroup l1_meshinfo
1980 def NbSubMesh(self):
1981 return self.mesh.NbSubMesh()
1983 ## Returns the list of mesh elements IDs
1984 # @return the list of integer values
1985 # @ingroup l1_meshinfo
1986 def GetElementsId(self):
1987 return self.mesh.GetElementsId()
1989 ## Returns the list of IDs of mesh elements with the given type
1990 # @param elementType the required type of elements (SMESH.NODE, SMESH.EDGE, SMESH.FACE or SMESH.VOLUME)
1991 # @return list of integer values
1992 # @ingroup l1_meshinfo
1993 def GetElementsByType(self, elementType):
1994 return self.mesh.GetElementsByType(elementType)
1996 ## Returns the list of mesh nodes IDs
1997 # @return the list of integer values
1998 # @ingroup l1_meshinfo
1999 def GetNodesId(self):
2000 return self.mesh.GetNodesId()
2002 # Get the information about mesh elements:
2003 # ------------------------------------
2005 ## Returns the type of mesh element
2006 # @return the value from SMESH::ElementType enumeration
2007 # @ingroup l1_meshinfo
2008 def GetElementType(self, id, iselem):
2009 return self.mesh.GetElementType(id, iselem)
2011 ## Returns the geometric type of mesh element
2012 # @return the value from SMESH::EntityType enumeration
2013 # @ingroup l1_meshinfo
2014 def GetElementGeomType(self, id):
2015 return self.mesh.GetElementGeomType(id)
2017 ## Returns the list of submesh elements IDs
2018 # @param Shape a geom object(sub-shape) IOR
2019 # Shape must be the sub-shape of a ShapeToMesh()
2020 # @return the list of integer values
2021 # @ingroup l1_meshinfo
2022 def GetSubMeshElementsId(self, Shape):
2023 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2024 ShapeID = Shape.GetSubShapeIndices()[0]
2027 return self.mesh.GetSubMeshElementsId(ShapeID)
2029 ## Returns the list of submesh nodes IDs
2030 # @param Shape a geom object(sub-shape) IOR
2031 # Shape must be the sub-shape of a ShapeToMesh()
2032 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
2033 # @return the list of integer values
2034 # @ingroup l1_meshinfo
2035 def GetSubMeshNodesId(self, Shape, all):
2036 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2037 ShapeID = Shape.GetSubShapeIndices()[0]
2040 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2042 ## Returns type of elements on given shape
2043 # @param Shape a geom object(sub-shape) IOR
2044 # Shape must be a sub-shape of a ShapeToMesh()
2045 # @return element type
2046 # @ingroup l1_meshinfo
2047 def GetSubMeshElementType(self, Shape):
2048 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2049 ShapeID = Shape.GetSubShapeIndices()[0]
2052 return self.mesh.GetSubMeshElementType(ShapeID)
2054 ## Gets the mesh description
2055 # @return string value
2056 # @ingroup l1_meshinfo
2058 return self.mesh.Dump()
2061 # Get the information about nodes and elements of a mesh by its IDs:
2062 # -----------------------------------------------------------
2064 ## Gets XYZ coordinates of a node
2065 # \n If there is no nodes for the given ID - returns an empty list
2066 # @return a list of double precision values
2067 # @ingroup l1_meshinfo
2068 def GetNodeXYZ(self, id):
2069 return self.mesh.GetNodeXYZ(id)
2071 ## Returns list of IDs of inverse elements for the given node
2072 # \n If there is no node for the given ID - returns an empty list
2073 # @return a list of integer values
2074 # @ingroup l1_meshinfo
2075 def GetNodeInverseElements(self, id):
2076 return self.mesh.GetNodeInverseElements(id)
2078 ## @brief Returns the position of a node on the shape
2079 # @return SMESH::NodePosition
2080 # @ingroup l1_meshinfo
2081 def GetNodePosition(self,NodeID):
2082 return self.mesh.GetNodePosition(NodeID)
2084 ## If the given element is a node, returns the ID of shape
2085 # \n If there is no node for the given ID - returns -1
2086 # @return an integer value
2087 # @ingroup l1_meshinfo
2088 def GetShapeID(self, id):
2089 return self.mesh.GetShapeID(id)
2091 ## Returns the ID of the result shape after
2092 # FindShape() from SMESH_MeshEditor for the given element
2093 # \n If there is no element for the given ID - returns -1
2094 # @return an integer value
2095 # @ingroup l1_meshinfo
2096 def GetShapeIDForElem(self,id):
2097 return self.mesh.GetShapeIDForElem(id)
2099 ## Returns the number of nodes for the given element
2100 # \n If there is no element for the given ID - returns -1
2101 # @return an integer value
2102 # @ingroup l1_meshinfo
2103 def GetElemNbNodes(self, id):
2104 return self.mesh.GetElemNbNodes(id)
2106 ## Returns the node ID the given index for the given element
2107 # \n If there is no element for the given ID - returns -1
2108 # \n If there is no node for the given index - returns -2
2109 # @return an integer value
2110 # @ingroup l1_meshinfo
2111 def GetElemNode(self, id, index):
2112 return self.mesh.GetElemNode(id, index)
2114 ## Returns the IDs of nodes of the given element
2115 # @return a list of integer values
2116 # @ingroup l1_meshinfo
2117 def GetElemNodes(self, id):
2118 return self.mesh.GetElemNodes(id)
2120 ## Returns true if the given node is the medium node in the given quadratic element
2121 # @ingroup l1_meshinfo
2122 def IsMediumNode(self, elementID, nodeID):
2123 return self.mesh.IsMediumNode(elementID, nodeID)
2125 ## Returns true if the given node is the medium node in one of quadratic elements
2126 # @ingroup l1_meshinfo
2127 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2128 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2130 ## Returns the number of edges for the given element
2131 # @ingroup l1_meshinfo
2132 def ElemNbEdges(self, id):
2133 return self.mesh.ElemNbEdges(id)
2135 ## Returns the number of faces for the given element
2136 # @ingroup l1_meshinfo
2137 def ElemNbFaces(self, id):
2138 return self.mesh.ElemNbFaces(id)
2140 ## Returns nodes of given face (counted from zero) for given volumic element.
2141 # @ingroup l1_meshinfo
2142 def GetElemFaceNodes(self,elemId, faceIndex):
2143 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2145 ## Returns an element based on all given nodes.
2146 # @ingroup l1_meshinfo
2147 def FindElementByNodes(self,nodes):
2148 return self.mesh.FindElementByNodes(nodes)
2150 ## Returns true if the given element is a polygon
2151 # @ingroup l1_meshinfo
2152 def IsPoly(self, id):
2153 return self.mesh.IsPoly(id)
2155 ## Returns true if the given element is quadratic
2156 # @ingroup l1_meshinfo
2157 def IsQuadratic(self, id):
2158 return self.mesh.IsQuadratic(id)
2160 ## Returns XYZ coordinates of the barycenter of the given element
2161 # \n If there is no element for the given ID - returns an empty list
2162 # @return a list of three double values
2163 # @ingroup l1_meshinfo
2164 def BaryCenter(self, id):
2165 return self.mesh.BaryCenter(id)
2168 # Get mesh measurements information:
2169 # ------------------------------------
2171 ## Get minimum distance between two nodes, elements or distance to the origin
2172 # @param id1 first node/element id
2173 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2174 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2175 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2176 # @return minimum distance value
2177 # @sa GetMinDistance()
2178 def MinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2179 aMeasure = self.GetMinDistance(id1, id2, isElem1, isElem2)
2180 return aMeasure.value
2182 ## Get measure structure specifying minimum distance data between two objects
2183 # @param id1 first node/element id
2184 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2185 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2186 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2187 # @return Measure structure
2189 def GetMinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2191 id1 = self.editor.MakeIDSource([id1], SMESH.FACE)
2193 id1 = self.editor.MakeIDSource([id1], SMESH.NODE)
2196 id2 = self.editor.MakeIDSource([id2], SMESH.FACE)
2198 id2 = self.editor.MakeIDSource([id2], SMESH.NODE)
2203 aMeasurements = self.smeshpyD.CreateMeasurements()
2204 aMeasure = aMeasurements.MinDistance(id1, id2)
2205 aMeasurements.UnRegister()
2208 ## Get bounding box of the specified object(s)
2209 # @param objects single source object or list of source objects or list of nodes/elements IDs
2210 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2211 # @c False specifies that @a objects are nodes
2212 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
2213 # @sa GetBoundingBox()
2214 def BoundingBox(self, objects=None, isElem=False):
2215 result = self.GetBoundingBox(objects, isElem)
2219 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
2222 ## Get measure structure specifying bounding box data of the specified object(s)
2223 # @param IDs single source object or list of source objects or list of nodes/elements IDs
2224 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2225 # @c False specifies that @a objects are nodes
2226 # @return Measure structure
2228 def GetBoundingBox(self, IDs=None, isElem=False):
2231 elif isinstance(IDs, tuple):
2233 if not isinstance(IDs, list):
2235 if len(IDs) > 0 and isinstance(IDs[0], int):
2239 if isinstance(o, Mesh):
2240 srclist.append(o.mesh)
2241 elif hasattr(o, "_narrow"):
2242 src = o._narrow(SMESH.SMESH_IDSource)
2243 if src: srclist.append(src)
2245 elif isinstance(o, list):
2247 srclist.append(self.editor.MakeIDSource(o, SMESH.FACE))
2249 srclist.append(self.editor.MakeIDSource(o, SMESH.NODE))
2252 aMeasurements = self.smeshpyD.CreateMeasurements()
2253 aMeasure = aMeasurements.BoundingBox(srclist)
2254 aMeasurements.UnRegister()
2257 # Mesh edition (SMESH_MeshEditor functionality):
2258 # ---------------------------------------------
2260 ## Removes the elements from the mesh by ids
2261 # @param IDsOfElements is a list of ids of elements to remove
2262 # @return True or False
2263 # @ingroup l2_modif_del
2264 def RemoveElements(self, IDsOfElements):
2265 return self.editor.RemoveElements(IDsOfElements)
2267 ## Removes nodes from mesh by ids
2268 # @param IDsOfNodes is a list of ids of nodes to remove
2269 # @return True or False
2270 # @ingroup l2_modif_del
2271 def RemoveNodes(self, IDsOfNodes):
2272 return self.editor.RemoveNodes(IDsOfNodes)
2274 ## Removes all orphan (free) nodes from mesh
2275 # @return number of the removed nodes
2276 # @ingroup l2_modif_del
2277 def RemoveOrphanNodes(self):
2278 return self.editor.RemoveOrphanNodes()
2280 ## Add a node to the mesh by coordinates
2281 # @return Id of the new node
2282 # @ingroup l2_modif_add
2283 def AddNode(self, x, y, z):
2284 x,y,z,Parameters,hasVars = ParseParameters(x,y,z)
2285 if hasVars: self.mesh.SetParameters(Parameters)
2286 return self.editor.AddNode( x, y, z)
2288 ## Creates a 0D element on a node with given number.
2289 # @param IDOfNode the ID of node for creation of the element.
2290 # @return the Id of the new 0D element
2291 # @ingroup l2_modif_add
2292 def Add0DElement(self, IDOfNode):
2293 return self.editor.Add0DElement(IDOfNode)
2295 ## Creates a linear or quadratic edge (this is determined
2296 # by the number of given nodes).
2297 # @param IDsOfNodes the list of node IDs for creation of the element.
2298 # The order of nodes in this list should correspond to the description
2299 # of MED. \n This description is located by the following link:
2300 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2301 # @return the Id of the new edge
2302 # @ingroup l2_modif_add
2303 def AddEdge(self, IDsOfNodes):
2304 return self.editor.AddEdge(IDsOfNodes)
2306 ## Creates a linear or quadratic face (this is determined
2307 # by the number of given nodes).
2308 # @param IDsOfNodes the list of node IDs for creation of the element.
2309 # The order of nodes in this list should correspond to the description
2310 # of MED. \n This description is located by the following link:
2311 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2312 # @return the Id of the new face
2313 # @ingroup l2_modif_add
2314 def AddFace(self, IDsOfNodes):
2315 return self.editor.AddFace(IDsOfNodes)
2317 ## Adds a polygonal face to the mesh by the list of node IDs
2318 # @param IdsOfNodes the list of node IDs for creation of the element.
2319 # @return the Id of the new face
2320 # @ingroup l2_modif_add
2321 def AddPolygonalFace(self, IdsOfNodes):
2322 return self.editor.AddPolygonalFace(IdsOfNodes)
2324 ## Creates both simple and quadratic volume (this is determined
2325 # by the number of given nodes).
2326 # @param IDsOfNodes the list of node IDs for creation of the element.
2327 # The order of nodes in this list should correspond to the description
2328 # of MED. \n This description is located by the following link:
2329 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2330 # @return the Id of the new volumic element
2331 # @ingroup l2_modif_add
2332 def AddVolume(self, IDsOfNodes):
2333 return self.editor.AddVolume(IDsOfNodes)
2335 ## Creates a volume of many faces, giving nodes for each face.
2336 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2337 # @param Quantities the list of integer values, Quantities[i]
2338 # gives the quantity of nodes in face number i.
2339 # @return the Id of the new volumic element
2340 # @ingroup l2_modif_add
2341 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2342 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2344 ## Creates a volume of many faces, giving the IDs of the existing faces.
2345 # @param IdsOfFaces the list of face IDs for volume creation.
2347 # Note: The created volume will refer only to the nodes
2348 # of the given faces, not to the faces themselves.
2349 # @return the Id of the new volumic element
2350 # @ingroup l2_modif_add
2351 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2352 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2355 ## @brief Binds a node to a vertex
2356 # @param NodeID a node ID
2357 # @param Vertex a vertex or vertex ID
2358 # @return True if succeed else raises an exception
2359 # @ingroup l2_modif_add
2360 def SetNodeOnVertex(self, NodeID, Vertex):
2361 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2362 VertexID = Vertex.GetSubShapeIndices()[0]
2366 self.editor.SetNodeOnVertex(NodeID, VertexID)
2367 except SALOME.SALOME_Exception, inst:
2368 raise ValueError, inst.details.text
2372 ## @brief Stores the node position on an edge
2373 # @param NodeID a node ID
2374 # @param Edge an edge or edge ID
2375 # @param paramOnEdge a parameter on the edge where the node is located
2376 # @return True if succeed else raises an exception
2377 # @ingroup l2_modif_add
2378 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2379 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2380 EdgeID = Edge.GetSubShapeIndices()[0]
2384 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2385 except SALOME.SALOME_Exception, inst:
2386 raise ValueError, inst.details.text
2389 ## @brief Stores node position on a face
2390 # @param NodeID a node ID
2391 # @param Face a face or face ID
2392 # @param u U parameter on the face where the node is located
2393 # @param v V parameter on the face where the node is located
2394 # @return True if succeed else raises an exception
2395 # @ingroup l2_modif_add
2396 def SetNodeOnFace(self, NodeID, Face, u, v):
2397 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2398 FaceID = Face.GetSubShapeIndices()[0]
2402 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2403 except SALOME.SALOME_Exception, inst:
2404 raise ValueError, inst.details.text
2407 ## @brief Binds a node to a solid
2408 # @param NodeID a node ID
2409 # @param Solid a solid or solid ID
2410 # @return True if succeed else raises an exception
2411 # @ingroup l2_modif_add
2412 def SetNodeInVolume(self, NodeID, Solid):
2413 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2414 SolidID = Solid.GetSubShapeIndices()[0]
2418 self.editor.SetNodeInVolume(NodeID, SolidID)
2419 except SALOME.SALOME_Exception, inst:
2420 raise ValueError, inst.details.text
2423 ## @brief Bind an element to a shape
2424 # @param ElementID an element ID
2425 # @param Shape a shape or shape ID
2426 # @return True if succeed else raises an exception
2427 # @ingroup l2_modif_add
2428 def SetMeshElementOnShape(self, ElementID, Shape):
2429 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2430 ShapeID = Shape.GetSubShapeIndices()[0]
2434 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2435 except SALOME.SALOME_Exception, inst:
2436 raise ValueError, inst.details.text
2440 ## Moves the node with the given id
2441 # @param NodeID the id of the node
2442 # @param x a new X coordinate
2443 # @param y a new Y coordinate
2444 # @param z a new Z coordinate
2445 # @return True if succeed else False
2446 # @ingroup l2_modif_movenode
2447 def MoveNode(self, NodeID, x, y, z):
2448 x,y,z,Parameters,hasVars = ParseParameters(x,y,z)
2449 if hasVars: self.mesh.SetParameters(Parameters)
2450 return self.editor.MoveNode(NodeID, x, y, z)
2452 ## Finds the node closest to a point and moves it to a point location
2453 # @param x the X coordinate of a point
2454 # @param y the Y coordinate of a point
2455 # @param z the Z coordinate of a point
2456 # @param NodeID if specified (>0), the node with this ID is moved,
2457 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2458 # @return the ID of a node
2459 # @ingroup l2_modif_throughp
2460 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2461 x,y,z,Parameters,hasVars = ParseParameters(x,y,z)
2462 if hasVars: self.mesh.SetParameters(Parameters)
2463 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2465 ## Finds the node closest to a point
2466 # @param x the X coordinate of a point
2467 # @param y the Y coordinate of a point
2468 # @param z the Z coordinate of a point
2469 # @return the ID of a node
2470 # @ingroup l2_modif_throughp
2471 def FindNodeClosestTo(self, x, y, z):
2472 #preview = self.mesh.GetMeshEditPreviewer()
2473 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2474 return self.editor.FindNodeClosestTo(x, y, z)
2476 ## Finds the elements where a point lays IN or ON
2477 # @param x the X coordinate of a point
2478 # @param y the Y coordinate of a point
2479 # @param z the Z coordinate of a point
2480 # @param elementType type of elements to find (SMESH.ALL type
2481 # means elements of any type excluding nodes and 0D elements)
2482 # @param meshPart a part of mesh (group, sub-mesh) to search within
2483 # @return list of IDs of found elements
2484 # @ingroup l2_modif_throughp
2485 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL, meshPart=None):
2487 return self.editor.FindAmongElementsByPoint( meshPart, x, y, z, elementType );
2489 return self.editor.FindElementsByPoint(x, y, z, elementType)
2491 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2492 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2494 def GetPointState(self, x, y, z):
2495 return self.editor.GetPointState(x, y, z)
2497 ## Finds the node closest to a point and moves it to a point location
2498 # @param x the X coordinate of a point
2499 # @param y the Y coordinate of a point
2500 # @param z the Z coordinate of a point
2501 # @return the ID of a moved node
2502 # @ingroup l2_modif_throughp
2503 def MeshToPassThroughAPoint(self, x, y, z):
2504 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2506 ## Replaces two neighbour triangles sharing Node1-Node2 link
2507 # with the triangles built on the same 4 nodes but having other common link.
2508 # @param NodeID1 the ID of the first node
2509 # @param NodeID2 the ID of the second node
2510 # @return false if proper faces were not found
2511 # @ingroup l2_modif_invdiag
2512 def InverseDiag(self, NodeID1, NodeID2):
2513 return self.editor.InverseDiag(NodeID1, NodeID2)
2515 ## Replaces two neighbour triangles sharing Node1-Node2 link
2516 # with a quadrangle built on the same 4 nodes.
2517 # @param NodeID1 the ID of the first node
2518 # @param NodeID2 the ID of the second node
2519 # @return false if proper faces were not found
2520 # @ingroup l2_modif_unitetri
2521 def DeleteDiag(self, NodeID1, NodeID2):
2522 return self.editor.DeleteDiag(NodeID1, NodeID2)
2524 ## Reorients elements by ids
2525 # @param IDsOfElements if undefined reorients all mesh elements
2526 # @return True if succeed else False
2527 # @ingroup l2_modif_changori
2528 def Reorient(self, IDsOfElements=None):
2529 if IDsOfElements == None:
2530 IDsOfElements = self.GetElementsId()
2531 return self.editor.Reorient(IDsOfElements)
2533 ## Reorients all elements of the object
2534 # @param theObject mesh, submesh or group
2535 # @return True if succeed else False
2536 # @ingroup l2_modif_changori
2537 def ReorientObject(self, theObject):
2538 if ( isinstance( theObject, Mesh )):
2539 theObject = theObject.GetMesh()
2540 return self.editor.ReorientObject(theObject)
2542 ## Fuses the neighbouring triangles into quadrangles.
2543 # @param IDsOfElements The triangles to be fused,
2544 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2545 # @param MaxAngle is the maximum angle between element normals at which the fusion
2546 # is still performed; theMaxAngle is mesured in radians.
2547 # Also it could be a name of variable which defines angle in degrees.
2548 # @return TRUE in case of success, FALSE otherwise.
2549 # @ingroup l2_modif_unitetri
2550 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2552 if isinstance(MaxAngle,str):
2554 MaxAngle,Parameters,hasVars = ParseAngles(MaxAngle)
2555 self.mesh.SetParameters(Parameters)
2556 if not IDsOfElements:
2557 IDsOfElements = self.GetElementsId()
2559 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2560 Functor = theCriterion
2562 Functor = self.smeshpyD.GetFunctor(theCriterion)
2563 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2565 ## Fuses the neighbouring triangles of the object into quadrangles
2566 # @param theObject is mesh, submesh or group
2567 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2568 # @param MaxAngle a max angle between element normals at which the fusion
2569 # is still performed; theMaxAngle is mesured in radians.
2570 # @return TRUE in case of success, FALSE otherwise.
2571 # @ingroup l2_modif_unitetri
2572 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2573 MaxAngle,Parameters,hasVars = ParseAngles(MaxAngle)
2574 self.mesh.SetParameters(Parameters)
2575 if ( isinstance( theObject, Mesh )):
2576 theObject = theObject.GetMesh()
2577 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2579 ## Splits quadrangles into triangles.
2580 # @param IDsOfElements the faces to be splitted.
2581 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2582 # @return TRUE in case of success, FALSE otherwise.
2583 # @ingroup l2_modif_cutquadr
2584 def QuadToTri (self, IDsOfElements, theCriterion):
2585 if IDsOfElements == []:
2586 IDsOfElements = self.GetElementsId()
2587 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2589 ## Splits quadrangles into triangles.
2590 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2591 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2592 # @return TRUE in case of success, FALSE otherwise.
2593 # @ingroup l2_modif_cutquadr
2594 def QuadToTriObject (self, theObject, theCriterion):
2595 if ( isinstance( theObject, Mesh )):
2596 theObject = theObject.GetMesh()
2597 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2599 ## Splits quadrangles into triangles.
2600 # @param IDsOfElements the faces to be splitted
2601 # @param Diag13 is used to choose a diagonal for splitting.
2602 # @return TRUE in case of success, FALSE otherwise.
2603 # @ingroup l2_modif_cutquadr
2604 def SplitQuad (self, IDsOfElements, Diag13):
2605 if IDsOfElements == []:
2606 IDsOfElements = self.GetElementsId()
2607 return self.editor.SplitQuad(IDsOfElements, Diag13)
2609 ## Splits quadrangles into triangles.
2610 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2611 # @param Diag13 is used to choose a diagonal for splitting.
2612 # @return TRUE in case of success, FALSE otherwise.
2613 # @ingroup l2_modif_cutquadr
2614 def SplitQuadObject (self, theObject, Diag13):
2615 if ( isinstance( theObject, Mesh )):
2616 theObject = theObject.GetMesh()
2617 return self.editor.SplitQuadObject(theObject, Diag13)
2619 ## Finds a better splitting of the given quadrangle.
2620 # @param IDOfQuad the ID of the quadrangle to be splitted.
2621 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2622 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2623 # diagonal is better, 0 if error occurs.
2624 # @ingroup l2_modif_cutquadr
2625 def BestSplit (self, IDOfQuad, theCriterion):
2626 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2628 ## Splits volumic elements into tetrahedrons
2629 # @param elemIDs either list of elements or mesh or group or submesh
2630 # @param method flags passing splitting method: Hex_5Tet, Hex_6Tet, Hex_24Tet
2631 # Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc
2632 # @ingroup l2_modif_cutquadr
2633 def SplitVolumesIntoTetra(self, elemIDs, method=Hex_5Tet ):
2634 if isinstance( elemIDs, Mesh ):
2635 elemIDs = elemIDs.GetMesh()
2636 if ( isinstance( elemIDs, list )):
2637 elemIDs = self.editor.MakeIDSource(elemIDs, SMESH.VOLUME)
2638 self.editor.SplitVolumesIntoTetra(elemIDs, method)
2640 ## Splits quadrangle faces near triangular facets of volumes
2642 # @ingroup l1_auxiliary
2643 def SplitQuadsNearTriangularFacets(self):
2644 faces_array = self.GetElementsByType(SMESH.FACE)
2645 for face_id in faces_array:
2646 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2647 quad_nodes = self.mesh.GetElemNodes(face_id)
2648 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2649 isVolumeFound = False
2650 for node1_elem in node1_elems:
2651 if not isVolumeFound:
2652 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2653 nb_nodes = self.GetElemNbNodes(node1_elem)
2654 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2655 volume_elem = node1_elem
2656 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2657 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2658 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2659 isVolumeFound = True
2660 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2661 self.SplitQuad([face_id], False) # diagonal 2-4
2662 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2663 isVolumeFound = True
2664 self.SplitQuad([face_id], True) # diagonal 1-3
2665 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2666 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2667 isVolumeFound = True
2668 self.SplitQuad([face_id], True) # diagonal 1-3
2670 ## @brief Splits hexahedrons into tetrahedrons.
2672 # This operation uses pattern mapping functionality for splitting.
2673 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2674 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2675 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2676 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2677 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2678 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2679 # @return TRUE in case of success, FALSE otherwise.
2680 # @ingroup l1_auxiliary
2681 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2682 # Pattern: 5.---------.6
2687 # (0,0,1) 4.---------.7 * |
2694 # (0,0,0) 0.---------.3
2695 pattern_tetra = "!!! Nb of points: \n 8 \n\
2705 !!! Indices of points of 6 tetras: \n\
2713 pattern = self.smeshpyD.GetPattern()
2714 isDone = pattern.LoadFromFile(pattern_tetra)
2716 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2719 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2720 isDone = pattern.MakeMesh(self.mesh, False, False)
2721 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2723 # split quafrangle faces near triangular facets of volumes
2724 self.SplitQuadsNearTriangularFacets()
2728 ## @brief Split hexahedrons into prisms.
2730 # Uses the pattern mapping functionality for splitting.
2731 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2732 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2733 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2734 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2735 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2736 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2737 # @return TRUE in case of success, FALSE otherwise.
2738 # @ingroup l1_auxiliary
2739 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2740 # Pattern: 5.---------.6
2745 # (0,0,1) 4.---------.7 |
2752 # (0,0,0) 0.---------.3
2753 pattern_prism = "!!! Nb of points: \n 8 \n\
2763 !!! Indices of points of 2 prisms: \n\
2767 pattern = self.smeshpyD.GetPattern()
2768 isDone = pattern.LoadFromFile(pattern_prism)
2770 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2773 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2774 isDone = pattern.MakeMesh(self.mesh, False, False)
2775 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2777 # Splits quafrangle faces near triangular facets of volumes
2778 self.SplitQuadsNearTriangularFacets()
2782 ## Smoothes elements
2783 # @param IDsOfElements the list if ids of elements to smooth
2784 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2785 # Note that nodes built on edges and boundary nodes are always fixed.
2786 # @param MaxNbOfIterations the maximum number of iterations
2787 # @param MaxAspectRatio varies in range [1.0, inf]
2788 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2789 # @return TRUE in case of success, FALSE otherwise.
2790 # @ingroup l2_modif_smooth
2791 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2792 MaxNbOfIterations, MaxAspectRatio, Method):
2793 if IDsOfElements == []:
2794 IDsOfElements = self.GetElementsId()
2795 MaxNbOfIterations,MaxAspectRatio,Parameters,hasVars = ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2796 self.mesh.SetParameters(Parameters)
2797 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2798 MaxNbOfIterations, MaxAspectRatio, Method)
2800 ## Smoothes elements which belong to the given object
2801 # @param theObject the object to smooth
2802 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2803 # Note that nodes built on edges and boundary nodes are always fixed.
2804 # @param MaxNbOfIterations the maximum number of iterations
2805 # @param MaxAspectRatio varies in range [1.0, inf]
2806 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2807 # @return TRUE in case of success, FALSE otherwise.
2808 # @ingroup l2_modif_smooth
2809 def SmoothObject(self, theObject, IDsOfFixedNodes,
2810 MaxNbOfIterations, MaxAspectRatio, Method):
2811 if ( isinstance( theObject, Mesh )):
2812 theObject = theObject.GetMesh()
2813 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2814 MaxNbOfIterations, MaxAspectRatio, Method)
2816 ## Parametrically smoothes the given elements
2817 # @param IDsOfElements the list if ids of elements to smooth
2818 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2819 # Note that nodes built on edges and boundary nodes are always fixed.
2820 # @param MaxNbOfIterations the maximum number of iterations
2821 # @param MaxAspectRatio varies in range [1.0, inf]
2822 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2823 # @return TRUE in case of success, FALSE otherwise.
2824 # @ingroup l2_modif_smooth
2825 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2826 MaxNbOfIterations, MaxAspectRatio, Method):
2827 if IDsOfElements == []:
2828 IDsOfElements = self.GetElementsId()
2829 MaxNbOfIterations,MaxAspectRatio,Parameters,hasVars = ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2830 self.mesh.SetParameters(Parameters)
2831 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2832 MaxNbOfIterations, MaxAspectRatio, Method)
2834 ## Parametrically smoothes the elements which belong to the given object
2835 # @param theObject the object to smooth
2836 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2837 # Note that nodes built on edges and boundary nodes are always fixed.
2838 # @param MaxNbOfIterations the maximum number of iterations
2839 # @param MaxAspectRatio varies in range [1.0, inf]
2840 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2841 # @return TRUE in case of success, FALSE otherwise.
2842 # @ingroup l2_modif_smooth
2843 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2844 MaxNbOfIterations, MaxAspectRatio, Method):
2845 if ( isinstance( theObject, Mesh )):
2846 theObject = theObject.GetMesh()
2847 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2848 MaxNbOfIterations, MaxAspectRatio, Method)
2850 ## Converts the mesh to quadratic, deletes old elements, replacing
2851 # them with quadratic with the same id.
2852 # @param theForce3d new node creation method:
2853 # 0 - the medium node lies at the geometrical entity from which the mesh element is built
2854 # 1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element
2855 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
2856 # @ingroup l2_modif_tofromqu
2857 def ConvertToQuadratic(self, theForce3d, theSubMesh=None):
2859 self.editor.ConvertToQuadraticObject(theForce3d,theSubMesh)
2861 self.editor.ConvertToQuadratic(theForce3d)
2863 ## Converts the mesh from quadratic to ordinary,
2864 # deletes old quadratic elements, \n replacing
2865 # them with ordinary mesh elements with the same id.
2866 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
2867 # @ingroup l2_modif_tofromqu
2868 def ConvertFromQuadratic(self, theSubMesh=None):
2870 self.editor.ConvertFromQuadraticObject(theSubMesh)
2872 return self.editor.ConvertFromQuadratic()
2874 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
2875 # @return TRUE if operation has been completed successfully, FALSE otherwise
2876 # @ingroup l2_modif_edit
2877 def Make2DMeshFrom3D(self):
2878 return self.editor. Make2DMeshFrom3D()
2880 ## Creates missing boundary elements
2881 # @param elements - elements whose boundary is to be checked:
2882 # mesh, group, sub-mesh or list of elements
2883 # if elements is mesh, it must be the mesh whose MakeBoundaryMesh() is called
2884 # @param dimension - defines type of boundary elements to create:
2885 # SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D
2886 # SMESH.BND_1DFROM3D creates mesh edges on all borders of free facets of 3D cells
2887 # @param groupName - a name of group to store created boundary elements in,
2888 # "" means not to create the group
2889 # @param meshName - a name of new mesh to store created boundary elements in,
2890 # "" means not to create the new mesh
2891 # @param toCopyElements - if true, the checked elements will be copied into
2892 # the new mesh else only boundary elements will be copied into the new mesh
2893 # @param toCopyExistingBondary - if true, not only new but also pre-existing
2894 # boundary elements will be copied into the new mesh
2895 # @return tuple (mesh, group) where bondary elements were added to
2896 # @ingroup l2_modif_edit
2897 def MakeBoundaryMesh(self, elements, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
2898 toCopyElements=False, toCopyExistingBondary=False):
2899 if isinstance( elements, Mesh ):
2900 elements = elements.GetMesh()
2901 if ( isinstance( elements, list )):
2902 elemType = SMESH.ALL
2903 if elements: elemType = self.GetElementType( elements[0], iselem=True)
2904 elements = self.editor.MakeIDSource(elements, elemType)
2905 mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName,
2906 toCopyElements,toCopyExistingBondary)
2907 if mesh: mesh = self.smeshpyD.Mesh(mesh)
2911 # @brief Creates missing boundary elements around either the whole mesh or
2912 # groups of 2D elements
2913 # @param dimension - defines type of boundary elements to create
2914 # @param groupName - a name of group to store all boundary elements in,
2915 # "" means not to create the group
2916 # @param meshName - a name of a new mesh, which is a copy of the initial
2917 # mesh + created boundary elements; "" means not to create the new mesh
2918 # @param toCopyAll - if true, the whole initial mesh will be copied into
2919 # the new mesh else only boundary elements will be copied into the new mesh
2920 # @param groups - groups of 2D elements to make boundary around
2921 # @retval tuple( long, mesh, groups )
2922 # long - number of added boundary elements
2923 # mesh - the mesh where elements were added to
2924 # group - the group of boundary elements or None
2926 def MakeBoundaryElements(self, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
2927 toCopyAll=False, groups=[]):
2928 nb, mesh, group = self.editor.MakeBoundaryElements(dimension,groupName,meshName,
2930 if mesh: mesh = self.smeshpyD.Mesh(mesh)
2931 return nb, mesh, group
2933 ## Renumber mesh nodes
2934 # @ingroup l2_modif_renumber
2935 def RenumberNodes(self):
2936 self.editor.RenumberNodes()
2938 ## Renumber mesh elements
2939 # @ingroup l2_modif_renumber
2940 def RenumberElements(self):
2941 self.editor.RenumberElements()
2943 ## Generates new elements by rotation of the elements around the axis
2944 # @param IDsOfElements the list of ids of elements to sweep
2945 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2946 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2947 # @param NbOfSteps the number of steps
2948 # @param Tolerance tolerance
2949 # @param MakeGroups forces the generation of new groups from existing ones
2950 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2951 # of all steps, else - size of each step
2952 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2953 # @ingroup l2_modif_extrurev
2954 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2955 MakeGroups=False, TotalAngle=False):
2956 if IDsOfElements == []:
2957 IDsOfElements = self.GetElementsId()
2958 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2959 Axis = self.smeshpyD.GetAxisStruct(Axis)
2960 AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians)
2961 NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance)
2962 Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters
2963 self.mesh.SetParameters(Parameters)
2964 if TotalAngle and NbOfSteps:
2965 AngleInRadians /= NbOfSteps
2967 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2968 AngleInRadians, NbOfSteps, Tolerance)
2969 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2972 ## Generates new elements by rotation of the elements of object around the axis
2973 # @param theObject object which elements should be sweeped.
2974 # It can be a mesh, a sub mesh or a group.
2975 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2976 # @param AngleInRadians the angle of Rotation
2977 # @param NbOfSteps number of steps
2978 # @param Tolerance tolerance
2979 # @param MakeGroups forces the generation of new groups from existing ones
2980 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2981 # of all steps, else - size of each step
2982 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2983 # @ingroup l2_modif_extrurev
2984 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2985 MakeGroups=False, TotalAngle=False):
2986 if ( isinstance( theObject, Mesh )):
2987 theObject = theObject.GetMesh()
2988 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2989 Axis = self.smeshpyD.GetAxisStruct(Axis)
2990 AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians)
2991 NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance)
2992 Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters
2993 self.mesh.SetParameters(Parameters)
2994 if TotalAngle and NbOfSteps:
2995 AngleInRadians /= NbOfSteps
2997 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2998 NbOfSteps, Tolerance)
2999 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3002 ## Generates new elements by rotation of the elements of object around the axis
3003 # @param theObject object which elements should be sweeped.
3004 # It can be a mesh, a sub mesh or a group.
3005 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3006 # @param AngleInRadians the angle of Rotation
3007 # @param NbOfSteps number of steps
3008 # @param Tolerance tolerance
3009 # @param MakeGroups forces the generation of new groups from existing ones
3010 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3011 # of all steps, else - size of each step
3012 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3013 # @ingroup l2_modif_extrurev
3014 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3015 MakeGroups=False, TotalAngle=False):
3016 if ( isinstance( theObject, Mesh )):
3017 theObject = theObject.GetMesh()
3018 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3019 Axis = self.smeshpyD.GetAxisStruct(Axis)
3020 AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians)
3021 NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance)
3022 Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters
3023 self.mesh.SetParameters(Parameters)
3024 if TotalAngle and NbOfSteps:
3025 AngleInRadians /= NbOfSteps
3027 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
3028 NbOfSteps, Tolerance)
3029 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3032 ## Generates new elements by rotation of the elements of object around the axis
3033 # @param theObject object which elements should be sweeped.
3034 # It can be a mesh, a sub mesh or a group.
3035 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3036 # @param AngleInRadians the angle of Rotation
3037 # @param NbOfSteps number of steps
3038 # @param Tolerance tolerance
3039 # @param MakeGroups forces the generation of new groups from existing ones
3040 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3041 # of all steps, else - size of each step
3042 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3043 # @ingroup l2_modif_extrurev
3044 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3045 MakeGroups=False, TotalAngle=False):
3046 if ( isinstance( theObject, Mesh )):
3047 theObject = theObject.GetMesh()
3048 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3049 Axis = self.smeshpyD.GetAxisStruct(Axis)
3050 AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians)
3051 NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance)
3052 Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters
3053 self.mesh.SetParameters(Parameters)
3054 if TotalAngle and NbOfSteps:
3055 AngleInRadians /= NbOfSteps
3057 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
3058 NbOfSteps, Tolerance)
3059 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3062 ## Generates new elements by extrusion of the elements with given ids
3063 # @param IDsOfElements the list of elements ids for extrusion
3064 # @param StepVector vector or DirStruct, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3065 # @param NbOfSteps the number of steps
3066 # @param MakeGroups forces the generation of new groups from existing ones
3067 # @param IsNodes is True if elements with given ids are nodes
3068 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3069 # @ingroup l2_modif_extrurev
3070 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False, IsNodes = False):
3071 if IDsOfElements == []:
3072 IDsOfElements = self.GetElementsId()
3073 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3074 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3075 NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
3076 Parameters = StepVector.PS.parameters + var_separator + Parameters
3077 self.mesh.SetParameters(Parameters)
3080 return self.editor.ExtrusionSweepMakeGroups0D(IDsOfElements, StepVector, NbOfSteps)
3082 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
3084 self.editor.ExtrusionSweep0D(IDsOfElements, StepVector, NbOfSteps)
3086 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
3089 ## Generates new elements by extrusion of the elements with given ids
3090 # @param IDsOfElements is ids of elements
3091 # @param StepVector vector, defining the direction and value of extrusion
3092 # @param NbOfSteps the number of steps
3093 # @param ExtrFlags sets flags for extrusion
3094 # @param SewTolerance uses for comparing locations of nodes if flag
3095 # EXTRUSION_FLAG_SEW is set
3096 # @param MakeGroups forces the generation of new groups from existing ones
3097 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3098 # @ingroup l2_modif_extrurev
3099 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
3100 ExtrFlags, SewTolerance, MakeGroups=False):
3101 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3102 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3104 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
3105 ExtrFlags, SewTolerance)
3106 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
3107 ExtrFlags, SewTolerance)
3110 ## Generates new elements by extrusion of the elements which belong to the object
3111 # @param theObject the object which elements should be processed.
3112 # It can be a mesh, a sub mesh or a group.
3113 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3114 # @param NbOfSteps the number of steps
3115 # @param MakeGroups forces the generation of new groups from existing ones
3116 # @param IsNodes is True if elements which belong to the object are nodes
3117 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3118 # @ingroup l2_modif_extrurev
3119 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False, IsNodes=False):
3120 if ( isinstance( theObject, Mesh )):
3121 theObject = theObject.GetMesh()
3122 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3123 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3124 NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
3125 Parameters = StepVector.PS.parameters + var_separator + Parameters
3126 self.mesh.SetParameters(Parameters)
3129 return self.editor.ExtrusionSweepObject0DMakeGroups(theObject, StepVector, NbOfSteps)
3131 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3133 self.editor.ExtrusionSweepObject0D(theObject, StepVector, NbOfSteps)
3135 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
3138 ## Generates new elements by extrusion of the elements which belong to the object
3139 # @param theObject object which elements should be processed.
3140 # It can be a mesh, a sub mesh or a group.
3141 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3142 # @param NbOfSteps the number of steps
3143 # @param MakeGroups to generate new groups from existing ones
3144 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3145 # @ingroup l2_modif_extrurev
3146 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3147 if ( isinstance( theObject, Mesh )):
3148 theObject = theObject.GetMesh()
3149 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3150 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3151 NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
3152 Parameters = StepVector.PS.parameters + var_separator + Parameters
3153 self.mesh.SetParameters(Parameters)
3155 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3156 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3159 ## Generates new elements by extrusion of the elements which belong to the object
3160 # @param theObject object which elements should be processed.
3161 # It can be a mesh, a sub mesh or a group.
3162 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3163 # @param NbOfSteps the number of steps
3164 # @param MakeGroups forces the generation of new groups from existing ones
3165 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3166 # @ingroup l2_modif_extrurev
3167 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3168 if ( isinstance( theObject, Mesh )):
3169 theObject = theObject.GetMesh()
3170 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3171 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3172 NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
3173 Parameters = StepVector.PS.parameters + var_separator + Parameters
3174 self.mesh.SetParameters(Parameters)
3176 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3177 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3182 ## Generates new elements by extrusion of the given elements
3183 # The path of extrusion must be a meshed edge.
3184 # @param Base mesh or group, or submesh, or list of ids of elements for extrusion
3185 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3186 # @param NodeStart the start node from Path. Defines the direction of extrusion
3187 # @param HasAngles allows the shape to be rotated around the path
3188 # to get the resulting mesh in a helical fashion
3189 # @param Angles list of angles in radians
3190 # @param LinearVariation forces the computation of rotation angles as linear
3191 # variation of the given Angles along path steps
3192 # @param HasRefPoint allows using the reference point
3193 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3194 # The User can specify any point as the Reference Point.
3195 # @param MakeGroups forces the generation of new groups from existing ones
3196 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3197 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3198 # only SMESH::Extrusion_Error otherwise
3199 # @ingroup l2_modif_extrurev
3200 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3201 HasAngles, Angles, LinearVariation,
3202 HasRefPoint, RefPoint, MakeGroups, ElemType):
3203 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3204 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3206 Angles,AnglesParameters,hasVars = ParseAngles(Angles)
3207 Parameters = AnglesParameters + var_separator + RefPoint.parameters
3208 self.mesh.SetParameters(Parameters)
3210 if (isinstance(Path, Mesh)): Path = Path.GetMesh()
3212 if isinstance(Base, list):
3214 if Base == []: IDsOfElements = self.GetElementsId()
3215 else: IDsOfElements = Base
3216 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3217 HasAngles, Angles, LinearVariation,
3218 HasRefPoint, RefPoint, MakeGroups, ElemType)
3220 if isinstance(Base, Mesh): Base = Base.GetMesh()
3221 if isinstance(Base, SMESH._objref_SMESH_Mesh) or isinstance(Base, SMESH._objref_SMESH_Group) or isinstance(Base, SMESH._objref_SMESH_subMesh):
3222 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3223 HasAngles, Angles, LinearVariation,
3224 HasRefPoint, RefPoint, MakeGroups, ElemType)
3226 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3229 ## Generates new elements by extrusion of the given elements
3230 # The path of extrusion must be a meshed edge.
3231 # @param IDsOfElements ids of elements
3232 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3233 # @param PathShape shape(edge) defines the sub-mesh for the path
3234 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3235 # @param HasAngles allows the shape to be rotated around the path
3236 # to get the resulting mesh in a helical fashion
3237 # @param Angles list of angles in radians
3238 # @param HasRefPoint allows using the reference point
3239 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3240 # The User can specify any point as the Reference Point.
3241 # @param MakeGroups forces the generation of new groups from existing ones
3242 # @param LinearVariation forces the computation of rotation angles as linear
3243 # variation of the given Angles along path steps
3244 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3245 # only SMESH::Extrusion_Error otherwise
3246 # @ingroup l2_modif_extrurev
3247 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3248 HasAngles, Angles, HasRefPoint, RefPoint,
3249 MakeGroups=False, LinearVariation=False):
3250 if IDsOfElements == []:
3251 IDsOfElements = self.GetElementsId()
3252 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3253 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3255 if ( isinstance( PathMesh, Mesh )):
3256 PathMesh = PathMesh.GetMesh()
3257 Angles,AnglesParameters,hasVars = ParseAngles(Angles)
3258 Parameters = AnglesParameters + var_separator + RefPoint.parameters
3259 self.mesh.SetParameters(Parameters)
3260 if HasAngles and Angles and LinearVariation:
3261 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3264 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3265 PathShape, NodeStart, HasAngles,
3266 Angles, HasRefPoint, RefPoint)
3267 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3268 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3270 ## Generates new elements by extrusion of the elements which belong to the object
3271 # The path of extrusion must be a meshed edge.
3272 # @param theObject the object which elements should be processed.
3273 # It can be a mesh, a sub mesh or a group.
3274 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3275 # @param PathShape shape(edge) defines the sub-mesh for the path
3276 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3277 # @param HasAngles allows the shape to be rotated around the path
3278 # to get the resulting mesh in a helical fashion
3279 # @param Angles list of angles
3280 # @param HasRefPoint allows using the reference point
3281 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3282 # The User can specify any point as the Reference Point.
3283 # @param MakeGroups forces the generation of new groups from existing ones
3284 # @param LinearVariation forces the computation of rotation angles as linear
3285 # variation of the given Angles along path steps
3286 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3287 # only SMESH::Extrusion_Error otherwise
3288 # @ingroup l2_modif_extrurev
3289 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3290 HasAngles, Angles, HasRefPoint, RefPoint,
3291 MakeGroups=False, LinearVariation=False):
3292 if ( isinstance( theObject, Mesh )):
3293 theObject = theObject.GetMesh()
3294 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3295 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3296 if ( isinstance( PathMesh, Mesh )):
3297 PathMesh = PathMesh.GetMesh()
3298 Angles,AnglesParameters,hasVars = ParseAngles(Angles)
3299 Parameters = AnglesParameters + var_separator + RefPoint.parameters
3300 self.mesh.SetParameters(Parameters)
3301 if HasAngles and Angles and LinearVariation:
3302 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3305 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3306 PathShape, NodeStart, HasAngles,
3307 Angles, HasRefPoint, RefPoint)
3308 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3309 NodeStart, HasAngles, Angles, HasRefPoint,
3312 ## Generates new elements by extrusion of the elements which belong to the object
3313 # The path of extrusion must be a meshed edge.
3314 # @param theObject the object which elements should be processed.
3315 # It can be a mesh, a sub mesh or a group.
3316 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3317 # @param PathShape shape(edge) defines the sub-mesh for the path
3318 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3319 # @param HasAngles allows the shape to be rotated around the path
3320 # to get the resulting mesh in a helical fashion
3321 # @param Angles list of angles
3322 # @param HasRefPoint allows using the reference point
3323 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3324 # The User can specify any point as the Reference Point.
3325 # @param MakeGroups forces the generation of new groups from existing ones
3326 # @param LinearVariation forces the computation of rotation angles as linear
3327 # variation of the given Angles along path steps
3328 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3329 # only SMESH::Extrusion_Error otherwise
3330 # @ingroup l2_modif_extrurev
3331 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3332 HasAngles, Angles, HasRefPoint, RefPoint,
3333 MakeGroups=False, LinearVariation=False):
3334 if ( isinstance( theObject, Mesh )):
3335 theObject = theObject.GetMesh()
3336 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3337 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3338 if ( isinstance( PathMesh, Mesh )):
3339 PathMesh = PathMesh.GetMesh()
3340 Angles,AnglesParameters,hasVars = ParseAngles(Angles)
3341 Parameters = AnglesParameters + var_separator + RefPoint.parameters
3342 self.mesh.SetParameters(Parameters)
3343 if HasAngles and Angles and LinearVariation:
3344 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3347 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3348 PathShape, NodeStart, HasAngles,
3349 Angles, HasRefPoint, RefPoint)
3350 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3351 NodeStart, HasAngles, Angles, HasRefPoint,
3354 ## Generates new elements by extrusion of the elements which belong to the object
3355 # The path of extrusion must be a meshed edge.
3356 # @param theObject the object which elements should be processed.
3357 # It can be a mesh, a sub mesh or a group.
3358 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3359 # @param PathShape shape(edge) defines the sub-mesh for the path
3360 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3361 # @param HasAngles allows the shape to be rotated around the path
3362 # to get the resulting mesh in a helical fashion
3363 # @param Angles list of angles
3364 # @param HasRefPoint allows using the reference point
3365 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3366 # The User can specify any point as the Reference Point.
3367 # @param MakeGroups forces the generation of new groups from existing ones
3368 # @param LinearVariation forces the computation of rotation angles as linear
3369 # variation of the given Angles along path steps
3370 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3371 # only SMESH::Extrusion_Error otherwise
3372 # @ingroup l2_modif_extrurev
3373 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3374 HasAngles, Angles, HasRefPoint, RefPoint,
3375 MakeGroups=False, LinearVariation=False):
3376 if ( isinstance( theObject, Mesh )):
3377 theObject = theObject.GetMesh()
3378 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3379 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3380 if ( isinstance( PathMesh, Mesh )):
3381 PathMesh = PathMesh.GetMesh()
3382 Angles,AnglesParameters,hasVars = ParseAngles(Angles)
3383 Parameters = AnglesParameters + var_separator + RefPoint.parameters
3384 self.mesh.SetParameters(Parameters)
3385 if HasAngles and Angles and LinearVariation:
3386 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3389 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3390 PathShape, NodeStart, HasAngles,
3391 Angles, HasRefPoint, RefPoint)
3392 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3393 NodeStart, HasAngles, Angles, HasRefPoint,
3396 ## Creates a symmetrical copy of mesh elements
3397 # @param IDsOfElements list of elements ids
3398 # @param Mirror is AxisStruct or geom object(point, line, plane)
3399 # @param theMirrorType is POINT, AXIS or PLANE
3400 # If the Mirror is a geom object this parameter is unnecessary
3401 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3402 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3403 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3404 # @ingroup l2_modif_trsf
3405 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3406 if IDsOfElements == []:
3407 IDsOfElements = self.GetElementsId()
3408 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3409 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3410 self.mesh.SetParameters(Mirror.parameters)
3411 if Copy and MakeGroups:
3412 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3413 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3416 ## Creates a new mesh by a symmetrical copy of mesh elements
3417 # @param IDsOfElements the list of elements ids
3418 # @param Mirror is AxisStruct or geom object (point, line, plane)
3419 # @param theMirrorType is POINT, AXIS or PLANE
3420 # If the Mirror is a geom object this parameter is unnecessary
3421 # @param MakeGroups to generate new groups from existing ones
3422 # @param NewMeshName a name of the new mesh to create
3423 # @return instance of Mesh class
3424 # @ingroup l2_modif_trsf
3425 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3426 if IDsOfElements == []:
3427 IDsOfElements = self.GetElementsId()
3428 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3429 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3430 self.mesh.SetParameters(Mirror.parameters)
3431 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3432 MakeGroups, NewMeshName)
3433 return Mesh(self.smeshpyD,self.geompyD,mesh)
3435 ## Creates a symmetrical copy of the object
3436 # @param theObject mesh, submesh or group
3437 # @param Mirror AxisStruct or geom object (point, line, plane)
3438 # @param theMirrorType is POINT, AXIS or PLANE
3439 # If the Mirror is a geom object this parameter is unnecessary
3440 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3441 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3442 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3443 # @ingroup l2_modif_trsf
3444 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3445 if ( isinstance( theObject, Mesh )):
3446 theObject = theObject.GetMesh()
3447 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3448 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3449 self.mesh.SetParameters(Mirror.parameters)
3450 if Copy and MakeGroups:
3451 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3452 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3455 ## Creates a new mesh by a symmetrical copy of the object
3456 # @param theObject mesh, submesh or group
3457 # @param Mirror AxisStruct or geom object (point, line, plane)
3458 # @param theMirrorType POINT, AXIS or PLANE
3459 # If the Mirror is a geom object this parameter is unnecessary
3460 # @param MakeGroups forces the generation of new groups from existing ones
3461 # @param NewMeshName the name of the new mesh to create
3462 # @return instance of Mesh class
3463 # @ingroup l2_modif_trsf
3464 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3465 if ( isinstance( theObject, Mesh )):
3466 theObject = theObject.GetMesh()
3467 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3468 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3469 self.mesh.SetParameters(Mirror.parameters)
3470 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3471 MakeGroups, NewMeshName)
3472 return Mesh( self.smeshpyD,self.geompyD,mesh )
3474 ## Translates the elements
3475 # @param IDsOfElements list of elements ids
3476 # @param Vector the direction of translation (DirStruct or vector)
3477 # @param Copy allows copying the translated elements
3478 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3479 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3480 # @ingroup l2_modif_trsf
3481 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3482 if IDsOfElements == []:
3483 IDsOfElements = self.GetElementsId()
3484 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3485 Vector = self.smeshpyD.GetDirStruct(Vector)
3486 self.mesh.SetParameters(Vector.PS.parameters)
3487 if Copy and MakeGroups:
3488 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3489 self.editor.Translate(IDsOfElements, Vector, Copy)
3492 ## Creates a new mesh of translated elements
3493 # @param IDsOfElements list of elements ids
3494 # @param Vector the direction of translation (DirStruct or vector)
3495 # @param MakeGroups forces the generation of new groups from existing ones
3496 # @param NewMeshName the name of the newly created mesh
3497 # @return instance of Mesh class
3498 # @ingroup l2_modif_trsf
3499 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3500 if IDsOfElements == []:
3501 IDsOfElements = self.GetElementsId()
3502 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3503 Vector = self.smeshpyD.GetDirStruct(Vector)
3504 self.mesh.SetParameters(Vector.PS.parameters)
3505 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3506 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3508 ## Translates the object
3509 # @param theObject the object to translate (mesh, submesh, or group)
3510 # @param Vector direction of translation (DirStruct or geom vector)
3511 # @param Copy allows copying the translated elements
3512 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3513 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3514 # @ingroup l2_modif_trsf
3515 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3516 if ( isinstance( theObject, Mesh )):
3517 theObject = theObject.GetMesh()
3518 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3519 Vector = self.smeshpyD.GetDirStruct(Vector)
3520 self.mesh.SetParameters(Vector.PS.parameters)
3521 if Copy and MakeGroups:
3522 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3523 self.editor.TranslateObject(theObject, Vector, Copy)
3526 ## Creates a new mesh from the translated object
3527 # @param theObject the object to translate (mesh, submesh, or group)
3528 # @param Vector the direction of translation (DirStruct or geom vector)
3529 # @param MakeGroups forces the generation of new groups from existing ones
3530 # @param NewMeshName the name of the newly created mesh
3531 # @return instance of Mesh class
3532 # @ingroup l2_modif_trsf
3533 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3534 if (isinstance(theObject, Mesh)):
3535 theObject = theObject.GetMesh()
3536 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3537 Vector = self.smeshpyD.GetDirStruct(Vector)
3538 self.mesh.SetParameters(Vector.PS.parameters)
3539 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3540 return Mesh( self.smeshpyD, self.geompyD, mesh )
3544 ## Scales the object
3545 # @param theObject - the object to translate (mesh, submesh, or group)
3546 # @param thePoint - base point for scale
3547 # @param theScaleFact - list of 1-3 scale factors for axises
3548 # @param Copy - allows copying the translated elements
3549 # @param MakeGroups - forces the generation of new groups from existing
3551 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3552 # empty list otherwise
3553 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3554 if ( isinstance( theObject, Mesh )):
3555 theObject = theObject.GetMesh()
3556 if ( isinstance( theObject, list )):
3557 theObject = self.GetIDSource(theObject, SMESH.ALL)
3559 self.mesh.SetParameters(thePoint.parameters)
3561 if Copy and MakeGroups:
3562 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3563 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3566 ## Creates a new mesh from the translated object
3567 # @param theObject - the object to translate (mesh, submesh, or group)
3568 # @param thePoint - base point for scale
3569 # @param theScaleFact - list of 1-3 scale factors for axises
3570 # @param MakeGroups - forces the generation of new groups from existing ones
3571 # @param NewMeshName - the name of the newly created mesh
3572 # @return instance of Mesh class
3573 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3574 if (isinstance(theObject, Mesh)):
3575 theObject = theObject.GetMesh()
3576 if ( isinstance( theObject, list )):
3577 theObject = self.GetIDSource(theObject,SMESH.ALL)
3579 self.mesh.SetParameters(thePoint.parameters)
3580 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3581 MakeGroups, NewMeshName)
3582 return Mesh( self.smeshpyD, self.geompyD, mesh )
3586 ## Rotates the elements
3587 # @param IDsOfElements list of elements ids
3588 # @param Axis the axis of rotation (AxisStruct or geom line)
3589 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3590 # @param Copy allows copying the rotated elements
3591 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3592 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3593 # @ingroup l2_modif_trsf
3594 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3595 if IDsOfElements == []:
3596 IDsOfElements = self.GetElementsId()
3597 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3598 Axis = self.smeshpyD.GetAxisStruct(Axis)
3599 AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians)
3600 Parameters = Axis.parameters + var_separator + Parameters
3601 self.mesh.SetParameters(Parameters)
3602 if Copy and MakeGroups:
3603 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3604 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3607 ## Creates a new mesh of rotated elements
3608 # @param IDsOfElements list of element ids
3609 # @param Axis the axis of rotation (AxisStruct or geom line)
3610 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3611 # @param MakeGroups forces the generation of new groups from existing ones
3612 # @param NewMeshName the name of the newly created mesh
3613 # @return instance of Mesh class
3614 # @ingroup l2_modif_trsf
3615 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3616 if IDsOfElements == []:
3617 IDsOfElements = self.GetElementsId()
3618 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3619 Axis = self.smeshpyD.GetAxisStruct(Axis)
3620 AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians)
3621 Parameters = Axis.parameters + var_separator + Parameters
3622 self.mesh.SetParameters(Parameters)
3623 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3624 MakeGroups, NewMeshName)
3625 return Mesh( self.smeshpyD, self.geompyD, mesh )
3627 ## Rotates the object
3628 # @param theObject the object to rotate( mesh, submesh, or group)
3629 # @param Axis the axis of rotation (AxisStruct or geom line)
3630 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3631 # @param Copy allows copying the rotated elements
3632 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3633 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3634 # @ingroup l2_modif_trsf
3635 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3636 if (isinstance(theObject, Mesh)):
3637 theObject = theObject.GetMesh()
3638 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3639 Axis = self.smeshpyD.GetAxisStruct(Axis)
3640 AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians)
3641 Parameters = Axis.parameters + ":" + Parameters
3642 self.mesh.SetParameters(Parameters)
3643 if Copy and MakeGroups:
3644 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3645 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3648 ## Creates a new mesh from the rotated object
3649 # @param theObject the object to rotate (mesh, submesh, or group)
3650 # @param Axis the axis of rotation (AxisStruct or geom line)
3651 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3652 # @param MakeGroups forces the generation of new groups from existing ones
3653 # @param NewMeshName the name of the newly created mesh
3654 # @return instance of Mesh class
3655 # @ingroup l2_modif_trsf
3656 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3657 if (isinstance( theObject, Mesh )):
3658 theObject = theObject.GetMesh()
3659 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3660 Axis = self.smeshpyD.GetAxisStruct(Axis)
3661 AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians)
3662 Parameters = Axis.parameters + ":" + Parameters
3663 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3664 MakeGroups, NewMeshName)
3665 self.mesh.SetParameters(Parameters)
3666 return Mesh( self.smeshpyD, self.geompyD, mesh )
3668 ## Finds groups of ajacent nodes within Tolerance.
3669 # @param Tolerance the value of tolerance
3670 # @return the list of groups of nodes
3671 # @ingroup l2_modif_trsf
3672 def FindCoincidentNodes (self, Tolerance):
3673 return self.editor.FindCoincidentNodes(Tolerance)
3675 ## Finds groups of ajacent nodes within Tolerance.
3676 # @param Tolerance the value of tolerance
3677 # @param SubMeshOrGroup SubMesh or Group
3678 # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
3679 # @return the list of groups of nodes
3680 # @ingroup l2_modif_trsf
3681 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
3682 if (isinstance( SubMeshOrGroup, Mesh )):
3683 SubMeshOrGroup = SubMeshOrGroup.GetMesh()
3684 if not isinstance( exceptNodes, list):
3685 exceptNodes = [ exceptNodes ]
3686 if exceptNodes and isinstance( exceptNodes[0], int):
3687 exceptNodes = [ self.GetIDSource( exceptNodes, SMESH.NODE)]
3688 return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes)
3691 # @param GroupsOfNodes the list of groups of nodes
3692 # @ingroup l2_modif_trsf
3693 def MergeNodes (self, GroupsOfNodes):
3694 self.editor.MergeNodes(GroupsOfNodes)
3696 ## Finds the elements built on the same nodes.
3697 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3698 # @return a list of groups of equal elements
3699 # @ingroup l2_modif_trsf
3700 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3701 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3702 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3703 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3705 ## Merges elements in each given group.
3706 # @param GroupsOfElementsID groups of elements for merging
3707 # @ingroup l2_modif_trsf
3708 def MergeElements(self, GroupsOfElementsID):
3709 self.editor.MergeElements(GroupsOfElementsID)
3711 ## Leaves one element and removes all other elements built on the same nodes.
3712 # @ingroup l2_modif_trsf
3713 def MergeEqualElements(self):
3714 self.editor.MergeEqualElements()
3716 ## Sews free borders
3717 # @return SMESH::Sew_Error
3718 # @ingroup l2_modif_trsf
3719 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3720 FirstNodeID2, SecondNodeID2, LastNodeID2,
3721 CreatePolygons, CreatePolyedrs):
3722 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3723 FirstNodeID2, SecondNodeID2, LastNodeID2,
3724 CreatePolygons, CreatePolyedrs)
3726 ## Sews conform free borders
3727 # @return SMESH::Sew_Error
3728 # @ingroup l2_modif_trsf
3729 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3730 FirstNodeID2, SecondNodeID2):
3731 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3732 FirstNodeID2, SecondNodeID2)
3734 ## Sews border to side
3735 # @return SMESH::Sew_Error
3736 # @ingroup l2_modif_trsf
3737 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3738 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3739 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3740 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3742 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3743 # merged with the nodes of elements of Side2.
3744 # The number of elements in theSide1 and in theSide2 must be
3745 # equal and they should have similar nodal connectivity.
3746 # The nodes to merge should belong to side borders and
3747 # the first node should be linked to the second.
3748 # @return SMESH::Sew_Error
3749 # @ingroup l2_modif_trsf
3750 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3751 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3752 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3753 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3754 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3755 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3757 ## Sets new nodes for the given element.
3758 # @param ide the element id
3759 # @param newIDs nodes ids
3760 # @return If the number of nodes does not correspond to the type of element - returns false
3761 # @ingroup l2_modif_edit
3762 def ChangeElemNodes(self, ide, newIDs):
3763 return self.editor.ChangeElemNodes(ide, newIDs)
3765 ## If during the last operation of MeshEditor some nodes were
3766 # created, this method returns the list of their IDs, \n
3767 # if new nodes were not created - returns empty list
3768 # @return the list of integer values (can be empty)
3769 # @ingroup l1_auxiliary
3770 def GetLastCreatedNodes(self):
3771 return self.editor.GetLastCreatedNodes()
3773 ## If during the last operation of MeshEditor some elements were
3774 # created this method returns the list of their IDs, \n
3775 # if new elements were not created - returns empty list
3776 # @return the list of integer values (can be empty)
3777 # @ingroup l1_auxiliary
3778 def GetLastCreatedElems(self):
3779 return self.editor.GetLastCreatedElems()
3781 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3782 # @param theNodes identifiers of nodes to be doubled
3783 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
3784 # nodes. If list of element identifiers is empty then nodes are doubled but
3785 # they not assigned to elements
3786 # @return TRUE if operation has been completed successfully, FALSE otherwise
3787 # @ingroup l2_modif_edit
3788 def DoubleNodes(self, theNodes, theModifiedElems):
3789 return self.editor.DoubleNodes(theNodes, theModifiedElems)
3791 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3792 # This method provided for convenience works as DoubleNodes() described above.
3793 # @param theNodeId identifiers of node to be doubled
3794 # @param theModifiedElems identifiers of elements to be updated
3795 # @return TRUE if operation has been completed successfully, FALSE otherwise
3796 # @ingroup l2_modif_edit
3797 def DoubleNode(self, theNodeId, theModifiedElems):
3798 return self.editor.DoubleNode(theNodeId, theModifiedElems)
3800 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3801 # This method provided for convenience works as DoubleNodes() described above.
3802 # @param theNodes group of nodes to be doubled
3803 # @param theModifiedElems group of elements to be updated.
3804 # @param theMakeGroup forces the generation of a group containing new nodes.
3805 # @return TRUE or a created group if operation has been completed successfully,
3806 # FALSE or None otherwise
3807 # @ingroup l2_modif_edit
3808 def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
3810 return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
3811 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3813 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3814 # This method provided for convenience works as DoubleNodes() described above.
3815 # @param theNodes list of groups of nodes to be doubled
3816 # @param theModifiedElems list of groups of elements to be updated.
3817 # @param theMakeGroup forces the generation of a group containing new nodes.
3818 # @return TRUE if operation has been completed successfully, FALSE otherwise
3819 # @ingroup l2_modif_edit
3820 def DoubleNodeGroups(self, theNodes, theModifiedElems, theMakeGroup=False):
3822 return self.editor.DoubleNodeGroupsNew(theNodes, theModifiedElems)
3823 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3825 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3826 # @param theElems - the list of elements (edges or faces) to be replicated
3827 # The nodes for duplication could be found from these elements
3828 # @param theNodesNot - list of nodes to NOT replicate
3829 # @param theAffectedElems - the list of elements (cells and edges) to which the
3830 # replicated nodes should be associated to.
3831 # @return TRUE if operation has been completed successfully, FALSE otherwise
3832 # @ingroup l2_modif_edit
3833 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
3834 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
3836 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3837 # @param theElems - the list of elements (edges or faces) to be replicated
3838 # The nodes for duplication could be found from these elements
3839 # @param theNodesNot - list of nodes to NOT replicate
3840 # @param theShape - shape to detect affected elements (element which geometric center
3841 # located on or inside shape).
3842 # The replicated nodes should be associated to affected elements.
3843 # @return TRUE if operation has been completed successfully, FALSE otherwise
3844 # @ingroup l2_modif_edit
3845 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
3846 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
3848 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3849 # This method provided for convenience works as DoubleNodes() described above.
3850 # @param theElems - group of of elements (edges or faces) to be replicated
3851 # @param theNodesNot - group of nodes not to replicated
3852 # @param theAffectedElems - group of elements to which the replicated nodes
3853 # should be associated to.
3854 # @param theMakeGroup forces the generation of a group containing new elements.
3855 # @return TRUE or a created group if operation has been completed successfully,
3856 # FALSE or None otherwise
3857 # @ingroup l2_modif_edit
3858 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
3860 return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
3861 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
3863 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3864 # This method provided for convenience works as DoubleNodes() described above.
3865 # @param theElems - group of of elements (edges or faces) to be replicated
3866 # @param theNodesNot - group of nodes not to replicated
3867 # @param theShape - shape to detect affected elements (element which geometric center
3868 # located on or inside shape).
3869 # The replicated nodes should be associated to affected elements.
3870 # @ingroup l2_modif_edit
3871 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
3872 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
3874 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3875 # This method provided for convenience works as DoubleNodes() described above.
3876 # @param theElems - list of groups of elements (edges or faces) to be replicated
3877 # @param theNodesNot - list of groups of nodes not to replicated
3878 # @param theAffectedElems - group of elements to which the replicated nodes
3879 # should be associated to.
3880 # @param theMakeGroup forces the generation of a group containing new elements.
3881 # @return TRUE or a created group if operation has been completed successfully,
3882 # FALSE or None otherwise
3883 # @ingroup l2_modif_edit
3884 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
3886 return self.editor.DoubleNodeElemGroupsNew(theElems, theNodesNot, theAffectedElems)
3887 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
3889 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3890 # This method provided for convenience works as DoubleNodes() described above.
3891 # @param theElems - list of groups of elements (edges or faces) to be replicated
3892 # @param theNodesNot - list of groups of nodes not to replicated
3893 # @param theShape - shape to detect affected elements (element which geometric center
3894 # located on or inside shape).
3895 # The replicated nodes should be associated to affected elements.
3896 # @return TRUE if operation has been completed successfully, FALSE otherwise
3897 # @ingroup l2_modif_edit
3898 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
3899 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
3901 ## Double nodes on shared faces between groups of volumes and create flat elements on demand.
3902 # The list of groups must describe a partition of the mesh volumes.
3903 # The nodes of the internal faces at the boundaries of the groups are doubled.
3904 # In option, the internal faces are replaced by flat elements.
3905 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
3906 # @param theDomains - list of groups of volumes
3907 # @param createJointElems - if TRUE, create the elements
3908 # @return TRUE if operation has been completed successfully, FALSE otherwise
3909 def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems ):
3910 return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems )
3912 ## Double nodes on some external faces and create flat elements.
3913 # Flat elements are mainly used by some types of mechanic calculations.
3915 # Each group of the list must be constituted of faces.
3916 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
3917 # @param theGroupsOfFaces - list of groups of faces
3918 # @return TRUE if operation has been completed successfully, FALSE otherwise
3919 def CreateFlatElementsOnFacesGroups(self, theGroupsOfFaces ):
3920 return self.editor.CreateFlatElementsOnFacesGroups( theGroupsOfFaces )
3922 def _valueFromFunctor(self, funcType, elemId):
3923 fn = self.smeshpyD.GetFunctor(funcType)
3924 fn.SetMesh(self.mesh)
3925 if fn.GetElementType() == self.GetElementType(elemId, True):
3926 val = fn.GetValue(elemId)
3931 ## Get length of 1D element.
3932 # @param elemId mesh element ID
3933 # @return element's length value
3934 # @ingroup l1_measurements
3935 def GetLength(self, elemId):
3936 return self._valueFromFunctor(SMESH.FT_Length, elemId)
3938 ## Get area of 2D element.
3939 # @param elemId mesh element ID
3940 # @return element's area value
3941 # @ingroup l1_measurements
3942 def GetArea(self, elemId):
3943 return self._valueFromFunctor(SMESH.FT_Area, elemId)
3945 ## Get volume of 3D element.
3946 # @param elemId mesh element ID
3947 # @return element's volume value
3948 # @ingroup l1_measurements
3949 def GetVolume(self, elemId):
3950 return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
3952 ## Get maximum element length.
3953 # @param elemId mesh element ID
3954 # @return element's maximum length value
3955 # @ingroup l1_measurements
3956 def GetMaxElementLength(self, elemId):
3957 if self.GetElementType(elemId, True) == SMESH.VOLUME:
3958 ftype = SMESH.FT_MaxElementLength3D
3960 ftype = SMESH.FT_MaxElementLength2D
3961 return self._valueFromFunctor(ftype, elemId)
3963 ## Get aspect ratio of 2D or 3D element.
3964 # @param elemId mesh element ID
3965 # @return element's aspect ratio value
3966 # @ingroup l1_measurements
3967 def GetAspectRatio(self, elemId):
3968 if self.GetElementType(elemId, True) == SMESH.VOLUME:
3969 ftype = SMESH.FT_AspectRatio3D
3971 ftype = SMESH.FT_AspectRatio
3972 return self._valueFromFunctor(ftype, elemId)
3974 ## Get warping angle of 2D element.
3975 # @param elemId mesh element ID
3976 # @return element's warping angle value
3977 # @ingroup l1_measurements
3978 def GetWarping(self, elemId):
3979 return self._valueFromFunctor(SMESH.FT_Warping, elemId)
3981 ## Get minimum angle of 2D element.
3982 # @param elemId mesh element ID
3983 # @return element's minimum angle value
3984 # @ingroup l1_measurements
3985 def GetMinimumAngle(self, elemId):
3986 return self._valueFromFunctor(SMESH.FT_MinimumAngle, elemId)
3988 ## Get taper of 2D element.
3989 # @param elemId mesh element ID
3990 # @return element's taper value
3991 # @ingroup l1_measurements
3992 def GetTaper(self, elemId):
3993 return self._valueFromFunctor(SMESH.FT_Taper, elemId)
3995 ## Get skew of 2D element.
3996 # @param elemId mesh element ID
3997 # @return element's skew value
3998 # @ingroup l1_measurements
3999 def GetSkew(self, elemId):
4000 return self._valueFromFunctor(SMESH.FT_Skew, elemId)
4002 ## The mother class to define algorithm, it is not recommended to use it directly.
4004 # For each meshing algorithm, a python class inheriting from class Mesh_Algorithm
4005 # should be defined. This descendant class sould have two attributes defining the way
4006 # it is created by class Mesh (see e.g. class StdMeshersDC_Segment in StdMeshersDC.py).
4007 # - meshMethod attribute defines name of method of class Mesh by calling which the
4008 # python class of algorithm is created. E.g. if in class MyPlugin_Algorithm
4009 # meshMethod = "MyAlgorithm", then an instance of MyPlugin_Algorithm is created
4010 # by the following code: my_algo = mesh.MyAlgorithm()
4011 # - algoType defines name of algorithm type and is used mostly to discriminate
4012 # algorithms that are created by the same method of class Mesh. E.g. if
4013 # MyPlugin_Algorithm.algoType = "MyPLUGIN" then it's creation code can be:
4014 # my_algo = mesh.MyAlgorithm(algo="MyPLUGIN")
4015 # @ingroup l2_algorithms
4016 class Mesh_Algorithm:
4017 # @class Mesh_Algorithm
4018 # @brief Class Mesh_Algorithm
4020 #def __init__(self,smesh):
4028 ## Finds a hypothesis in the study by its type name and parameters.
4029 # Finds only the hypotheses created in smeshpyD engine.
4030 # @return SMESH.SMESH_Hypothesis
4031 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
4032 study = smeshpyD.GetCurrentStudy()
4033 #to do: find component by smeshpyD object, not by its data type
4034 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4035 if scomp is not None:
4036 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
4037 # Check if the root label of the hypotheses exists
4038 if res and hypRoot is not None:
4039 iter = study.NewChildIterator(hypRoot)
4040 # Check all published hypotheses
4042 hypo_so_i = iter.Value()
4043 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
4044 if attr is not None:
4045 anIOR = attr.Value()
4046 hypo_o_i = salome.orb.string_to_object(anIOR)
4047 if hypo_o_i is not None:
4048 # Check if this is a hypothesis
4049 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
4050 if hypo_i is not None:
4051 # Check if the hypothesis belongs to current engine
4052 if smeshpyD.GetObjectId(hypo_i) > 0:
4053 # Check if this is the required hypothesis
4054 if hypo_i.GetName() == hypname:
4056 if CompareMethod(hypo_i, args):
4070 ## Finds the algorithm in the study by its type name.
4071 # Finds only the algorithms, which have been created in smeshpyD engine.
4072 # @return SMESH.SMESH_Algo
4073 def FindAlgorithm (self, algoname, smeshpyD):
4074 study = smeshpyD.GetCurrentStudy()
4075 if not study: return None
4076 #to do: find component by smeshpyD object, not by its data type
4077 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4078 if scomp is not None:
4079 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
4080 # Check if the root label of the algorithms exists
4081 if res and hypRoot is not None:
4082 iter = study.NewChildIterator(hypRoot)
4083 # Check all published algorithms
4085 algo_so_i = iter.Value()
4086 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
4087 if attr is not None:
4088 anIOR = attr.Value()
4089 algo_o_i = salome.orb.string_to_object(anIOR)
4090 if algo_o_i is not None:
4091 # Check if this is an algorithm
4092 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
4093 if algo_i is not None:
4094 # Checks if the algorithm belongs to the current engine
4095 if smeshpyD.GetObjectId(algo_i) > 0:
4096 # Check if this is the required algorithm
4097 if algo_i.GetName() == algoname:
4110 ## If the algorithm is global, returns 0; \n
4111 # else returns the submesh associated to this algorithm.
4112 def GetSubMesh(self):
4115 ## Returns the wrapped mesher.
4116 def GetAlgorithm(self):
4119 ## Gets the list of hypothesis that can be used with this algorithm
4120 def GetCompatibleHypothesis(self):
4123 mylist = self.algo.GetCompatibleHypothesis()
4126 ## Gets the name of the algorithm
4130 ## Sets the name to the algorithm
4131 def SetName(self, name):
4132 self.mesh.smeshpyD.SetName(self.algo, name)
4134 ## Gets the id of the algorithm
4136 return self.algo.GetId()
4139 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
4141 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
4142 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
4144 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
4146 self.Assign(algo, mesh, geom)
4150 def Assign(self, algo, mesh, geom):
4152 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
4156 self.geom = mesh.geom
4159 AssureGeomPublished( mesh, geom )
4161 name = GetName(geom)
4165 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
4167 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
4168 TreatHypoStatus( status, algo.GetName(), name, True )
4171 def CompareHyp (self, hyp, args):
4172 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
4175 def CompareEqualHyp (self, hyp, args):
4179 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
4180 UseExisting=0, CompareMethod=""):
4183 if CompareMethod == "": CompareMethod = self.CompareHyp
4184 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
4187 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
4192 if isinstance( arg, geompyDC.GEOM._objref_GEOM_Object ):
4193 argStr = arg.GetStudyEntry()
4194 if not argStr: argStr = "GEOM_Obj_%s", arg.GetEntry()
4195 if len( argStr ) > 10:
4196 argStr = argStr[:7]+"..."
4197 if argStr[0] == '[': argStr += ']'
4203 self.mesh.smeshpyD.SetName(hypo, hyp + a)
4207 geomName = GetName(self.geom)
4208 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
4209 TreatHypoStatus( status, GetName(hypo), geomName, 0 )
4212 ## Returns entry of the shape to mesh in the study
4213 def MainShapeEntry(self):
4214 if not self.mesh or not self.mesh.GetMesh(): return ""
4215 if not self.mesh.GetMesh().HasShapeToMesh(): return ""
4216 shape = self.mesh.GetShape()
4217 return shape.GetStudyEntry()
4219 ## Defines "ViscousLayers" hypothesis to give parameters of layers of prisms to build
4220 # near mesh boundary. This hypothesis can be used by several 3D algorithms:
4221 # NETGEN 3D, GHS3D, Hexahedron(i,j,k)
4222 # @param thickness total thickness of layers of prisms
4223 # @param numberOfLayers number of layers of prisms
4224 # @param stretchFactor factor (>1.0) of growth of layer thickness towards inside of mesh
4225 # @param ignoreFaces list of geometrical faces (or their ids) not to generate layers on
4226 # @ingroup l3_hypos_additi
4227 def ViscousLayers(self, thickness, numberOfLayers, stretchFactor, ignoreFaces=[]):
4228 if not isinstance(self.algo, SMESH._objref_SMESH_3D_Algo):
4229 raise TypeError, "ViscousLayers are supported by 3D algorithms only"
4230 if not "ViscousLayers" in self.GetCompatibleHypothesis():
4231 raise TypeError, "ViscousLayers are not supported by %s"%self.algo.GetName()
4232 if ignoreFaces and isinstance( ignoreFaces[0], geompyDC.GEOM._objref_GEOM_Object ):
4233 ignoreFaces = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, f) for f in ignoreFaces ]
4234 hyp = self.Hypothesis("ViscousLayers",
4235 [thickness, numberOfLayers, stretchFactor, ignoreFaces])
4236 hyp.SetTotalThickness(thickness)
4237 hyp.SetNumberLayers(numberOfLayers)
4238 hyp.SetStretchFactor(stretchFactor)
4239 hyp.SetIgnoreFaces(ignoreFaces)
4242 ## Transform a list of ether edges or tuples (edge 1st_vertex_of_edge)
4243 # into a list acceptable to SetReversedEdges() of some 1D hypotheses
4244 # @ingroup l3_hypos_1dhyps
4245 def ReversedEdgeIndices(self, reverseList):
4247 geompy = self.mesh.geompyD
4248 for i in reverseList:
4249 if isinstance( i, int ):
4250 s = geompy.SubShapes(self.mesh.geom, [i])[0]
4251 if s.GetShapeType() != geompyDC.GEOM.EDGE:
4252 raise TypeError, "Not EDGE index given"
4254 elif isinstance( i, geompyDC.GEOM._objref_GEOM_Object ):
4255 if i.GetShapeType() != geompyDC.GEOM.EDGE:
4256 raise TypeError, "Not an EDGE given"
4257 resList.append( geompy.GetSubShapeID(self.mesh.geom, i ))
4261 if not isinstance( e, geompyDC.GEOM._objref_GEOM_Object ) or \
4262 not isinstance( v, geompyDC.GEOM._objref_GEOM_Object ):
4263 raise TypeError, "A list item must be a tuple (edge 1st_vertex_of_edge)"
4264 if v.GetShapeType() == geompyDC.GEOM.EDGE and \
4265 e.GetShapeType() == geompyDC.GEOM.VERTEX:
4267 if e.GetShapeType() != geompyDC.GEOM.EDGE or \
4268 v.GetShapeType() != geompyDC.GEOM.VERTEX:
4269 raise TypeError, "A list item must be a tuple (edge 1st_vertex_of_edge)"
4270 vFirst = FirstVertexOnCurve( e )
4271 tol = geompy.Tolerance( vFirst )[-1]
4272 if geompy.MinDistance( v, vFirst ) > 1.5*tol:
4273 resList.append( geompy.GetSubShapeID(self.mesh.geom, e ))
4275 raise TypeError, "Item must be either an edge or tuple (edge 1st_vertex_of_edge)"
4279 class Pattern(SMESH._objref_SMESH_Pattern):
4281 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
4282 decrFun = lambda i: i-1
4283 theNodeIndexOnKeyPoint1,Parameters,hasVars = ParseParameters(theNodeIndexOnKeyPoint1, decrFun)
4284 theMesh.SetParameters(Parameters)
4285 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
4287 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
4288 decrFun = lambda i: i-1
4289 theNode000Index,theNode001Index,Parameters,hasVars = ParseParameters(theNode000Index,theNode001Index, decrFun)
4290 theMesh.SetParameters(Parameters)
4291 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
4293 #Registering the new proxy for Pattern
4294 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)
4300 ## Private class used to bind methods creating algorithms to the class Mesh
4305 self.defaultAlgoType = ""
4306 self.algoTypeToClass = {}
4308 # Stores a python class of algorithm
4309 def add(self, algoClass):
4310 if type( algoClass ).__name__ == 'classobj' and \
4311 hasattr( algoClass, "algoType"):
4312 self.algoTypeToClass[ algoClass.algoType ] = algoClass
4313 if not self.defaultAlgoType and \
4314 hasattr( algoClass, "isDefault") and algoClass.isDefault:
4315 self.defaultAlgoType = algoClass.algoType
4316 #print "Add",algoClass.algoType, "dflt",self.defaultAlgoType
4318 # creates a copy of self and assign mesh to the copy
4319 def copy(self, mesh):
4320 other = algoCreator()
4321 other.defaultAlgoType = self.defaultAlgoType
4322 other.algoTypeToClass = self.algoTypeToClass
4326 # creates an instance of algorithm
4327 def __call__(self,algo="",geom=0,*args):
4328 algoType = self.defaultAlgoType
4329 for arg in args + (algo,geom):
4330 if isinstance( arg, geompyDC.GEOM._objref_GEOM_Object ):
4332 if isinstance( arg, str ) and arg:
4334 if not algoType and self.algoTypeToClass:
4335 algoType = self.algoTypeToClass.keys()[0]
4336 if self.algoTypeToClass.has_key( algoType ):
4337 #print "Create algo",algoType
4338 return self.algoTypeToClass[ algoType ]( self.mesh, geom )
4339 raise RuntimeError, "No class found for algo type %s" % algoType
4342 # Private class used to substitute and store variable parameters of hypotheses.
4343 class hypMethodWrapper:
4344 def __init__(self, hyp, method):
4346 self.method = method
4347 #print "REBIND:", method.__name__
4350 # call a method of hypothesis with calling SetVarParameter() before
4351 def __call__(self,*args):
4353 return self.method( self.hyp, *args ) # hypothesis method with no args
4355 #print "MethWrapper.__call__",self.method.__name__, args
4357 parsed = ParseParameters(*args) # replace variables with their values
4358 self.hyp.SetVarParameter( parsed[-2], self.method.__name__ )
4359 result = self.method( self.hyp, *parsed[:-2] ) # call hypothesis method
4360 except omniORB.CORBA.BAD_PARAM: # raised by hypothesis method call
4361 # maybe there is a replaced string arg which is not variable
4362 result = self.method( self.hyp, *args )
4363 except ValueError, detail: # raised by ParseParameters()
4365 result = self.method( self.hyp, *args )
4366 except omniORB.CORBA.BAD_PARAM:
4367 raise ValueError, detail # wrong variable name