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