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