1 # Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 # Author : Francis KLOSS, OCC
28 ## @defgroup l1_auxiliary Auxiliary methods and structures
29 ## @defgroup l1_creating Creating meshes
31 ## @defgroup l2_impexp Importing and exporting meshes
32 ## @defgroup l2_construct Constructing meshes
33 ## @defgroup l2_algorithms Defining Algorithms
35 ## @defgroup l3_algos_basic Basic meshing algorithms
36 ## @defgroup l3_algos_proj Projection Algorithms
37 ## @defgroup l3_algos_radialp Radial Prism
38 ## @defgroup l3_algos_segmarv Segments around Vertex
39 ## @defgroup l3_algos_3dextr 3D extrusion meshing algorithm
42 ## @defgroup l2_hypotheses Defining hypotheses
44 ## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
45 ## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
46 ## @defgroup l3_hypos_maxvol Max Element Volume hypothesis
47 ## @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
48 ## @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
49 ## @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
50 ## @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
51 ## @defgroup l3_hypos_quad Quadrangle Parameters hypothesis
52 ## @defgroup l3_hypos_additi Additional Hypotheses
55 ## @defgroup l2_submeshes Constructing submeshes
56 ## @defgroup l2_compounds Building Compounds
57 ## @defgroup l2_editing Editing Meshes
60 ## @defgroup l1_meshinfo Mesh Information
61 ## @defgroup l1_controls Quality controls and Filtering
62 ## @defgroup l1_grouping Grouping elements
64 ## @defgroup l2_grps_create Creating groups
65 ## @defgroup l2_grps_edit Editing groups
66 ## @defgroup l2_grps_operon Using operations on groups
67 ## @defgroup l2_grps_delete Deleting Groups
70 ## @defgroup l1_modifying Modifying meshes
72 ## @defgroup l2_modif_add Adding nodes and elements
73 ## @defgroup l2_modif_del Removing nodes and elements
74 ## @defgroup l2_modif_edit Modifying nodes and elements
75 ## @defgroup l2_modif_renumber Renumbering nodes and elements
76 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
77 ## @defgroup l2_modif_movenode Moving nodes
78 ## @defgroup l2_modif_throughp Mesh through point
79 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
80 ## @defgroup l2_modif_unitetri Uniting triangles
81 ## @defgroup l2_modif_changori Changing orientation of elements
82 ## @defgroup l2_modif_cutquadr Cutting quadrangles
83 ## @defgroup l2_modif_smooth Smoothing
84 ## @defgroup l2_modif_extrurev Extrusion and Revolution
85 ## @defgroup l2_modif_patterns Pattern mapping
86 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
89 ## @defgroup l1_measurements Measurements
94 import SMESH # This is necessary for back compatibility
100 ## @addtogroup l1_auxiliary
103 # MirrorType enumeration
104 POINT = SMESH_MeshEditor.POINT
105 AXIS = SMESH_MeshEditor.AXIS
106 PLANE = SMESH_MeshEditor.PLANE
108 # Smooth_Method enumeration
109 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
110 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
112 PrecisionConfusion = 1e-07
114 # TopAbs_State enumeration
115 [TopAbs_IN, TopAbs_OUT, TopAbs_ON, TopAbs_UNKNOWN] = range(4)
117 # Methods of splitting a hexahedron into tetrahedra
118 Hex_5Tet, Hex_6Tet, Hex_24Tet = 1, 2, 3
120 ## Converts an angle from degrees to radians
121 def DegreesToRadians(AngleInDegrees):
123 return AngleInDegrees * pi / 180.0
125 import salome_notebook
126 notebook = salome_notebook.notebook
127 # Salome notebook variable separator
130 ## Return list of variable values from salome notebook.
131 # The last argument, if is callable, is used to modify values got from notebook
132 def ParseParameters(*args):
137 if args and callable( args[-1] ):
138 args, varModifFun = args[:-1], args[-1]
139 for parameter in args:
141 Parameters += str(parameter) + var_separator
143 if isinstance(parameter,str):
144 # check if there is an inexistent variable name
145 if not notebook.isVariable(parameter):
146 raise ValueError, "Variable with name '" + parameter + "' doesn't exist!!!"
147 parameter = notebook.get(parameter)
150 parameter = varModifFun(parameter)
153 Result.append(parameter)
156 Parameters = Parameters[:-1]
157 Result.append( Parameters )
158 Result.append( hasVariables )
161 # Parse parameters converting variables to radians
162 def ParseAngles(*args):
163 return ParseParameters( *( args + (DegreesToRadians, )))
165 # Substitute PointStruct.__init__() to create SMESH.PointStruct using notebook variables.
166 # Parameters are stored in PointStruct.parameters attribute
167 def __initPointStruct(point,*args):
168 point.x, point.y, point.z, point.parameters,hasVars = ParseParameters(*args)
170 SMESH.PointStruct.__init__ = __initPointStruct
172 # Substitute AxisStruct.__init__() to create SMESH.AxisStruct using notebook variables.
173 # Parameters are stored in AxisStruct.parameters attribute
174 def __initAxisStruct(ax,*args):
175 ax.x, ax.y, ax.z, ax.vx, ax.vy, ax.vz, ax.parameters,hasVars = ParseParameters(*args)
177 SMESH.AxisStruct.__init__ = __initAxisStruct
180 def IsEqual(val1, val2, tol=PrecisionConfusion):
181 if abs(val1 - val2) < tol:
191 if isinstance(obj, SALOMEDS._objref_SObject):
194 ior = salome.orb.object_to_string(obj)
197 studies = salome.myStudyManager.GetOpenStudies()
198 for sname in studies:
199 s = salome.myStudyManager.GetStudyByName(sname)
201 sobj = s.FindObjectIOR(ior)
202 if not sobj: continue
203 return sobj.GetName()
204 if hasattr(obj, "GetName"):
205 # unknown CORBA object, having GetName() method
208 # unknown CORBA object, no GetName() method
211 if hasattr(obj, "GetName"):
212 # unknown non-CORBA object, having GetName() method
215 raise RuntimeError, "Null or invalid object"
217 ## Prints error message if a hypothesis was not assigned.
218 def TreatHypoStatus(status, hypName, geomName, isAlgo):
220 hypType = "algorithm"
222 hypType = "hypothesis"
224 if status == HYP_UNKNOWN_FATAL :
225 reason = "for unknown reason"
226 elif status == HYP_INCOMPATIBLE :
227 reason = "this hypothesis mismatches the algorithm"
228 elif status == HYP_NOTCONFORM :
229 reason = "a non-conform mesh would be built"
230 elif status == HYP_ALREADY_EXIST :
231 if isAlgo: return # it does not influence anything
232 reason = hypType + " of the same dimension is already assigned to this shape"
233 elif status == HYP_BAD_DIM :
234 reason = hypType + " mismatches the shape"
235 elif status == HYP_CONCURENT :
236 reason = "there are concurrent hypotheses on sub-shapes"
237 elif status == HYP_BAD_SUBSHAPE :
238 reason = "the shape is neither the main one, nor its sub-shape, nor a valid group"
239 elif status == HYP_BAD_GEOMETRY:
240 reason = "geometry mismatches the expectation of the algorithm"
241 elif status == HYP_HIDDEN_ALGO:
242 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
243 elif status == HYP_HIDING_ALGO:
244 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
245 elif status == HYP_NEED_SHAPE:
246 reason = "Algorithm can't work without shape"
249 hypName = '"' + hypName + '"'
250 geomName= '"' + geomName+ '"'
251 if status < HYP_UNKNOWN_FATAL and not geomName =='""':
252 print hypName, "was assigned to", geomName,"but", reason
253 elif not geomName == '""':
254 print hypName, "was not assigned to",geomName,":", reason
256 print hypName, "was not assigned:", reason
259 ## Private method. Add geom (sub-shape of the main shape) into the study if not yet there
260 def AssureGeomPublished(mesh, geom, name=''):
261 if not isinstance( geom, geompyDC.GEOM._objref_GEOM_Object ):
263 if not geom.IsSame( mesh.geom ) and not geom.GetStudyEntry():
265 studyID = mesh.smeshpyD.GetCurrentStudy()._get_StudyId()
266 if studyID != mesh.geompyD.myStudyId:
267 mesh.geompyD.init_geom( mesh.smeshpyD.GetCurrentStudy())
269 if not name and geom.GetShapeType() != geompyDC.GEOM.COMPOUND:
270 # for all groups SubShapeName() returns "Compound_-1"
271 name = mesh.geompyD.SubShapeName(geom, mesh.geom)
273 name = "%s_%s"%(geom.GetShapeType(), id(geom)%10000)
275 mesh.geompyD.addToStudyInFather( mesh.geom, geom, name )
278 ## Return the first vertex of a geomertical edge by ignoring orienation
279 def FirstVertexOnCurve(edge):
280 from geompy import SubShapeAll, ShapeType, KindOfShape, PointCoordinates
281 vv = SubShapeAll( edge, ShapeType["VERTEX"])
283 raise TypeError, "Given object has no vertices"
284 if len( vv ) == 1: return vv[0]
285 info = KindOfShape(edge)
286 xyz = info[1:4] # coords of the first vertex
287 xyz1 = PointCoordinates( vv[0] )
288 xyz2 = PointCoordinates( vv[1] )
291 dist1 += abs( xyz[i] - xyz1[i] )
292 dist2 += abs( xyz[i] - xyz2[i] )
298 # end of l1_auxiliary
301 # All methods of this class are accessible directly from the smesh.py package.
302 class smeshDC(SMESH._objref_SMESH_Gen):
304 ## Dump component to the Python script
305 # This method overrides IDL function to allow default values for the parameters.
306 def DumpPython(self, theStudy, theIsPublished=True, theIsMultiFile=True):
307 return SMESH._objref_SMESH_Gen.DumpPython(self, theStudy, theIsPublished, theIsMultiFile)
309 ## Set mode of DumpPython(), \a historical or \a snapshot.
310 # In the \a historical mode, the Python Dump script includes all commands
311 # performed by SMESH engine. In the \a snapshot mode, commands
312 # relating to objects removed from the Study are excluded from the script
313 # as well as commands not influencing the current state of meshes
314 def SetDumpPythonHistorical(self, isHistorical):
315 if isHistorical: val = "true"
317 SMESH._objref_SMESH_Gen.SetOption(self, "historical_python_dump", val)
319 ## Sets the current study and Geometry component
320 # @ingroup l1_auxiliary
321 def init_smesh(self,theStudy,geompyD):
322 self.SetCurrentStudy(theStudy,geompyD)
324 ## Creates an empty Mesh. This mesh can have an underlying geometry.
325 # @param obj the Geometrical object on which the mesh is built. If not defined,
326 # the mesh will have no underlying geometry.
327 # @param name the name for the new mesh.
328 # @return an instance of Mesh class.
329 # @ingroup l2_construct
330 def Mesh(self, obj=0, name=0):
331 if isinstance(obj,str):
333 return Mesh(self,self.geompyD,obj,name)
335 ## Returns a long value from enumeration
336 # Should be used for SMESH.FunctorType enumeration
337 # @ingroup l1_controls
338 def EnumToLong(self,theItem):
341 ## Returns a string representation of the color.
342 # To be used with filters.
343 # @param c color value (SALOMEDS.Color)
344 # @ingroup l1_controls
345 def ColorToString(self,c):
347 if isinstance(c, SALOMEDS.Color):
348 val = "%s;%s;%s" % (c.R, c.G, c.B)
349 elif isinstance(c, str):
352 raise ValueError, "Color value should be of string or SALOMEDS.Color type"
355 ## Gets PointStruct from vertex
356 # @param theVertex a GEOM object(vertex)
357 # @return SMESH.PointStruct
358 # @ingroup l1_auxiliary
359 def GetPointStruct(self,theVertex):
360 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
361 return PointStruct(x,y,z)
363 ## Gets DirStruct from vector
364 # @param theVector a GEOM object(vector)
365 # @return SMESH.DirStruct
366 # @ingroup l1_auxiliary
367 def GetDirStruct(self,theVector):
368 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
369 if(len(vertices) != 2):
370 print "Error: vector object is incorrect."
372 p1 = self.geompyD.PointCoordinates(vertices[0])
373 p2 = self.geompyD.PointCoordinates(vertices[1])
374 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
375 dirst = DirStruct(pnt)
378 ## Makes DirStruct from a triplet
379 # @param x,y,z vector components
380 # @return SMESH.DirStruct
381 # @ingroup l1_auxiliary
382 def MakeDirStruct(self,x,y,z):
383 pnt = PointStruct(x,y,z)
384 return DirStruct(pnt)
386 ## Get AxisStruct from object
387 # @param theObj a GEOM object (line or plane)
388 # @return SMESH.AxisStruct
389 # @ingroup l1_auxiliary
390 def GetAxisStruct(self,theObj):
391 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
393 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
394 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
395 vertex1 = self.geompyD.PointCoordinates(vertex1)
396 vertex2 = self.geompyD.PointCoordinates(vertex2)
397 vertex3 = self.geompyD.PointCoordinates(vertex3)
398 vertex4 = self.geompyD.PointCoordinates(vertex4)
399 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
400 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
401 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] ]
402 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
404 elif len(edges) == 1:
405 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
406 p1 = self.geompyD.PointCoordinates( vertex1 )
407 p2 = self.geompyD.PointCoordinates( vertex2 )
408 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
412 # From SMESH_Gen interface:
413 # ------------------------
415 ## Sets the given name to the object
416 # @param obj the object to rename
417 # @param name a new object name
418 # @ingroup l1_auxiliary
419 def SetName(self, obj, name):
420 if isinstance( obj, Mesh ):
422 elif isinstance( obj, Mesh_Algorithm ):
423 obj = obj.GetAlgorithm()
424 ior = salome.orb.object_to_string(obj)
425 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
427 ## Sets the current mode
428 # @ingroup l1_auxiliary
429 def SetEmbeddedMode( self,theMode ):
430 #self.SetEmbeddedMode(theMode)
431 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
433 ## Gets the current mode
434 # @ingroup l1_auxiliary
435 def IsEmbeddedMode(self):
436 #return self.IsEmbeddedMode()
437 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
439 ## Sets the current study
440 # @ingroup l1_auxiliary
441 def SetCurrentStudy( self, theStudy, geompyD = None ):
442 #self.SetCurrentStudy(theStudy)
445 geompyD = geompy.geom
448 self.SetGeomEngine(geompyD)
449 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
451 ## Gets the current study
452 # @ingroup l1_auxiliary
453 def GetCurrentStudy(self):
454 #return self.GetCurrentStudy()
455 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
457 ## Creates a Mesh object importing data from the given UNV file
458 # @return an instance of Mesh class
460 def CreateMeshesFromUNV( self,theFileName ):
461 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
462 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
465 ## Creates a Mesh object(s) importing data from the given MED file
466 # @return a list of Mesh class instances
468 def CreateMeshesFromMED( self,theFileName ):
469 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
471 for iMesh in range(len(aSmeshMeshes)) :
472 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
473 aMeshes.append(aMesh)
474 return aMeshes, aStatus
476 ## Creates a Mesh object(s) importing data from the given SAUV file
477 # @return a list of Mesh class instances
479 def CreateMeshesFromSAUV( self,theFileName ):
480 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromSAUV(self,theFileName)
482 for iMesh in range(len(aSmeshMeshes)) :
483 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
484 aMeshes.append(aMesh)
485 return aMeshes, aStatus
487 ## Creates a Mesh object importing data from the given STL file
488 # @return an instance of Mesh class
490 def CreateMeshesFromSTL( self, theFileName ):
491 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
492 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
495 ## Creates Mesh objects importing data from the given CGNS file
496 # @return an instance of Mesh class
498 def CreateMeshesFromCGNS( self, theFileName ):
499 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromCGNS(self,theFileName)
501 for iMesh in range(len(aSmeshMeshes)) :
502 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
503 aMeshes.append(aMesh)
504 return aMeshes, aStatus
506 ## Concatenate the given meshes into one mesh.
507 # @return an instance of Mesh class
508 # @param meshes the meshes to combine into one mesh
509 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
510 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
511 # @param mergeTolerance tolerance for merging nodes
512 # @param allGroups forces creation of groups of all elements
513 def Concatenate( self, meshes, uniteIdenticalGroups,
514 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
515 if not meshes: return None
516 for i,m in enumerate(meshes):
517 if isinstance(m, Mesh):
518 meshes[i] = m.GetMesh()
519 mergeTolerance,Parameters,hasVars = ParseParameters(mergeTolerance)
520 meshes[0].SetParameters(Parameters)
522 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
523 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
525 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
526 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
527 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
530 ## Create a mesh by copying a part of another mesh.
531 # @param meshPart a part of mesh to copy, either a Mesh, a sub-mesh or a group;
532 # to copy nodes or elements not contained in any mesh object,
533 # pass result of Mesh.GetIDSource( list_of_ids, type ) as meshPart
534 # @param meshName a name of the new mesh
535 # @param toCopyGroups to create in the new mesh groups the copied elements belongs to
536 # @param toKeepIDs to preserve IDs of the copied elements or not
537 # @return an instance of Mesh class
538 def CopyMesh( self, meshPart, meshName, toCopyGroups=False, toKeepIDs=False):
539 if (isinstance( meshPart, Mesh )):
540 meshPart = meshPart.GetMesh()
541 mesh = SMESH._objref_SMESH_Gen.CopyMesh( self,meshPart,meshName,toCopyGroups,toKeepIDs )
542 return Mesh(self, self.geompyD, mesh)
544 ## From SMESH_Gen interface
545 # @return the list of integer values
546 # @ingroup l1_auxiliary
547 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
548 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
550 ## From SMESH_Gen interface. Creates a pattern
551 # @return an instance of SMESH_Pattern
553 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
554 # @ingroup l2_modif_patterns
555 def GetPattern(self):
556 return SMESH._objref_SMESH_Gen.GetPattern(self)
558 ## Sets number of segments per diagonal of boundary box of geometry by which
559 # default segment length of appropriate 1D hypotheses is defined.
560 # Default value is 10
561 # @ingroup l1_auxiliary
562 def SetBoundaryBoxSegmentation(self, nbSegments):
563 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
565 # Filtering. Auxiliary functions:
566 # ------------------------------
568 ## Creates an empty criterion
569 # @return SMESH.Filter.Criterion
570 # @ingroup l1_controls
571 def GetEmptyCriterion(self):
572 Type = self.EnumToLong(FT_Undefined)
573 Compare = self.EnumToLong(FT_Undefined)
577 UnaryOp = self.EnumToLong(FT_Undefined)
578 BinaryOp = self.EnumToLong(FT_Undefined)
581 Precision = -1 ##@1e-07
582 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
583 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
585 ## Creates a criterion by the given parameters
586 # \n Criterion structures allow to define complex filters by combining them with logical operations (AND / OR) (see example below)
587 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
588 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
589 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
590 # @param Threshold the threshold value (range of ids as string, shape, numeric)
591 # @param UnaryOp FT_LogicalNOT or FT_Undefined
592 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
593 # FT_Undefined (must be for the last criterion of all criteria)
594 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
595 # FT_LyingOnGeom, FT_CoplanarFaces criteria
596 # @return SMESH.Filter.Criterion
598 # <a href="../tui_filters_page.html#combining_filters">Example of Criteria usage</a>
599 # @ingroup l1_controls
600 def GetCriterion(self,elementType,
602 Compare = FT_EqualTo,
604 UnaryOp=FT_Undefined,
605 BinaryOp=FT_Undefined,
607 if not CritType in SMESH.FunctorType._items:
608 raise TypeError, "CritType should be of SMESH.FunctorType"
609 aCriterion = self.GetEmptyCriterion()
610 aCriterion.TypeOfElement = elementType
611 aCriterion.Type = self.EnumToLong(CritType)
612 aCriterion.Tolerance = Tolerance
614 aThreshold = Threshold
616 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
617 aCriterion.Compare = self.EnumToLong(Compare)
618 elif Compare == "=" or Compare == "==":
619 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
621 aCriterion.Compare = self.EnumToLong(FT_LessThan)
623 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
624 elif Compare != FT_Undefined:
625 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
628 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
629 FT_BelongToCylinder, FT_LyingOnGeom]:
630 # Checks the Threshold
631 if isinstance(aThreshold, geompyDC.GEOM._objref_GEOM_Object):
632 aCriterion.ThresholdStr = GetName(aThreshold)
633 aCriterion.ThresholdID = salome.ObjectToID(aThreshold)
635 print "Error: The Threshold should be a shape."
637 if isinstance(UnaryOp,float):
638 aCriterion.Tolerance = UnaryOp
639 UnaryOp = FT_Undefined
641 elif CritType == FT_RangeOfIds:
642 # Checks the Threshold
643 if isinstance(aThreshold, str):
644 aCriterion.ThresholdStr = aThreshold
646 print "Error: The Threshold should be a string."
648 elif CritType == FT_CoplanarFaces:
649 # Checks the Threshold
650 if isinstance(aThreshold, int):
651 aCriterion.ThresholdID = "%s"%aThreshold
652 elif isinstance(aThreshold, str):
655 raise ValueError, "Invalid ID of mesh face: '%s'"%aThreshold
656 aCriterion.ThresholdID = aThreshold
659 "The Threshold should be an ID of mesh face and not '%s'"%aThreshold
660 elif CritType == FT_ElemGeomType:
661 # Checks the Threshold
663 aCriterion.Threshold = self.EnumToLong(aThreshold)
664 assert( aThreshold in SMESH.GeometryType._items )
666 if isinstance(aThreshold, int):
667 aCriterion.Threshold = aThreshold
669 print "Error: The Threshold should be an integer or SMESH.GeometryType."
673 elif CritType == FT_GroupColor:
674 # Checks the Threshold
676 aCriterion.ThresholdStr = self.ColorToString(aThreshold)
678 print "Error: The threshold value should be of SALOMEDS.Color type"
681 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_FreeNodes, FT_FreeFaces,
682 FT_LinearOrQuadratic, FT_BadOrientedVolume,
683 FT_BareBorderFace, FT_BareBorderVolume,
684 FT_OverConstrainedFace, FT_OverConstrainedVolume,
685 FT_EqualNodes,FT_EqualEdges,FT_EqualFaces,FT_EqualVolumes ]:
686 # At this point the Threshold is unnecessary
687 if aThreshold == FT_LogicalNOT:
688 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
689 elif aThreshold in [FT_LogicalAND, FT_LogicalOR]:
690 aCriterion.BinaryOp = aThreshold
694 aThreshold = float(aThreshold)
695 aCriterion.Threshold = aThreshold
697 print "Error: The Threshold should be a number."
700 if Threshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
701 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
703 if Threshold in [FT_LogicalAND, FT_LogicalOR]:
704 aCriterion.BinaryOp = self.EnumToLong(Threshold)
706 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
707 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
709 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
710 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
714 ## Creates a filter with the given parameters
715 # @param elementType the type of elements in the group
716 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
717 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
718 # @param Threshold the threshold value (range of id ids as string, shape, numeric)
719 # @param UnaryOp FT_LogicalNOT or FT_Undefined
720 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
721 # FT_LyingOnGeom, FT_CoplanarFaces and FT_EqualNodes criteria
722 # @return SMESH_Filter
724 # <a href="../tui_filters_page.html#tui_filters">Example of Filters usage</a>
725 # @ingroup l1_controls
726 def GetFilter(self,elementType,
727 CritType=FT_Undefined,
730 UnaryOp=FT_Undefined,
732 aCriterion = self.GetCriterion(elementType, CritType, Compare, Threshold, UnaryOp, FT_Undefined,Tolerance)
733 aFilterMgr = self.CreateFilterManager()
734 aFilter = aFilterMgr.CreateFilter()
736 aCriteria.append(aCriterion)
737 aFilter.SetCriteria(aCriteria)
738 aFilterMgr.UnRegister()
741 ## Creates a filter from criteria
742 # @param criteria a list of 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 GetFilterFromCriteria(self,criteria):
748 aFilterMgr = self.CreateFilterManager()
749 aFilter = aFilterMgr.CreateFilter()
750 aFilter.SetCriteria(criteria)
751 aFilterMgr.UnRegister()
754 ## Creates a numerical functor by its type
755 # @param theCriterion FT_...; functor type
756 # @return SMESH_NumericalFunctor
757 # @ingroup l1_controls
758 def GetFunctor(self,theCriterion):
759 aFilterMgr = self.CreateFilterManager()
760 if theCriterion == FT_AspectRatio:
761 return aFilterMgr.CreateAspectRatio()
762 elif theCriterion == FT_AspectRatio3D:
763 return aFilterMgr.CreateAspectRatio3D()
764 elif theCriterion == FT_Warping:
765 return aFilterMgr.CreateWarping()
766 elif theCriterion == FT_MinimumAngle:
767 return aFilterMgr.CreateMinimumAngle()
768 elif theCriterion == FT_Taper:
769 return aFilterMgr.CreateTaper()
770 elif theCriterion == FT_Skew:
771 return aFilterMgr.CreateSkew()
772 elif theCriterion == FT_Area:
773 return aFilterMgr.CreateArea()
774 elif theCriterion == FT_Volume3D:
775 return aFilterMgr.CreateVolume3D()
776 elif theCriterion == FT_MaxElementLength2D:
777 return aFilterMgr.CreateMaxElementLength2D()
778 elif theCriterion == FT_MaxElementLength3D:
779 return aFilterMgr.CreateMaxElementLength3D()
780 elif theCriterion == FT_MultiConnection:
781 return aFilterMgr.CreateMultiConnection()
782 elif theCriterion == FT_MultiConnection2D:
783 return aFilterMgr.CreateMultiConnection2D()
784 elif theCriterion == FT_Length:
785 return aFilterMgr.CreateLength()
786 elif theCriterion == FT_Length2D:
787 return aFilterMgr.CreateLength2D()
789 print "Error: given parameter is not numerical functor type."
791 ## Creates hypothesis
792 # @param theHType mesh hypothesis type (string)
793 # @param theLibName mesh plug-in library name
794 # @return created hypothesis instance
795 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
796 hyp = SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
798 if isinstance( hyp, SMESH._objref_SMESH_Algo ):
801 # wrap hypothesis methods
802 #print "HYPOTHESIS", theHType
803 for meth_name in dir( hyp.__class__ ):
804 if not meth_name.startswith("Get") and \
805 not meth_name in dir ( SMESH._objref_SMESH_Hypothesis ):
806 method = getattr ( hyp.__class__, meth_name )
808 setattr( hyp, meth_name, hypMethodWrapper( hyp, method ))
812 ## Gets the mesh statistic
813 # @return dictionary "element type" - "count of elements"
814 # @ingroup l1_meshinfo
815 def GetMeshInfo(self, obj):
816 if isinstance( obj, Mesh ):
819 if hasattr(obj, "GetMeshInfo"):
820 values = obj.GetMeshInfo()
821 for i in range(SMESH.Entity_Last._v):
822 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
826 ## Get minimum distance between two objects
828 # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
829 # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
831 # @param src1 first source object
832 # @param src2 second source object
833 # @param id1 node/element id from the first source
834 # @param id2 node/element id from the second (or first) source
835 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
836 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
837 # @return minimum distance value
838 # @sa GetMinDistance()
839 # @ingroup l1_measurements
840 def MinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
841 result = self.GetMinDistance(src1, src2, id1, id2, isElem1, isElem2)
845 result = result.value
848 ## Get measure structure specifying minimum distance data between two objects
850 # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
851 # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
853 # @param src1 first source object
854 # @param src2 second source object
855 # @param id1 node/element id from the first source
856 # @param id2 node/element id from the second (or first) source
857 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
858 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
859 # @return Measure structure or None if input data is invalid
861 # @ingroup l1_measurements
862 def GetMinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
863 if isinstance(src1, Mesh): src1 = src1.mesh
864 if isinstance(src2, Mesh): src2 = src2.mesh
865 if src2 is None and id2 != 0: src2 = src1
866 if not hasattr(src1, "_narrow"): return None
867 src1 = src1._narrow(SMESH.SMESH_IDSource)
868 if not src1: return None
871 e = m.GetMeshEditor()
873 src1 = e.MakeIDSource([id1], SMESH.FACE)
875 src1 = e.MakeIDSource([id1], SMESH.NODE)
877 if hasattr(src2, "_narrow"):
878 src2 = src2._narrow(SMESH.SMESH_IDSource)
879 if src2 and id2 != 0:
881 e = m.GetMeshEditor()
883 src2 = e.MakeIDSource([id2], SMESH.FACE)
885 src2 = e.MakeIDSource([id2], SMESH.NODE)
888 aMeasurements = self.CreateMeasurements()
889 result = aMeasurements.MinDistance(src1, src2)
890 aMeasurements.UnRegister()
893 ## Get bounding box of the specified object(s)
894 # @param objects single source object or list of source objects
895 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
896 # @sa GetBoundingBox()
897 # @ingroup l1_measurements
898 def BoundingBox(self, objects):
899 result = self.GetBoundingBox(objects)
903 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
906 ## Get measure structure specifying bounding box data of the specified object(s)
907 # @param objects single source object or list of source objects
908 # @return Measure structure
910 # @ingroup l1_measurements
911 def GetBoundingBox(self, objects):
912 if isinstance(objects, tuple):
913 objects = list(objects)
914 if not isinstance(objects, list):
918 if isinstance(o, Mesh):
919 srclist.append(o.mesh)
920 elif hasattr(o, "_narrow"):
921 src = o._narrow(SMESH.SMESH_IDSource)
922 if src: srclist.append(src)
925 aMeasurements = self.CreateMeasurements()
926 result = aMeasurements.BoundingBox(srclist)
927 aMeasurements.UnRegister()
931 #Registering the new proxy for SMESH_Gen
932 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
938 ## This class allows defining and managing a mesh.
939 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
940 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
941 # new nodes and elements and by changing the existing entities), to get information
942 # about a mesh and to export a mesh into different formats.
951 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
952 # sets the GUI name of this mesh to \a name.
953 # @param smeshpyD an instance of smeshDC class
954 # @param geompyD an instance of geompyDC class
955 # @param obj Shape to be meshed or SMESH_Mesh object
956 # @param name Study name of the mesh
957 # @ingroup l2_construct
958 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
959 self.smeshpyD=smeshpyD
964 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
966 # publish geom of mesh (issue 0021122)
967 if not self.geom.GetStudyEntry():
968 studyID = smeshpyD.GetCurrentStudy()._get_StudyId()
969 if studyID != geompyD.myStudyId:
970 geompyD.init_geom( smeshpyD.GetCurrentStudy())
972 geo_name = "%s_%s"%(self.geom.GetShapeType(), id(self.geom)%100)
973 geompyD.addToStudy( self.geom, geo_name )
974 self.mesh = self.smeshpyD.CreateMesh(self.geom)
976 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
979 self.mesh = self.smeshpyD.CreateEmptyMesh()
981 self.smeshpyD.SetName(self.mesh, name)
983 self.smeshpyD.SetName(self.mesh, GetName(obj))
986 self.geom = self.mesh.GetShapeToMesh()
988 self.editor = self.mesh.GetMeshEditor()
990 # set self to algoCreator's
991 for attrName in dir(self):
992 attr = getattr( self, attrName )
993 if isinstance( attr, algoCreator ):
994 setattr( self, attrName, attr.copy( self ))
996 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
997 # @param theMesh a SMESH_Mesh object
998 # @ingroup l2_construct
999 def SetMesh(self, theMesh):
1001 self.geom = self.mesh.GetShapeToMesh()
1003 ## Returns the mesh, that is an instance of SMESH_Mesh interface
1004 # @return a SMESH_Mesh object
1005 # @ingroup l2_construct
1009 ## Gets the name of the mesh
1010 # @return the name of the mesh as a string
1011 # @ingroup l2_construct
1013 name = GetName(self.GetMesh())
1016 ## Sets a name to the mesh
1017 # @param name a new name of the mesh
1018 # @ingroup l2_construct
1019 def SetName(self, name):
1020 self.smeshpyD.SetName(self.GetMesh(), name)
1022 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
1023 # The subMesh object gives access to the IDs of nodes and elements.
1024 # @param geom a geometrical object (shape)
1025 # @param name a name for the submesh
1026 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
1027 # @ingroup l2_submeshes
1028 def GetSubMesh(self, geom, name):
1029 AssureGeomPublished( self, geom, name )
1030 submesh = self.mesh.GetSubMesh( geom, name )
1033 ## Returns the shape associated to the mesh
1034 # @return a GEOM_Object
1035 # @ingroup l2_construct
1039 ## Associates the given shape to the mesh (entails the recreation of the mesh)
1040 # @param geom the shape to be meshed (GEOM_Object)
1041 # @ingroup l2_construct
1042 def SetShape(self, geom):
1043 self.mesh = self.smeshpyD.CreateMesh(geom)
1045 ## Loads mesh from the study after opening the study
1049 ## Returns true if the hypotheses are defined well
1050 # @param theSubObject a sub-shape of a mesh shape
1051 # @return True or False
1052 # @ingroup l2_construct
1053 def IsReadyToCompute(self, theSubObject):
1054 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
1056 ## Returns errors of hypotheses definition.
1057 # The list of errors is empty if everything is OK.
1058 # @param theSubObject a sub-shape of a mesh shape
1059 # @return a list of errors
1060 # @ingroup l2_construct
1061 def GetAlgoState(self, theSubObject):
1062 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
1064 ## Returns a geometrical object on which the given element was built.
1065 # The returned geometrical object, if not nil, is either found in the
1066 # study or published by this method with the given name
1067 # @param theElementID the id of the mesh element
1068 # @param theGeomName the user-defined name of the geometrical object
1069 # @return GEOM::GEOM_Object instance
1070 # @ingroup l2_construct
1071 def GetGeometryByMeshElement(self, theElementID, theGeomName):
1072 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
1074 ## Returns the mesh dimension depending on the dimension of the underlying shape
1075 # @return mesh dimension as an integer value [0,3]
1076 # @ingroup l1_auxiliary
1077 def MeshDimension(self):
1078 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
1079 if len( shells ) > 0 :
1081 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
1083 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
1089 ## Evaluates size of prospective mesh on a shape
1090 # @return a list where i-th element is a number of elements of i-th SMESH.EntityType
1091 # To know predicted number of e.g. edges, inquire it this way
1092 # Evaluate()[ EnumToLong( Entity_Edge )]
1093 def Evaluate(self, geom=0):
1094 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1096 geom = self.mesh.GetShapeToMesh()
1099 return self.smeshpyD.Evaluate(self.mesh, geom)
1102 ## Computes the mesh and returns the status of the computation
1103 # @param geom geomtrical shape on which mesh data should be computed
1104 # @param discardModifs if True and the mesh has been edited since
1105 # a last total re-compute and that may prevent successful partial re-compute,
1106 # then the mesh is cleaned before Compute()
1107 # @return True or False
1108 # @ingroup l2_construct
1109 def Compute(self, geom=0, discardModifs=False):
1110 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1112 geom = self.mesh.GetShapeToMesh()
1117 if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693
1119 ok = self.smeshpyD.Compute(self.mesh, geom)
1120 except SALOME.SALOME_Exception, ex:
1121 print "Mesh computation failed, exception caught:"
1122 print " ", ex.details.text
1125 print "Mesh computation failed, exception caught:"
1126 traceback.print_exc()
1130 # Treat compute errors
1131 computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
1132 for err in computeErrors:
1134 if self.mesh.HasShapeToMesh():
1136 mainIOR = salome.orb.object_to_string(geom)
1137 for sname in salome.myStudyManager.GetOpenStudies():
1138 s = salome.myStudyManager.GetStudyByName(sname)
1140 mainSO = s.FindObjectIOR(mainIOR)
1141 if not mainSO: continue
1142 if err.subShapeID == 1:
1143 shapeText = ' on "%s"' % mainSO.GetName()
1144 subIt = s.NewChildIterator(mainSO)
1146 subSO = subIt.Value()
1148 obj = subSO.GetObject()
1149 if not obj: continue
1150 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
1152 ids = go.GetSubShapeIndices()
1153 if len(ids) == 1 and ids[0] == err.subShapeID:
1154 shapeText = ' on "%s"' % subSO.GetName()
1157 shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
1159 shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID)
1161 shapeText = " on subshape #%s" % (err.subShapeID)
1163 shapeText = " on subshape #%s" % (err.subShapeID)
1165 stdErrors = ["OK", #COMPERR_OK
1166 "Invalid input mesh", #COMPERR_BAD_INPUT_MESH
1167 "std::exception", #COMPERR_STD_EXCEPTION
1168 "OCC exception", #COMPERR_OCC_EXCEPTION
1169 "SALOME exception", #COMPERR_SLM_EXCEPTION
1170 "Unknown exception", #COMPERR_EXCEPTION
1171 "Memory allocation problem", #COMPERR_MEMORY_PB
1172 "Algorithm failed", #COMPERR_ALGO_FAILED
1173 "Unexpected geometry"]#COMPERR_BAD_SHAPE
1175 if err.code < len(stdErrors): errText = stdErrors[err.code]
1177 errText = "code %s" % -err.code
1178 if errText: errText += ". "
1179 errText += err.comment
1180 if allReasons != "":allReasons += "\n"
1181 allReasons += '"%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
1185 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1187 if err.isGlobalAlgo:
1195 reason = '%s %sD algorithm is missing' % (glob, dim)
1196 elif err.state == HYP_MISSING:
1197 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1198 % (glob, dim, name, dim))
1199 elif err.state == HYP_NOTCONFORM:
1200 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1201 elif err.state == HYP_BAD_PARAMETER:
1202 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1203 % ( glob, dim, name ))
1204 elif err.state == HYP_BAD_GEOMETRY:
1205 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1206 'geometry' % ( glob, dim, name ))
1208 reason = "For unknown reason."+\
1209 " Revise Mesh.Compute() implementation in smeshDC.py!"
1211 if allReasons != "":allReasons += "\n"
1212 allReasons += reason
1214 if allReasons != "":
1215 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1219 print '"' + GetName(self.mesh) + '"',"has not been computed."
1222 if salome.sg.hasDesktop():
1223 smeshgui = salome.ImportComponentGUI("SMESH")
1224 smeshgui.Init(self.mesh.GetStudyId())
1225 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1226 salome.sg.updateObjBrowser(1)
1230 ## Return submesh objects list in meshing order
1231 # @return list of list of submesh objects
1232 # @ingroup l2_construct
1233 def GetMeshOrder(self):
1234 return self.mesh.GetMeshOrder()
1236 ## Return submesh objects list in meshing order
1237 # @return list of list of submesh objects
1238 # @ingroup l2_construct
1239 def SetMeshOrder(self, submeshes):
1240 return self.mesh.SetMeshOrder(submeshes)
1242 ## Removes all nodes and elements
1243 # @ingroup l2_construct
1246 if salome.sg.hasDesktop():
1247 smeshgui = salome.ImportComponentGUI("SMESH")
1248 smeshgui.Init(self.mesh.GetStudyId())
1249 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1250 salome.sg.updateObjBrowser(1)
1252 ## Removes all nodes and elements of indicated shape
1253 # @ingroup l2_construct
1254 def ClearSubMesh(self, geomId):
1255 self.mesh.ClearSubMesh(geomId)
1256 if salome.sg.hasDesktop():
1257 smeshgui = salome.ImportComponentGUI("SMESH")
1258 smeshgui.Init(self.mesh.GetStudyId())
1259 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1260 salome.sg.updateObjBrowser(1)
1262 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1263 # @param fineness [0.0,1.0] defines mesh fineness
1264 # @return True or False
1265 # @ingroup l3_algos_basic
1266 def AutomaticTetrahedralization(self, fineness=0):
1267 dim = self.MeshDimension()
1269 self.RemoveGlobalHypotheses()
1270 self.Segment().AutomaticLength(fineness)
1272 self.Triangle().LengthFromEdges()
1275 from NETGENPluginDC import NETGEN
1276 self.Tetrahedron(NETGEN)
1278 return self.Compute()
1280 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1281 # @param fineness [0.0, 1.0] defines mesh fineness
1282 # @return True or False
1283 # @ingroup l3_algos_basic
1284 def AutomaticHexahedralization(self, fineness=0):
1285 dim = self.MeshDimension()
1286 # assign the hypotheses
1287 self.RemoveGlobalHypotheses()
1288 self.Segment().AutomaticLength(fineness)
1295 return self.Compute()
1297 ## Assigns a hypothesis
1298 # @param hyp a hypothesis to assign
1299 # @param geom a subhape of mesh geometry
1300 # @return SMESH.Hypothesis_Status
1301 # @ingroup l2_hypotheses
1302 def AddHypothesis(self, hyp, geom=0):
1303 if isinstance( hyp, Mesh_Algorithm ):
1304 hyp = hyp.GetAlgorithm()
1309 geom = self.mesh.GetShapeToMesh()
1311 status = self.mesh.AddHypothesis(geom, hyp)
1312 isAlgo = hyp._narrow( SMESH_Algo )
1313 hyp_name = GetName( hyp )
1316 geom_name = GetName( geom )
1317 TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1320 ## Return True if an algorithm of hypothesis is assigned to a given shape
1321 # @param hyp a hypothesis to check
1322 # @param geom a subhape of mesh geometry
1323 # @return True of False
1324 # @ingroup l2_hypotheses
1325 def IsUsedHypothesis(self, hyp, geom):
1326 if not hyp or not geom:
1328 if isinstance( hyp, Mesh_Algorithm ):
1329 hyp = hyp.GetAlgorithm()
1331 hyps = self.GetHypothesisList(geom)
1333 if h.GetId() == hyp.GetId():
1337 ## Unassigns a hypothesis
1338 # @param hyp a hypothesis to unassign
1339 # @param geom a sub-shape of mesh geometry
1340 # @return SMESH.Hypothesis_Status
1341 # @ingroup l2_hypotheses
1342 def RemoveHypothesis(self, hyp, geom=0):
1343 if isinstance( hyp, Mesh_Algorithm ):
1344 hyp = hyp.GetAlgorithm()
1349 status = self.mesh.RemoveHypothesis(geom, hyp)
1352 ## Gets the list of hypotheses added on a geometry
1353 # @param geom a sub-shape of mesh geometry
1354 # @return the sequence of SMESH_Hypothesis
1355 # @ingroup l2_hypotheses
1356 def GetHypothesisList(self, geom):
1357 return self.mesh.GetHypothesisList( geom )
1359 ## Removes all global hypotheses
1360 # @ingroup l2_hypotheses
1361 def RemoveGlobalHypotheses(self):
1362 current_hyps = self.mesh.GetHypothesisList( self.geom )
1363 for hyp in current_hyps:
1364 self.mesh.RemoveHypothesis( self.geom, hyp )
1368 ## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead.
1369 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1370 ## allowing to overwrite the file if it exists or add the exported data to its contents
1371 # @param f the file name
1372 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1373 # @param opt boolean parameter for creating/not creating
1374 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1375 # @param overwrite boolean parameter for overwriting/not overwriting the file
1376 # @ingroup l2_impexp
1377 def ExportToMED(self, f, version, opt=0, overwrite=1):
1378 self.mesh.ExportToMEDX(f, opt, version, overwrite)
1380 ## Exports the mesh in a file in MED format and chooses the \a version of MED format
1381 ## allowing to overwrite the file if it exists or add the exported data to its contents
1382 # @param f is the file name
1383 # @param auto_groups boolean parameter for creating/not creating
1384 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1385 # the typical use is auto_groups=false.
1386 # @param version MED format version(MED_V2_1 or MED_V2_2)
1387 # @param overwrite boolean parameter for overwriting/not overwriting the file
1388 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1389 # @ingroup l2_impexp
1390 def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1, meshPart=None):
1392 if isinstance( meshPart, list ):
1393 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1394 self.mesh.ExportPartToMED( meshPart, f, auto_groups, version, overwrite )
1396 self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
1398 ## Exports the mesh in a file in SAUV format
1399 # @param f is the file name
1400 # @param auto_groups boolean parameter for creating/not creating
1401 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1402 # the typical use is auto_groups=false.
1403 # @ingroup l2_impexp
1404 def ExportSAUV(self, f, auto_groups=0):
1405 self.mesh.ExportSAUV(f, auto_groups)
1407 ## Exports the mesh in a file in DAT format
1408 # @param f the file name
1409 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1410 # @ingroup l2_impexp
1411 def ExportDAT(self, f, meshPart=None):
1413 if isinstance( meshPart, list ):
1414 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1415 self.mesh.ExportPartToDAT( meshPart, f )
1417 self.mesh.ExportDAT(f)
1419 ## Exports the mesh in a file in UNV format
1420 # @param f the file name
1421 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1422 # @ingroup l2_impexp
1423 def ExportUNV(self, f, meshPart=None):
1425 if isinstance( meshPart, list ):
1426 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1427 self.mesh.ExportPartToUNV( meshPart, f )
1429 self.mesh.ExportUNV(f)
1431 ## Export the mesh in a file in STL format
1432 # @param f the file name
1433 # @param ascii defines the file encoding
1434 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1435 # @ingroup l2_impexp
1436 def ExportSTL(self, f, ascii=1, meshPart=None):
1438 if isinstance( meshPart, list ):
1439 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1440 self.mesh.ExportPartToSTL( meshPart, f, ascii )
1442 self.mesh.ExportSTL(f, ascii)
1444 ## Exports the mesh in a file in CGNS format
1445 # @param f is the file name
1446 # @param overwrite boolean parameter for overwriting/not overwriting the file
1447 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1448 # @ingroup l2_impexp
1449 def ExportCGNS(self, f, overwrite=1, meshPart=None):
1450 if isinstance( meshPart, list ):
1451 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1452 if isinstance( meshPart, Mesh ):
1453 meshPart = meshPart.mesh
1455 meshPart = self.mesh
1456 self.mesh.ExportCGNS(meshPart, f, overwrite)
1458 # Operations with groups:
1459 # ----------------------
1461 ## Creates an empty mesh group
1462 # @param elementType the type of elements in the group
1463 # @param name the name of the mesh group
1464 # @return SMESH_Group
1465 # @ingroup l2_grps_create
1466 def CreateEmptyGroup(self, elementType, name):
1467 return self.mesh.CreateGroup(elementType, name)
1469 ## Creates a mesh group based on the geometric object \a grp
1470 # and gives a \a name, \n if this parameter is not defined
1471 # the name is the same as the geometric group name \n
1472 # Note: Works like GroupOnGeom().
1473 # @param grp a geometric group, a vertex, an edge, a face or a solid
1474 # @param name the name of the mesh group
1475 # @return SMESH_GroupOnGeom
1476 # @ingroup l2_grps_create
1477 def Group(self, grp, name=""):
1478 return self.GroupOnGeom(grp, name)
1480 ## Creates a mesh group based on the geometrical object \a grp
1481 # and gives a \a name, \n if this parameter is not defined
1482 # the name is the same as the geometrical group name
1483 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1484 # @param name the name of the mesh group
1485 # @param typ the type of elements in the group. If not set, it is
1486 # automatically detected by the type of the geometry
1487 # @return SMESH_GroupOnGeom
1488 # @ingroup l2_grps_create
1489 def GroupOnGeom(self, grp, name="", typ=None):
1490 AssureGeomPublished( self, grp, name )
1492 name = grp.GetName()
1494 typ = self._groupTypeFromShape( grp )
1495 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1497 ## Pivate method to get a type of group on geometry
1498 def _groupTypeFromShape( self, shape ):
1499 tgeo = str(shape.GetShapeType())
1500 if tgeo == "VERTEX":
1502 elif tgeo == "EDGE":
1504 elif tgeo == "FACE" or tgeo == "SHELL":
1506 elif tgeo == "SOLID" or tgeo == "COMPSOLID":
1508 elif tgeo == "COMPOUND":
1509 sub = self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHAPE"])
1511 raise ValueError,"_groupTypeFromShape(): empty geometric group or compound '%s'" % GetName(shape)
1512 return self._groupTypeFromShape( sub[0] )
1515 "_groupTypeFromShape(): invalid geometry '%s'" % GetName(shape)
1518 ## Creates a mesh group with given \a name based on the \a filter which
1519 ## is a special type of group dynamically updating it's contents during
1520 ## mesh modification
1521 # @param typ the type of elements in the group
1522 # @param name the name of the mesh group
1523 # @param filter the filter defining group contents
1524 # @return SMESH_GroupOnFilter
1525 # @ingroup l2_grps_create
1526 def GroupOnFilter(self, typ, name, filter):
1527 return self.mesh.CreateGroupFromFilter(typ, name, filter)
1529 ## Creates a mesh group by the given ids of elements
1530 # @param groupName the name of the mesh group
1531 # @param elementType the type of elements in the group
1532 # @param elemIDs the list of ids
1533 # @return SMESH_Group
1534 # @ingroup l2_grps_create
1535 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1536 group = self.mesh.CreateGroup(elementType, groupName)
1540 ## Creates a mesh group by the given conditions
1541 # @param groupName the name of the mesh group
1542 # @param elementType the type of elements in the group
1543 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1544 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1545 # @param Threshold the threshold value (range of id ids as string, shape, numeric)
1546 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1547 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
1548 # FT_LyingOnGeom, FT_CoplanarFaces criteria
1549 # @return SMESH_Group
1550 # @ingroup l2_grps_create
1554 CritType=FT_Undefined,
1557 UnaryOp=FT_Undefined,
1559 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Threshold, UnaryOp, FT_Undefined,Tolerance)
1560 group = self.MakeGroupByCriterion(groupName, aCriterion)
1563 ## Creates a mesh group by the given criterion
1564 # @param groupName the name of the mesh group
1565 # @param Criterion the instance of Criterion class
1566 # @return SMESH_Group
1567 # @ingroup l2_grps_create
1568 def MakeGroupByCriterion(self, groupName, Criterion):
1569 aFilterMgr = self.smeshpyD.CreateFilterManager()
1570 aFilter = aFilterMgr.CreateFilter()
1572 aCriteria.append(Criterion)
1573 aFilter.SetCriteria(aCriteria)
1574 group = self.MakeGroupByFilter(groupName, aFilter)
1575 aFilterMgr.UnRegister()
1578 ## Creates a mesh group by the given criteria (list of criteria)
1579 # @param groupName the name of the mesh group
1580 # @param theCriteria the list of criteria
1581 # @return SMESH_Group
1582 # @ingroup l2_grps_create
1583 def MakeGroupByCriteria(self, groupName, theCriteria):
1584 aFilterMgr = self.smeshpyD.CreateFilterManager()
1585 aFilter = aFilterMgr.CreateFilter()
1586 aFilter.SetCriteria(theCriteria)
1587 group = self.MakeGroupByFilter(groupName, aFilter)
1588 aFilterMgr.UnRegister()
1591 ## Creates a mesh group by the given filter
1592 # @param groupName the name of the mesh group
1593 # @param theFilter the instance of Filter class
1594 # @return SMESH_Group
1595 # @ingroup l2_grps_create
1596 def MakeGroupByFilter(self, groupName, theFilter):
1597 group = self.CreateEmptyGroup(theFilter.GetElementType(), groupName)
1598 theFilter.SetMesh( self.mesh )
1599 group.AddFrom( theFilter )
1602 ## Passes mesh elements through the given filter and return IDs of fitting elements
1603 # @param theFilter SMESH_Filter
1604 # @return a list of ids
1605 # @ingroup l1_controls
1606 def GetIdsFromFilter(self, theFilter):
1607 theFilter.SetMesh( self.mesh )
1608 return theFilter.GetIDs()
1610 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1611 # Returns a list of special structures (borders).
1612 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1613 # @ingroup l1_controls
1614 def GetFreeBorders(self):
1615 aFilterMgr = self.smeshpyD.CreateFilterManager()
1616 aPredicate = aFilterMgr.CreateFreeEdges()
1617 aPredicate.SetMesh(self.mesh)
1618 aBorders = aPredicate.GetBorders()
1619 aFilterMgr.UnRegister()
1623 # @ingroup l2_grps_delete
1624 def RemoveGroup(self, group):
1625 self.mesh.RemoveGroup(group)
1627 ## Removes a group with its contents
1628 # @ingroup l2_grps_delete
1629 def RemoveGroupWithContents(self, group):
1630 self.mesh.RemoveGroupWithContents(group)
1632 ## Gets the list of groups existing in the mesh
1633 # @return a sequence of SMESH_GroupBase
1634 # @ingroup l2_grps_create
1635 def GetGroups(self):
1636 return self.mesh.GetGroups()
1638 ## Gets the number of groups existing in the mesh
1639 # @return the quantity of groups as an integer value
1640 # @ingroup l2_grps_create
1642 return self.mesh.NbGroups()
1644 ## Gets the list of names of groups existing in the mesh
1645 # @return list of strings
1646 # @ingroup l2_grps_create
1647 def GetGroupNames(self):
1648 groups = self.GetGroups()
1650 for group in groups:
1651 names.append(group.GetName())
1654 ## Produces a union of two groups
1655 # A new group is created. All mesh elements that are
1656 # present in the initial groups are added to the new one
1657 # @return an instance of SMESH_Group
1658 # @ingroup l2_grps_operon
1659 def UnionGroups(self, group1, group2, name):
1660 return self.mesh.UnionGroups(group1, group2, name)
1662 ## Produces a union list of groups
1663 # New group is created. All mesh elements that are present in
1664 # initial groups are added to the new one
1665 # @return an instance of SMESH_Group
1666 # @ingroup l2_grps_operon
1667 def UnionListOfGroups(self, groups, name):
1668 return self.mesh.UnionListOfGroups(groups, name)
1670 ## Prodices an intersection of two groups
1671 # A new group is created. All mesh elements that are common
1672 # for the two initial groups are added to the new one.
1673 # @return an instance of SMESH_Group
1674 # @ingroup l2_grps_operon
1675 def IntersectGroups(self, group1, group2, name):
1676 return self.mesh.IntersectGroups(group1, group2, name)
1678 ## Produces an intersection of groups
1679 # New group is created. All mesh elements that are present in all
1680 # initial groups simultaneously are added to the new one
1681 # @return an instance of SMESH_Group
1682 # @ingroup l2_grps_operon
1683 def IntersectListOfGroups(self, groups, name):
1684 return self.mesh.IntersectListOfGroups(groups, name)
1686 ## Produces a cut of two groups
1687 # A new group is created. All mesh elements that are present in
1688 # the main group but are not present in the tool group are added to the new one
1689 # @return an instance of SMESH_Group
1690 # @ingroup l2_grps_operon
1691 def CutGroups(self, main_group, tool_group, name):
1692 return self.mesh.CutGroups(main_group, tool_group, name)
1694 ## Produces a cut of groups
1695 # A new group is created. All mesh elements that are present in main groups
1696 # but do not present in tool groups are added to the new one
1697 # @return an instance of SMESH_Group
1698 # @ingroup l2_grps_operon
1699 def CutListOfGroups(self, main_groups, tool_groups, name):
1700 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1702 ## Produces a group of elements of specified type using list of existing groups
1703 # A new group is created. System
1704 # 1) extracts all nodes on which groups elements are built
1705 # 2) combines all elements of specified dimension laying on these nodes
1706 # @return an instance of SMESH_Group
1707 # @ingroup l2_grps_operon
1708 def CreateDimGroup(self, groups, elem_type, name):
1709 return self.mesh.CreateDimGroup(groups, elem_type, name)
1712 ## Convert group on geom into standalone group
1713 # @ingroup l2_grps_delete
1714 def ConvertToStandalone(self, group):
1715 return self.mesh.ConvertToStandalone(group)
1717 # Get some info about mesh:
1718 # ------------------------
1720 ## Returns the log of nodes and elements added or removed
1721 # since the previous clear of the log.
1722 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1723 # @return list of log_block structures:
1728 # @ingroup l1_auxiliary
1729 def GetLog(self, clearAfterGet):
1730 return self.mesh.GetLog(clearAfterGet)
1732 ## Clears the log of nodes and elements added or removed since the previous
1733 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1734 # @ingroup l1_auxiliary
1736 self.mesh.ClearLog()
1738 ## Toggles auto color mode on the object.
1739 # @param theAutoColor the flag which toggles auto color mode.
1740 # @ingroup l1_auxiliary
1741 def SetAutoColor(self, theAutoColor):
1742 self.mesh.SetAutoColor(theAutoColor)
1744 ## Gets flag of object auto color mode.
1745 # @return True or False
1746 # @ingroup l1_auxiliary
1747 def GetAutoColor(self):
1748 return self.mesh.GetAutoColor()
1750 ## Gets the internal ID
1751 # @return integer value, which is the internal Id of the mesh
1752 # @ingroup l1_auxiliary
1754 return self.mesh.GetId()
1757 # @return integer value, which is the study Id of the mesh
1758 # @ingroup l1_auxiliary
1759 def GetStudyId(self):
1760 return self.mesh.GetStudyId()
1762 ## Checks the group names for duplications.
1763 # Consider the maximum group name length stored in MED file.
1764 # @return True or False
1765 # @ingroup l1_auxiliary
1766 def HasDuplicatedGroupNamesMED(self):
1767 return self.mesh.HasDuplicatedGroupNamesMED()
1769 ## Obtains the mesh editor tool
1770 # @return an instance of SMESH_MeshEditor
1771 # @ingroup l1_modifying
1772 def GetMeshEditor(self):
1773 return self.mesh.GetMeshEditor()
1775 ## Wrap a list of IDs of elements or nodes into SMESH_IDSource which
1776 # can be passed as argument to accepting mesh, group or sub-mesh
1777 # @return an instance of SMESH_IDSource
1778 # @ingroup l1_auxiliary
1779 def GetIDSource(self, ids, elemType):
1780 return self.GetMeshEditor().MakeIDSource(ids, elemType)
1783 # @return an instance of SALOME_MED::MESH
1784 # @ingroup l1_auxiliary
1785 def GetMEDMesh(self):
1786 return self.mesh.GetMEDMesh()
1789 # Get informations about mesh contents:
1790 # ------------------------------------
1792 ## Gets the mesh stattistic
1793 # @return dictionary type element - count of elements
1794 # @ingroup l1_meshinfo
1795 def GetMeshInfo(self, obj = None):
1796 if not obj: obj = self.mesh
1797 return self.smeshpyD.GetMeshInfo(obj)
1799 ## Returns the number of nodes in the mesh
1800 # @return an integer value
1801 # @ingroup l1_meshinfo
1803 return self.mesh.NbNodes()
1805 ## Returns the number of elements in the mesh
1806 # @return an integer value
1807 # @ingroup l1_meshinfo
1808 def NbElements(self):
1809 return self.mesh.NbElements()
1811 ## Returns the number of 0d elements in the mesh
1812 # @return an integer value
1813 # @ingroup l1_meshinfo
1814 def Nb0DElements(self):
1815 return self.mesh.Nb0DElements()
1817 ## Returns the number of edges in the mesh
1818 # @return an integer value
1819 # @ingroup l1_meshinfo
1821 return self.mesh.NbEdges()
1823 ## Returns the number of edges with the given order in the mesh
1824 # @param elementOrder the order of elements:
1825 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1826 # @return an integer value
1827 # @ingroup l1_meshinfo
1828 def NbEdgesOfOrder(self, elementOrder):
1829 return self.mesh.NbEdgesOfOrder(elementOrder)
1831 ## Returns the number of faces in the mesh
1832 # @return an integer value
1833 # @ingroup l1_meshinfo
1835 return self.mesh.NbFaces()
1837 ## Returns the number of faces with the given order in the mesh
1838 # @param elementOrder the order of elements:
1839 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1840 # @return an integer value
1841 # @ingroup l1_meshinfo
1842 def NbFacesOfOrder(self, elementOrder):
1843 return self.mesh.NbFacesOfOrder(elementOrder)
1845 ## Returns the number of triangles in the mesh
1846 # @return an integer value
1847 # @ingroup l1_meshinfo
1848 def NbTriangles(self):
1849 return self.mesh.NbTriangles()
1851 ## Returns the number of triangles with the given order in the mesh
1852 # @param elementOrder is the order of elements:
1853 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1854 # @return an integer value
1855 # @ingroup l1_meshinfo
1856 def NbTrianglesOfOrder(self, elementOrder):
1857 return self.mesh.NbTrianglesOfOrder(elementOrder)
1859 ## Returns the number of quadrangles in the mesh
1860 # @return an integer value
1861 # @ingroup l1_meshinfo
1862 def NbQuadrangles(self):
1863 return self.mesh.NbQuadrangles()
1865 ## Returns the number of quadrangles with the given order in the mesh
1866 # @param elementOrder the order of elements:
1867 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1868 # @return an integer value
1869 # @ingroup l1_meshinfo
1870 def NbQuadranglesOfOrder(self, elementOrder):
1871 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1873 ## Returns the number of biquadratic quadrangles in the mesh
1874 # @return an integer value
1875 # @ingroup l1_meshinfo
1876 def NbBiQuadQuadrangles(self):
1877 return self.mesh.NbBiQuadQuadrangles()
1879 ## Returns the number of polygons in the mesh
1880 # @return an integer value
1881 # @ingroup l1_meshinfo
1882 def NbPolygons(self):
1883 return self.mesh.NbPolygons()
1885 ## Returns the number of volumes in the mesh
1886 # @return an integer value
1887 # @ingroup l1_meshinfo
1888 def NbVolumes(self):
1889 return self.mesh.NbVolumes()
1891 ## Returns the number of volumes with the given order in the mesh
1892 # @param elementOrder the order of elements:
1893 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1894 # @return an integer value
1895 # @ingroup l1_meshinfo
1896 def NbVolumesOfOrder(self, elementOrder):
1897 return self.mesh.NbVolumesOfOrder(elementOrder)
1899 ## Returns the number of tetrahedrons in the mesh
1900 # @return an integer value
1901 # @ingroup l1_meshinfo
1903 return self.mesh.NbTetras()
1905 ## Returns the number of tetrahedrons with the given order in the mesh
1906 # @param elementOrder the order of elements:
1907 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1908 # @return an integer value
1909 # @ingroup l1_meshinfo
1910 def NbTetrasOfOrder(self, elementOrder):
1911 return self.mesh.NbTetrasOfOrder(elementOrder)
1913 ## Returns the number of hexahedrons in the mesh
1914 # @return an integer value
1915 # @ingroup l1_meshinfo
1917 return self.mesh.NbHexas()
1919 ## Returns the number of hexahedrons with the given order in the mesh
1920 # @param elementOrder the order of elements:
1921 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1922 # @return an integer value
1923 # @ingroup l1_meshinfo
1924 def NbHexasOfOrder(self, elementOrder):
1925 return self.mesh.NbHexasOfOrder(elementOrder)
1927 ## Returns the number of triquadratic hexahedrons in the mesh
1928 # @return an integer value
1929 # @ingroup l1_meshinfo
1930 def NbTriQuadraticHexas(self):
1931 return self.mesh.NbTriQuadraticHexas()
1933 ## Returns the number of pyramids in the mesh
1934 # @return an integer value
1935 # @ingroup l1_meshinfo
1936 def NbPyramids(self):
1937 return self.mesh.NbPyramids()
1939 ## Returns the number of pyramids with the given order in the mesh
1940 # @param elementOrder the order of elements:
1941 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1942 # @return an integer value
1943 # @ingroup l1_meshinfo
1944 def NbPyramidsOfOrder(self, elementOrder):
1945 return self.mesh.NbPyramidsOfOrder(elementOrder)
1947 ## Returns the number of prisms in the mesh
1948 # @return an integer value
1949 # @ingroup l1_meshinfo
1951 return self.mesh.NbPrisms()
1953 ## Returns the number of prisms with the given order in the mesh
1954 # @param elementOrder the order of elements:
1955 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1956 # @return an integer value
1957 # @ingroup l1_meshinfo
1958 def NbPrismsOfOrder(self, elementOrder):
1959 return self.mesh.NbPrismsOfOrder(elementOrder)
1961 ## Returns the number of hexagonal prisms in the mesh
1962 # @return an integer value
1963 # @ingroup l1_meshinfo
1964 def NbHexagonalPrisms(self):
1965 return self.mesh.NbHexagonalPrisms()
1967 ## Returns the number of polyhedrons in the mesh
1968 # @return an integer value
1969 # @ingroup l1_meshinfo
1970 def NbPolyhedrons(self):
1971 return self.mesh.NbPolyhedrons()
1973 ## Returns the number of submeshes in the mesh
1974 # @return an integer value
1975 # @ingroup l1_meshinfo
1976 def NbSubMesh(self):
1977 return self.mesh.NbSubMesh()
1979 ## Returns the list of mesh elements IDs
1980 # @return the list of integer values
1981 # @ingroup l1_meshinfo
1982 def GetElementsId(self):
1983 return self.mesh.GetElementsId()
1985 ## Returns the list of IDs of mesh elements with the given type
1986 # @param elementType the required type of elements (SMESH.NODE, SMESH.EDGE, SMESH.FACE or SMESH.VOLUME)
1987 # @return list of integer values
1988 # @ingroup l1_meshinfo
1989 def GetElementsByType(self, elementType):
1990 return self.mesh.GetElementsByType(elementType)
1992 ## Returns the list of mesh nodes IDs
1993 # @return the list of integer values
1994 # @ingroup l1_meshinfo
1995 def GetNodesId(self):
1996 return self.mesh.GetNodesId()
1998 # Get the information about mesh elements:
1999 # ------------------------------------
2001 ## Returns the type of mesh element
2002 # @return the value from SMESH::ElementType enumeration
2003 # @ingroup l1_meshinfo
2004 def GetElementType(self, id, iselem):
2005 return self.mesh.GetElementType(id, iselem)
2007 ## Returns the geometric type of mesh element
2008 # @return the value from SMESH::EntityType enumeration
2009 # @ingroup l1_meshinfo
2010 def GetElementGeomType(self, id):
2011 return self.mesh.GetElementGeomType(id)
2013 ## Returns the list of submesh elements IDs
2014 # @param Shape a geom object(sub-shape) IOR
2015 # Shape must be the sub-shape of a ShapeToMesh()
2016 # @return the list of integer values
2017 # @ingroup l1_meshinfo
2018 def GetSubMeshElementsId(self, Shape):
2019 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2020 ShapeID = Shape.GetSubShapeIndices()[0]
2023 return self.mesh.GetSubMeshElementsId(ShapeID)
2025 ## Returns the list of submesh nodes IDs
2026 # @param Shape a geom object(sub-shape) IOR
2027 # Shape must be the sub-shape of a ShapeToMesh()
2028 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
2029 # @return the list of integer values
2030 # @ingroup l1_meshinfo
2031 def GetSubMeshNodesId(self, Shape, all):
2032 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2033 ShapeID = Shape.GetSubShapeIndices()[0]
2036 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2038 ## Returns type of elements on given shape
2039 # @param Shape a geom object(sub-shape) IOR
2040 # Shape must be a sub-shape of a ShapeToMesh()
2041 # @return element type
2042 # @ingroup l1_meshinfo
2043 def GetSubMeshElementType(self, Shape):
2044 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2045 ShapeID = Shape.GetSubShapeIndices()[0]
2048 return self.mesh.GetSubMeshElementType(ShapeID)
2050 ## Gets the mesh description
2051 # @return string value
2052 # @ingroup l1_meshinfo
2054 return self.mesh.Dump()
2057 # Get the information about nodes and elements of a mesh by its IDs:
2058 # -----------------------------------------------------------
2060 ## Gets XYZ coordinates of a node
2061 # \n If there is no nodes for the given ID - returns an empty list
2062 # @return a list of double precision values
2063 # @ingroup l1_meshinfo
2064 def GetNodeXYZ(self, id):
2065 return self.mesh.GetNodeXYZ(id)
2067 ## Returns list of IDs of inverse elements for the given node
2068 # \n If there is no node for the given ID - returns an empty list
2069 # @return a list of integer values
2070 # @ingroup l1_meshinfo
2071 def GetNodeInverseElements(self, id):
2072 return self.mesh.GetNodeInverseElements(id)
2074 ## @brief Returns the position of a node on the shape
2075 # @return SMESH::NodePosition
2076 # @ingroup l1_meshinfo
2077 def GetNodePosition(self,NodeID):
2078 return self.mesh.GetNodePosition(NodeID)
2080 ## If the given element is a node, returns the ID of shape
2081 # \n If there is no node for the given ID - returns -1
2082 # @return an integer value
2083 # @ingroup l1_meshinfo
2084 def GetShapeID(self, id):
2085 return self.mesh.GetShapeID(id)
2087 ## Returns the ID of the result shape after
2088 # FindShape() from SMESH_MeshEditor for the given element
2089 # \n If there is no element for the given ID - returns -1
2090 # @return an integer value
2091 # @ingroup l1_meshinfo
2092 def GetShapeIDForElem(self,id):
2093 return self.mesh.GetShapeIDForElem(id)
2095 ## Returns the number of nodes for the given element
2096 # \n If there is no element for the given ID - returns -1
2097 # @return an integer value
2098 # @ingroup l1_meshinfo
2099 def GetElemNbNodes(self, id):
2100 return self.mesh.GetElemNbNodes(id)
2102 ## Returns the node ID the given index for the given element
2103 # \n If there is no element for the given ID - returns -1
2104 # \n If there is no node for the given index - returns -2
2105 # @return an integer value
2106 # @ingroup l1_meshinfo
2107 def GetElemNode(self, id, index):
2108 return self.mesh.GetElemNode(id, index)
2110 ## Returns the IDs of nodes of the given element
2111 # @return a list of integer values
2112 # @ingroup l1_meshinfo
2113 def GetElemNodes(self, id):
2114 return self.mesh.GetElemNodes(id)
2116 ## Returns true if the given node is the medium node in the given quadratic element
2117 # @ingroup l1_meshinfo
2118 def IsMediumNode(self, elementID, nodeID):
2119 return self.mesh.IsMediumNode(elementID, nodeID)
2121 ## Returns true if the given node is the medium node in one of quadratic elements
2122 # @ingroup l1_meshinfo
2123 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2124 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2126 ## Returns the number of edges for the given element
2127 # @ingroup l1_meshinfo
2128 def ElemNbEdges(self, id):
2129 return self.mesh.ElemNbEdges(id)
2131 ## Returns the number of faces for the given element
2132 # @ingroup l1_meshinfo
2133 def ElemNbFaces(self, id):
2134 return self.mesh.ElemNbFaces(id)
2136 ## Returns nodes of given face (counted from zero) for given volumic element.
2137 # @ingroup l1_meshinfo
2138 def GetElemFaceNodes(self,elemId, faceIndex):
2139 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2141 ## Returns an element based on all given nodes.
2142 # @ingroup l1_meshinfo
2143 def FindElementByNodes(self,nodes):
2144 return self.mesh.FindElementByNodes(nodes)
2146 ## Returns true if the given element is a polygon
2147 # @ingroup l1_meshinfo
2148 def IsPoly(self, id):
2149 return self.mesh.IsPoly(id)
2151 ## Returns true if the given element is quadratic
2152 # @ingroup l1_meshinfo
2153 def IsQuadratic(self, id):
2154 return self.mesh.IsQuadratic(id)
2156 ## Returns XYZ coordinates of the barycenter of the given element
2157 # \n If there is no element for the given ID - returns an empty list
2158 # @return a list of three double values
2159 # @ingroup l1_meshinfo
2160 def BaryCenter(self, id):
2161 return self.mesh.BaryCenter(id)
2164 # Get mesh measurements information:
2165 # ------------------------------------
2167 ## Get minimum distance between two nodes, elements or distance to the origin
2168 # @param id1 first node/element id
2169 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2170 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2171 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2172 # @return minimum distance value
2173 # @sa GetMinDistance()
2174 def MinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2175 aMeasure = self.GetMinDistance(id1, id2, isElem1, isElem2)
2176 return aMeasure.value
2178 ## Get measure structure specifying minimum distance data between two objects
2179 # @param id1 first node/element id
2180 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2181 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2182 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2183 # @return Measure structure
2185 def GetMinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2187 id1 = self.editor.MakeIDSource([id1], SMESH.FACE)
2189 id1 = self.editor.MakeIDSource([id1], SMESH.NODE)
2192 id2 = self.editor.MakeIDSource([id2], SMESH.FACE)
2194 id2 = self.editor.MakeIDSource([id2], SMESH.NODE)
2199 aMeasurements = self.smeshpyD.CreateMeasurements()
2200 aMeasure = aMeasurements.MinDistance(id1, id2)
2201 aMeasurements.UnRegister()
2204 ## Get bounding box of the specified object(s)
2205 # @param objects single source object or list of source objects or list of nodes/elements IDs
2206 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2207 # @c False specifies that @a objects are nodes
2208 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
2209 # @sa GetBoundingBox()
2210 def BoundingBox(self, objects=None, isElem=False):
2211 result = self.GetBoundingBox(objects, isElem)
2215 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
2218 ## Get measure structure specifying bounding box data of the specified object(s)
2219 # @param IDs single source object or list of source objects or list of nodes/elements IDs
2220 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2221 # @c False specifies that @a objects are nodes
2222 # @return Measure structure
2224 def GetBoundingBox(self, IDs=None, isElem=False):
2227 elif isinstance(IDs, tuple):
2229 if not isinstance(IDs, list):
2231 if len(IDs) > 0 and isinstance(IDs[0], int):
2235 if isinstance(o, Mesh):
2236 srclist.append(o.mesh)
2237 elif hasattr(o, "_narrow"):
2238 src = o._narrow(SMESH.SMESH_IDSource)
2239 if src: srclist.append(src)
2241 elif isinstance(o, list):
2243 srclist.append(self.editor.MakeIDSource(o, SMESH.FACE))
2245 srclist.append(self.editor.MakeIDSource(o, SMESH.NODE))
2248 aMeasurements = self.smeshpyD.CreateMeasurements()
2249 aMeasure = aMeasurements.BoundingBox(srclist)
2250 aMeasurements.UnRegister()
2253 # Mesh edition (SMESH_MeshEditor functionality):
2254 # ---------------------------------------------
2256 ## Removes the elements from the mesh by ids
2257 # @param IDsOfElements is a list of ids of elements to remove
2258 # @return True or False
2259 # @ingroup l2_modif_del
2260 def RemoveElements(self, IDsOfElements):
2261 return self.editor.RemoveElements(IDsOfElements)
2263 ## Removes nodes from mesh by ids
2264 # @param IDsOfNodes is a list of ids of nodes to remove
2265 # @return True or False
2266 # @ingroup l2_modif_del
2267 def RemoveNodes(self, IDsOfNodes):
2268 return self.editor.RemoveNodes(IDsOfNodes)
2270 ## Removes all orphan (free) nodes from mesh
2271 # @return number of the removed nodes
2272 # @ingroup l2_modif_del
2273 def RemoveOrphanNodes(self):
2274 return self.editor.RemoveOrphanNodes()
2276 ## Add a node to the mesh by coordinates
2277 # @return Id of the new node
2278 # @ingroup l2_modif_add
2279 def AddNode(self, x, y, z):
2280 x,y,z,Parameters,hasVars = ParseParameters(x,y,z)
2281 if hasVars: self.mesh.SetParameters(Parameters)
2282 return self.editor.AddNode( x, y, z)
2284 ## Creates a 0D element on a node with given number.
2285 # @param IDOfNode the ID of node for creation of the element.
2286 # @return the Id of the new 0D element
2287 # @ingroup l2_modif_add
2288 def Add0DElement(self, IDOfNode):
2289 return self.editor.Add0DElement(IDOfNode)
2291 ## Creates a linear or quadratic edge (this is determined
2292 # by the number of given nodes).
2293 # @param IDsOfNodes the list of node IDs for creation of the element.
2294 # The order of nodes in this list should correspond to the description
2295 # of MED. \n This description is located by the following link:
2296 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2297 # @return the Id of the new edge
2298 # @ingroup l2_modif_add
2299 def AddEdge(self, IDsOfNodes):
2300 return self.editor.AddEdge(IDsOfNodes)
2302 ## Creates a linear or quadratic face (this is determined
2303 # by the number of given nodes).
2304 # @param IDsOfNodes the list of node IDs for creation of the element.
2305 # The order of nodes in this list should correspond to the description
2306 # of MED. \n This description is located by the following link:
2307 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2308 # @return the Id of the new face
2309 # @ingroup l2_modif_add
2310 def AddFace(self, IDsOfNodes):
2311 return self.editor.AddFace(IDsOfNodes)
2313 ## Adds a polygonal face to the mesh by the list of node IDs
2314 # @param IdsOfNodes the list of node IDs for creation of the element.
2315 # @return the Id of the new face
2316 # @ingroup l2_modif_add
2317 def AddPolygonalFace(self, IdsOfNodes):
2318 return self.editor.AddPolygonalFace(IdsOfNodes)
2320 ## Creates both simple and quadratic volume (this is determined
2321 # by the number of given nodes).
2322 # @param IDsOfNodes the list of node IDs for creation of the element.
2323 # The order of nodes in this list should correspond to the description
2324 # of MED. \n This description is located by the following link:
2325 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2326 # @return the Id of the new volumic element
2327 # @ingroup l2_modif_add
2328 def AddVolume(self, IDsOfNodes):
2329 return self.editor.AddVolume(IDsOfNodes)
2331 ## Creates a volume of many faces, giving nodes for each face.
2332 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2333 # @param Quantities the list of integer values, Quantities[i]
2334 # gives the quantity of nodes in face number i.
2335 # @return the Id of the new volumic element
2336 # @ingroup l2_modif_add
2337 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2338 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2340 ## Creates a volume of many faces, giving the IDs of the existing faces.
2341 # @param IdsOfFaces the list of face IDs for volume creation.
2343 # Note: The created volume will refer only to the nodes
2344 # of the given faces, not to the faces themselves.
2345 # @return the Id of the new volumic element
2346 # @ingroup l2_modif_add
2347 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2348 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2351 ## @brief Binds a node to a vertex
2352 # @param NodeID a node ID
2353 # @param Vertex a vertex or vertex ID
2354 # @return True if succeed else raises an exception
2355 # @ingroup l2_modif_add
2356 def SetNodeOnVertex(self, NodeID, Vertex):
2357 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2358 VertexID = Vertex.GetSubShapeIndices()[0]
2362 self.editor.SetNodeOnVertex(NodeID, VertexID)
2363 except SALOME.SALOME_Exception, inst:
2364 raise ValueError, inst.details.text
2368 ## @brief Stores the node position on an edge
2369 # @param NodeID a node ID
2370 # @param Edge an edge or edge ID
2371 # @param paramOnEdge a parameter on the edge where the node is located
2372 # @return True if succeed else raises an exception
2373 # @ingroup l2_modif_add
2374 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2375 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2376 EdgeID = Edge.GetSubShapeIndices()[0]
2380 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2381 except SALOME.SALOME_Exception, inst:
2382 raise ValueError, inst.details.text
2385 ## @brief Stores node position on a face
2386 # @param NodeID a node ID
2387 # @param Face a face or face ID
2388 # @param u U parameter on the face where the node is located
2389 # @param v V parameter on the face where the node is located
2390 # @return True if succeed else raises an exception
2391 # @ingroup l2_modif_add
2392 def SetNodeOnFace(self, NodeID, Face, u, v):
2393 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2394 FaceID = Face.GetSubShapeIndices()[0]
2398 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2399 except SALOME.SALOME_Exception, inst:
2400 raise ValueError, inst.details.text
2403 ## @brief Binds a node to a solid
2404 # @param NodeID a node ID
2405 # @param Solid a solid or solid ID
2406 # @return True if succeed else raises an exception
2407 # @ingroup l2_modif_add
2408 def SetNodeInVolume(self, NodeID, Solid):
2409 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2410 SolidID = Solid.GetSubShapeIndices()[0]
2414 self.editor.SetNodeInVolume(NodeID, SolidID)
2415 except SALOME.SALOME_Exception, inst:
2416 raise ValueError, inst.details.text
2419 ## @brief Bind an element to a shape
2420 # @param ElementID an element ID
2421 # @param Shape a shape or shape ID
2422 # @return True if succeed else raises an exception
2423 # @ingroup l2_modif_add
2424 def SetMeshElementOnShape(self, ElementID, Shape):
2425 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2426 ShapeID = Shape.GetSubShapeIndices()[0]
2430 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2431 except SALOME.SALOME_Exception, inst:
2432 raise ValueError, inst.details.text
2436 ## Moves the node with the given id
2437 # @param NodeID the id of the node
2438 # @param x a new X coordinate
2439 # @param y a new Y coordinate
2440 # @param z a new Z coordinate
2441 # @return True if succeed else False
2442 # @ingroup l2_modif_movenode
2443 def MoveNode(self, NodeID, x, y, z):
2444 x,y,z,Parameters,hasVars = ParseParameters(x,y,z)
2445 if hasVars: self.mesh.SetParameters(Parameters)
2446 return self.editor.MoveNode(NodeID, x, y, z)
2448 ## Finds the node closest to a point and moves it to a point location
2449 # @param x the X coordinate of a point
2450 # @param y the Y coordinate of a point
2451 # @param z the Z coordinate of a point
2452 # @param NodeID if specified (>0), the node with this ID is moved,
2453 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2454 # @return the ID of a node
2455 # @ingroup l2_modif_throughp
2456 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2457 x,y,z,Parameters,hasVars = ParseParameters(x,y,z)
2458 if hasVars: self.mesh.SetParameters(Parameters)
2459 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2461 ## Finds the node closest to a point
2462 # @param x the X coordinate of a point
2463 # @param y the Y coordinate of a point
2464 # @param z the Z coordinate of a point
2465 # @return the ID of a node
2466 # @ingroup l2_modif_throughp
2467 def FindNodeClosestTo(self, x, y, z):
2468 #preview = self.mesh.GetMeshEditPreviewer()
2469 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2470 return self.editor.FindNodeClosestTo(x, y, z)
2472 ## Finds the elements where a point lays IN or ON
2473 # @param x the X coordinate of a point
2474 # @param y the Y coordinate of a point
2475 # @param z the Z coordinate of a point
2476 # @param elementType type of elements to find (SMESH.ALL type
2477 # means elements of any type excluding nodes and 0D elements)
2478 # @param meshPart a part of mesh (group, sub-mesh) to search within
2479 # @return list of IDs of found elements
2480 # @ingroup l2_modif_throughp
2481 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL, meshPart=None):
2483 return self.editor.FindAmongElementsByPoint( meshPart, x, y, z, elementType );
2485 return self.editor.FindElementsByPoint(x, y, z, elementType)
2487 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2488 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2490 def GetPointState(self, x, y, z):
2491 return self.editor.GetPointState(x, y, z)
2493 ## Finds the node closest to a point and moves it to a point location
2494 # @param x the X coordinate of a point
2495 # @param y the Y coordinate of a point
2496 # @param z the Z coordinate of a point
2497 # @return the ID of a moved node
2498 # @ingroup l2_modif_throughp
2499 def MeshToPassThroughAPoint(self, x, y, z):
2500 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2502 ## Replaces two neighbour triangles sharing Node1-Node2 link
2503 # with the triangles built on the same 4 nodes but having other common link.
2504 # @param NodeID1 the ID of the first node
2505 # @param NodeID2 the ID of the second node
2506 # @return false if proper faces were not found
2507 # @ingroup l2_modif_invdiag
2508 def InverseDiag(self, NodeID1, NodeID2):
2509 return self.editor.InverseDiag(NodeID1, NodeID2)
2511 ## Replaces two neighbour triangles sharing Node1-Node2 link
2512 # with a quadrangle built on the same 4 nodes.
2513 # @param NodeID1 the ID of the first node
2514 # @param NodeID2 the ID of the second node
2515 # @return false if proper faces were not found
2516 # @ingroup l2_modif_unitetri
2517 def DeleteDiag(self, NodeID1, NodeID2):
2518 return self.editor.DeleteDiag(NodeID1, NodeID2)
2520 ## Reorients elements by ids
2521 # @param IDsOfElements if undefined reorients all mesh elements
2522 # @return True if succeed else False
2523 # @ingroup l2_modif_changori
2524 def Reorient(self, IDsOfElements=None):
2525 if IDsOfElements == None:
2526 IDsOfElements = self.GetElementsId()
2527 return self.editor.Reorient(IDsOfElements)
2529 ## Reorients all elements of the object
2530 # @param theObject mesh, submesh or group
2531 # @return True if succeed else False
2532 # @ingroup l2_modif_changori
2533 def ReorientObject(self, theObject):
2534 if ( isinstance( theObject, Mesh )):
2535 theObject = theObject.GetMesh()
2536 return self.editor.ReorientObject(theObject)
2538 ## Fuses the neighbouring triangles into quadrangles.
2539 # @param IDsOfElements The triangles to be fused,
2540 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2541 # @param MaxAngle is the maximum angle between element normals at which the fusion
2542 # is still performed; theMaxAngle is mesured in radians.
2543 # Also it could be a name of variable which defines angle in degrees.
2544 # @return TRUE in case of success, FALSE otherwise.
2545 # @ingroup l2_modif_unitetri
2546 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2548 if isinstance(MaxAngle,str):
2550 MaxAngle,Parameters,hasVars = ParseAngles(MaxAngle)
2551 self.mesh.SetParameters(Parameters)
2552 if not IDsOfElements:
2553 IDsOfElements = self.GetElementsId()
2555 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2556 Functor = theCriterion
2558 Functor = self.smeshpyD.GetFunctor(theCriterion)
2559 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2561 ## Fuses the neighbouring triangles of the object into quadrangles
2562 # @param theObject is mesh, submesh or group
2563 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2564 # @param MaxAngle a max angle between element normals at which the fusion
2565 # is still performed; theMaxAngle is mesured in radians.
2566 # @return TRUE in case of success, FALSE otherwise.
2567 # @ingroup l2_modif_unitetri
2568 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2569 MaxAngle,Parameters,hasVars = ParseAngles(MaxAngle)
2570 self.mesh.SetParameters(Parameters)
2571 if ( isinstance( theObject, Mesh )):
2572 theObject = theObject.GetMesh()
2573 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2575 ## Splits quadrangles into triangles.
2576 # @param IDsOfElements the faces to be splitted.
2577 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2578 # @return TRUE in case of success, FALSE otherwise.
2579 # @ingroup l2_modif_cutquadr
2580 def QuadToTri (self, IDsOfElements, theCriterion):
2581 if IDsOfElements == []:
2582 IDsOfElements = self.GetElementsId()
2583 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2585 ## Splits quadrangles into triangles.
2586 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2587 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2588 # @return TRUE in case of success, FALSE otherwise.
2589 # @ingroup l2_modif_cutquadr
2590 def QuadToTriObject (self, theObject, theCriterion):
2591 if ( isinstance( theObject, Mesh )):
2592 theObject = theObject.GetMesh()
2593 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2595 ## Splits quadrangles into triangles.
2596 # @param IDsOfElements the faces to be splitted
2597 # @param Diag13 is used to choose a diagonal for splitting.
2598 # @return TRUE in case of success, FALSE otherwise.
2599 # @ingroup l2_modif_cutquadr
2600 def SplitQuad (self, IDsOfElements, Diag13):
2601 if IDsOfElements == []:
2602 IDsOfElements = self.GetElementsId()
2603 return self.editor.SplitQuad(IDsOfElements, Diag13)
2605 ## Splits quadrangles into triangles.
2606 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2607 # @param Diag13 is used to choose a diagonal for splitting.
2608 # @return TRUE in case of success, FALSE otherwise.
2609 # @ingroup l2_modif_cutquadr
2610 def SplitQuadObject (self, theObject, Diag13):
2611 if ( isinstance( theObject, Mesh )):
2612 theObject = theObject.GetMesh()
2613 return self.editor.SplitQuadObject(theObject, Diag13)
2615 ## Finds a better splitting of the given quadrangle.
2616 # @param IDOfQuad the ID of the quadrangle to be splitted.
2617 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2618 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2619 # diagonal is better, 0 if error occurs.
2620 # @ingroup l2_modif_cutquadr
2621 def BestSplit (self, IDOfQuad, theCriterion):
2622 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2624 ## Splits volumic elements into tetrahedrons
2625 # @param elemIDs either list of elements or mesh or group or submesh
2626 # @param method flags passing splitting method: Hex_5Tet, Hex_6Tet, Hex_24Tet
2627 # Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc
2628 # @ingroup l2_modif_cutquadr
2629 def SplitVolumesIntoTetra(self, elemIDs, method=Hex_5Tet ):
2630 if isinstance( elemIDs, Mesh ):
2631 elemIDs = elemIDs.GetMesh()
2632 if ( isinstance( elemIDs, list )):
2633 elemIDs = self.editor.MakeIDSource(elemIDs, SMESH.VOLUME)
2634 self.editor.SplitVolumesIntoTetra(elemIDs, method)
2636 ## Splits quadrangle faces near triangular facets of volumes
2638 # @ingroup l1_auxiliary
2639 def SplitQuadsNearTriangularFacets(self):
2640 faces_array = self.GetElementsByType(SMESH.FACE)
2641 for face_id in faces_array:
2642 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2643 quad_nodes = self.mesh.GetElemNodes(face_id)
2644 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2645 isVolumeFound = False
2646 for node1_elem in node1_elems:
2647 if not isVolumeFound:
2648 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2649 nb_nodes = self.GetElemNbNodes(node1_elem)
2650 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2651 volume_elem = node1_elem
2652 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2653 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2654 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2655 isVolumeFound = True
2656 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2657 self.SplitQuad([face_id], False) # diagonal 2-4
2658 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2659 isVolumeFound = True
2660 self.SplitQuad([face_id], True) # diagonal 1-3
2661 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2662 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2663 isVolumeFound = True
2664 self.SplitQuad([face_id], True) # diagonal 1-3
2666 ## @brief Splits hexahedrons into tetrahedrons.
2668 # This operation uses pattern mapping functionality for splitting.
2669 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2670 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2671 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2672 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2673 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2674 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2675 # @return TRUE in case of success, FALSE otherwise.
2676 # @ingroup l1_auxiliary
2677 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2678 # Pattern: 5.---------.6
2683 # (0,0,1) 4.---------.7 * |
2690 # (0,0,0) 0.---------.3
2691 pattern_tetra = "!!! Nb of points: \n 8 \n\
2701 !!! Indices of points of 6 tetras: \n\
2709 pattern = self.smeshpyD.GetPattern()
2710 isDone = pattern.LoadFromFile(pattern_tetra)
2712 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2715 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2716 isDone = pattern.MakeMesh(self.mesh, False, False)
2717 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2719 # split quafrangle faces near triangular facets of volumes
2720 self.SplitQuadsNearTriangularFacets()
2724 ## @brief Split hexahedrons into prisms.
2726 # Uses the pattern mapping functionality for splitting.
2727 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2728 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2729 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2730 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2731 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2732 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2733 # @return TRUE in case of success, FALSE otherwise.
2734 # @ingroup l1_auxiliary
2735 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2736 # Pattern: 5.---------.6
2741 # (0,0,1) 4.---------.7 |
2748 # (0,0,0) 0.---------.3
2749 pattern_prism = "!!! Nb of points: \n 8 \n\
2759 !!! Indices of points of 2 prisms: \n\
2763 pattern = self.smeshpyD.GetPattern()
2764 isDone = pattern.LoadFromFile(pattern_prism)
2766 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2769 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2770 isDone = pattern.MakeMesh(self.mesh, False, False)
2771 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2773 # Splits quafrangle faces near triangular facets of volumes
2774 self.SplitQuadsNearTriangularFacets()
2778 ## Smoothes elements
2779 # @param IDsOfElements the list if ids of elements to smooth
2780 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2781 # Note that nodes built on edges and boundary nodes are always fixed.
2782 # @param MaxNbOfIterations the maximum number of iterations
2783 # @param MaxAspectRatio varies in range [1.0, inf]
2784 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2785 # @return TRUE in case of success, FALSE otherwise.
2786 # @ingroup l2_modif_smooth
2787 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2788 MaxNbOfIterations, MaxAspectRatio, Method):
2789 if IDsOfElements == []:
2790 IDsOfElements = self.GetElementsId()
2791 MaxNbOfIterations,MaxAspectRatio,Parameters,hasVars = ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2792 self.mesh.SetParameters(Parameters)
2793 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2794 MaxNbOfIterations, MaxAspectRatio, Method)
2796 ## Smoothes elements which belong to the given object
2797 # @param theObject the object to smooth
2798 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2799 # Note that nodes built on edges and boundary nodes are always fixed.
2800 # @param MaxNbOfIterations the maximum number of iterations
2801 # @param MaxAspectRatio varies in range [1.0, inf]
2802 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2803 # @return TRUE in case of success, FALSE otherwise.
2804 # @ingroup l2_modif_smooth
2805 def SmoothObject(self, theObject, IDsOfFixedNodes,
2806 MaxNbOfIterations, MaxAspectRatio, Method):
2807 if ( isinstance( theObject, Mesh )):
2808 theObject = theObject.GetMesh()
2809 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2810 MaxNbOfIterations, MaxAspectRatio, Method)
2812 ## Parametrically smoothes the given elements
2813 # @param IDsOfElements the list if ids of elements to smooth
2814 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2815 # Note that nodes built on edges and boundary nodes are always fixed.
2816 # @param MaxNbOfIterations the maximum number of iterations
2817 # @param MaxAspectRatio varies in range [1.0, inf]
2818 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2819 # @return TRUE in case of success, FALSE otherwise.
2820 # @ingroup l2_modif_smooth
2821 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2822 MaxNbOfIterations, MaxAspectRatio, Method):
2823 if IDsOfElements == []:
2824 IDsOfElements = self.GetElementsId()
2825 MaxNbOfIterations,MaxAspectRatio,Parameters,hasVars = ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2826 self.mesh.SetParameters(Parameters)
2827 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2828 MaxNbOfIterations, MaxAspectRatio, Method)
2830 ## Parametrically smoothes the elements which belong to the given object
2831 # @param theObject the object to smooth
2832 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2833 # Note that nodes built on edges and boundary nodes are always fixed.
2834 # @param MaxNbOfIterations the maximum number of iterations
2835 # @param MaxAspectRatio varies in range [1.0, inf]
2836 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2837 # @return TRUE in case of success, FALSE otherwise.
2838 # @ingroup l2_modif_smooth
2839 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2840 MaxNbOfIterations, MaxAspectRatio, Method):
2841 if ( isinstance( theObject, Mesh )):
2842 theObject = theObject.GetMesh()
2843 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2844 MaxNbOfIterations, MaxAspectRatio, Method)
2846 ## Converts the mesh to quadratic, deletes old elements, replacing
2847 # them with quadratic with the same id.
2848 # @param theForce3d new node creation method:
2849 # 0 - the medium node lies at the geometrical entity from which the mesh element is built
2850 # 1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element
2851 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
2852 # @ingroup l2_modif_tofromqu
2853 def ConvertToQuadratic(self, theForce3d, theSubMesh=None):
2855 self.editor.ConvertToQuadraticObject(theForce3d,theSubMesh)
2857 self.editor.ConvertToQuadratic(theForce3d)
2859 ## Converts the mesh from quadratic to ordinary,
2860 # deletes old quadratic elements, \n replacing
2861 # them with ordinary mesh elements with the same id.
2862 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
2863 # @ingroup l2_modif_tofromqu
2864 def ConvertFromQuadratic(self, theSubMesh=None):
2866 self.editor.ConvertFromQuadraticObject(theSubMesh)
2868 return self.editor.ConvertFromQuadratic()
2870 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
2871 # @return TRUE if operation has been completed successfully, FALSE otherwise
2872 # @ingroup l2_modif_edit
2873 def Make2DMeshFrom3D(self):
2874 return self.editor. Make2DMeshFrom3D()
2876 ## Creates missing boundary elements
2877 # @param elements - elements whose boundary is to be checked:
2878 # mesh, group, sub-mesh or list of elements
2879 # if elements is mesh, it must be the mesh whose MakeBoundaryMesh() is called
2880 # @param dimension - defines type of boundary elements to create:
2881 # SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D
2882 # SMESH.BND_1DFROM3D creates mesh edges on all borders of free facets of 3D cells
2883 # @param groupName - a name of group to store created boundary elements in,
2884 # "" means not to create the group
2885 # @param meshName - a name of new mesh to store created boundary elements in,
2886 # "" means not to create the new mesh
2887 # @param toCopyElements - if true, the checked elements will be copied into
2888 # the new mesh else only boundary elements will be copied into the new mesh
2889 # @param toCopyExistingBondary - if true, not only new but also pre-existing
2890 # boundary elements will be copied into the new mesh
2891 # @return tuple (mesh, group) where bondary elements were added to
2892 # @ingroup l2_modif_edit
2893 def MakeBoundaryMesh(self, elements, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
2894 toCopyElements=False, toCopyExistingBondary=False):
2895 if isinstance( elements, Mesh ):
2896 elements = elements.GetMesh()
2897 if ( isinstance( elements, list )):
2898 elemType = SMESH.ALL
2899 if elements: elemType = self.GetElementType( elements[0], iselem=True)
2900 elements = self.editor.MakeIDSource(elements, elemType)
2901 mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName,
2902 toCopyElements,toCopyExistingBondary)
2903 if mesh: mesh = self.smeshpyD.Mesh(mesh)
2907 # @brief Creates missing boundary elements around either the whole mesh or
2908 # groups of 2D elements
2909 # @param dimension - defines type of boundary elements to create
2910 # @param groupName - a name of group to store all boundary elements in,
2911 # "" means not to create the group
2912 # @param meshName - a name of a new mesh, which is a copy of the initial
2913 # mesh + created boundary elements; "" means not to create the new mesh
2914 # @param toCopyAll - if true, the whole initial mesh will be copied into
2915 # the new mesh else only boundary elements will be copied into the new mesh
2916 # @param groups - groups of 2D elements to make boundary around
2917 # @retval tuple( long, mesh, groups )
2918 # long - number of added boundary elements
2919 # mesh - the mesh where elements were added to
2920 # group - the group of boundary elements or None
2922 def MakeBoundaryElements(self, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
2923 toCopyAll=False, groups=[]):
2924 nb, mesh, group = self.editor.MakeBoundaryElements(dimension,groupName,meshName,
2926 if mesh: mesh = self.smeshpyD.Mesh(mesh)
2927 return nb, mesh, group
2929 ## Renumber mesh nodes
2930 # @ingroup l2_modif_renumber
2931 def RenumberNodes(self):
2932 self.editor.RenumberNodes()
2934 ## Renumber mesh elements
2935 # @ingroup l2_modif_renumber
2936 def RenumberElements(self):
2937 self.editor.RenumberElements()
2939 ## Generates new elements by rotation of the elements around the axis
2940 # @param IDsOfElements the list of ids of elements to sweep
2941 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2942 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2943 # @param NbOfSteps the number of steps
2944 # @param Tolerance tolerance
2945 # @param MakeGroups forces the generation of new groups from existing ones
2946 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2947 # of all steps, else - size of each step
2948 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2949 # @ingroup l2_modif_extrurev
2950 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2951 MakeGroups=False, TotalAngle=False):
2952 if IDsOfElements == []:
2953 IDsOfElements = self.GetElementsId()
2954 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2955 Axis = self.smeshpyD.GetAxisStruct(Axis)
2956 AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians)
2957 NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance)
2958 Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters
2959 self.mesh.SetParameters(Parameters)
2960 if TotalAngle and NbOfSteps:
2961 AngleInRadians /= NbOfSteps
2963 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2964 AngleInRadians, NbOfSteps, Tolerance)
2965 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2968 ## Generates new elements by rotation of the elements of object around the axis
2969 # @param theObject object which elements should be sweeped.
2970 # It can be a mesh, a sub mesh or a group.
2971 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2972 # @param AngleInRadians the angle of Rotation
2973 # @param NbOfSteps number of steps
2974 # @param Tolerance tolerance
2975 # @param MakeGroups forces the generation of new groups from existing ones
2976 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2977 # of all steps, else - size of each step
2978 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2979 # @ingroup l2_modif_extrurev
2980 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2981 MakeGroups=False, TotalAngle=False):
2982 if ( isinstance( theObject, Mesh )):
2983 theObject = theObject.GetMesh()
2984 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2985 Axis = self.smeshpyD.GetAxisStruct(Axis)
2986 AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians)
2987 NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance)
2988 Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters
2989 self.mesh.SetParameters(Parameters)
2990 if TotalAngle and NbOfSteps:
2991 AngleInRadians /= NbOfSteps
2993 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2994 NbOfSteps, Tolerance)
2995 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2998 ## Generates new elements by rotation of the elements of object around the axis
2999 # @param theObject object which elements should be sweeped.
3000 # It can be a mesh, a sub mesh or a group.
3001 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3002 # @param AngleInRadians the angle of Rotation
3003 # @param NbOfSteps number of steps
3004 # @param Tolerance tolerance
3005 # @param MakeGroups forces the generation of new groups from existing ones
3006 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3007 # of all steps, else - size of each step
3008 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3009 # @ingroup l2_modif_extrurev
3010 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3011 MakeGroups=False, TotalAngle=False):
3012 if ( isinstance( theObject, Mesh )):
3013 theObject = theObject.GetMesh()
3014 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3015 Axis = self.smeshpyD.GetAxisStruct(Axis)
3016 AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians)
3017 NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance)
3018 Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters
3019 self.mesh.SetParameters(Parameters)
3020 if TotalAngle and NbOfSteps:
3021 AngleInRadians /= NbOfSteps
3023 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
3024 NbOfSteps, Tolerance)
3025 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3028 ## Generates new elements by rotation of the elements of object around the axis
3029 # @param theObject object which elements should be sweeped.
3030 # It can be a mesh, a sub mesh or a group.
3031 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3032 # @param AngleInRadians the angle of Rotation
3033 # @param NbOfSteps number of steps
3034 # @param Tolerance tolerance
3035 # @param MakeGroups forces the generation of new groups from existing ones
3036 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3037 # of all steps, else - size of each step
3038 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3039 # @ingroup l2_modif_extrurev
3040 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3041 MakeGroups=False, TotalAngle=False):
3042 if ( isinstance( theObject, Mesh )):
3043 theObject = theObject.GetMesh()
3044 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3045 Axis = self.smeshpyD.GetAxisStruct(Axis)
3046 AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians)
3047 NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance)
3048 Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters
3049 self.mesh.SetParameters(Parameters)
3050 if TotalAngle and NbOfSteps:
3051 AngleInRadians /= NbOfSteps
3053 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
3054 NbOfSteps, Tolerance)
3055 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3058 ## Generates new elements by extrusion of the elements with given ids
3059 # @param IDsOfElements the list of elements ids for extrusion
3060 # @param StepVector vector or DirStruct, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3061 # @param NbOfSteps the number of steps
3062 # @param MakeGroups forces the generation of new groups from existing ones
3063 # @param IsNodes is True if elements with given ids are nodes
3064 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3065 # @ingroup l2_modif_extrurev
3066 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False, IsNodes = False):
3067 if IDsOfElements == []:
3068 IDsOfElements = self.GetElementsId()
3069 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3070 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3071 NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
3072 Parameters = StepVector.PS.parameters + var_separator + Parameters
3073 self.mesh.SetParameters(Parameters)
3076 return self.editor.ExtrusionSweepMakeGroups0D(IDsOfElements, StepVector, NbOfSteps)
3078 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
3080 self.editor.ExtrusionSweep0D(IDsOfElements, StepVector, NbOfSteps)
3082 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
3085 ## Generates new elements by extrusion of the elements with given ids
3086 # @param IDsOfElements is ids of elements
3087 # @param StepVector vector, defining the direction and value of extrusion
3088 # @param NbOfSteps the number of steps
3089 # @param ExtrFlags sets flags for extrusion
3090 # @param SewTolerance uses for comparing locations of nodes if flag
3091 # EXTRUSION_FLAG_SEW is set
3092 # @param MakeGroups forces the generation of new groups from existing ones
3093 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3094 # @ingroup l2_modif_extrurev
3095 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
3096 ExtrFlags, SewTolerance, MakeGroups=False):
3097 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3098 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3100 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
3101 ExtrFlags, SewTolerance)
3102 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
3103 ExtrFlags, SewTolerance)
3106 ## Generates new elements by extrusion of the elements which belong to the object
3107 # @param theObject the object which elements should be processed.
3108 # It can be a mesh, a sub mesh or a group.
3109 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3110 # @param NbOfSteps the number of steps
3111 # @param MakeGroups forces the generation of new groups from existing ones
3112 # @param IsNodes is True if elements which belong to the object are nodes
3113 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3114 # @ingroup l2_modif_extrurev
3115 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False, IsNodes=False):
3116 if ( isinstance( theObject, Mesh )):
3117 theObject = theObject.GetMesh()
3118 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3119 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3120 NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
3121 Parameters = StepVector.PS.parameters + var_separator + Parameters
3122 self.mesh.SetParameters(Parameters)
3125 return self.editor.ExtrusionSweepObject0DMakeGroups(theObject, StepVector, NbOfSteps)
3127 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3129 self.editor.ExtrusionSweepObject0D(theObject, StepVector, NbOfSteps)
3131 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
3134 ## Generates new elements by extrusion of the elements which belong to the object
3135 # @param theObject object which elements should be processed.
3136 # It can be a mesh, a sub mesh or a group.
3137 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3138 # @param NbOfSteps the number of steps
3139 # @param MakeGroups to generate new groups from existing ones
3140 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3141 # @ingroup l2_modif_extrurev
3142 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3143 if ( isinstance( theObject, Mesh )):
3144 theObject = theObject.GetMesh()
3145 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3146 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3147 NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
3148 Parameters = StepVector.PS.parameters + var_separator + Parameters
3149 self.mesh.SetParameters(Parameters)
3151 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3152 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3155 ## Generates new elements by extrusion of the elements which belong to the object
3156 # @param theObject object which elements should be processed.
3157 # It can be a mesh, a sub mesh or a group.
3158 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3159 # @param NbOfSteps the number of steps
3160 # @param MakeGroups forces the generation of new groups from existing ones
3161 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3162 # @ingroup l2_modif_extrurev
3163 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3164 if ( isinstance( theObject, Mesh )):
3165 theObject = theObject.GetMesh()
3166 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3167 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3168 NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
3169 Parameters = StepVector.PS.parameters + var_separator + Parameters
3170 self.mesh.SetParameters(Parameters)
3172 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3173 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3178 ## Generates new elements by extrusion of the given elements
3179 # The path of extrusion must be a meshed edge.
3180 # @param Base mesh or group, or submesh, or list of ids of elements for extrusion
3181 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3182 # @param NodeStart the start node from Path. Defines the direction of extrusion
3183 # @param HasAngles allows the shape to be rotated around the path
3184 # to get the resulting mesh in a helical fashion
3185 # @param Angles list of angles in radians
3186 # @param LinearVariation forces the computation of rotation angles as linear
3187 # variation of the given Angles along path steps
3188 # @param HasRefPoint allows using the reference point
3189 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3190 # The User can specify any point as the Reference Point.
3191 # @param MakeGroups forces the generation of new groups from existing ones
3192 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3193 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3194 # only SMESH::Extrusion_Error otherwise
3195 # @ingroup l2_modif_extrurev
3196 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3197 HasAngles, Angles, LinearVariation,
3198 HasRefPoint, RefPoint, MakeGroups, ElemType):
3199 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3200 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3202 Angles,AnglesParameters,hasVars = ParseAngles(Angles)
3203 Parameters = AnglesParameters + var_separator + RefPoint.parameters
3204 self.mesh.SetParameters(Parameters)
3206 if (isinstance(Path, Mesh)): Path = Path.GetMesh()
3208 if isinstance(Base, list):
3210 if Base == []: IDsOfElements = self.GetElementsId()
3211 else: IDsOfElements = Base
3212 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3213 HasAngles, Angles, LinearVariation,
3214 HasRefPoint, RefPoint, MakeGroups, ElemType)
3216 if isinstance(Base, Mesh): Base = Base.GetMesh()
3217 if isinstance(Base, SMESH._objref_SMESH_Mesh) or isinstance(Base, SMESH._objref_SMESH_Group) or isinstance(Base, SMESH._objref_SMESH_subMesh):
3218 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3219 HasAngles, Angles, LinearVariation,
3220 HasRefPoint, RefPoint, MakeGroups, ElemType)
3222 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3225 ## Generates new elements by extrusion of the given elements
3226 # The path of extrusion must be a meshed edge.
3227 # @param IDsOfElements ids of elements
3228 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3229 # @param PathShape shape(edge) defines the sub-mesh for the path
3230 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3231 # @param HasAngles allows the shape to be rotated around the path
3232 # to get the resulting mesh in a helical fashion
3233 # @param Angles list of angles in radians
3234 # @param HasRefPoint allows using the reference point
3235 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3236 # The User can specify any point as the Reference Point.
3237 # @param MakeGroups forces the generation of new groups from existing ones
3238 # @param LinearVariation forces the computation of rotation angles as linear
3239 # variation of the given Angles along path steps
3240 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3241 # only SMESH::Extrusion_Error otherwise
3242 # @ingroup l2_modif_extrurev
3243 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3244 HasAngles, Angles, HasRefPoint, RefPoint,
3245 MakeGroups=False, LinearVariation=False):
3246 if IDsOfElements == []:
3247 IDsOfElements = self.GetElementsId()
3248 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3249 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3251 if ( isinstance( PathMesh, Mesh )):
3252 PathMesh = PathMesh.GetMesh()
3253 Angles,AnglesParameters,hasVars = ParseAngles(Angles)
3254 Parameters = AnglesParameters + var_separator + RefPoint.parameters
3255 self.mesh.SetParameters(Parameters)
3256 if HasAngles and Angles and LinearVariation:
3257 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3260 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3261 PathShape, NodeStart, HasAngles,
3262 Angles, HasRefPoint, RefPoint)
3263 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3264 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3266 ## Generates new elements by extrusion of the elements which belong to the object
3267 # The path of extrusion must be a meshed edge.
3268 # @param theObject the object which elements should be processed.
3269 # It can be a mesh, a sub mesh or a group.
3270 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3271 # @param PathShape shape(edge) defines the sub-mesh for the path
3272 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3273 # @param HasAngles allows the shape to be rotated around the path
3274 # to get the resulting mesh in a helical fashion
3275 # @param Angles list of angles
3276 # @param HasRefPoint allows using the reference point
3277 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3278 # The User can specify any point as the Reference Point.
3279 # @param MakeGroups forces the generation of new groups from existing ones
3280 # @param LinearVariation forces the computation of rotation angles as linear
3281 # variation of the given Angles along path steps
3282 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3283 # only SMESH::Extrusion_Error otherwise
3284 # @ingroup l2_modif_extrurev
3285 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3286 HasAngles, Angles, HasRefPoint, RefPoint,
3287 MakeGroups=False, LinearVariation=False):
3288 if ( isinstance( theObject, Mesh )):
3289 theObject = theObject.GetMesh()
3290 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3291 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3292 if ( isinstance( PathMesh, Mesh )):
3293 PathMesh = PathMesh.GetMesh()
3294 Angles,AnglesParameters,hasVars = ParseAngles(Angles)
3295 Parameters = AnglesParameters + var_separator + RefPoint.parameters
3296 self.mesh.SetParameters(Parameters)
3297 if HasAngles and Angles and LinearVariation:
3298 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3301 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3302 PathShape, NodeStart, HasAngles,
3303 Angles, HasRefPoint, RefPoint)
3304 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3305 NodeStart, HasAngles, Angles, HasRefPoint,
3308 ## Generates new elements by extrusion of the elements which belong to the object
3309 # The path of extrusion must be a meshed edge.
3310 # @param theObject the object which elements should be processed.
3311 # It can be a mesh, a sub mesh or a group.
3312 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3313 # @param PathShape shape(edge) defines the sub-mesh for the path
3314 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3315 # @param HasAngles allows the shape to be rotated around the path
3316 # to get the resulting mesh in a helical fashion
3317 # @param Angles list of angles
3318 # @param HasRefPoint allows using the reference point
3319 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3320 # The User can specify any point as the Reference Point.
3321 # @param MakeGroups forces the generation of new groups from existing ones
3322 # @param LinearVariation forces the computation of rotation angles as linear
3323 # variation of the given Angles along path steps
3324 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3325 # only SMESH::Extrusion_Error otherwise
3326 # @ingroup l2_modif_extrurev
3327 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3328 HasAngles, Angles, HasRefPoint, RefPoint,
3329 MakeGroups=False, LinearVariation=False):
3330 if ( isinstance( theObject, Mesh )):
3331 theObject = theObject.GetMesh()
3332 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3333 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3334 if ( isinstance( PathMesh, Mesh )):
3335 PathMesh = PathMesh.GetMesh()
3336 Angles,AnglesParameters,hasVars = ParseAngles(Angles)
3337 Parameters = AnglesParameters + var_separator + RefPoint.parameters
3338 self.mesh.SetParameters(Parameters)
3339 if HasAngles and Angles and LinearVariation:
3340 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3343 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3344 PathShape, NodeStart, HasAngles,
3345 Angles, HasRefPoint, RefPoint)
3346 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3347 NodeStart, HasAngles, Angles, HasRefPoint,
3350 ## Generates new elements by extrusion of the elements which belong to the object
3351 # The path of extrusion must be a meshed edge.
3352 # @param theObject the object which elements should be processed.
3353 # It can be a mesh, a sub mesh or a group.
3354 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3355 # @param PathShape shape(edge) defines the sub-mesh for the path
3356 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3357 # @param HasAngles allows the shape to be rotated around the path
3358 # to get the resulting mesh in a helical fashion
3359 # @param Angles list of angles
3360 # @param HasRefPoint allows using the reference point
3361 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3362 # The User can specify any point as the Reference Point.
3363 # @param MakeGroups forces the generation of new groups from existing ones
3364 # @param LinearVariation forces the computation of rotation angles as linear
3365 # variation of the given Angles along path steps
3366 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3367 # only SMESH::Extrusion_Error otherwise
3368 # @ingroup l2_modif_extrurev
3369 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3370 HasAngles, Angles, HasRefPoint, RefPoint,
3371 MakeGroups=False, LinearVariation=False):
3372 if ( isinstance( theObject, Mesh )):
3373 theObject = theObject.GetMesh()
3374 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3375 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3376 if ( isinstance( PathMesh, Mesh )):
3377 PathMesh = PathMesh.GetMesh()
3378 Angles,AnglesParameters,hasVars = ParseAngles(Angles)
3379 Parameters = AnglesParameters + var_separator + RefPoint.parameters
3380 self.mesh.SetParameters(Parameters)
3381 if HasAngles and Angles and LinearVariation:
3382 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3385 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3386 PathShape, NodeStart, HasAngles,
3387 Angles, HasRefPoint, RefPoint)
3388 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3389 NodeStart, HasAngles, Angles, HasRefPoint,
3392 ## Creates a symmetrical copy of mesh elements
3393 # @param IDsOfElements list of elements ids
3394 # @param Mirror is AxisStruct or geom object(point, line, plane)
3395 # @param theMirrorType is POINT, AXIS or PLANE
3396 # If the Mirror is a geom object this parameter is unnecessary
3397 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3398 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3399 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3400 # @ingroup l2_modif_trsf
3401 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3402 if IDsOfElements == []:
3403 IDsOfElements = self.GetElementsId()
3404 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3405 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3406 self.mesh.SetParameters(Mirror.parameters)
3407 if Copy and MakeGroups:
3408 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3409 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3412 ## Creates a new mesh by a symmetrical copy of mesh elements
3413 # @param IDsOfElements the list of elements ids
3414 # @param Mirror is AxisStruct or geom object (point, line, plane)
3415 # @param theMirrorType is POINT, AXIS or PLANE
3416 # If the Mirror is a geom object this parameter is unnecessary
3417 # @param MakeGroups to generate new groups from existing ones
3418 # @param NewMeshName a name of the new mesh to create
3419 # @return instance of Mesh class
3420 # @ingroup l2_modif_trsf
3421 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3422 if IDsOfElements == []:
3423 IDsOfElements = self.GetElementsId()
3424 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3425 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3426 self.mesh.SetParameters(Mirror.parameters)
3427 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3428 MakeGroups, NewMeshName)
3429 return Mesh(self.smeshpyD,self.geompyD,mesh)
3431 ## Creates a symmetrical copy of the object
3432 # @param theObject mesh, submesh or group
3433 # @param Mirror AxisStruct or geom object (point, line, plane)
3434 # @param theMirrorType is POINT, AXIS or PLANE
3435 # If the Mirror is a geom object this parameter is unnecessary
3436 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3437 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3438 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3439 # @ingroup l2_modif_trsf
3440 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3441 if ( isinstance( theObject, Mesh )):
3442 theObject = theObject.GetMesh()
3443 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3444 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3445 self.mesh.SetParameters(Mirror.parameters)
3446 if Copy and MakeGroups:
3447 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3448 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3451 ## Creates a new mesh by a symmetrical copy of the object
3452 # @param theObject mesh, submesh or group
3453 # @param Mirror AxisStruct or geom object (point, line, plane)
3454 # @param theMirrorType POINT, AXIS or PLANE
3455 # If the Mirror is a geom object this parameter is unnecessary
3456 # @param MakeGroups forces the generation of new groups from existing ones
3457 # @param NewMeshName the name of the new mesh to create
3458 # @return instance of Mesh class
3459 # @ingroup l2_modif_trsf
3460 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3461 if ( isinstance( theObject, Mesh )):
3462 theObject = theObject.GetMesh()
3463 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3464 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3465 self.mesh.SetParameters(Mirror.parameters)
3466 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3467 MakeGroups, NewMeshName)
3468 return Mesh( self.smeshpyD,self.geompyD,mesh )
3470 ## Translates the elements
3471 # @param IDsOfElements list of elements ids
3472 # @param Vector the direction of translation (DirStruct or vector)
3473 # @param Copy allows copying the translated elements
3474 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3475 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3476 # @ingroup l2_modif_trsf
3477 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3478 if IDsOfElements == []:
3479 IDsOfElements = self.GetElementsId()
3480 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3481 Vector = self.smeshpyD.GetDirStruct(Vector)
3482 self.mesh.SetParameters(Vector.PS.parameters)
3483 if Copy and MakeGroups:
3484 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3485 self.editor.Translate(IDsOfElements, Vector, Copy)
3488 ## Creates a new mesh of translated elements
3489 # @param IDsOfElements list of elements ids
3490 # @param Vector the direction of translation (DirStruct or vector)
3491 # @param MakeGroups forces the generation of new groups from existing ones
3492 # @param NewMeshName the name of the newly created mesh
3493 # @return instance of Mesh class
3494 # @ingroup l2_modif_trsf
3495 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3496 if IDsOfElements == []:
3497 IDsOfElements = self.GetElementsId()
3498 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3499 Vector = self.smeshpyD.GetDirStruct(Vector)
3500 self.mesh.SetParameters(Vector.PS.parameters)
3501 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3502 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3504 ## Translates the object
3505 # @param theObject the object to translate (mesh, submesh, or group)
3506 # @param Vector direction of translation (DirStruct or geom vector)
3507 # @param Copy allows copying the translated elements
3508 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3509 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3510 # @ingroup l2_modif_trsf
3511 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3512 if ( isinstance( theObject, Mesh )):
3513 theObject = theObject.GetMesh()
3514 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3515 Vector = self.smeshpyD.GetDirStruct(Vector)
3516 self.mesh.SetParameters(Vector.PS.parameters)
3517 if Copy and MakeGroups:
3518 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3519 self.editor.TranslateObject(theObject, Vector, Copy)
3522 ## Creates a new mesh from the translated object
3523 # @param theObject the object to translate (mesh, submesh, or group)
3524 # @param Vector the direction of translation (DirStruct or geom vector)
3525 # @param MakeGroups forces the generation of new groups from existing ones
3526 # @param NewMeshName the name of the newly created mesh
3527 # @return instance of Mesh class
3528 # @ingroup l2_modif_trsf
3529 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3530 if (isinstance(theObject, Mesh)):
3531 theObject = theObject.GetMesh()
3532 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3533 Vector = self.smeshpyD.GetDirStruct(Vector)
3534 self.mesh.SetParameters(Vector.PS.parameters)
3535 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3536 return Mesh( self.smeshpyD, self.geompyD, mesh )
3540 ## Scales the object
3541 # @param theObject - the object to translate (mesh, submesh, or group)
3542 # @param thePoint - base point for scale
3543 # @param theScaleFact - list of 1-3 scale factors for axises
3544 # @param Copy - allows copying the translated elements
3545 # @param MakeGroups - forces the generation of new groups from existing
3547 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3548 # empty list otherwise
3549 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3550 if ( isinstance( theObject, Mesh )):
3551 theObject = theObject.GetMesh()
3552 if ( isinstance( theObject, list )):
3553 theObject = self.GetIDSource(theObject, SMESH.ALL)
3555 self.mesh.SetParameters(thePoint.parameters)
3557 if Copy and MakeGroups:
3558 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3559 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3562 ## Creates a new mesh from the translated object
3563 # @param theObject - the object to translate (mesh, submesh, or group)
3564 # @param thePoint - base point for scale
3565 # @param theScaleFact - list of 1-3 scale factors for axises
3566 # @param MakeGroups - forces the generation of new groups from existing ones
3567 # @param NewMeshName - the name of the newly created mesh
3568 # @return instance of Mesh class
3569 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3570 if (isinstance(theObject, Mesh)):
3571 theObject = theObject.GetMesh()
3572 if ( isinstance( theObject, list )):
3573 theObject = self.GetIDSource(theObject,SMESH.ALL)
3575 self.mesh.SetParameters(thePoint.parameters)
3576 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3577 MakeGroups, NewMeshName)
3578 return Mesh( self.smeshpyD, self.geompyD, mesh )
3582 ## Rotates the elements
3583 # @param IDsOfElements list of elements ids
3584 # @param Axis the axis of rotation (AxisStruct or geom line)
3585 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3586 # @param Copy allows copying the rotated elements
3587 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3588 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3589 # @ingroup l2_modif_trsf
3590 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3591 if IDsOfElements == []:
3592 IDsOfElements = self.GetElementsId()
3593 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3594 Axis = self.smeshpyD.GetAxisStruct(Axis)
3595 AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians)
3596 Parameters = Axis.parameters + var_separator + Parameters
3597 self.mesh.SetParameters(Parameters)
3598 if Copy and MakeGroups:
3599 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3600 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3603 ## Creates a new mesh of rotated elements
3604 # @param IDsOfElements list of element ids
3605 # @param Axis the axis of rotation (AxisStruct or geom line)
3606 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3607 # @param MakeGroups forces the generation of new groups from existing ones
3608 # @param NewMeshName the name of the newly created mesh
3609 # @return instance of Mesh class
3610 # @ingroup l2_modif_trsf
3611 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3612 if IDsOfElements == []:
3613 IDsOfElements = self.GetElementsId()
3614 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3615 Axis = self.smeshpyD.GetAxisStruct(Axis)
3616 AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians)
3617 Parameters = Axis.parameters + var_separator + Parameters
3618 self.mesh.SetParameters(Parameters)
3619 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3620 MakeGroups, NewMeshName)
3621 return Mesh( self.smeshpyD, self.geompyD, mesh )
3623 ## Rotates the object
3624 # @param theObject the object to rotate( mesh, submesh, or group)
3625 # @param Axis the axis of rotation (AxisStruct or geom line)
3626 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3627 # @param Copy allows copying the rotated elements
3628 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3629 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3630 # @ingroup l2_modif_trsf
3631 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3632 if (isinstance(theObject, Mesh)):
3633 theObject = theObject.GetMesh()
3634 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3635 Axis = self.smeshpyD.GetAxisStruct(Axis)
3636 AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians)
3637 Parameters = Axis.parameters + ":" + Parameters
3638 self.mesh.SetParameters(Parameters)
3639 if Copy and MakeGroups:
3640 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3641 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3644 ## Creates a new mesh from the rotated object
3645 # @param theObject the object to rotate (mesh, submesh, or group)
3646 # @param Axis the axis of rotation (AxisStruct or geom line)
3647 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3648 # @param MakeGroups forces the generation of new groups from existing ones
3649 # @param NewMeshName the name of the newly created mesh
3650 # @return instance of Mesh class
3651 # @ingroup l2_modif_trsf
3652 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3653 if (isinstance( theObject, Mesh )):
3654 theObject = theObject.GetMesh()
3655 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3656 Axis = self.smeshpyD.GetAxisStruct(Axis)
3657 AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians)
3658 Parameters = Axis.parameters + ":" + Parameters
3659 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3660 MakeGroups, NewMeshName)
3661 self.mesh.SetParameters(Parameters)
3662 return Mesh( self.smeshpyD, self.geompyD, mesh )
3664 ## Finds groups of ajacent nodes within Tolerance.
3665 # @param Tolerance the value of tolerance
3666 # @return the list of groups of nodes
3667 # @ingroup l2_modif_trsf
3668 def FindCoincidentNodes (self, Tolerance):
3669 return self.editor.FindCoincidentNodes(Tolerance)
3671 ## Finds groups of ajacent nodes within Tolerance.
3672 # @param Tolerance the value of tolerance
3673 # @param SubMeshOrGroup SubMesh or Group
3674 # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
3675 # @return the list of groups of nodes
3676 # @ingroup l2_modif_trsf
3677 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
3678 if (isinstance( SubMeshOrGroup, Mesh )):
3679 SubMeshOrGroup = SubMeshOrGroup.GetMesh()
3680 if not isinstance( exceptNodes, list):
3681 exceptNodes = [ exceptNodes ]
3682 if exceptNodes and isinstance( exceptNodes[0], int):
3683 exceptNodes = [ self.GetIDSource( exceptNodes, SMESH.NODE)]
3684 return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes)
3687 # @param GroupsOfNodes the list of groups of nodes
3688 # @ingroup l2_modif_trsf
3689 def MergeNodes (self, GroupsOfNodes):
3690 self.editor.MergeNodes(GroupsOfNodes)
3692 ## Finds the elements built on the same nodes.
3693 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3694 # @return a list of groups of equal elements
3695 # @ingroup l2_modif_trsf
3696 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3697 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3698 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3699 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3701 ## Merges elements in each given group.
3702 # @param GroupsOfElementsID groups of elements for merging
3703 # @ingroup l2_modif_trsf
3704 def MergeElements(self, GroupsOfElementsID):
3705 self.editor.MergeElements(GroupsOfElementsID)
3707 ## Leaves one element and removes all other elements built on the same nodes.
3708 # @ingroup l2_modif_trsf
3709 def MergeEqualElements(self):
3710 self.editor.MergeEqualElements()
3712 ## Sews free borders
3713 # @return SMESH::Sew_Error
3714 # @ingroup l2_modif_trsf
3715 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3716 FirstNodeID2, SecondNodeID2, LastNodeID2,
3717 CreatePolygons, CreatePolyedrs):
3718 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3719 FirstNodeID2, SecondNodeID2, LastNodeID2,
3720 CreatePolygons, CreatePolyedrs)
3722 ## Sews conform free borders
3723 # @return SMESH::Sew_Error
3724 # @ingroup l2_modif_trsf
3725 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3726 FirstNodeID2, SecondNodeID2):
3727 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3728 FirstNodeID2, SecondNodeID2)
3730 ## Sews border to side
3731 # @return SMESH::Sew_Error
3732 # @ingroup l2_modif_trsf
3733 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3734 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3735 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3736 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3738 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3739 # merged with the nodes of elements of Side2.
3740 # The number of elements in theSide1 and in theSide2 must be
3741 # equal and they should have similar nodal connectivity.
3742 # The nodes to merge should belong to side borders and
3743 # the first node should be linked to the second.
3744 # @return SMESH::Sew_Error
3745 # @ingroup l2_modif_trsf
3746 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3747 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3748 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3749 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3750 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3751 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3753 ## Sets new nodes for the given element.
3754 # @param ide the element id
3755 # @param newIDs nodes ids
3756 # @return If the number of nodes does not correspond to the type of element - returns false
3757 # @ingroup l2_modif_edit
3758 def ChangeElemNodes(self, ide, newIDs):
3759 return self.editor.ChangeElemNodes(ide, newIDs)
3761 ## If during the last operation of MeshEditor some nodes were
3762 # created, this method returns the list of their IDs, \n
3763 # if new nodes were not created - returns empty list
3764 # @return the list of integer values (can be empty)
3765 # @ingroup l1_auxiliary
3766 def GetLastCreatedNodes(self):
3767 return self.editor.GetLastCreatedNodes()
3769 ## If during the last operation of MeshEditor some elements were
3770 # created this method returns the list of their IDs, \n
3771 # if new elements were not created - returns empty list
3772 # @return the list of integer values (can be empty)
3773 # @ingroup l1_auxiliary
3774 def GetLastCreatedElems(self):
3775 return self.editor.GetLastCreatedElems()
3777 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3778 # @param theNodes identifiers of nodes to be doubled
3779 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
3780 # nodes. If list of element identifiers is empty then nodes are doubled but
3781 # they not assigned to elements
3782 # @return TRUE if operation has been completed successfully, FALSE otherwise
3783 # @ingroup l2_modif_edit
3784 def DoubleNodes(self, theNodes, theModifiedElems):
3785 return self.editor.DoubleNodes(theNodes, theModifiedElems)
3787 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3788 # This method provided for convenience works as DoubleNodes() described above.
3789 # @param theNodeId identifiers of node to be doubled
3790 # @param theModifiedElems identifiers of elements to be updated
3791 # @return TRUE if operation has been completed successfully, FALSE otherwise
3792 # @ingroup l2_modif_edit
3793 def DoubleNode(self, theNodeId, theModifiedElems):
3794 return self.editor.DoubleNode(theNodeId, theModifiedElems)
3796 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3797 # This method provided for convenience works as DoubleNodes() described above.
3798 # @param theNodes group of nodes to be doubled
3799 # @param theModifiedElems group of elements to be updated.
3800 # @param theMakeGroup forces the generation of a group containing new nodes.
3801 # @return TRUE or a created group if operation has been completed successfully,
3802 # FALSE or None otherwise
3803 # @ingroup l2_modif_edit
3804 def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
3806 return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
3807 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3809 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3810 # This method provided for convenience works as DoubleNodes() described above.
3811 # @param theNodes list of groups of nodes to be doubled
3812 # @param theModifiedElems list of groups of elements to be updated.
3813 # @param theMakeGroup forces the generation of a group containing new nodes.
3814 # @return TRUE if operation has been completed successfully, FALSE otherwise
3815 # @ingroup l2_modif_edit
3816 def DoubleNodeGroups(self, theNodes, theModifiedElems, theMakeGroup=False):
3818 return self.editor.DoubleNodeGroupsNew(theNodes, theModifiedElems)
3819 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3821 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3822 # @param theElems - the list of elements (edges or faces) to be replicated
3823 # The nodes for duplication could be found from these elements
3824 # @param theNodesNot - list of nodes to NOT replicate
3825 # @param theAffectedElems - the list of elements (cells and edges) to which the
3826 # replicated nodes should be associated to.
3827 # @return TRUE if operation has been completed successfully, FALSE otherwise
3828 # @ingroup l2_modif_edit
3829 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
3830 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
3832 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3833 # @param theElems - the list of elements (edges or faces) to be replicated
3834 # The nodes for duplication could be found from these elements
3835 # @param theNodesNot - list of nodes to NOT replicate
3836 # @param theShape - shape to detect affected elements (element which geometric center
3837 # located on or inside shape).
3838 # The replicated nodes should be associated to affected elements.
3839 # @return TRUE if operation has been completed successfully, FALSE otherwise
3840 # @ingroup l2_modif_edit
3841 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
3842 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
3844 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3845 # This method provided for convenience works as DoubleNodes() described above.
3846 # @param theElems - group of of elements (edges or faces) to be replicated
3847 # @param theNodesNot - group of nodes not to replicated
3848 # @param theAffectedElems - group of elements to which the replicated nodes
3849 # should be associated to.
3850 # @param theMakeGroup forces the generation of a group containing new elements.
3851 # @return TRUE or a created group if operation has been completed successfully,
3852 # FALSE or None otherwise
3853 # @ingroup l2_modif_edit
3854 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
3856 return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
3857 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
3859 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3860 # This method provided for convenience works as DoubleNodes() described above.
3861 # @param theElems - group of of elements (edges or faces) to be replicated
3862 # @param theNodesNot - group of nodes not to replicated
3863 # @param theShape - shape to detect affected elements (element which geometric center
3864 # located on or inside shape).
3865 # The replicated nodes should be associated to affected elements.
3866 # @ingroup l2_modif_edit
3867 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
3868 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
3870 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3871 # This method provided for convenience works as DoubleNodes() described above.
3872 # @param theElems - list of groups of elements (edges or faces) to be replicated
3873 # @param theNodesNot - list of groups of nodes not to replicated
3874 # @param theAffectedElems - group of elements to which the replicated nodes
3875 # should be associated to.
3876 # @param theMakeGroup forces the generation of a group containing new elements.
3877 # @return TRUE or a created group if operation has been completed successfully,
3878 # FALSE or None otherwise
3879 # @ingroup l2_modif_edit
3880 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
3882 return self.editor.DoubleNodeElemGroupsNew(theElems, theNodesNot, theAffectedElems)
3883 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
3885 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3886 # This method provided for convenience works as DoubleNodes() described above.
3887 # @param theElems - list of groups of elements (edges or faces) to be replicated
3888 # @param theNodesNot - list of groups of nodes not to replicated
3889 # @param theShape - shape to detect affected elements (element which geometric center
3890 # located on or inside shape).
3891 # The replicated nodes should be associated to affected elements.
3892 # @return TRUE if operation has been completed successfully, FALSE otherwise
3893 # @ingroup l2_modif_edit
3894 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
3895 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
3897 ## Double nodes on shared faces between groups of volumes and create flat elements on demand.
3898 # The list of groups must describe a partition of the mesh volumes.
3899 # The nodes of the internal faces at the boundaries of the groups are doubled.
3900 # In option, the internal faces are replaced by flat elements.
3901 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
3902 # @param theDomains - list of groups of volumes
3903 # @param createJointElems - if TRUE, create the elements
3904 # @return TRUE if operation has been completed successfully, FALSE otherwise
3905 def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems ):
3906 return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems )
3908 ## Double nodes on some external faces and create flat elements.
3909 # Flat elements are mainly used by some types of mechanic calculations.
3911 # Each group of the list must be constituted of faces.
3912 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
3913 # @param theGroupsOfFaces - list of groups of faces
3914 # @return TRUE if operation has been completed successfully, FALSE otherwise
3915 def CreateFlatElementsOnFacesGroups(self, theGroupsOfFaces ):
3916 return self.editor.CreateFlatElementsOnFacesGroups( theGroupsOfFaces )
3918 def _valueFromFunctor(self, funcType, elemId):
3919 fn = self.smeshpyD.GetFunctor(funcType)
3920 fn.SetMesh(self.mesh)
3921 if fn.GetElementType() == self.GetElementType(elemId, True):
3922 val = fn.GetValue(elemId)
3927 ## Get length of 1D element.
3928 # @param elemId mesh element ID
3929 # @return element's length value
3930 # @ingroup l1_measurements
3931 def GetLength(self, elemId):
3932 return self._valueFromFunctor(SMESH.FT_Length, elemId)
3934 ## Get area of 2D element.
3935 # @param elemId mesh element ID
3936 # @return element's area value
3937 # @ingroup l1_measurements
3938 def GetArea(self, elemId):
3939 return self._valueFromFunctor(SMESH.FT_Area, elemId)
3941 ## Get volume of 3D element.
3942 # @param elemId mesh element ID
3943 # @return element's volume value
3944 # @ingroup l1_measurements
3945 def GetVolume(self, elemId):
3946 return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
3948 ## Get maximum element length.
3949 # @param elemId mesh element ID
3950 # @return element's maximum length value
3951 # @ingroup l1_measurements
3952 def GetMaxElementLength(self, elemId):
3953 if self.GetElementType(elemId, True) == SMESH.VOLUME:
3954 ftype = SMESH.FT_MaxElementLength3D
3956 ftype = SMESH.FT_MaxElementLength2D
3957 return self._valueFromFunctor(ftype, elemId)
3959 ## Get aspect ratio of 2D or 3D element.
3960 # @param elemId mesh element ID
3961 # @return element's aspect ratio value
3962 # @ingroup l1_measurements
3963 def GetAspectRatio(self, elemId):
3964 if self.GetElementType(elemId, True) == SMESH.VOLUME:
3965 ftype = SMESH.FT_AspectRatio3D
3967 ftype = SMESH.FT_AspectRatio
3968 return self._valueFromFunctor(ftype, elemId)
3970 ## Get warping angle of 2D element.
3971 # @param elemId mesh element ID
3972 # @return element's warping angle value
3973 # @ingroup l1_measurements
3974 def GetWarping(self, elemId):
3975 return self._valueFromFunctor(SMESH.FT_Warping, elemId)
3977 ## Get minimum angle of 2D element.
3978 # @param elemId mesh element ID
3979 # @return element's minimum angle value
3980 # @ingroup l1_measurements
3981 def GetMinimumAngle(self, elemId):
3982 return self._valueFromFunctor(SMESH.FT_MinimumAngle, elemId)
3984 ## Get taper of 2D element.
3985 # @param elemId mesh element ID
3986 # @return element's taper value
3987 # @ingroup l1_measurements
3988 def GetTaper(self, elemId):
3989 return self._valueFromFunctor(SMESH.FT_Taper, elemId)
3991 ## Get skew of 2D element.
3992 # @param elemId mesh element ID
3993 # @return element's skew value
3994 # @ingroup l1_measurements
3995 def GetSkew(self, elemId):
3996 return self._valueFromFunctor(SMESH.FT_Skew, elemId)
3998 ## The mother class to define algorithm, it is not recommended to use it directly.
4000 # For each meshing algorithm, a python class inheriting from class Mesh_Algorithm
4001 # should be defined. This descendant class sould have two attributes defining the way
4002 # it is created by class Mesh (see e.g. class StdMeshersDC_Segment in StdMeshersDC.py).
4003 # - meshMethod attribute defines name of method of class Mesh by calling which the
4004 # python class of algorithm is created. E.g. if in class MyPlugin_Algorithm
4005 # meshMethod = "MyAlgorithm", then an instance of MyPlugin_Algorithm is created
4006 # by the following code: my_algo = mesh.MyAlgorithm()
4007 # - algoType defines name of algorithm type and is used mostly to discriminate
4008 # algorithms that are created by the same method of class Mesh. E.g. if
4009 # MyPlugin_Algorithm.algoType = "MyPLUGIN" then it's creation code can be:
4010 # my_algo = mesh.MyAlgorithm(algo="MyPLUGIN")
4011 # @ingroup l2_algorithms
4012 class Mesh_Algorithm:
4013 # @class Mesh_Algorithm
4014 # @brief Class Mesh_Algorithm
4016 #def __init__(self,smesh):
4024 ## Finds a hypothesis in the study by its type name and parameters.
4025 # Finds only the hypotheses created in smeshpyD engine.
4026 # @return SMESH.SMESH_Hypothesis
4027 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
4028 study = smeshpyD.GetCurrentStudy()
4029 #to do: find component by smeshpyD object, not by its data type
4030 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4031 if scomp is not None:
4032 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
4033 # Check if the root label of the hypotheses exists
4034 if res and hypRoot is not None:
4035 iter = study.NewChildIterator(hypRoot)
4036 # Check all published hypotheses
4038 hypo_so_i = iter.Value()
4039 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
4040 if attr is not None:
4041 anIOR = attr.Value()
4042 hypo_o_i = salome.orb.string_to_object(anIOR)
4043 if hypo_o_i is not None:
4044 # Check if this is a hypothesis
4045 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
4046 if hypo_i is not None:
4047 # Check if the hypothesis belongs to current engine
4048 if smeshpyD.GetObjectId(hypo_i) > 0:
4049 # Check if this is the required hypothesis
4050 if hypo_i.GetName() == hypname:
4052 if CompareMethod(hypo_i, args):
4066 ## Finds the algorithm in the study by its type name.
4067 # Finds only the algorithms, which have been created in smeshpyD engine.
4068 # @return SMESH.SMESH_Algo
4069 def FindAlgorithm (self, algoname, smeshpyD):
4070 study = smeshpyD.GetCurrentStudy()
4071 #to do: find component by smeshpyD object, not by its data type
4072 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4073 if scomp is not None:
4074 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
4075 # Check if the root label of the algorithms exists
4076 if res and hypRoot is not None:
4077 iter = study.NewChildIterator(hypRoot)
4078 # Check all published algorithms
4080 algo_so_i = iter.Value()
4081 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
4082 if attr is not None:
4083 anIOR = attr.Value()
4084 algo_o_i = salome.orb.string_to_object(anIOR)
4085 if algo_o_i is not None:
4086 # Check if this is an algorithm
4087 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
4088 if algo_i is not None:
4089 # Checks if the algorithm belongs to the current engine
4090 if smeshpyD.GetObjectId(algo_i) > 0:
4091 # Check if this is the required algorithm
4092 if algo_i.GetName() == algoname:
4105 ## If the algorithm is global, returns 0; \n
4106 # else returns the submesh associated to this algorithm.
4107 def GetSubMesh(self):
4110 ## Returns the wrapped mesher.
4111 def GetAlgorithm(self):
4114 ## Gets the list of hypothesis that can be used with this algorithm
4115 def GetCompatibleHypothesis(self):
4118 mylist = self.algo.GetCompatibleHypothesis()
4121 ## Gets the name of the algorithm
4125 ## Sets the name to the algorithm
4126 def SetName(self, name):
4127 self.mesh.smeshpyD.SetName(self.algo, name)
4129 ## Gets the id of the algorithm
4131 return self.algo.GetId()
4134 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
4136 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
4137 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
4139 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
4141 self.Assign(algo, mesh, geom)
4145 def Assign(self, algo, mesh, geom):
4147 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
4151 self.geom = mesh.geom
4154 AssureGeomPublished( mesh, geom )
4156 name = GetName(geom)
4160 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
4162 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
4163 TreatHypoStatus( status, algo.GetName(), name, True )
4166 def CompareHyp (self, hyp, args):
4167 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
4170 def CompareEqualHyp (self, hyp, args):
4174 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
4175 UseExisting=0, CompareMethod=""):
4178 if CompareMethod == "": CompareMethod = self.CompareHyp
4179 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
4182 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
4187 if isinstance( arg, geompyDC.GEOM._objref_GEOM_Object ):
4188 argStr = arg.GetStudyEntry()
4189 if not argStr: argStr = "GEOM_Obj_%s", arg.GetEntry()
4190 if len( argStr ) > 10:
4191 argStr = argStr[:7]+"..."
4192 if argStr[0] == '[': argStr += ']'
4198 self.mesh.smeshpyD.SetName(hypo, hyp + a)
4202 geomName = GetName(self.geom)
4203 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
4204 TreatHypoStatus( status, GetName(hypo), geomName, 0 )
4207 ## Returns entry of the shape to mesh in the study
4208 def MainShapeEntry(self):
4210 if not self.mesh or not self.mesh.GetMesh(): return entry
4211 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
4212 study = self.mesh.smeshpyD.GetCurrentStudy()
4213 ior = salome.orb.object_to_string( self.mesh.GetShape() )
4214 sobj = study.FindObjectIOR(ior)
4215 if sobj: entry = sobj.GetID()
4216 if not entry: return ""
4219 ## Defines "ViscousLayers" hypothesis to give parameters of layers of prisms to build
4220 # near mesh boundary. This hypothesis can be used by several 3D algorithms:
4221 # NETGEN 3D, GHS3D, Hexahedron(i,j,k)
4222 # @param thickness total thickness of layers of prisms
4223 # @param numberOfLayers number of layers of prisms
4224 # @param stretchFactor factor (>1.0) of growth of layer thickness towards inside of mesh
4225 # @param ignoreFaces list of geometrical faces (or their ids) not to generate layers on
4226 # @ingroup l3_hypos_additi
4227 def ViscousLayers(self, thickness, numberOfLayers, stretchFactor, ignoreFaces=[]):
4228 if not isinstance(self.algo, SMESH._objref_SMESH_3D_Algo):
4229 raise TypeError, "ViscousLayers are supported by 3D algorithms only"
4230 if not "ViscousLayers" in self.GetCompatibleHypothesis():
4231 raise TypeError, "ViscousLayers are not supported by %s"%self.algo.GetName()
4232 if ignoreFaces and isinstance( ignoreFaces[0], geompyDC.GEOM._objref_GEOM_Object ):
4233 ignoreFaces = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, f) for f in ignoreFaces ]
4234 hyp = self.Hypothesis("ViscousLayers",
4235 [thickness, numberOfLayers, stretchFactor, ignoreFaces])
4236 hyp.SetTotalThickness(thickness)
4237 hyp.SetNumberLayers(numberOfLayers)
4238 hyp.SetStretchFactor(stretchFactor)
4239 hyp.SetIgnoreFaces(ignoreFaces)
4242 ## Transform a list of ether edges or tuples (edge 1st_vertex_of_edge)
4243 # into a list acceptable to SetReversedEdges() of some 1D hypotheses
4244 # @ingroup l3_hypos_1dhyps
4245 def ReversedEdgeIndices(self, reverseList):
4247 geompy = self.mesh.geompyD
4248 for i in reverseList:
4249 if isinstance( i, int ):
4250 s = geompy.SubShapes(self.mesh.geom, [i])[0]
4251 if s.GetShapeType() != geompyDC.GEOM.EDGE:
4252 raise TypeError, "Not EDGE index given"
4254 elif isinstance( i, geompyDC.GEOM._objref_GEOM_Object ):
4255 if i.GetShapeType() != geompyDC.GEOM.EDGE:
4256 raise TypeError, "Not an EDGE given"
4257 resList.append( geompy.GetSubShapeID(self.mesh.geom, i ))
4261 if not isinstance( e, geompyDC.GEOM._objref_GEOM_Object ) or \
4262 not isinstance( v, geompyDC.GEOM._objref_GEOM_Object ):
4263 raise TypeError, "A list item must be a tuple (edge 1st_vertex_of_edge)"
4264 if v.GetShapeType() == geompyDC.GEOM.EDGE and \
4265 e.GetShapeType() == geompyDC.GEOM.VERTEX:
4267 if e.GetShapeType() != geompyDC.GEOM.EDGE or \
4268 v.GetShapeType() != geompyDC.GEOM.VERTEX:
4269 raise TypeError, "A list item must be a tuple (edge 1st_vertex_of_edge)"
4270 vFirst = FirstVertexOnCurve( e )
4271 tol = geompy.Tolerance( vFirst )[-1]
4272 if geompy.MinDistance( v, vFirst ) > 1.5*tol:
4273 resList.append( geompy.GetSubShapeID(self.mesh.geom, e ))
4275 raise TypeError, "Item must be either an edge or tuple (edge 1st_vertex_of_edge)"
4279 class Pattern(SMESH._objref_SMESH_Pattern):
4281 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
4282 decrFun = lambda i: i-1
4283 theNodeIndexOnKeyPoint1,Parameters,hasVars = ParseParameters(theNodeIndexOnKeyPoint1, decrFun)
4284 theMesh.SetParameters(Parameters)
4285 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
4287 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
4288 decrFun = lambda i: i-1
4289 theNode000Index,theNode001Index,Parameters,hasVars = ParseParameters(theNode000Index,theNode001Index, decrFun)
4290 theMesh.SetParameters(Parameters)
4291 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
4293 #Registering the new proxy for Pattern
4294 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)
4300 ## Private class used to bind methods creating algorithms to the class Mesh
4305 self.defaultAlgoType = ""
4306 self.algoTypeToClass = {}
4308 # Stores a python class of algorithm
4309 def add(self, algoClass):
4310 if type( algoClass ).__name__ == 'classobj' and \
4311 hasattr( algoClass, "algoType"):
4312 self.algoTypeToClass[ algoClass.algoType ] = algoClass
4313 if not self.defaultAlgoType and \
4314 hasattr( algoClass, "isDefault") and algoClass.isDefault:
4315 self.defaultAlgoType = algoClass.algoType
4316 #print "Add",algoClass.algoType, "dflt",self.defaultAlgoType
4318 # creates a copy of self and assign mesh to the copy
4319 def copy(self, mesh):
4320 other = algoCreator()
4321 other.defaultAlgoType = self.defaultAlgoType
4322 other.algoTypeToClass = self.algoTypeToClass
4326 # creates an instance of algorithm
4327 def __call__(self,algo="",geom=0,*args):
4328 algoType = self.defaultAlgoType
4329 for arg in args + (algo,):
4330 if isinstance( arg, geompyDC.GEOM._objref_GEOM_Object ):
4332 if isinstance( arg, str ) and arg:
4334 if not algoType and self.algoTypeToClass:
4335 algoType = self.algoTypeToClass.keys()[0]
4336 if self.algoTypeToClass.has_key( algoType ):
4337 #print "Create algo",algoType
4338 return self.algoTypeToClass[ algoType ]( self.mesh, geom )
4339 raise RuntimeError, "No class found for algo type" % algoType
4342 # Private class used to substitute and store variable parameters of hypotheses.
4343 class hypMethodWrapper:
4344 def __init__(self, hyp, method):
4346 self.method = method
4347 #print "REBIND:", method.__name__
4350 # call a method of hypothesis with calling SetVarParameter() before
4351 def __call__(self,*args):
4353 return self.method( self.hyp, *args ) # hypothesis method with no args
4355 #print "MethWrapper.__call__",self.method.__name__, args
4357 parsed = ParseParameters(*args) # replace variables with their values
4358 self.hyp.SetVarParameter( parsed[-2], self.method.__name__ )
4359 result = self.method( self.hyp, *parsed[:-2] ) # call hypothesis method
4360 except omniORB.CORBA.BAD_PARAM: # raised by hypothesis method call
4361 # maybe there is a replaced string arg which is not variable
4362 result = self.method( self.hyp, *args )
4363 except ValueError, detail: # raised by ParseParameters()
4365 result = self.method( self.hyp, *args )
4366 except omniORB.CORBA.BAD_PARAM:
4367 raise ValueError, detail # wrong variable name