1 # Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 # Author : Francis KLOSS, OCC
28 ## @defgroup l1_auxiliary Auxiliary methods and structures
29 ## @defgroup l1_creating Creating meshes
31 ## @defgroup l2_impexp Importing and exporting meshes
32 ## @defgroup l2_construct Constructing meshes
33 ## @defgroup l2_algorithms Defining Algorithms
35 ## @defgroup l3_algos_basic Basic meshing algorithms
36 ## @defgroup l3_algos_proj Projection Algorithms
37 ## @defgroup l3_algos_radialp Radial Prism
38 ## @defgroup l3_algos_segmarv Segments around Vertex
39 ## @defgroup l3_algos_3dextr 3D extrusion meshing algorithm
42 ## @defgroup l2_hypotheses Defining hypotheses
44 ## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
45 ## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
46 ## @defgroup l3_hypos_maxvol Max Element Volume hypothesis
47 ## @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
48 ## @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
49 ## @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
50 ## @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
51 ## @defgroup l3_hypos_quad Quadrangle Parameters hypothesis
52 ## @defgroup l3_hypos_additi Additional Hypotheses
55 ## @defgroup l2_submeshes Constructing submeshes
56 ## @defgroup l2_compounds Building Compounds
57 ## @defgroup l2_editing Editing Meshes
60 ## @defgroup l1_meshinfo Mesh Information
61 ## @defgroup l1_controls Quality controls and Filtering
62 ## @defgroup l1_grouping Grouping elements
64 ## @defgroup l2_grps_create Creating groups
65 ## @defgroup l2_grps_edit Editing groups
66 ## @defgroup l2_grps_operon Using operations on groups
67 ## @defgroup l2_grps_delete Deleting Groups
70 ## @defgroup l1_modifying Modifying meshes
72 ## @defgroup l2_modif_add Adding nodes and elements
73 ## @defgroup l2_modif_del Removing nodes and elements
74 ## @defgroup l2_modif_edit Modifying nodes and elements
75 ## @defgroup l2_modif_renumber Renumbering nodes and elements
76 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
77 ## @defgroup l2_modif_movenode Moving nodes
78 ## @defgroup l2_modif_throughp Mesh through point
79 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
80 ## @defgroup l2_modif_unitetri Uniting triangles
81 ## @defgroup l2_modif_changori Changing orientation of elements
82 ## @defgroup l2_modif_cutquadr Cutting quadrangles
83 ## @defgroup l2_modif_smooth Smoothing
84 ## @defgroup l2_modif_extrurev Extrusion and Revolution
85 ## @defgroup l2_modif_patterns Pattern mapping
86 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
89 ## @defgroup l1_measurements Measurements
94 import SMESH # This is necessary for back compatibility
102 # import NETGENPlugin module if possible
110 # import GHS3DPlugin module if possible
118 # import GHS3DPRLPlugin module if possible
121 import GHS3DPRLPlugin
126 # import HexoticPlugin module if possible
134 # import BLSURFPlugin module if possible
142 ## @addtogroup l1_auxiliary
145 # Types of algorithms
158 NETGEN_1D2D3D = FULL_NETGEN
159 NETGEN_FULL = FULL_NETGEN
167 # MirrorType enumeration
168 POINT = SMESH_MeshEditor.POINT
169 AXIS = SMESH_MeshEditor.AXIS
170 PLANE = SMESH_MeshEditor.PLANE
172 # Smooth_Method enumeration
173 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
174 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
176 # Fineness enumeration (for NETGEN)
184 # Optimization level of GHS3D
186 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
187 # V4.1 (partialy redefines V3.1). Issue 0020574
188 None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization, Strong_Optimization = 0,1,2,3,4
190 # Topology treatment way of BLSURF
191 FromCAD, PreProcess, PreProcessPlus, PreCAD = 0,1,2,3
193 # Element size flag of BLSURF
194 DefaultSize, DefaultGeom, BLSURF_Custom, SizeMap = 0,0,1,2
196 PrecisionConfusion = 1e-07
198 # TopAbs_State enumeration
199 [TopAbs_IN, TopAbs_OUT, TopAbs_ON, TopAbs_UNKNOWN] = range(4)
201 # Methods of splitting a hexahedron into tetrahedra
202 Hex_5Tet, Hex_6Tet, Hex_24Tet = 1, 2, 3
204 # import items of enum QuadType
205 for e in StdMeshers.QuadType._items: exec('%s = StdMeshers.%s'%(e,e))
207 ## Converts an angle from degrees to radians
208 def DegreesToRadians(AngleInDegrees):
210 return AngleInDegrees * pi / 180.0
212 # Salome notebook variable separator
215 # Parametrized substitute for PointStruct
216 class PointStructStr:
225 def __init__(self, xStr, yStr, zStr):
229 if isinstance(xStr, str) and notebook.isVariable(xStr):
230 self.x = notebook.get(xStr)
233 if isinstance(yStr, str) and notebook.isVariable(yStr):
234 self.y = notebook.get(yStr)
237 if isinstance(zStr, str) and notebook.isVariable(zStr):
238 self.z = notebook.get(zStr)
242 # Parametrized substitute for PointStruct (with 6 parameters)
243 class PointStructStr6:
258 def __init__(self, x1Str, x2Str, y1Str, y2Str, z1Str, z2Str):
265 if isinstance(x1Str, str) and notebook.isVariable(x1Str):
266 self.x1 = notebook.get(x1Str)
269 if isinstance(x2Str, str) and notebook.isVariable(x2Str):
270 self.x2 = notebook.get(x2Str)
273 if isinstance(y1Str, str) and notebook.isVariable(y1Str):
274 self.y1 = notebook.get(y1Str)
277 if isinstance(y2Str, str) and notebook.isVariable(y2Str):
278 self.y2 = notebook.get(y2Str)
281 if isinstance(z1Str, str) and notebook.isVariable(z1Str):
282 self.z1 = notebook.get(z1Str)
285 if isinstance(z2Str, str) and notebook.isVariable(z2Str):
286 self.z2 = notebook.get(z2Str)
290 # Parametrized substitute for AxisStruct
306 def __init__(self, xStr, yStr, zStr, dxStr, dyStr, dzStr):
313 if isinstance(xStr, str) and notebook.isVariable(xStr):
314 self.x = notebook.get(xStr)
317 if isinstance(yStr, str) and notebook.isVariable(yStr):
318 self.y = notebook.get(yStr)
321 if isinstance(zStr, str) and notebook.isVariable(zStr):
322 self.z = notebook.get(zStr)
325 if isinstance(dxStr, str) and notebook.isVariable(dxStr):
326 self.dx = notebook.get(dxStr)
329 if isinstance(dyStr, str) and notebook.isVariable(dyStr):
330 self.dy = notebook.get(dyStr)
333 if isinstance(dzStr, str) and notebook.isVariable(dzStr):
334 self.dz = notebook.get(dzStr)
338 # Parametrized substitute for DirStruct
341 def __init__(self, pointStruct):
342 self.pointStruct = pointStruct
344 # Returns list of variable values from salome notebook
345 def ParsePointStruct(Point):
346 Parameters = 2*var_separator
347 if isinstance(Point, PointStructStr):
348 Parameters = str(Point.xStr) + var_separator + str(Point.yStr) + var_separator + str(Point.zStr)
349 Point = PointStruct(Point.x, Point.y, Point.z)
350 return Point, Parameters
352 # Returns list of variable values from salome notebook
353 def ParseDirStruct(Dir):
354 Parameters = 2*var_separator
355 if isinstance(Dir, DirStructStr):
356 pntStr = Dir.pointStruct
357 if isinstance(pntStr, PointStructStr6):
358 Parameters = str(pntStr.x1Str) + var_separator + str(pntStr.x2Str) + var_separator
359 Parameters += str(pntStr.y1Str) + var_separator + str(pntStr.y2Str) + var_separator
360 Parameters += str(pntStr.z1Str) + var_separator + str(pntStr.z2Str)
361 Point = PointStruct(pntStr.x2 - pntStr.x1, pntStr.y2 - pntStr.y1, pntStr.z2 - pntStr.z1)
363 Parameters = str(pntStr.xStr) + var_separator + str(pntStr.yStr) + var_separator + str(pntStr.zStr)
364 Point = PointStruct(pntStr.x, pntStr.y, pntStr.z)
365 Dir = DirStruct(Point)
366 return Dir, Parameters
368 # Returns list of variable values from salome notebook
369 def ParseAxisStruct(Axis):
370 Parameters = 5*var_separator
371 if isinstance(Axis, AxisStructStr):
372 Parameters = str(Axis.xStr) + var_separator + str(Axis.yStr) + var_separator + str(Axis.zStr) + var_separator
373 Parameters += str(Axis.dxStr) + var_separator + str(Axis.dyStr) + var_separator + str(Axis.dzStr)
374 Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz)
375 return Axis, Parameters
377 ## Return list of variable values from salome notebook
378 def ParseAngles(list):
381 for parameter in list:
382 if isinstance(parameter,str) and notebook.isVariable(parameter):
383 Result.append(DegreesToRadians(notebook.get(parameter)))
386 Result.append(parameter)
389 Parameters = Parameters + str(parameter)
390 Parameters = Parameters + var_separator
392 Parameters = Parameters[:len(Parameters)-1]
393 return Result, Parameters
395 def IsEqual(val1, val2, tol=PrecisionConfusion):
396 if abs(val1 - val2) < tol:
406 if isinstance(obj, SALOMEDS._objref_SObject):
409 ior = salome.orb.object_to_string(obj)
412 studies = salome.myStudyManager.GetOpenStudies()
413 for sname in studies:
414 s = salome.myStudyManager.GetStudyByName(sname)
416 sobj = s.FindObjectIOR(ior)
417 if not sobj: continue
418 return sobj.GetName()
419 if hasattr(obj, "GetName"):
420 # unknown CORBA object, having GetName() method
423 # unknown CORBA object, no GetName() method
426 if hasattr(obj, "GetName"):
427 # unknown non-CORBA object, having GetName() method
430 raise RuntimeError, "Null or invalid object"
432 ## Prints error message if a hypothesis was not assigned.
433 def TreatHypoStatus(status, hypName, geomName, isAlgo):
435 hypType = "algorithm"
437 hypType = "hypothesis"
439 if status == HYP_UNKNOWN_FATAL :
440 reason = "for unknown reason"
441 elif status == HYP_INCOMPATIBLE :
442 reason = "this hypothesis mismatches the algorithm"
443 elif status == HYP_NOTCONFORM :
444 reason = "a non-conform mesh would be built"
445 elif status == HYP_ALREADY_EXIST :
446 if isAlgo: return # it does not influence anything
447 reason = hypType + " of the same dimension is already assigned to this shape"
448 elif status == HYP_BAD_DIM :
449 reason = hypType + " mismatches the shape"
450 elif status == HYP_CONCURENT :
451 reason = "there are concurrent hypotheses on sub-shapes"
452 elif status == HYP_BAD_SUBSHAPE :
453 reason = "the shape is neither the main one, nor its sub-shape, nor a valid group"
454 elif status == HYP_BAD_GEOMETRY:
455 reason = "geometry mismatches the expectation of the algorithm"
456 elif status == HYP_HIDDEN_ALGO:
457 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
458 elif status == HYP_HIDING_ALGO:
459 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
460 elif status == HYP_NEED_SHAPE:
461 reason = "Algorithm can't work without shape"
464 hypName = '"' + hypName + '"'
465 geomName= '"' + geomName+ '"'
466 if status < HYP_UNKNOWN_FATAL and not geomName =='""':
467 print hypName, "was assigned to", geomName,"but", reason
468 elif not geomName == '""':
469 print hypName, "was not assigned to",geomName,":", reason
471 print hypName, "was not assigned:", reason
474 ## Check meshing plugin availability
475 def CheckPlugin(plugin):
476 if plugin == NETGEN and noNETGENPlugin:
477 print "Warning: NETGENPlugin module unavailable"
479 elif plugin == GHS3D and noGHS3DPlugin:
480 print "Warning: GHS3DPlugin module unavailable"
482 elif plugin == GHS3DPRL and noGHS3DPRLPlugin:
483 print "Warning: GHS3DPRLPlugin module unavailable"
485 elif plugin == Hexotic and noHexoticPlugin:
486 print "Warning: HexoticPlugin module unavailable"
488 elif plugin == BLSURF and noBLSURFPlugin:
489 print "Warning: BLSURFPlugin module unavailable"
493 ## Private method. Add geom (sub-shape of the main shape) into the study if not yet there
494 def AssureGeomPublished(mesh, geom, name=''):
495 if not isinstance( geom, geompyDC.GEOM._objref_GEOM_Object ):
497 if not geom.IsSame( mesh.geom ) and not geom.GetStudyEntry():
499 studyID = mesh.smeshpyD.GetCurrentStudy()._get_StudyId()
500 if studyID != mesh.geompyD.myStudyId:
501 mesh.geompyD.init_geom( mesh.smeshpyD.GetCurrentStudy())
503 if not name and geom.GetShapeType() != geompyDC.GEOM.COMPOUND:
504 # for all groups SubShapeName() returns "Compound_-1"
505 name = mesh.geompyD.SubShapeName(geom, mesh.geom)
507 name = "%s_%s"%(geom.GetShapeType(), id(geom)%10000)
509 mesh.geompyD.addToStudyInFather( mesh.geom, geom, name )
512 ## Return the first vertex of a geomertical edge by ignoring orienation
513 def FirstVertexOnCurve(edge):
514 from geompy import SubShapeAll, ShapeType, KindOfShape, PointCoordinates
515 vv = SubShapeAll( edge, ShapeType["VERTEX"])
517 raise TypeError, "Given object has no vertices"
518 if len( vv ) == 1: return vv[0]
519 info = KindOfShape(edge)
520 xyz = info[1:4] # coords of the first vertex
521 xyz1 = PointCoordinates( vv[0] )
522 xyz2 = PointCoordinates( vv[1] )
525 dist1 += abs( xyz[i] - xyz1[i] )
526 dist2 += abs( xyz[i] - xyz2[i] )
532 # end of l1_auxiliary
535 # All methods of this class are accessible directly from the smesh.py package.
536 class smeshDC(SMESH._objref_SMESH_Gen):
538 ## Dump component to the Python script
539 # This method overrides IDL function to allow default values for the parameters.
540 def DumpPython(self, theStudy, theIsPublished=True, theIsMultiFile=True):
541 return SMESH._objref_SMESH_Gen.DumpPython(self, theStudy, theIsPublished, theIsMultiFile)
543 ## Set mode of DumpPython(), \a historical or \a snapshot.
544 # In the \a historical mode, the Python Dump script includes all commands
545 # performed by SMESH engine. In the \a snapshot mode, commands
546 # relating to objects removed from the Study are excluded from the script
547 # as well as commands not influencing the current state of meshes
548 def SetDumpPythonHistorical(self, isHistorical):
549 if isHistorical: val = "true"
551 SMESH._objref_SMESH_Gen.SetOption(self, "historical_python_dump", val)
553 ## Sets the current study and Geometry component
554 # @ingroup l1_auxiliary
555 def init_smesh(self,theStudy,geompyD):
556 self.SetCurrentStudy(theStudy,geompyD)
558 ## Creates an empty Mesh. This mesh can have an underlying geometry.
559 # @param obj the Geometrical object on which the mesh is built. If not defined,
560 # the mesh will have no underlying geometry.
561 # @param name the name for the new mesh.
562 # @return an instance of Mesh class.
563 # @ingroup l2_construct
564 def Mesh(self, obj=0, name=0):
565 if isinstance(obj,str):
567 return Mesh(self,self.geompyD,obj,name)
569 ## Returns a long value from enumeration
570 # Should be used for SMESH.FunctorType enumeration
571 # @ingroup l1_controls
572 def EnumToLong(self,theItem):
575 ## Returns a string representation of the color.
576 # To be used with filters.
577 # @param c color value (SALOMEDS.Color)
578 # @ingroup l1_controls
579 def ColorToString(self,c):
581 if isinstance(c, SALOMEDS.Color):
582 val = "%s;%s;%s" % (c.R, c.G, c.B)
583 elif isinstance(c, str):
586 raise ValueError, "Color value should be of string or SALOMEDS.Color type"
589 ## Gets PointStruct from vertex
590 # @param theVertex a GEOM object(vertex)
591 # @return SMESH.PointStruct
592 # @ingroup l1_auxiliary
593 def GetPointStruct(self,theVertex):
594 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
595 return PointStruct(x,y,z)
597 ## Gets DirStruct from vector
598 # @param theVector a GEOM object(vector)
599 # @return SMESH.DirStruct
600 # @ingroup l1_auxiliary
601 def GetDirStruct(self,theVector):
602 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
603 if(len(vertices) != 2):
604 print "Error: vector object is incorrect."
606 p1 = self.geompyD.PointCoordinates(vertices[0])
607 p2 = self.geompyD.PointCoordinates(vertices[1])
608 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
609 dirst = DirStruct(pnt)
612 ## Makes DirStruct from a triplet
613 # @param x,y,z vector components
614 # @return SMESH.DirStruct
615 # @ingroup l1_auxiliary
616 def MakeDirStruct(self,x,y,z):
617 pnt = PointStruct(x,y,z)
618 return DirStruct(pnt)
620 ## Get AxisStruct from object
621 # @param theObj a GEOM object (line or plane)
622 # @return SMESH.AxisStruct
623 # @ingroup l1_auxiliary
624 def GetAxisStruct(self,theObj):
625 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
627 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
628 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
629 vertex1 = self.geompyD.PointCoordinates(vertex1)
630 vertex2 = self.geompyD.PointCoordinates(vertex2)
631 vertex3 = self.geompyD.PointCoordinates(vertex3)
632 vertex4 = self.geompyD.PointCoordinates(vertex4)
633 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
634 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
635 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] ]
636 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
638 elif len(edges) == 1:
639 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
640 p1 = self.geompyD.PointCoordinates( vertex1 )
641 p2 = self.geompyD.PointCoordinates( vertex2 )
642 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
646 # From SMESH_Gen interface:
647 # ------------------------
649 ## Sets the given name to the object
650 # @param obj the object to rename
651 # @param name a new object name
652 # @ingroup l1_auxiliary
653 def SetName(self, obj, name):
654 if isinstance( obj, Mesh ):
656 elif isinstance( obj, Mesh_Algorithm ):
657 obj = obj.GetAlgorithm()
658 ior = salome.orb.object_to_string(obj)
659 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
661 ## Sets the current mode
662 # @ingroup l1_auxiliary
663 def SetEmbeddedMode( self,theMode ):
664 #self.SetEmbeddedMode(theMode)
665 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
667 ## Gets the current mode
668 # @ingroup l1_auxiliary
669 def IsEmbeddedMode(self):
670 #return self.IsEmbeddedMode()
671 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
673 ## Sets the current study
674 # @ingroup l1_auxiliary
675 def SetCurrentStudy( self, theStudy, geompyD = None ):
676 #self.SetCurrentStudy(theStudy)
679 geompyD = geompy.geom
682 self.SetGeomEngine(geompyD)
683 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
685 ## Gets the current study
686 # @ingroup l1_auxiliary
687 def GetCurrentStudy(self):
688 #return self.GetCurrentStudy()
689 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
691 ## Creates a Mesh object importing data from the given UNV file
692 # @return an instance of Mesh class
694 def CreateMeshesFromUNV( self,theFileName ):
695 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
696 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
699 ## Creates a Mesh object(s) importing data from the given MED file
700 # @return a list of Mesh class instances
702 def CreateMeshesFromMED( self,theFileName ):
703 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
705 for iMesh in range(len(aSmeshMeshes)) :
706 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
707 aMeshes.append(aMesh)
708 return aMeshes, aStatus
710 ## Creates a Mesh object(s) importing data from the given SAUV file
711 # @return a list of Mesh class instances
713 def CreateMeshesFromSAUV( self,theFileName ):
714 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromSAUV(self,theFileName)
716 for iMesh in range(len(aSmeshMeshes)) :
717 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
718 aMeshes.append(aMesh)
719 return aMeshes, aStatus
721 ## Creates a Mesh object importing data from the given STL file
722 # @return an instance of Mesh class
724 def CreateMeshesFromSTL( self, theFileName ):
725 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
726 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
729 ## Creates Mesh objects importing data from the given CGNS file
730 # @return an instance of Mesh class
732 def CreateMeshesFromCGNS( self, theFileName ):
733 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromCGNS(self,theFileName)
735 for iMesh in range(len(aSmeshMeshes)) :
736 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
737 aMeshes.append(aMesh)
738 return aMeshes, aStatus
740 ## Concatenate the given meshes into one mesh.
741 # @return an instance of Mesh class
742 # @param meshes the meshes to combine into one mesh
743 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
744 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
745 # @param mergeTolerance tolerance for merging nodes
746 # @param allGroups forces creation of groups of all elements
747 def Concatenate( self, meshes, uniteIdenticalGroups,
748 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
749 mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
750 for i,m in enumerate(meshes):
751 if isinstance(m, Mesh):
752 meshes[i] = m.GetMesh()
754 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
755 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
757 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
758 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
759 aSmeshMesh.SetParameters(Parameters)
760 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
763 ## Create a mesh by copying a part of another mesh.
764 # @param meshPart a part of mesh to copy, either a Mesh, a sub-mesh or a group;
765 # to copy nodes or elements not contained in any mesh object,
766 # pass result of Mesh.GetIDSource( list_of_ids, type ) as meshPart
767 # @param meshName a name of the new mesh
768 # @param toCopyGroups to create in the new mesh groups the copied elements belongs to
769 # @param toKeepIDs to preserve IDs of the copied elements or not
770 # @return an instance of Mesh class
771 def CopyMesh( self, meshPart, meshName, toCopyGroups=False, toKeepIDs=False):
772 if (isinstance( meshPart, Mesh )):
773 meshPart = meshPart.GetMesh()
774 mesh = SMESH._objref_SMESH_Gen.CopyMesh( self,meshPart,meshName,toCopyGroups,toKeepIDs )
775 return Mesh(self, self.geompyD, mesh)
777 ## From SMESH_Gen interface
778 # @return the list of integer values
779 # @ingroup l1_auxiliary
780 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
781 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
783 ## From SMESH_Gen interface. Creates a pattern
784 # @return an instance of SMESH_Pattern
786 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
787 # @ingroup l2_modif_patterns
788 def GetPattern(self):
789 return SMESH._objref_SMESH_Gen.GetPattern(self)
791 ## Sets number of segments per diagonal of boundary box of geometry by which
792 # default segment length of appropriate 1D hypotheses is defined.
793 # Default value is 10
794 # @ingroup l1_auxiliary
795 def SetBoundaryBoxSegmentation(self, nbSegments):
796 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
798 # Filtering. Auxiliary functions:
799 # ------------------------------
801 ## Creates an empty criterion
802 # @return SMESH.Filter.Criterion
803 # @ingroup l1_controls
804 def GetEmptyCriterion(self):
805 Type = self.EnumToLong(FT_Undefined)
806 Compare = self.EnumToLong(FT_Undefined)
810 UnaryOp = self.EnumToLong(FT_Undefined)
811 BinaryOp = self.EnumToLong(FT_Undefined)
814 Precision = -1 ##@1e-07
815 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
816 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
818 ## Creates a criterion by the given parameters
819 # \n Criterion structures allow to define complex filters by combining them with logical operations (AND / OR) (see example below)
820 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
821 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
822 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
823 # @param Threshold the threshold value (range of ids as string, shape, numeric)
824 # @param UnaryOp FT_LogicalNOT or FT_Undefined
825 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
826 # FT_Undefined (must be for the last criterion of all criteria)
827 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
828 # FT_LyingOnGeom, FT_CoplanarFaces criteria
829 # @return SMESH.Filter.Criterion
831 # <a href="../tui_filters_page.html#combining_filters">Example of Criteria usage</a>
832 # @ingroup l1_controls
833 def GetCriterion(self,elementType,
835 Compare = FT_EqualTo,
837 UnaryOp=FT_Undefined,
838 BinaryOp=FT_Undefined,
840 if not CritType in SMESH.FunctorType._items:
841 raise TypeError, "CritType should be of SMESH.FunctorType"
842 aCriterion = self.GetEmptyCriterion()
843 aCriterion.TypeOfElement = elementType
844 aCriterion.Type = self.EnumToLong(CritType)
845 aCriterion.Tolerance = Tolerance
847 aThreshold = Threshold
849 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
850 aCriterion.Compare = self.EnumToLong(Compare)
851 elif Compare == "=" or Compare == "==":
852 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
854 aCriterion.Compare = self.EnumToLong(FT_LessThan)
856 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
857 elif Compare != FT_Undefined:
858 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
861 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
862 FT_BelongToCylinder, FT_LyingOnGeom]:
863 # Checks the Threshold
864 if isinstance(aThreshold, geompyDC.GEOM._objref_GEOM_Object):
865 aCriterion.ThresholdStr = GetName(aThreshold)
866 aCriterion.ThresholdID = salome.ObjectToID(aThreshold)
868 print "Error: The Threshold should be a shape."
870 if isinstance(UnaryOp,float):
871 aCriterion.Tolerance = UnaryOp
872 UnaryOp = FT_Undefined
874 elif CritType == FT_RangeOfIds:
875 # Checks the Threshold
876 if isinstance(aThreshold, str):
877 aCriterion.ThresholdStr = aThreshold
879 print "Error: The Threshold should be a string."
881 elif CritType == FT_CoplanarFaces:
882 # Checks the Threshold
883 if isinstance(aThreshold, int):
884 aCriterion.ThresholdID = "%s"%aThreshold
885 elif isinstance(aThreshold, str):
888 raise ValueError, "Invalid ID of mesh face: '%s'"%aThreshold
889 aCriterion.ThresholdID = aThreshold
892 "The Threshold should be an ID of mesh face and not '%s'"%aThreshold
893 elif CritType == FT_ElemGeomType:
894 # Checks the Threshold
896 aCriterion.Threshold = self.EnumToLong(aThreshold)
897 assert( aThreshold in SMESH.GeometryType._items )
899 if isinstance(aThreshold, int):
900 aCriterion.Threshold = aThreshold
902 print "Error: The Threshold should be an integer or SMESH.GeometryType."
906 elif CritType == FT_GroupColor:
907 # Checks the Threshold
909 aCriterion.ThresholdStr = self.ColorToString(aThreshold)
911 print "Error: The threshold value should be of SALOMEDS.Color type"
914 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_FreeNodes, FT_FreeFaces,
915 FT_LinearOrQuadratic, FT_BadOrientedVolume,
916 FT_BareBorderFace, FT_BareBorderVolume,
917 FT_OverConstrainedFace, FT_OverConstrainedVolume,
918 FT_EqualNodes,FT_EqualEdges,FT_EqualFaces,FT_EqualVolumes ]:
919 # At this point the Threshold is unnecessary
920 if aThreshold == FT_LogicalNOT:
921 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
922 elif aThreshold in [FT_LogicalAND, FT_LogicalOR]:
923 aCriterion.BinaryOp = aThreshold
927 aThreshold = float(aThreshold)
928 aCriterion.Threshold = aThreshold
930 print "Error: The Threshold should be a number."
933 if Threshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
934 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
936 if Threshold in [FT_LogicalAND, FT_LogicalOR]:
937 aCriterion.BinaryOp = self.EnumToLong(Threshold)
939 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
940 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
942 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
943 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
947 ## Creates a filter with the given parameters
948 # @param elementType the type of elements in the group
949 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
950 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
951 # @param Threshold the threshold value (range of id ids as string, shape, numeric)
952 # @param UnaryOp FT_LogicalNOT or FT_Undefined
953 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
954 # FT_LyingOnGeom, FT_CoplanarFaces and FT_EqualNodes criteria
955 # @return SMESH_Filter
957 # <a href="../tui_filters_page.html#tui_filters">Example of Filters usage</a>
958 # @ingroup l1_controls
959 def GetFilter(self,elementType,
960 CritType=FT_Undefined,
963 UnaryOp=FT_Undefined,
965 aCriterion = self.GetCriterion(elementType, CritType, Compare, Threshold, UnaryOp, FT_Undefined,Tolerance)
966 aFilterMgr = self.CreateFilterManager()
967 aFilter = aFilterMgr.CreateFilter()
969 aCriteria.append(aCriterion)
970 aFilter.SetCriteria(aCriteria)
971 aFilterMgr.UnRegister()
974 ## Creates a filter from criteria
975 # @param criteria a list of criteria
976 # @return SMESH_Filter
978 # <a href="../tui_filters_page.html#tui_filters">Example of Filters usage</a>
979 # @ingroup l1_controls
980 def GetFilterFromCriteria(self,criteria):
981 aFilterMgr = self.CreateFilterManager()
982 aFilter = aFilterMgr.CreateFilter()
983 aFilter.SetCriteria(criteria)
984 aFilterMgr.UnRegister()
987 ## Creates a numerical functor by its type
988 # @param theCriterion FT_...; functor type
989 # @return SMESH_NumericalFunctor
990 # @ingroup l1_controls
991 def GetFunctor(self,theCriterion):
992 aFilterMgr = self.CreateFilterManager()
993 if theCriterion == FT_AspectRatio:
994 return aFilterMgr.CreateAspectRatio()
995 elif theCriterion == FT_AspectRatio3D:
996 return aFilterMgr.CreateAspectRatio3D()
997 elif theCriterion == FT_Warping:
998 return aFilterMgr.CreateWarping()
999 elif theCriterion == FT_MinimumAngle:
1000 return aFilterMgr.CreateMinimumAngle()
1001 elif theCriterion == FT_Taper:
1002 return aFilterMgr.CreateTaper()
1003 elif theCriterion == FT_Skew:
1004 return aFilterMgr.CreateSkew()
1005 elif theCriterion == FT_Area:
1006 return aFilterMgr.CreateArea()
1007 elif theCriterion == FT_Volume3D:
1008 return aFilterMgr.CreateVolume3D()
1009 elif theCriterion == FT_MaxElementLength2D:
1010 return aFilterMgr.CreateMaxElementLength2D()
1011 elif theCriterion == FT_MaxElementLength3D:
1012 return aFilterMgr.CreateMaxElementLength3D()
1013 elif theCriterion == FT_MultiConnection:
1014 return aFilterMgr.CreateMultiConnection()
1015 elif theCriterion == FT_MultiConnection2D:
1016 return aFilterMgr.CreateMultiConnection2D()
1017 elif theCriterion == FT_Length:
1018 return aFilterMgr.CreateLength()
1019 elif theCriterion == FT_Length2D:
1020 return aFilterMgr.CreateLength2D()
1022 print "Error: given parameter is not numerucal functor type."
1024 ## Creates hypothesis
1025 # @param theHType mesh hypothesis type (string)
1026 # @param theLibName mesh plug-in library name
1027 # @return created hypothesis instance
1028 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
1029 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
1031 ## Gets the mesh statistic
1032 # @return dictionary "element type" - "count of elements"
1033 # @ingroup l1_meshinfo
1034 def GetMeshInfo(self, obj):
1035 if isinstance( obj, Mesh ):
1038 if hasattr(obj, "GetMeshInfo"):
1039 values = obj.GetMeshInfo()
1040 for i in range(SMESH.Entity_Last._v):
1041 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
1045 ## Get minimum distance between two objects
1047 # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
1048 # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
1050 # @param src1 first source object
1051 # @param src2 second source object
1052 # @param id1 node/element id from the first source
1053 # @param id2 node/element id from the second (or first) source
1054 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
1055 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
1056 # @return minimum distance value
1057 # @sa GetMinDistance()
1058 # @ingroup l1_measurements
1059 def MinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
1060 result = self.GetMinDistance(src1, src2, id1, id2, isElem1, isElem2)
1064 result = result.value
1067 ## Get measure structure specifying minimum distance data between two objects
1069 # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
1070 # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
1072 # @param src1 first source object
1073 # @param src2 second source object
1074 # @param id1 node/element id from the first source
1075 # @param id2 node/element id from the second (or first) source
1076 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
1077 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
1078 # @return Measure structure or None if input data is invalid
1080 # @ingroup l1_measurements
1081 def GetMinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
1082 if isinstance(src1, Mesh): src1 = src1.mesh
1083 if isinstance(src2, Mesh): src2 = src2.mesh
1084 if src2 is None and id2 != 0: src2 = src1
1085 if not hasattr(src1, "_narrow"): return None
1086 src1 = src1._narrow(SMESH.SMESH_IDSource)
1087 if not src1: return None
1090 e = m.GetMeshEditor()
1092 src1 = e.MakeIDSource([id1], SMESH.FACE)
1094 src1 = e.MakeIDSource([id1], SMESH.NODE)
1096 if hasattr(src2, "_narrow"):
1097 src2 = src2._narrow(SMESH.SMESH_IDSource)
1098 if src2 and id2 != 0:
1100 e = m.GetMeshEditor()
1102 src2 = e.MakeIDSource([id2], SMESH.FACE)
1104 src2 = e.MakeIDSource([id2], SMESH.NODE)
1107 aMeasurements = self.CreateMeasurements()
1108 result = aMeasurements.MinDistance(src1, src2)
1109 aMeasurements.UnRegister()
1112 ## Get bounding box of the specified object(s)
1113 # @param objects single source object or list of source objects
1114 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
1115 # @sa GetBoundingBox()
1116 # @ingroup l1_measurements
1117 def BoundingBox(self, objects):
1118 result = self.GetBoundingBox(objects)
1122 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
1125 ## Get measure structure specifying bounding box data of the specified object(s)
1126 # @param objects single source object or list of source objects
1127 # @return Measure structure
1129 # @ingroup l1_measurements
1130 def GetBoundingBox(self, objects):
1131 if isinstance(objects, tuple):
1132 objects = list(objects)
1133 if not isinstance(objects, list):
1137 if isinstance(o, Mesh):
1138 srclist.append(o.mesh)
1139 elif hasattr(o, "_narrow"):
1140 src = o._narrow(SMESH.SMESH_IDSource)
1141 if src: srclist.append(src)
1144 aMeasurements = self.CreateMeasurements()
1145 result = aMeasurements.BoundingBox(srclist)
1146 aMeasurements.UnRegister()
1150 #Registering the new proxy for SMESH_Gen
1151 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
1154 # Public class: Mesh
1155 # ==================
1157 ## This class allows defining and managing a mesh.
1158 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
1159 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
1160 # new nodes and elements and by changing the existing entities), to get information
1161 # about a mesh and to export a mesh into different formats.
1170 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
1171 # sets the GUI name of this mesh to \a name.
1172 # @param smeshpyD an instance of smeshDC class
1173 # @param geompyD an instance of geompyDC class
1174 # @param obj Shape to be meshed or SMESH_Mesh object
1175 # @param name Study name of the mesh
1176 # @ingroup l2_construct
1177 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
1178 self.smeshpyD=smeshpyD
1179 self.geompyD=geompyD
1183 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
1185 # publish geom of mesh (issue 0021122)
1186 if not self.geom.GetStudyEntry():
1187 studyID = smeshpyD.GetCurrentStudy()._get_StudyId()
1188 if studyID != geompyD.myStudyId:
1189 geompyD.init_geom( smeshpyD.GetCurrentStudy())
1191 geo_name = "%s_%s"%(self.geom.GetShapeType(), id(self.geom)%100)
1192 geompyD.addToStudy( self.geom, geo_name )
1193 self.mesh = self.smeshpyD.CreateMesh(self.geom)
1195 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
1198 self.mesh = self.smeshpyD.CreateEmptyMesh()
1200 self.smeshpyD.SetName(self.mesh, name)
1202 self.smeshpyD.SetName(self.mesh, GetName(obj))
1205 self.geom = self.mesh.GetShapeToMesh()
1207 self.editor = self.mesh.GetMeshEditor()
1209 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
1210 # @param theMesh a SMESH_Mesh object
1211 # @ingroup l2_construct
1212 def SetMesh(self, theMesh):
1214 self.geom = self.mesh.GetShapeToMesh()
1216 ## Returns the mesh, that is an instance of SMESH_Mesh interface
1217 # @return a SMESH_Mesh object
1218 # @ingroup l2_construct
1222 ## Gets the name of the mesh
1223 # @return the name of the mesh as a string
1224 # @ingroup l2_construct
1226 name = GetName(self.GetMesh())
1229 ## Sets a name to the mesh
1230 # @param name a new name of the mesh
1231 # @ingroup l2_construct
1232 def SetName(self, name):
1233 self.smeshpyD.SetName(self.GetMesh(), name)
1235 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
1236 # The subMesh object gives access to the IDs of nodes and elements.
1237 # @param geom a geometrical object (shape)
1238 # @param name a name for the submesh
1239 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
1240 # @ingroup l2_submeshes
1241 def GetSubMesh(self, geom, name):
1242 AssureGeomPublished( self, geom, name )
1243 submesh = self.mesh.GetSubMesh( geom, name )
1246 ## Returns the shape associated to the mesh
1247 # @return a GEOM_Object
1248 # @ingroup l2_construct
1252 ## Associates the given shape to the mesh (entails the recreation of the mesh)
1253 # @param geom the shape to be meshed (GEOM_Object)
1254 # @ingroup l2_construct
1255 def SetShape(self, geom):
1256 self.mesh = self.smeshpyD.CreateMesh(geom)
1258 ## Loads mesh from the study after opening the study
1262 ## Returns true if the hypotheses are defined well
1263 # @param theSubObject a sub-shape of a mesh shape
1264 # @return True or False
1265 # @ingroup l2_construct
1266 def IsReadyToCompute(self, theSubObject):
1267 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
1269 ## Returns errors of hypotheses definition.
1270 # The list of errors is empty if everything is OK.
1271 # @param theSubObject a sub-shape of a mesh shape
1272 # @return a list of errors
1273 # @ingroup l2_construct
1274 def GetAlgoState(self, theSubObject):
1275 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
1277 ## Returns a geometrical object on which the given element was built.
1278 # The returned geometrical object, if not nil, is either found in the
1279 # study or published by this method with the given name
1280 # @param theElementID the id of the mesh element
1281 # @param theGeomName the user-defined name of the geometrical object
1282 # @return GEOM::GEOM_Object instance
1283 # @ingroup l2_construct
1284 def GetGeometryByMeshElement(self, theElementID, theGeomName):
1285 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
1287 ## Returns the mesh dimension depending on the dimension of the underlying shape
1288 # @return mesh dimension as an integer value [0,3]
1289 # @ingroup l1_auxiliary
1290 def MeshDimension(self):
1291 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
1292 if len( shells ) > 0 :
1294 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
1296 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
1302 ## Creates a segment discretization 1D algorithm.
1303 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
1304 # \n If the optional \a geom parameter is not set, this algorithm is global.
1305 # Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1306 # @param algo the type of the required algorithm. Possible values are:
1308 # - smesh.PYTHON for discretization via a python function,
1309 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
1310 # @param geom If defined is the sub-shape to be meshed
1311 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
1312 # @ingroup l3_algos_basic
1313 def Segment(self, algo=REGULAR, geom=0):
1314 ## if Segment(geom) is called by mistake
1315 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
1316 algo, geom = geom, algo
1317 if not algo: algo = REGULAR
1320 return Mesh_Segment(self, geom)
1321 elif algo == PYTHON:
1322 return Mesh_Segment_Python(self, geom)
1323 elif algo == COMPOSITE:
1324 return Mesh_CompositeSegment(self, geom)
1326 return Mesh_Segment(self, geom)
1328 ## Creates 1D algorithm importing segments conatined in groups of other mesh.
1329 # If the optional \a geom parameter is not set, this algorithm is global.
1330 # Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1331 # @param geom If defined the subshape is to be meshed
1332 # @return an instance of Mesh_UseExistingElements class
1333 # @ingroup l3_algos_basic
1334 def UseExisting1DElements(self, geom=0):
1335 return Mesh_UseExistingElements(1,self, geom)
1337 ## Creates 2D algorithm importing faces conatined in groups of other mesh.
1338 # If the optional \a geom parameter is not set, this algorithm is global.
1339 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1340 # @param geom If defined the sub-shape is to be meshed
1341 # @return an instance of Mesh_UseExistingElements class
1342 # @ingroup l3_algos_basic
1343 def UseExisting2DElements(self, geom=0):
1344 return Mesh_UseExistingElements(2,self, geom)
1346 ## Enables creation of nodes and segments usable by 2D algoritms.
1347 # The added nodes and segments must be bound to edges and vertices by
1348 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
1349 # If the optional \a geom parameter is not set, this algorithm is global.
1350 # \n Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1351 # @param geom the sub-shape to be manually meshed
1352 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
1353 # @ingroup l3_algos_basic
1354 def UseExistingSegments(self, geom=0):
1355 algo = Mesh_UseExisting(1,self,geom)
1356 return algo.GetAlgorithm()
1358 ## Enables creation of nodes and faces usable by 3D algoritms.
1359 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
1360 # and SetMeshElementOnShape()
1361 # If the optional \a geom parameter is not set, this algorithm is global.
1362 # \n Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1363 # @param geom the sub-shape to be manually meshed
1364 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1365 # @ingroup l3_algos_basic
1366 def UseExistingFaces(self, geom=0):
1367 algo = Mesh_UseExisting(2,self,geom)
1368 return algo.GetAlgorithm()
1370 ## Creates a triangle 2D algorithm for faces.
1371 # If the optional \a geom parameter is not set, this algorithm is global.
1372 # \n Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1373 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1374 # @param geom If defined, the sub-shape to be meshed (GEOM_Object)
1375 # @return an instance of Mesh_Triangle algorithm
1376 # @ingroup l3_algos_basic
1377 def Triangle(self, algo=MEFISTO, geom=0):
1378 ## if Triangle(geom) is called by mistake
1379 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1382 return Mesh_Triangle(self, algo, geom)
1384 ## Creates a quadrangle 2D algorithm for faces.
1385 # If the optional \a geom parameter is not set, this algorithm is global.
1386 # \n Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1387 # @param geom If defined, the sub-shape to be meshed (GEOM_Object)
1388 # @param algo values are: smesh.QUADRANGLE || smesh.RADIAL_QUAD
1389 # @return an instance of Mesh_Quadrangle algorithm
1390 # @ingroup l3_algos_basic
1391 def Quadrangle(self, geom=0, algo=QUADRANGLE):
1392 if algo==RADIAL_QUAD:
1393 return Mesh_RadialQuadrangle1D2D(self,geom)
1395 return Mesh_Quadrangle(self, geom)
1397 ## Creates a tetrahedron 3D algorithm for solids.
1398 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1399 # If the optional \a geom parameter is not set, this algorithm is global.
1400 # \n Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1401 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1402 # @param geom If defined, the sub-shape to be meshed (GEOM_Object)
1403 # @return an instance of Mesh_Tetrahedron algorithm
1404 # @ingroup l3_algos_basic
1405 def Tetrahedron(self, algo=NETGEN, geom=0):
1406 ## if Tetrahedron(geom) is called by mistake
1407 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1408 algo, geom = geom, algo
1409 if not algo: algo = NETGEN
1411 return Mesh_Tetrahedron(self, algo, geom)
1413 ## Creates a hexahedron 3D algorithm for solids.
1414 # If the optional \a geom parameter is not set, this algorithm is global.
1415 # \n Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1416 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1417 # @param geom If defined, the sub-shape to be meshed (GEOM_Object)
1418 # @return an instance of Mesh_Hexahedron algorithm
1419 # @ingroup l3_algos_basic
1420 def Hexahedron(self, algo=Hexa, geom=0):
1421 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1422 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1423 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1424 elif geom == 0: algo, geom = Hexa, algo
1425 return Mesh_Hexahedron(self, algo, geom)
1427 ## Deprecated, used only for compatibility!
1428 # @return an instance of Mesh_Netgen algorithm
1429 # @ingroup l3_algos_basic
1430 def Netgen(self, is3D, geom=0):
1431 return Mesh_Netgen(self, is3D, geom)
1433 ## Creates a projection 1D algorithm for edges.
1434 # If the optional \a geom parameter is not set, this algorithm is global.
1435 # Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1436 # @param geom If defined, the sub-shape to be meshed
1437 # @return an instance of Mesh_Projection1D algorithm
1438 # @ingroup l3_algos_proj
1439 def Projection1D(self, geom=0):
1440 return Mesh_Projection1D(self, geom)
1442 ## Creates a projection 1D-2D algorithm for faces.
1443 # If the optional \a geom parameter is not set, this algorithm is global.
1444 # Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1445 # @param geom If defined, the sub-shape to be meshed
1446 # @return an instance of Mesh_Projection2D algorithm
1447 # @ingroup l3_algos_proj
1448 def Projection1D2D(self, geom=0):
1449 return Mesh_Projection2D(self, geom, "Projection_1D2D")
1451 ## Creates a projection 2D algorithm for faces.
1452 # If the optional \a geom parameter is not set, this algorithm is global.
1453 # Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1454 # @param geom If defined, the sub-shape to be meshed
1455 # @return an instance of Mesh_Projection2D algorithm
1456 # @ingroup l3_algos_proj
1457 def Projection2D(self, geom=0):
1458 return Mesh_Projection2D(self, geom, "Projection_2D")
1460 ## Creates a projection 3D algorithm for solids.
1461 # If the optional \a geom parameter is not set, this algorithm is global.
1462 # Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1463 # @param geom If defined, the sub-shape to be meshed
1464 # @return an instance of Mesh_Projection3D algorithm
1465 # @ingroup l3_algos_proj
1466 def Projection3D(self, geom=0):
1467 return Mesh_Projection3D(self, geom)
1469 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1470 # If the optional \a geom parameter is not set, this algorithm is global.
1471 # Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1472 # @param geom If defined, the sub-shape to be meshed
1473 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1474 # @ingroup l3_algos_radialp l3_algos_3dextr
1475 def Prism(self, geom=0):
1479 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1480 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1481 if nbSolids == 0 or nbSolids == nbShells:
1482 return Mesh_Prism3D(self, geom)
1483 return Mesh_RadialPrism3D(self, geom)
1485 ## Creates a "Body Fitted" 3D algorithm for solids, which generates
1486 # 3D structured Cartesian mesh in the internal part of a solid shape
1487 # and polyhedral volumes near the shape boundary.
1488 # If the optional \a geom parameter is not set, this algorithm is global.
1489 # Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1490 # The algorithm does not support submeshes.
1491 # Generally usage of this algorithm as a local one is useless since
1492 # it does not discretize 1D and 2D sub-shapes in a usual way acceptable
1493 # for other algorithms.
1494 # @param geom If defined, the sub-shape to be meshed
1495 # @return an instance of Mesh_Cartesian_3D algorithm
1496 # @ingroup l3_algos_basic
1497 def BodyFitted(self, geom=0):
1498 return Mesh_Cartesian_3D(self, geom)
1500 ## Evaluates size of prospective mesh on a shape
1501 # @return a list where i-th element is a number of elements of i-th SMESH.EntityType
1502 # To know predicted number of e.g. edges, inquire it this way
1503 # Evaluate()[ EnumToLong( Entity_Edge )]
1504 def Evaluate(self, geom=0):
1505 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1507 geom = self.mesh.GetShapeToMesh()
1510 return self.smeshpyD.Evaluate(self.mesh, geom)
1513 ## Computes the mesh and returns the status of the computation
1514 # @param geom geomtrical shape on which mesh data should be computed
1515 # @param discardModifs if True and the mesh has been edited since
1516 # a last total re-compute and that may prevent successful partial re-compute,
1517 # then the mesh is cleaned before Compute()
1518 # @return True or False
1519 # @ingroup l2_construct
1520 def Compute(self, geom=0, discardModifs=False):
1521 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1523 geom = self.mesh.GetShapeToMesh()
1528 if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693
1530 ok = self.smeshpyD.Compute(self.mesh, geom)
1531 except SALOME.SALOME_Exception, ex:
1532 print "Mesh computation failed, exception caught:"
1533 print " ", ex.details.text
1536 print "Mesh computation failed, exception caught:"
1537 traceback.print_exc()
1541 # Treat compute errors
1542 computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
1543 for err in computeErrors:
1545 if self.mesh.HasShapeToMesh():
1547 mainIOR = salome.orb.object_to_string(geom)
1548 for sname in salome.myStudyManager.GetOpenStudies():
1549 s = salome.myStudyManager.GetStudyByName(sname)
1551 mainSO = s.FindObjectIOR(mainIOR)
1552 if not mainSO: continue
1553 if err.subShapeID == 1:
1554 shapeText = ' on "%s"' % mainSO.GetName()
1555 subIt = s.NewChildIterator(mainSO)
1557 subSO = subIt.Value()
1559 obj = subSO.GetObject()
1560 if not obj: continue
1561 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
1563 ids = go.GetSubShapeIndices()
1564 if len(ids) == 1 and ids[0] == err.subShapeID:
1565 shapeText = ' on "%s"' % subSO.GetName()
1568 shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
1570 shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID)
1572 shapeText = " on subshape #%s" % (err.subShapeID)
1574 shapeText = " on subshape #%s" % (err.subShapeID)
1576 stdErrors = ["OK", #COMPERR_OK
1577 "Invalid input mesh", #COMPERR_BAD_INPUT_MESH
1578 "std::exception", #COMPERR_STD_EXCEPTION
1579 "OCC exception", #COMPERR_OCC_EXCEPTION
1580 "SALOME exception", #COMPERR_SLM_EXCEPTION
1581 "Unknown exception", #COMPERR_EXCEPTION
1582 "Memory allocation problem", #COMPERR_MEMORY_PB
1583 "Algorithm failed", #COMPERR_ALGO_FAILED
1584 "Unexpected geometry"]#COMPERR_BAD_SHAPE
1586 if err.code < len(stdErrors): errText = stdErrors[err.code]
1588 errText = "code %s" % -err.code
1589 if errText: errText += ". "
1590 errText += err.comment
1591 if allReasons != "":allReasons += "\n"
1592 allReasons += '"%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
1596 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1598 if err.isGlobalAlgo:
1606 reason = '%s %sD algorithm is missing' % (glob, dim)
1607 elif err.state == HYP_MISSING:
1608 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1609 % (glob, dim, name, dim))
1610 elif err.state == HYP_NOTCONFORM:
1611 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1612 elif err.state == HYP_BAD_PARAMETER:
1613 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1614 % ( glob, dim, name ))
1615 elif err.state == HYP_BAD_GEOMETRY:
1616 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1617 'geometry' % ( glob, dim, name ))
1619 reason = "For unknown reason."+\
1620 " Revise Mesh.Compute() implementation in smeshDC.py!"
1622 if allReasons != "":allReasons += "\n"
1623 allReasons += reason
1625 if allReasons != "":
1626 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1630 print '"' + GetName(self.mesh) + '"',"has not been computed."
1633 if salome.sg.hasDesktop():
1634 smeshgui = salome.ImportComponentGUI("SMESH")
1635 smeshgui.Init(self.mesh.GetStudyId())
1636 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1637 salome.sg.updateObjBrowser(1)
1641 ## Return submesh objects list in meshing order
1642 # @return list of list of submesh objects
1643 # @ingroup l2_construct
1644 def GetMeshOrder(self):
1645 return self.mesh.GetMeshOrder()
1647 ## Return submesh objects list in meshing order
1648 # @return list of list of submesh objects
1649 # @ingroup l2_construct
1650 def SetMeshOrder(self, submeshes):
1651 return self.mesh.SetMeshOrder(submeshes)
1653 ## Removes all nodes and elements
1654 # @ingroup l2_construct
1657 if salome.sg.hasDesktop():
1658 smeshgui = salome.ImportComponentGUI("SMESH")
1659 smeshgui.Init(self.mesh.GetStudyId())
1660 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1661 salome.sg.updateObjBrowser(1)
1663 ## Removes all nodes and elements of indicated shape
1664 # @ingroup l2_construct
1665 def ClearSubMesh(self, geomId):
1666 self.mesh.ClearSubMesh(geomId)
1667 if salome.sg.hasDesktop():
1668 smeshgui = salome.ImportComponentGUI("SMESH")
1669 smeshgui.Init(self.mesh.GetStudyId())
1670 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1671 salome.sg.updateObjBrowser(1)
1673 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1674 # @param fineness [0.0,1.0] defines mesh fineness
1675 # @return True or False
1676 # @ingroup l3_algos_basic
1677 def AutomaticTetrahedralization(self, fineness=0):
1678 dim = self.MeshDimension()
1680 self.RemoveGlobalHypotheses()
1681 self.Segment().AutomaticLength(fineness)
1683 self.Triangle().LengthFromEdges()
1686 self.Tetrahedron(NETGEN)
1688 return self.Compute()
1690 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1691 # @param fineness [0.0, 1.0] defines mesh fineness
1692 # @return True or False
1693 # @ingroup l3_algos_basic
1694 def AutomaticHexahedralization(self, fineness=0):
1695 dim = self.MeshDimension()
1696 # assign the hypotheses
1697 self.RemoveGlobalHypotheses()
1698 self.Segment().AutomaticLength(fineness)
1705 return self.Compute()
1707 ## Assigns a hypothesis
1708 # @param hyp a hypothesis to assign
1709 # @param geom a subhape of mesh geometry
1710 # @return SMESH.Hypothesis_Status
1711 # @ingroup l2_hypotheses
1712 def AddHypothesis(self, hyp, geom=0):
1713 if isinstance( hyp, Mesh_Algorithm ):
1714 hyp = hyp.GetAlgorithm()
1719 geom = self.mesh.GetShapeToMesh()
1721 status = self.mesh.AddHypothesis(geom, hyp)
1722 isAlgo = hyp._narrow( SMESH_Algo )
1723 hyp_name = GetName( hyp )
1726 geom_name = GetName( geom )
1727 TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1730 ## Return True if an algorithm of hypothesis is assigned to a given shape
1731 # @param hyp a hypothesis to check
1732 # @param geom a subhape of mesh geometry
1733 # @return True of False
1734 # @ingroup l2_hypotheses
1735 def IsUsedHypothesis(self, hyp, geom):
1736 if not hyp or not geom:
1738 if isinstance( hyp, Mesh_Algorithm ):
1739 hyp = hyp.GetAlgorithm()
1741 hyps = self.GetHypothesisList(geom)
1743 if h.GetId() == hyp.GetId():
1747 ## Unassigns a hypothesis
1748 # @param hyp a hypothesis to unassign
1749 # @param geom a sub-shape of mesh geometry
1750 # @return SMESH.Hypothesis_Status
1751 # @ingroup l2_hypotheses
1752 def RemoveHypothesis(self, hyp, geom=0):
1753 if isinstance( hyp, Mesh_Algorithm ):
1754 hyp = hyp.GetAlgorithm()
1759 status = self.mesh.RemoveHypothesis(geom, hyp)
1762 ## Gets the list of hypotheses added on a geometry
1763 # @param geom a sub-shape of mesh geometry
1764 # @return the sequence of SMESH_Hypothesis
1765 # @ingroup l2_hypotheses
1766 def GetHypothesisList(self, geom):
1767 return self.mesh.GetHypothesisList( geom )
1769 ## Removes all global hypotheses
1770 # @ingroup l2_hypotheses
1771 def RemoveGlobalHypotheses(self):
1772 current_hyps = self.mesh.GetHypothesisList( self.geom )
1773 for hyp in current_hyps:
1774 self.mesh.RemoveHypothesis( self.geom, hyp )
1778 ## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead.
1779 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1780 ## allowing to overwrite the file if it exists or add the exported data to its contents
1781 # @param f the file name
1782 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1783 # @param opt boolean parameter for creating/not creating
1784 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1785 # @param overwrite boolean parameter for overwriting/not overwriting the file
1786 # @ingroup l2_impexp
1787 def ExportToMED(self, f, version, opt=0, overwrite=1):
1788 self.mesh.ExportToMEDX(f, opt, version, overwrite)
1790 ## Exports the mesh in a file in MED format and chooses the \a version of MED format
1791 ## allowing to overwrite the file if it exists or add the exported data to its contents
1792 # @param f is the file name
1793 # @param auto_groups boolean parameter for creating/not creating
1794 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1795 # the typical use is auto_groups=false.
1796 # @param version MED format version(MED_V2_1 or MED_V2_2)
1797 # @param overwrite boolean parameter for overwriting/not overwriting the file
1798 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1799 # @ingroup l2_impexp
1800 def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1, meshPart=None):
1802 if isinstance( meshPart, list ):
1803 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1804 self.mesh.ExportPartToMED( meshPart, f, auto_groups, version, overwrite )
1806 self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
1808 ## Exports the mesh in a file in SAUV format
1809 # @param f is the file name
1810 # @param auto_groups boolean parameter for creating/not creating
1811 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1812 # the typical use is auto_groups=false.
1813 # @ingroup l2_impexp
1814 def ExportSAUV(self, f, auto_groups=0):
1815 self.mesh.ExportSAUV(f, auto_groups)
1817 ## Exports the mesh in a file in DAT format
1818 # @param f the file name
1819 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1820 # @ingroup l2_impexp
1821 def ExportDAT(self, f, meshPart=None):
1823 if isinstance( meshPart, list ):
1824 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1825 self.mesh.ExportPartToDAT( meshPart, f )
1827 self.mesh.ExportDAT(f)
1829 ## Exports the mesh in a file in UNV format
1830 # @param f the file name
1831 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1832 # @ingroup l2_impexp
1833 def ExportUNV(self, f, meshPart=None):
1835 if isinstance( meshPart, list ):
1836 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1837 self.mesh.ExportPartToUNV( meshPart, f )
1839 self.mesh.ExportUNV(f)
1841 ## Export the mesh in a file in STL format
1842 # @param f the file name
1843 # @param ascii defines the file encoding
1844 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1845 # @ingroup l2_impexp
1846 def ExportSTL(self, f, ascii=1, meshPart=None):
1848 if isinstance( meshPart, list ):
1849 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1850 self.mesh.ExportPartToSTL( meshPart, f, ascii )
1852 self.mesh.ExportSTL(f, ascii)
1854 ## Exports the mesh in a file in CGNS format
1855 # @param f is the file name
1856 # @param overwrite boolean parameter for overwriting/not overwriting the file
1857 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1858 # @ingroup l2_impexp
1859 def ExportCGNS(self, f, overwrite=1, meshPart=None):
1860 if isinstance( meshPart, list ):
1861 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1862 if isinstance( meshPart, Mesh ):
1863 meshPart = meshPart.mesh
1865 meshPart = self.mesh
1866 self.mesh.ExportCGNS(meshPart, f, overwrite)
1868 # Operations with groups:
1869 # ----------------------
1871 ## Creates an empty mesh group
1872 # @param elementType the type of elements in the group
1873 # @param name the name of the mesh group
1874 # @return SMESH_Group
1875 # @ingroup l2_grps_create
1876 def CreateEmptyGroup(self, elementType, name):
1877 return self.mesh.CreateGroup(elementType, name)
1879 ## Creates a mesh group based on the geometric object \a grp
1880 # and gives a \a name, \n if this parameter is not defined
1881 # the name is the same as the geometric group name \n
1882 # Note: Works like GroupOnGeom().
1883 # @param grp a geometric group, a vertex, an edge, a face or a solid
1884 # @param name the name of the mesh group
1885 # @return SMESH_GroupOnGeom
1886 # @ingroup l2_grps_create
1887 def Group(self, grp, name=""):
1888 return self.GroupOnGeom(grp, name)
1890 ## Creates a mesh group based on the geometrical object \a grp
1891 # and gives a \a name, \n if this parameter is not defined
1892 # the name is the same as the geometrical group name
1893 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1894 # @param name the name of the mesh group
1895 # @param typ the type of elements in the group. If not set, it is
1896 # automatically detected by the type of the geometry
1897 # @return SMESH_GroupOnGeom
1898 # @ingroup l2_grps_create
1899 def GroupOnGeom(self, grp, name="", typ=None):
1900 AssureGeomPublished( self, grp, name )
1902 name = grp.GetName()
1904 typ = self._groupTypeFromShape( grp )
1905 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1907 ## Pivate method to get a type of group on geometry
1908 def _groupTypeFromShape( self, shape ):
1909 tgeo = str(shape.GetShapeType())
1910 if tgeo == "VERTEX":
1912 elif tgeo == "EDGE":
1914 elif tgeo == "FACE" or tgeo == "SHELL":
1916 elif tgeo == "SOLID" or tgeo == "COMPSOLID":
1918 elif tgeo == "COMPOUND":
1919 sub = self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHAPE"])
1921 raise ValueError,"_groupTypeFromShape(): empty geometric group or compound '%s'" % GetName(shape)
1922 return self._groupTypeFromShape( sub[0] )
1925 "_groupTypeFromShape(): invalid geometry '%s'" % GetName(shape)
1928 ## Creates a mesh group with given \a name based on the \a filter which
1929 ## is a special type of group dynamically updating it's contents during
1930 ## mesh modification
1931 # @param typ the type of elements in the group
1932 # @param name the name of the mesh group
1933 # @param filter the filter defining group contents
1934 # @return SMESH_GroupOnFilter
1935 # @ingroup l2_grps_create
1936 def GroupOnFilter(self, typ, name, filter):
1937 return self.mesh.CreateGroupFromFilter(typ, name, filter)
1939 ## Creates a mesh group by the given ids of elements
1940 # @param groupName the name of the mesh group
1941 # @param elementType the type of elements in the group
1942 # @param elemIDs the list of ids
1943 # @return SMESH_Group
1944 # @ingroup l2_grps_create
1945 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1946 group = self.mesh.CreateGroup(elementType, groupName)
1950 ## Creates a mesh group by the given conditions
1951 # @param groupName the name of the mesh group
1952 # @param elementType the type of elements in the group
1953 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1954 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1955 # @param Threshold the threshold value (range of id ids as string, shape, numeric)
1956 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1957 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
1958 # FT_LyingOnGeom, FT_CoplanarFaces criteria
1959 # @return SMESH_Group
1960 # @ingroup l2_grps_create
1964 CritType=FT_Undefined,
1967 UnaryOp=FT_Undefined,
1969 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Threshold, UnaryOp, FT_Undefined,Tolerance)
1970 group = self.MakeGroupByCriterion(groupName, aCriterion)
1973 ## Creates a mesh group by the given criterion
1974 # @param groupName the name of the mesh group
1975 # @param Criterion the instance of Criterion class
1976 # @return SMESH_Group
1977 # @ingroup l2_grps_create
1978 def MakeGroupByCriterion(self, groupName, Criterion):
1979 aFilterMgr = self.smeshpyD.CreateFilterManager()
1980 aFilter = aFilterMgr.CreateFilter()
1982 aCriteria.append(Criterion)
1983 aFilter.SetCriteria(aCriteria)
1984 group = self.MakeGroupByFilter(groupName, aFilter)
1985 aFilterMgr.UnRegister()
1988 ## Creates a mesh group by the given criteria (list of criteria)
1989 # @param groupName the name of the mesh group
1990 # @param theCriteria the list of criteria
1991 # @return SMESH_Group
1992 # @ingroup l2_grps_create
1993 def MakeGroupByCriteria(self, groupName, theCriteria):
1994 aFilterMgr = self.smeshpyD.CreateFilterManager()
1995 aFilter = aFilterMgr.CreateFilter()
1996 aFilter.SetCriteria(theCriteria)
1997 group = self.MakeGroupByFilter(groupName, aFilter)
1998 aFilterMgr.UnRegister()
2001 ## Creates a mesh group by the given filter
2002 # @param groupName the name of the mesh group
2003 # @param theFilter the instance of Filter class
2004 # @return SMESH_Group
2005 # @ingroup l2_grps_create
2006 def MakeGroupByFilter(self, groupName, theFilter):
2007 group = self.CreateEmptyGroup(theFilter.GetElementType(), groupName)
2008 theFilter.SetMesh( self.mesh )
2009 group.AddFrom( theFilter )
2012 ## Passes mesh elements through the given filter and return IDs of fitting elements
2013 # @param theFilter SMESH_Filter
2014 # @return a list of ids
2015 # @ingroup l1_controls
2016 def GetIdsFromFilter(self, theFilter):
2017 theFilter.SetMesh( self.mesh )
2018 return theFilter.GetIDs()
2020 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
2021 # Returns a list of special structures (borders).
2022 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
2023 # @ingroup l1_controls
2024 def GetFreeBorders(self):
2025 aFilterMgr = self.smeshpyD.CreateFilterManager()
2026 aPredicate = aFilterMgr.CreateFreeEdges()
2027 aPredicate.SetMesh(self.mesh)
2028 aBorders = aPredicate.GetBorders()
2029 aFilterMgr.UnRegister()
2033 # @ingroup l2_grps_delete
2034 def RemoveGroup(self, group):
2035 self.mesh.RemoveGroup(group)
2037 ## Removes a group with its contents
2038 # @ingroup l2_grps_delete
2039 def RemoveGroupWithContents(self, group):
2040 self.mesh.RemoveGroupWithContents(group)
2042 ## Gets the list of groups existing in the mesh
2043 # @return a sequence of SMESH_GroupBase
2044 # @ingroup l2_grps_create
2045 def GetGroups(self):
2046 return self.mesh.GetGroups()
2048 ## Gets the number of groups existing in the mesh
2049 # @return the quantity of groups as an integer value
2050 # @ingroup l2_grps_create
2052 return self.mesh.NbGroups()
2054 ## Gets the list of names of groups existing in the mesh
2055 # @return list of strings
2056 # @ingroup l2_grps_create
2057 def GetGroupNames(self):
2058 groups = self.GetGroups()
2060 for group in groups:
2061 names.append(group.GetName())
2064 ## Produces a union of two groups
2065 # A new group is created. All mesh elements that are
2066 # present in the initial groups are added to the new one
2067 # @return an instance of SMESH_Group
2068 # @ingroup l2_grps_operon
2069 def UnionGroups(self, group1, group2, name):
2070 return self.mesh.UnionGroups(group1, group2, name)
2072 ## Produces a union list of groups
2073 # New group is created. All mesh elements that are present in
2074 # initial groups are added to the new one
2075 # @return an instance of SMESH_Group
2076 # @ingroup l2_grps_operon
2077 def UnionListOfGroups(self, groups, name):
2078 return self.mesh.UnionListOfGroups(groups, name)
2080 ## Prodices an intersection of two groups
2081 # A new group is created. All mesh elements that are common
2082 # for the two initial groups are added to the new one.
2083 # @return an instance of SMESH_Group
2084 # @ingroup l2_grps_operon
2085 def IntersectGroups(self, group1, group2, name):
2086 return self.mesh.IntersectGroups(group1, group2, name)
2088 ## Produces an intersection of groups
2089 # New group is created. All mesh elements that are present in all
2090 # initial groups simultaneously are added to the new one
2091 # @return an instance of SMESH_Group
2092 # @ingroup l2_grps_operon
2093 def IntersectListOfGroups(self, groups, name):
2094 return self.mesh.IntersectListOfGroups(groups, name)
2096 ## Produces a cut of two groups
2097 # A new group is created. All mesh elements that are present in
2098 # the main group but are not present in the tool group are added to the new one
2099 # @return an instance of SMESH_Group
2100 # @ingroup l2_grps_operon
2101 def CutGroups(self, main_group, tool_group, name):
2102 return self.mesh.CutGroups(main_group, tool_group, name)
2104 ## Produces a cut of groups
2105 # A new group is created. All mesh elements that are present in main groups
2106 # but do not present in tool groups are added to the new one
2107 # @return an instance of SMESH_Group
2108 # @ingroup l2_grps_operon
2109 def CutListOfGroups(self, main_groups, tool_groups, name):
2110 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
2112 ## Produces a group of elements of specified type using list of existing groups
2113 # A new group is created. System
2114 # 1) extracts all nodes on which groups elements are built
2115 # 2) combines all elements of specified dimension laying on these nodes
2116 # @return an instance of SMESH_Group
2117 # @ingroup l2_grps_operon
2118 def CreateDimGroup(self, groups, elem_type, name):
2119 return self.mesh.CreateDimGroup(groups, elem_type, name)
2122 ## Convert group on geom into standalone group
2123 # @ingroup l2_grps_delete
2124 def ConvertToStandalone(self, group):
2125 return self.mesh.ConvertToStandalone(group)
2127 # Get some info about mesh:
2128 # ------------------------
2130 ## Returns the log of nodes and elements added or removed
2131 # since the previous clear of the log.
2132 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
2133 # @return list of log_block structures:
2138 # @ingroup l1_auxiliary
2139 def GetLog(self, clearAfterGet):
2140 return self.mesh.GetLog(clearAfterGet)
2142 ## Clears the log of nodes and elements added or removed since the previous
2143 # clear. Must be used immediately after GetLog if clearAfterGet is false.
2144 # @ingroup l1_auxiliary
2146 self.mesh.ClearLog()
2148 ## Toggles auto color mode on the object.
2149 # @param theAutoColor the flag which toggles auto color mode.
2150 # @ingroup l1_auxiliary
2151 def SetAutoColor(self, theAutoColor):
2152 self.mesh.SetAutoColor(theAutoColor)
2154 ## Gets flag of object auto color mode.
2155 # @return True or False
2156 # @ingroup l1_auxiliary
2157 def GetAutoColor(self):
2158 return self.mesh.GetAutoColor()
2160 ## Gets the internal ID
2161 # @return integer value, which is the internal Id of the mesh
2162 # @ingroup l1_auxiliary
2164 return self.mesh.GetId()
2167 # @return integer value, which is the study Id of the mesh
2168 # @ingroup l1_auxiliary
2169 def GetStudyId(self):
2170 return self.mesh.GetStudyId()
2172 ## Checks the group names for duplications.
2173 # Consider the maximum group name length stored in MED file.
2174 # @return True or False
2175 # @ingroup l1_auxiliary
2176 def HasDuplicatedGroupNamesMED(self):
2177 return self.mesh.HasDuplicatedGroupNamesMED()
2179 ## Obtains the mesh editor tool
2180 # @return an instance of SMESH_MeshEditor
2181 # @ingroup l1_modifying
2182 def GetMeshEditor(self):
2183 return self.mesh.GetMeshEditor()
2185 ## Wrap a list of IDs of elements or nodes into SMESH_IDSource which
2186 # can be passed as argument to accepting mesh, group or sub-mesh
2187 # @return an instance of SMESH_IDSource
2188 # @ingroup l1_auxiliary
2189 def GetIDSource(self, ids, elemType):
2190 return self.GetMeshEditor().MakeIDSource(ids, elemType)
2193 # @return an instance of SALOME_MED::MESH
2194 # @ingroup l1_auxiliary
2195 def GetMEDMesh(self):
2196 return self.mesh.GetMEDMesh()
2199 # Get informations about mesh contents:
2200 # ------------------------------------
2202 ## Gets the mesh stattistic
2203 # @return dictionary type element - count of elements
2204 # @ingroup l1_meshinfo
2205 def GetMeshInfo(self, obj = None):
2206 if not obj: obj = self.mesh
2207 return self.smeshpyD.GetMeshInfo(obj)
2209 ## Returns the number of nodes in the mesh
2210 # @return an integer value
2211 # @ingroup l1_meshinfo
2213 return self.mesh.NbNodes()
2215 ## Returns the number of elements in the mesh
2216 # @return an integer value
2217 # @ingroup l1_meshinfo
2218 def NbElements(self):
2219 return self.mesh.NbElements()
2221 ## Returns the number of 0d elements in the mesh
2222 # @return an integer value
2223 # @ingroup l1_meshinfo
2224 def Nb0DElements(self):
2225 return self.mesh.Nb0DElements()
2227 ## Returns the number of edges in the mesh
2228 # @return an integer value
2229 # @ingroup l1_meshinfo
2231 return self.mesh.NbEdges()
2233 ## Returns the number of edges with the given order in the mesh
2234 # @param elementOrder the order of elements:
2235 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2236 # @return an integer value
2237 # @ingroup l1_meshinfo
2238 def NbEdgesOfOrder(self, elementOrder):
2239 return self.mesh.NbEdgesOfOrder(elementOrder)
2241 ## Returns the number of faces in the mesh
2242 # @return an integer value
2243 # @ingroup l1_meshinfo
2245 return self.mesh.NbFaces()
2247 ## Returns the number of faces with the given order in the mesh
2248 # @param elementOrder the order of elements:
2249 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2250 # @return an integer value
2251 # @ingroup l1_meshinfo
2252 def NbFacesOfOrder(self, elementOrder):
2253 return self.mesh.NbFacesOfOrder(elementOrder)
2255 ## Returns the number of triangles in the mesh
2256 # @return an integer value
2257 # @ingroup l1_meshinfo
2258 def NbTriangles(self):
2259 return self.mesh.NbTriangles()
2261 ## Returns the number of triangles with the given order in the mesh
2262 # @param elementOrder is the order of elements:
2263 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2264 # @return an integer value
2265 # @ingroup l1_meshinfo
2266 def NbTrianglesOfOrder(self, elementOrder):
2267 return self.mesh.NbTrianglesOfOrder(elementOrder)
2269 ## Returns the number of quadrangles in the mesh
2270 # @return an integer value
2271 # @ingroup l1_meshinfo
2272 def NbQuadrangles(self):
2273 return self.mesh.NbQuadrangles()
2275 ## Returns the number of quadrangles with the given order in the mesh
2276 # @param elementOrder the order of elements:
2277 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2278 # @return an integer value
2279 # @ingroup l1_meshinfo
2280 def NbQuadranglesOfOrder(self, elementOrder):
2281 return self.mesh.NbQuadranglesOfOrder(elementOrder)
2283 ## Returns the number of biquadratic quadrangles in the mesh
2284 # @return an integer value
2285 # @ingroup l1_meshinfo
2286 def NbBiQuadQuadrangles(self):
2287 return self.mesh.NbBiQuadQuadrangles()
2289 ## Returns the number of polygons in the mesh
2290 # @return an integer value
2291 # @ingroup l1_meshinfo
2292 def NbPolygons(self):
2293 return self.mesh.NbPolygons()
2295 ## Returns the number of volumes in the mesh
2296 # @return an integer value
2297 # @ingroup l1_meshinfo
2298 def NbVolumes(self):
2299 return self.mesh.NbVolumes()
2301 ## Returns the number of volumes with the given order in the mesh
2302 # @param elementOrder the order of elements:
2303 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2304 # @return an integer value
2305 # @ingroup l1_meshinfo
2306 def NbVolumesOfOrder(self, elementOrder):
2307 return self.mesh.NbVolumesOfOrder(elementOrder)
2309 ## Returns the number of tetrahedrons in the mesh
2310 # @return an integer value
2311 # @ingroup l1_meshinfo
2313 return self.mesh.NbTetras()
2315 ## Returns the number of tetrahedrons with the given order in the mesh
2316 # @param elementOrder the order of elements:
2317 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2318 # @return an integer value
2319 # @ingroup l1_meshinfo
2320 def NbTetrasOfOrder(self, elementOrder):
2321 return self.mesh.NbTetrasOfOrder(elementOrder)
2323 ## Returns the number of hexahedrons in the mesh
2324 # @return an integer value
2325 # @ingroup l1_meshinfo
2327 return self.mesh.NbHexas()
2329 ## Returns the number of hexahedrons with the given order in the mesh
2330 # @param elementOrder the order of elements:
2331 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2332 # @return an integer value
2333 # @ingroup l1_meshinfo
2334 def NbHexasOfOrder(self, elementOrder):
2335 return self.mesh.NbHexasOfOrder(elementOrder)
2337 ## Returns the number of triquadratic hexahedrons in the mesh
2338 # @return an integer value
2339 # @ingroup l1_meshinfo
2340 def NbTriQuadraticHexas(self):
2341 return self.mesh.NbTriQuadraticHexas()
2343 ## Returns the number of pyramids in the mesh
2344 # @return an integer value
2345 # @ingroup l1_meshinfo
2346 def NbPyramids(self):
2347 return self.mesh.NbPyramids()
2349 ## Returns the number of pyramids with the given order in the mesh
2350 # @param elementOrder the order of elements:
2351 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2352 # @return an integer value
2353 # @ingroup l1_meshinfo
2354 def NbPyramidsOfOrder(self, elementOrder):
2355 return self.mesh.NbPyramidsOfOrder(elementOrder)
2357 ## Returns the number of prisms in the mesh
2358 # @return an integer value
2359 # @ingroup l1_meshinfo
2361 return self.mesh.NbPrisms()
2363 ## Returns the number of prisms with the given order in the mesh
2364 # @param elementOrder the order of elements:
2365 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2366 # @return an integer value
2367 # @ingroup l1_meshinfo
2368 def NbPrismsOfOrder(self, elementOrder):
2369 return self.mesh.NbPrismsOfOrder(elementOrder)
2371 ## Returns the number of hexagonal prisms in the mesh
2372 # @return an integer value
2373 # @ingroup l1_meshinfo
2374 def NbHexagonalPrisms(self):
2375 return self.mesh.NbHexagonalPrisms()
2377 ## Returns the number of polyhedrons in the mesh
2378 # @return an integer value
2379 # @ingroup l1_meshinfo
2380 def NbPolyhedrons(self):
2381 return self.mesh.NbPolyhedrons()
2383 ## Returns the number of submeshes in the mesh
2384 # @return an integer value
2385 # @ingroup l1_meshinfo
2386 def NbSubMesh(self):
2387 return self.mesh.NbSubMesh()
2389 ## Returns the list of mesh elements IDs
2390 # @return the list of integer values
2391 # @ingroup l1_meshinfo
2392 def GetElementsId(self):
2393 return self.mesh.GetElementsId()
2395 ## Returns the list of IDs of mesh elements with the given type
2396 # @param elementType the required type of elements (SMESH.NODE, SMESH.EDGE, SMESH.FACE or SMESH.VOLUME)
2397 # @return list of integer values
2398 # @ingroup l1_meshinfo
2399 def GetElementsByType(self, elementType):
2400 return self.mesh.GetElementsByType(elementType)
2402 ## Returns the list of mesh nodes IDs
2403 # @return the list of integer values
2404 # @ingroup l1_meshinfo
2405 def GetNodesId(self):
2406 return self.mesh.GetNodesId()
2408 # Get the information about mesh elements:
2409 # ------------------------------------
2411 ## Returns the type of mesh element
2412 # @return the value from SMESH::ElementType enumeration
2413 # @ingroup l1_meshinfo
2414 def GetElementType(self, id, iselem):
2415 return self.mesh.GetElementType(id, iselem)
2417 ## Returns the geometric type of mesh element
2418 # @return the value from SMESH::EntityType enumeration
2419 # @ingroup l1_meshinfo
2420 def GetElementGeomType(self, id):
2421 return self.mesh.GetElementGeomType(id)
2423 ## Returns the list of submesh elements IDs
2424 # @param Shape a geom object(sub-shape) IOR
2425 # Shape must be the sub-shape of a ShapeToMesh()
2426 # @return the list of integer values
2427 # @ingroup l1_meshinfo
2428 def GetSubMeshElementsId(self, Shape):
2429 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2430 ShapeID = Shape.GetSubShapeIndices()[0]
2433 return self.mesh.GetSubMeshElementsId(ShapeID)
2435 ## Returns the list of submesh nodes IDs
2436 # @param Shape a geom object(sub-shape) IOR
2437 # Shape must be the sub-shape of a ShapeToMesh()
2438 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
2439 # @return the list of integer values
2440 # @ingroup l1_meshinfo
2441 def GetSubMeshNodesId(self, Shape, all):
2442 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2443 ShapeID = Shape.GetSubShapeIndices()[0]
2446 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2448 ## Returns type of elements on given shape
2449 # @param Shape a geom object(sub-shape) IOR
2450 # Shape must be a sub-shape of a ShapeToMesh()
2451 # @return element type
2452 # @ingroup l1_meshinfo
2453 def GetSubMeshElementType(self, Shape):
2454 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2455 ShapeID = Shape.GetSubShapeIndices()[0]
2458 return self.mesh.GetSubMeshElementType(ShapeID)
2460 ## Gets the mesh description
2461 # @return string value
2462 # @ingroup l1_meshinfo
2464 return self.mesh.Dump()
2467 # Get the information about nodes and elements of a mesh by its IDs:
2468 # -----------------------------------------------------------
2470 ## Gets XYZ coordinates of a node
2471 # \n If there is no nodes for the given ID - returns an empty list
2472 # @return a list of double precision values
2473 # @ingroup l1_meshinfo
2474 def GetNodeXYZ(self, id):
2475 return self.mesh.GetNodeXYZ(id)
2477 ## Returns list of IDs of inverse elements for the given node
2478 # \n If there is no node for the given ID - returns an empty list
2479 # @return a list of integer values
2480 # @ingroup l1_meshinfo
2481 def GetNodeInverseElements(self, id):
2482 return self.mesh.GetNodeInverseElements(id)
2484 ## @brief Returns the position of a node on the shape
2485 # @return SMESH::NodePosition
2486 # @ingroup l1_meshinfo
2487 def GetNodePosition(self,NodeID):
2488 return self.mesh.GetNodePosition(NodeID)
2490 ## If the given element is a node, returns the ID of shape
2491 # \n If there is no node for the given ID - returns -1
2492 # @return an integer value
2493 # @ingroup l1_meshinfo
2494 def GetShapeID(self, id):
2495 return self.mesh.GetShapeID(id)
2497 ## Returns the ID of the result shape after
2498 # FindShape() from SMESH_MeshEditor for the given element
2499 # \n If there is no element for the given ID - returns -1
2500 # @return an integer value
2501 # @ingroup l1_meshinfo
2502 def GetShapeIDForElem(self,id):
2503 return self.mesh.GetShapeIDForElem(id)
2505 ## Returns the number of nodes for the given element
2506 # \n If there is no element for the given ID - returns -1
2507 # @return an integer value
2508 # @ingroup l1_meshinfo
2509 def GetElemNbNodes(self, id):
2510 return self.mesh.GetElemNbNodes(id)
2512 ## Returns the node ID the given index for the given element
2513 # \n If there is no element for the given ID - returns -1
2514 # \n If there is no node for the given index - returns -2
2515 # @return an integer value
2516 # @ingroup l1_meshinfo
2517 def GetElemNode(self, id, index):
2518 return self.mesh.GetElemNode(id, index)
2520 ## Returns the IDs of nodes of the given element
2521 # @return a list of integer values
2522 # @ingroup l1_meshinfo
2523 def GetElemNodes(self, id):
2524 return self.mesh.GetElemNodes(id)
2526 ## Returns true if the given node is the medium node in the given quadratic element
2527 # @ingroup l1_meshinfo
2528 def IsMediumNode(self, elementID, nodeID):
2529 return self.mesh.IsMediumNode(elementID, nodeID)
2531 ## Returns true if the given node is the medium node in one of quadratic elements
2532 # @ingroup l1_meshinfo
2533 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2534 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2536 ## Returns the number of edges for the given element
2537 # @ingroup l1_meshinfo
2538 def ElemNbEdges(self, id):
2539 return self.mesh.ElemNbEdges(id)
2541 ## Returns the number of faces for the given element
2542 # @ingroup l1_meshinfo
2543 def ElemNbFaces(self, id):
2544 return self.mesh.ElemNbFaces(id)
2546 ## Returns nodes of given face (counted from zero) for given volumic element.
2547 # @ingroup l1_meshinfo
2548 def GetElemFaceNodes(self,elemId, faceIndex):
2549 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2551 ## Returns an element based on all given nodes.
2552 # @ingroup l1_meshinfo
2553 def FindElementByNodes(self,nodes):
2554 return self.mesh.FindElementByNodes(nodes)
2556 ## Returns true if the given element is a polygon
2557 # @ingroup l1_meshinfo
2558 def IsPoly(self, id):
2559 return self.mesh.IsPoly(id)
2561 ## Returns true if the given element is quadratic
2562 # @ingroup l1_meshinfo
2563 def IsQuadratic(self, id):
2564 return self.mesh.IsQuadratic(id)
2566 ## Returns XYZ coordinates of the barycenter of the given element
2567 # \n If there is no element for the given ID - returns an empty list
2568 # @return a list of three double values
2569 # @ingroup l1_meshinfo
2570 def BaryCenter(self, id):
2571 return self.mesh.BaryCenter(id)
2574 # Get mesh measurements information:
2575 # ------------------------------------
2577 ## Get minimum distance between two nodes, elements or distance to the origin
2578 # @param id1 first node/element id
2579 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2580 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2581 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2582 # @return minimum distance value
2583 # @sa GetMinDistance()
2584 def MinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2585 aMeasure = self.GetMinDistance(id1, id2, isElem1, isElem2)
2586 return aMeasure.value
2588 ## Get measure structure specifying minimum distance data between two objects
2589 # @param id1 first node/element id
2590 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2591 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2592 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2593 # @return Measure structure
2595 def GetMinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2597 id1 = self.editor.MakeIDSource([id1], SMESH.FACE)
2599 id1 = self.editor.MakeIDSource([id1], SMESH.NODE)
2602 id2 = self.editor.MakeIDSource([id2], SMESH.FACE)
2604 id2 = self.editor.MakeIDSource([id2], SMESH.NODE)
2609 aMeasurements = self.smeshpyD.CreateMeasurements()
2610 aMeasure = aMeasurements.MinDistance(id1, id2)
2611 aMeasurements.UnRegister()
2614 ## Get bounding box of the specified object(s)
2615 # @param objects single source object or list of source objects or list of nodes/elements IDs
2616 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2617 # @c False specifies that @a objects are nodes
2618 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
2619 # @sa GetBoundingBox()
2620 def BoundingBox(self, objects=None, isElem=False):
2621 result = self.GetBoundingBox(objects, isElem)
2625 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
2628 ## Get measure structure specifying bounding box data of the specified object(s)
2629 # @param IDs single source object or list of source objects or list of nodes/elements IDs
2630 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2631 # @c False specifies that @a objects are nodes
2632 # @return Measure structure
2634 def GetBoundingBox(self, IDs=None, isElem=False):
2637 elif isinstance(IDs, tuple):
2639 if not isinstance(IDs, list):
2641 if len(IDs) > 0 and isinstance(IDs[0], int):
2645 if isinstance(o, Mesh):
2646 srclist.append(o.mesh)
2647 elif hasattr(o, "_narrow"):
2648 src = o._narrow(SMESH.SMESH_IDSource)
2649 if src: srclist.append(src)
2651 elif isinstance(o, list):
2653 srclist.append(self.editor.MakeIDSource(o, SMESH.FACE))
2655 srclist.append(self.editor.MakeIDSource(o, SMESH.NODE))
2658 aMeasurements = self.smeshpyD.CreateMeasurements()
2659 aMeasure = aMeasurements.BoundingBox(srclist)
2660 aMeasurements.UnRegister()
2663 # Mesh edition (SMESH_MeshEditor functionality):
2664 # ---------------------------------------------
2666 ## Removes the elements from the mesh by ids
2667 # @param IDsOfElements is a list of ids of elements to remove
2668 # @return True or False
2669 # @ingroup l2_modif_del
2670 def RemoveElements(self, IDsOfElements):
2671 return self.editor.RemoveElements(IDsOfElements)
2673 ## Removes nodes from mesh by ids
2674 # @param IDsOfNodes is a list of ids of nodes to remove
2675 # @return True or False
2676 # @ingroup l2_modif_del
2677 def RemoveNodes(self, IDsOfNodes):
2678 return self.editor.RemoveNodes(IDsOfNodes)
2680 ## Removes all orphan (free) nodes from mesh
2681 # @return number of the removed nodes
2682 # @ingroup l2_modif_del
2683 def RemoveOrphanNodes(self):
2684 return self.editor.RemoveOrphanNodes()
2686 ## Add a node to the mesh by coordinates
2687 # @return Id of the new node
2688 # @ingroup l2_modif_add
2689 def AddNode(self, x, y, z):
2690 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2691 self.mesh.SetParameters(Parameters)
2692 return self.editor.AddNode( x, y, z)
2694 ## Creates a 0D element on a node with given number.
2695 # @param IDOfNode the ID of node for creation of the element.
2696 # @return the Id of the new 0D element
2697 # @ingroup l2_modif_add
2698 def Add0DElement(self, IDOfNode):
2699 return self.editor.Add0DElement(IDOfNode)
2701 ## Creates a linear or quadratic edge (this is determined
2702 # by the number of given nodes).
2703 # @param IDsOfNodes the list of node IDs for creation of the element.
2704 # The order of nodes in this list should correspond to the description
2705 # of MED. \n This description is located by the following link:
2706 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2707 # @return the Id of the new edge
2708 # @ingroup l2_modif_add
2709 def AddEdge(self, IDsOfNodes):
2710 return self.editor.AddEdge(IDsOfNodes)
2712 ## Creates a linear or quadratic face (this is determined
2713 # by the number of given nodes).
2714 # @param IDsOfNodes the list of node IDs for creation of the element.
2715 # The order of nodes in this list should correspond to the description
2716 # of MED. \n This description is located by the following link:
2717 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2718 # @return the Id of the new face
2719 # @ingroup l2_modif_add
2720 def AddFace(self, IDsOfNodes):
2721 return self.editor.AddFace(IDsOfNodes)
2723 ## Adds a polygonal face to the mesh by the list of node IDs
2724 # @param IdsOfNodes the list of node IDs for creation of the element.
2725 # @return the Id of the new face
2726 # @ingroup l2_modif_add
2727 def AddPolygonalFace(self, IdsOfNodes):
2728 return self.editor.AddPolygonalFace(IdsOfNodes)
2730 ## Creates both simple and quadratic volume (this is determined
2731 # by the number of given nodes).
2732 # @param IDsOfNodes the list of node IDs for creation of the element.
2733 # The order of nodes in this list should correspond to the description
2734 # of MED. \n This description is located by the following link:
2735 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2736 # @return the Id of the new volumic element
2737 # @ingroup l2_modif_add
2738 def AddVolume(self, IDsOfNodes):
2739 return self.editor.AddVolume(IDsOfNodes)
2741 ## Creates a volume of many faces, giving nodes for each face.
2742 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2743 # @param Quantities the list of integer values, Quantities[i]
2744 # gives the quantity of nodes in face number i.
2745 # @return the Id of the new volumic element
2746 # @ingroup l2_modif_add
2747 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2748 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2750 ## Creates a volume of many faces, giving the IDs of the existing faces.
2751 # @param IdsOfFaces the list of face IDs for volume creation.
2753 # Note: The created volume will refer only to the nodes
2754 # of the given faces, not to the faces themselves.
2755 # @return the Id of the new volumic element
2756 # @ingroup l2_modif_add
2757 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2758 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2761 ## @brief Binds a node to a vertex
2762 # @param NodeID a node ID
2763 # @param Vertex a vertex or vertex ID
2764 # @return True if succeed else raises an exception
2765 # @ingroup l2_modif_add
2766 def SetNodeOnVertex(self, NodeID, Vertex):
2767 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2768 VertexID = Vertex.GetSubShapeIndices()[0]
2772 self.editor.SetNodeOnVertex(NodeID, VertexID)
2773 except SALOME.SALOME_Exception, inst:
2774 raise ValueError, inst.details.text
2778 ## @brief Stores the node position on an edge
2779 # @param NodeID a node ID
2780 # @param Edge an edge or edge ID
2781 # @param paramOnEdge a parameter on the edge where the node is located
2782 # @return True if succeed else raises an exception
2783 # @ingroup l2_modif_add
2784 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2785 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2786 EdgeID = Edge.GetSubShapeIndices()[0]
2790 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2791 except SALOME.SALOME_Exception, inst:
2792 raise ValueError, inst.details.text
2795 ## @brief Stores node position on a face
2796 # @param NodeID a node ID
2797 # @param Face a face or face ID
2798 # @param u U parameter on the face where the node is located
2799 # @param v V parameter on the face where the node is located
2800 # @return True if succeed else raises an exception
2801 # @ingroup l2_modif_add
2802 def SetNodeOnFace(self, NodeID, Face, u, v):
2803 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2804 FaceID = Face.GetSubShapeIndices()[0]
2808 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2809 except SALOME.SALOME_Exception, inst:
2810 raise ValueError, inst.details.text
2813 ## @brief Binds a node to a solid
2814 # @param NodeID a node ID
2815 # @param Solid a solid or solid ID
2816 # @return True if succeed else raises an exception
2817 # @ingroup l2_modif_add
2818 def SetNodeInVolume(self, NodeID, Solid):
2819 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2820 SolidID = Solid.GetSubShapeIndices()[0]
2824 self.editor.SetNodeInVolume(NodeID, SolidID)
2825 except SALOME.SALOME_Exception, inst:
2826 raise ValueError, inst.details.text
2829 ## @brief Bind an element to a shape
2830 # @param ElementID an element ID
2831 # @param Shape a shape or shape ID
2832 # @return True if succeed else raises an exception
2833 # @ingroup l2_modif_add
2834 def SetMeshElementOnShape(self, ElementID, Shape):
2835 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2836 ShapeID = Shape.GetSubShapeIndices()[0]
2840 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2841 except SALOME.SALOME_Exception, inst:
2842 raise ValueError, inst.details.text
2846 ## Moves the node with the given id
2847 # @param NodeID the id of the node
2848 # @param x a new X coordinate
2849 # @param y a new Y coordinate
2850 # @param z a new Z coordinate
2851 # @return True if succeed else False
2852 # @ingroup l2_modif_movenode
2853 def MoveNode(self, NodeID, x, y, z):
2854 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2855 self.mesh.SetParameters(Parameters)
2856 return self.editor.MoveNode(NodeID, x, y, z)
2858 ## Finds the node closest to a point and moves it to a point location
2859 # @param x the X coordinate of a point
2860 # @param y the Y coordinate of a point
2861 # @param z the Z coordinate of a point
2862 # @param NodeID if specified (>0), the node with this ID is moved,
2863 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2864 # @return the ID of a node
2865 # @ingroup l2_modif_throughp
2866 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2867 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2868 self.mesh.SetParameters(Parameters)
2869 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2871 ## Finds the node closest to a point
2872 # @param x the X coordinate of a point
2873 # @param y the Y coordinate of a point
2874 # @param z the Z coordinate of a point
2875 # @return the ID of a node
2876 # @ingroup l2_modif_throughp
2877 def FindNodeClosestTo(self, x, y, z):
2878 #preview = self.mesh.GetMeshEditPreviewer()
2879 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2880 return self.editor.FindNodeClosestTo(x, y, z)
2882 ## Finds the elements where a point lays IN or ON
2883 # @param x the X coordinate of a point
2884 # @param y the Y coordinate of a point
2885 # @param z the Z coordinate of a point
2886 # @param elementType type of elements to find (SMESH.ALL type
2887 # means elements of any type excluding nodes and 0D elements)
2888 # @param meshPart a part of mesh (group, sub-mesh) to search within
2889 # @return list of IDs of found elements
2890 # @ingroup l2_modif_throughp
2891 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL, meshPart=None):
2893 return self.editor.FindAmongElementsByPoint( meshPart, x, y, z, elementType );
2895 return self.editor.FindElementsByPoint(x, y, z, elementType)
2897 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2898 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2900 def GetPointState(self, x, y, z):
2901 return self.editor.GetPointState(x, y, z)
2903 ## Finds the node closest to a point and moves it to a point location
2904 # @param x the X coordinate of a point
2905 # @param y the Y coordinate of a point
2906 # @param z the Z coordinate of a point
2907 # @return the ID of a moved node
2908 # @ingroup l2_modif_throughp
2909 def MeshToPassThroughAPoint(self, x, y, z):
2910 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2912 ## Replaces two neighbour triangles sharing Node1-Node2 link
2913 # with the triangles built on the same 4 nodes but having other common link.
2914 # @param NodeID1 the ID of the first node
2915 # @param NodeID2 the ID of the second node
2916 # @return false if proper faces were not found
2917 # @ingroup l2_modif_invdiag
2918 def InverseDiag(self, NodeID1, NodeID2):
2919 return self.editor.InverseDiag(NodeID1, NodeID2)
2921 ## Replaces two neighbour triangles sharing Node1-Node2 link
2922 # with a quadrangle built on the same 4 nodes.
2923 # @param NodeID1 the ID of the first node
2924 # @param NodeID2 the ID of the second node
2925 # @return false if proper faces were not found
2926 # @ingroup l2_modif_unitetri
2927 def DeleteDiag(self, NodeID1, NodeID2):
2928 return self.editor.DeleteDiag(NodeID1, NodeID2)
2930 ## Reorients elements by ids
2931 # @param IDsOfElements if undefined reorients all mesh elements
2932 # @return True if succeed else False
2933 # @ingroup l2_modif_changori
2934 def Reorient(self, IDsOfElements=None):
2935 if IDsOfElements == None:
2936 IDsOfElements = self.GetElementsId()
2937 return self.editor.Reorient(IDsOfElements)
2939 ## Reorients all elements of the object
2940 # @param theObject mesh, submesh or group
2941 # @return True if succeed else False
2942 # @ingroup l2_modif_changori
2943 def ReorientObject(self, theObject):
2944 if ( isinstance( theObject, Mesh )):
2945 theObject = theObject.GetMesh()
2946 return self.editor.ReorientObject(theObject)
2948 ## Fuses the neighbouring triangles into quadrangles.
2949 # @param IDsOfElements The triangles to be fused,
2950 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2951 # @param MaxAngle is the maximum angle between element normals at which the fusion
2952 # is still performed; theMaxAngle is mesured in radians.
2953 # Also it could be a name of variable which defines angle in degrees.
2954 # @return TRUE in case of success, FALSE otherwise.
2955 # @ingroup l2_modif_unitetri
2956 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2958 if isinstance(MaxAngle,str):
2960 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2962 MaxAngle = DegreesToRadians(MaxAngle)
2963 if IDsOfElements == []:
2964 IDsOfElements = self.GetElementsId()
2965 self.mesh.SetParameters(Parameters)
2967 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2968 Functor = theCriterion
2970 Functor = self.smeshpyD.GetFunctor(theCriterion)
2971 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2973 ## Fuses the neighbouring triangles of the object into quadrangles
2974 # @param theObject is mesh, submesh or group
2975 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2976 # @param MaxAngle a max angle between element normals at which the fusion
2977 # is still performed; theMaxAngle is mesured in radians.
2978 # @return TRUE in case of success, FALSE otherwise.
2979 # @ingroup l2_modif_unitetri
2980 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2981 if ( isinstance( theObject, Mesh )):
2982 theObject = theObject.GetMesh()
2983 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2985 ## Splits quadrangles into triangles.
2986 # @param IDsOfElements the faces to be splitted.
2987 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2988 # @return TRUE in case of success, FALSE otherwise.
2989 # @ingroup l2_modif_cutquadr
2990 def QuadToTri (self, IDsOfElements, theCriterion):
2991 if IDsOfElements == []:
2992 IDsOfElements = self.GetElementsId()
2993 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2995 ## Splits quadrangles into triangles.
2996 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2997 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2998 # @return TRUE in case of success, FALSE otherwise.
2999 # @ingroup l2_modif_cutquadr
3000 def QuadToTriObject (self, theObject, theCriterion):
3001 if ( isinstance( theObject, Mesh )):
3002 theObject = theObject.GetMesh()
3003 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
3005 ## Splits quadrangles into triangles.
3006 # @param IDsOfElements the faces to be splitted
3007 # @param Diag13 is used to choose a diagonal for splitting.
3008 # @return TRUE in case of success, FALSE otherwise.
3009 # @ingroup l2_modif_cutquadr
3010 def SplitQuad (self, IDsOfElements, Diag13):
3011 if IDsOfElements == []:
3012 IDsOfElements = self.GetElementsId()
3013 return self.editor.SplitQuad(IDsOfElements, Diag13)
3015 ## Splits quadrangles into triangles.
3016 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
3017 # @param Diag13 is used to choose a diagonal for splitting.
3018 # @return TRUE in case of success, FALSE otherwise.
3019 # @ingroup l2_modif_cutquadr
3020 def SplitQuadObject (self, theObject, Diag13):
3021 if ( isinstance( theObject, Mesh )):
3022 theObject = theObject.GetMesh()
3023 return self.editor.SplitQuadObject(theObject, Diag13)
3025 ## Finds a better splitting of the given quadrangle.
3026 # @param IDOfQuad the ID of the quadrangle to be splitted.
3027 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
3028 # @return 1 if 1-3 diagonal is better, 2 if 2-4
3029 # diagonal is better, 0 if error occurs.
3030 # @ingroup l2_modif_cutquadr
3031 def BestSplit (self, IDOfQuad, theCriterion):
3032 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
3034 ## Splits volumic elements into tetrahedrons
3035 # @param elemIDs either list of elements or mesh or group or submesh
3036 # @param method flags passing splitting method: Hex_5Tet, Hex_6Tet, Hex_24Tet
3037 # Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc
3038 # @ingroup l2_modif_cutquadr
3039 def SplitVolumesIntoTetra(self, elemIDs, method=Hex_5Tet ):
3040 if isinstance( elemIDs, Mesh ):
3041 elemIDs = elemIDs.GetMesh()
3042 if ( isinstance( elemIDs, list )):
3043 elemIDs = self.editor.MakeIDSource(elemIDs, SMESH.VOLUME)
3044 self.editor.SplitVolumesIntoTetra(elemIDs, method)
3046 ## Splits quadrangle faces near triangular facets of volumes
3048 # @ingroup l1_auxiliary
3049 def SplitQuadsNearTriangularFacets(self):
3050 faces_array = self.GetElementsByType(SMESH.FACE)
3051 for face_id in faces_array:
3052 if self.GetElemNbNodes(face_id) == 4: # quadrangle
3053 quad_nodes = self.mesh.GetElemNodes(face_id)
3054 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
3055 isVolumeFound = False
3056 for node1_elem in node1_elems:
3057 if not isVolumeFound:
3058 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
3059 nb_nodes = self.GetElemNbNodes(node1_elem)
3060 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
3061 volume_elem = node1_elem
3062 volume_nodes = self.mesh.GetElemNodes(volume_elem)
3063 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
3064 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
3065 isVolumeFound = True
3066 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
3067 self.SplitQuad([face_id], False) # diagonal 2-4
3068 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
3069 isVolumeFound = True
3070 self.SplitQuad([face_id], True) # diagonal 1-3
3071 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
3072 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
3073 isVolumeFound = True
3074 self.SplitQuad([face_id], True) # diagonal 1-3
3076 ## @brief Splits hexahedrons into tetrahedrons.
3078 # This operation uses pattern mapping functionality for splitting.
3079 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
3080 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
3081 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
3082 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
3083 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
3084 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
3085 # @return TRUE in case of success, FALSE otherwise.
3086 # @ingroup l1_auxiliary
3087 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
3088 # Pattern: 5.---------.6
3093 # (0,0,1) 4.---------.7 * |
3100 # (0,0,0) 0.---------.3
3101 pattern_tetra = "!!! Nb of points: \n 8 \n\
3111 !!! Indices of points of 6 tetras: \n\
3119 pattern = self.smeshpyD.GetPattern()
3120 isDone = pattern.LoadFromFile(pattern_tetra)
3122 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
3125 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
3126 isDone = pattern.MakeMesh(self.mesh, False, False)
3127 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
3129 # split quafrangle faces near triangular facets of volumes
3130 self.SplitQuadsNearTriangularFacets()
3134 ## @brief Split hexahedrons into prisms.
3136 # Uses the pattern mapping functionality for splitting.
3137 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
3138 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
3139 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
3140 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
3141 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
3142 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
3143 # @return TRUE in case of success, FALSE otherwise.
3144 # @ingroup l1_auxiliary
3145 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
3146 # Pattern: 5.---------.6
3151 # (0,0,1) 4.---------.7 |
3158 # (0,0,0) 0.---------.3
3159 pattern_prism = "!!! Nb of points: \n 8 \n\
3169 !!! Indices of points of 2 prisms: \n\
3173 pattern = self.smeshpyD.GetPattern()
3174 isDone = pattern.LoadFromFile(pattern_prism)
3176 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
3179 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
3180 isDone = pattern.MakeMesh(self.mesh, False, False)
3181 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
3183 # Splits quafrangle faces near triangular facets of volumes
3184 self.SplitQuadsNearTriangularFacets()
3188 ## Smoothes elements
3189 # @param IDsOfElements the list if ids of elements to smooth
3190 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3191 # Note that nodes built on edges and boundary nodes are always fixed.
3192 # @param MaxNbOfIterations the maximum number of iterations
3193 # @param MaxAspectRatio varies in range [1.0, inf]
3194 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3195 # @return TRUE in case of success, FALSE otherwise.
3196 # @ingroup l2_modif_smooth
3197 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
3198 MaxNbOfIterations, MaxAspectRatio, Method):
3199 if IDsOfElements == []:
3200 IDsOfElements = self.GetElementsId()
3201 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
3202 self.mesh.SetParameters(Parameters)
3203 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
3204 MaxNbOfIterations, MaxAspectRatio, Method)
3206 ## Smoothes elements which belong to the given object
3207 # @param theObject the object to smooth
3208 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3209 # Note that nodes built on edges and boundary nodes are always fixed.
3210 # @param MaxNbOfIterations the maximum number of iterations
3211 # @param MaxAspectRatio varies in range [1.0, inf]
3212 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3213 # @return TRUE in case of success, FALSE otherwise.
3214 # @ingroup l2_modif_smooth
3215 def SmoothObject(self, theObject, IDsOfFixedNodes,
3216 MaxNbOfIterations, MaxAspectRatio, Method):
3217 if ( isinstance( theObject, Mesh )):
3218 theObject = theObject.GetMesh()
3219 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
3220 MaxNbOfIterations, MaxAspectRatio, Method)
3222 ## Parametrically smoothes the given elements
3223 # @param IDsOfElements the list if ids of elements to smooth
3224 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3225 # Note that nodes built on edges and boundary nodes are always fixed.
3226 # @param MaxNbOfIterations the maximum number of iterations
3227 # @param MaxAspectRatio varies in range [1.0, inf]
3228 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3229 # @return TRUE in case of success, FALSE otherwise.
3230 # @ingroup l2_modif_smooth
3231 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
3232 MaxNbOfIterations, MaxAspectRatio, Method):
3233 if IDsOfElements == []:
3234 IDsOfElements = self.GetElementsId()
3235 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
3236 self.mesh.SetParameters(Parameters)
3237 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
3238 MaxNbOfIterations, MaxAspectRatio, Method)
3240 ## Parametrically smoothes the elements which belong to the given object
3241 # @param theObject the object to smooth
3242 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3243 # Note that nodes built on edges and boundary nodes are always fixed.
3244 # @param MaxNbOfIterations the maximum number of iterations
3245 # @param MaxAspectRatio varies in range [1.0, inf]
3246 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3247 # @return TRUE in case of success, FALSE otherwise.
3248 # @ingroup l2_modif_smooth
3249 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
3250 MaxNbOfIterations, MaxAspectRatio, Method):
3251 if ( isinstance( theObject, Mesh )):
3252 theObject = theObject.GetMesh()
3253 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
3254 MaxNbOfIterations, MaxAspectRatio, Method)
3256 ## Converts the mesh to quadratic, deletes old elements, replacing
3257 # them with quadratic with the same id.
3258 # @param theForce3d new node creation method:
3259 # 0 - the medium node lies at the geometrical entity from which the mesh element is built
3260 # 1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element
3261 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
3262 # @ingroup l2_modif_tofromqu
3263 def ConvertToQuadratic(self, theForce3d, theSubMesh=None):
3265 self.editor.ConvertToQuadraticObject(theForce3d,theSubMesh)
3267 self.editor.ConvertToQuadratic(theForce3d)
3269 ## Converts the mesh from quadratic to ordinary,
3270 # deletes old quadratic elements, \n replacing
3271 # them with ordinary mesh elements with the same id.
3272 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
3273 # @ingroup l2_modif_tofromqu
3274 def ConvertFromQuadratic(self, theSubMesh=None):
3276 self.editor.ConvertFromQuadraticObject(theSubMesh)
3278 return self.editor.ConvertFromQuadratic()
3280 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
3281 # @return TRUE if operation has been completed successfully, FALSE otherwise
3282 # @ingroup l2_modif_edit
3283 def Make2DMeshFrom3D(self):
3284 return self.editor. Make2DMeshFrom3D()
3286 ## Creates missing boundary elements
3287 # @param elements - elements whose boundary is to be checked:
3288 # mesh, group, sub-mesh or list of elements
3289 # if elements is mesh, it must be the mesh whose MakeBoundaryMesh() is called
3290 # @param dimension - defines type of boundary elements to create:
3291 # SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D
3292 # SMESH.BND_1DFROM3D creates mesh edges on all borders of free facets of 3D cells
3293 # @param groupName - a name of group to store created boundary elements in,
3294 # "" means not to create the group
3295 # @param meshName - a name of new mesh to store created boundary elements in,
3296 # "" means not to create the new mesh
3297 # @param toCopyElements - if true, the checked elements will be copied into
3298 # the new mesh else only boundary elements will be copied into the new mesh
3299 # @param toCopyExistingBondary - if true, not only new but also pre-existing
3300 # boundary elements will be copied into the new mesh
3301 # @return tuple (mesh, group) where bondary elements were added to
3302 # @ingroup l2_modif_edit
3303 def MakeBoundaryMesh(self, elements, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3304 toCopyElements=False, toCopyExistingBondary=False):
3305 if isinstance( elements, Mesh ):
3306 elements = elements.GetMesh()
3307 if ( isinstance( elements, list )):
3308 elemType = SMESH.ALL
3309 if elements: elemType = self.GetElementType( elements[0], iselem=True)
3310 elements = self.editor.MakeIDSource(elements, elemType)
3311 mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName,
3312 toCopyElements,toCopyExistingBondary)
3313 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3317 # @brief Creates missing boundary elements around either the whole mesh or
3318 # groups of 2D elements
3319 # @param dimension - defines type of boundary elements to create
3320 # @param groupName - a name of group to store all boundary elements in,
3321 # "" means not to create the group
3322 # @param meshName - a name of a new mesh, which is a copy of the initial
3323 # mesh + created boundary elements; "" means not to create the new mesh
3324 # @param toCopyAll - if true, the whole initial mesh will be copied into
3325 # the new mesh else only boundary elements will be copied into the new mesh
3326 # @param groups - groups of 2D elements to make boundary around
3327 # @retval tuple( long, mesh, groups )
3328 # long - number of added boundary elements
3329 # mesh - the mesh where elements were added to
3330 # group - the group of boundary elements or None
3332 def MakeBoundaryElements(self, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3333 toCopyAll=False, groups=[]):
3334 nb, mesh, group = self.editor.MakeBoundaryElements(dimension,groupName,meshName,
3336 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3337 return nb, mesh, group
3339 ## Renumber mesh nodes
3340 # @ingroup l2_modif_renumber
3341 def RenumberNodes(self):
3342 self.editor.RenumberNodes()
3344 ## Renumber mesh elements
3345 # @ingroup l2_modif_renumber
3346 def RenumberElements(self):
3347 self.editor.RenumberElements()
3349 ## Generates new elements by rotation of the elements around the axis
3350 # @param IDsOfElements the list of ids of elements to sweep
3351 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3352 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
3353 # @param NbOfSteps the number of steps
3354 # @param Tolerance tolerance
3355 # @param MakeGroups forces the generation of new groups from existing ones
3356 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3357 # of all steps, else - size of each step
3358 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3359 # @ingroup l2_modif_extrurev
3360 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
3361 MakeGroups=False, TotalAngle=False):
3363 if isinstance(AngleInRadians,str):
3365 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3367 AngleInRadians = DegreesToRadians(AngleInRadians)
3368 if IDsOfElements == []:
3369 IDsOfElements = self.GetElementsId()
3370 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3371 Axis = self.smeshpyD.GetAxisStruct(Axis)
3372 Axis,AxisParameters = ParseAxisStruct(Axis)
3373 if TotalAngle and NbOfSteps:
3374 AngleInRadians /= NbOfSteps
3375 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3376 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3377 self.mesh.SetParameters(Parameters)
3379 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
3380 AngleInRadians, NbOfSteps, Tolerance)
3381 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
3384 ## Generates new elements by rotation of the elements of object around the axis
3385 # @param theObject object which elements should be sweeped.
3386 # It can be a mesh, a sub mesh or a group.
3387 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3388 # @param AngleInRadians the angle of Rotation
3389 # @param NbOfSteps number of steps
3390 # @param Tolerance tolerance
3391 # @param MakeGroups forces the generation of new groups from existing ones
3392 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3393 # of all steps, else - size of each step
3394 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3395 # @ingroup l2_modif_extrurev
3396 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3397 MakeGroups=False, TotalAngle=False):
3399 if isinstance(AngleInRadians,str):
3401 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3403 AngleInRadians = DegreesToRadians(AngleInRadians)
3404 if ( isinstance( theObject, Mesh )):
3405 theObject = theObject.GetMesh()
3406 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3407 Axis = self.smeshpyD.GetAxisStruct(Axis)
3408 Axis,AxisParameters = ParseAxisStruct(Axis)
3409 if TotalAngle and NbOfSteps:
3410 AngleInRadians /= NbOfSteps
3411 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3412 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3413 self.mesh.SetParameters(Parameters)
3415 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
3416 NbOfSteps, Tolerance)
3417 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3420 ## Generates new elements by rotation of the elements of object around the axis
3421 # @param theObject object which elements should be sweeped.
3422 # It can be a mesh, a sub mesh or a group.
3423 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3424 # @param AngleInRadians the angle of Rotation
3425 # @param NbOfSteps number of steps
3426 # @param Tolerance tolerance
3427 # @param MakeGroups forces the generation of new groups from existing ones
3428 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3429 # of all steps, else - size of each step
3430 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3431 # @ingroup l2_modif_extrurev
3432 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3433 MakeGroups=False, TotalAngle=False):
3435 if isinstance(AngleInRadians,str):
3437 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3439 AngleInRadians = DegreesToRadians(AngleInRadians)
3440 if ( isinstance( theObject, Mesh )):
3441 theObject = theObject.GetMesh()
3442 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3443 Axis = self.smeshpyD.GetAxisStruct(Axis)
3444 Axis,AxisParameters = ParseAxisStruct(Axis)
3445 if TotalAngle and NbOfSteps:
3446 AngleInRadians /= NbOfSteps
3447 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3448 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3449 self.mesh.SetParameters(Parameters)
3451 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
3452 NbOfSteps, Tolerance)
3453 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3456 ## Generates new elements by rotation of the elements of object around the axis
3457 # @param theObject object which elements should be sweeped.
3458 # It can be a mesh, a sub mesh or a group.
3459 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3460 # @param AngleInRadians the angle of Rotation
3461 # @param NbOfSteps number of steps
3462 # @param Tolerance tolerance
3463 # @param MakeGroups forces the generation of new groups from existing ones
3464 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3465 # of all steps, else - size of each step
3466 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3467 # @ingroup l2_modif_extrurev
3468 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3469 MakeGroups=False, TotalAngle=False):
3471 if isinstance(AngleInRadians,str):
3473 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3475 AngleInRadians = DegreesToRadians(AngleInRadians)
3476 if ( isinstance( theObject, Mesh )):
3477 theObject = theObject.GetMesh()
3478 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3479 Axis = self.smeshpyD.GetAxisStruct(Axis)
3480 Axis,AxisParameters = ParseAxisStruct(Axis)
3481 if TotalAngle and NbOfSteps:
3482 AngleInRadians /= NbOfSteps
3483 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3484 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3485 self.mesh.SetParameters(Parameters)
3487 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
3488 NbOfSteps, Tolerance)
3489 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3492 ## Generates new elements by extrusion of the elements with given ids
3493 # @param IDsOfElements the list of elements ids for extrusion
3494 # @param StepVector vector or DirStruct, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3495 # @param NbOfSteps the number of steps
3496 # @param MakeGroups forces the generation of new groups from existing ones
3497 # @param IsNodes is True if elements with given ids are nodes
3498 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3499 # @ingroup l2_modif_extrurev
3500 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False, IsNodes = False):
3501 if IDsOfElements == []:
3502 IDsOfElements = self.GetElementsId()
3503 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3504 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3505 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3506 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3507 Parameters = StepVectorParameters + var_separator + Parameters
3508 self.mesh.SetParameters(Parameters)
3511 return self.editor.ExtrusionSweepMakeGroups0D(IDsOfElements, StepVector, NbOfSteps)
3513 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
3515 self.editor.ExtrusionSweep0D(IDsOfElements, StepVector, NbOfSteps)
3517 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
3520 ## Generates new elements by extrusion of the elements with given ids
3521 # @param IDsOfElements is ids of elements
3522 # @param StepVector vector, defining the direction and value of extrusion
3523 # @param NbOfSteps the number of steps
3524 # @param ExtrFlags sets flags for extrusion
3525 # @param SewTolerance uses for comparing locations of nodes if flag
3526 # EXTRUSION_FLAG_SEW is set
3527 # @param MakeGroups forces the generation of new groups from existing ones
3528 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3529 # @ingroup l2_modif_extrurev
3530 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
3531 ExtrFlags, SewTolerance, MakeGroups=False):
3532 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3533 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3535 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
3536 ExtrFlags, SewTolerance)
3537 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
3538 ExtrFlags, SewTolerance)
3541 ## Generates new elements by extrusion of the elements which belong to the object
3542 # @param theObject the object which elements should be processed.
3543 # It can be a mesh, a sub mesh or a group.
3544 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3545 # @param NbOfSteps the number of steps
3546 # @param MakeGroups forces the generation of new groups from existing ones
3547 # @param IsNodes is True if elements which belong to the object are nodes
3548 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3549 # @ingroup l2_modif_extrurev
3550 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False, IsNodes=False):
3551 if ( isinstance( theObject, Mesh )):
3552 theObject = theObject.GetMesh()
3553 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3554 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3555 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3556 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3557 Parameters = StepVectorParameters + var_separator + Parameters
3558 self.mesh.SetParameters(Parameters)
3561 return self.editor.ExtrusionSweepObject0DMakeGroups(theObject, StepVector, NbOfSteps)
3563 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3565 self.editor.ExtrusionSweepObject0D(theObject, StepVector, NbOfSteps)
3567 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
3570 ## Generates new elements by extrusion of the elements which belong to the object
3571 # @param theObject object which elements should be processed.
3572 # It can be a mesh, a sub mesh or a group.
3573 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3574 # @param NbOfSteps the number of steps
3575 # @param MakeGroups to generate new groups from existing ones
3576 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3577 # @ingroup l2_modif_extrurev
3578 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3579 if ( isinstance( theObject, Mesh )):
3580 theObject = theObject.GetMesh()
3581 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3582 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3583 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3584 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3585 Parameters = StepVectorParameters + var_separator + Parameters
3586 self.mesh.SetParameters(Parameters)
3588 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3589 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3592 ## Generates new elements by extrusion of the elements which belong to the object
3593 # @param theObject object which elements should be processed.
3594 # It can be a mesh, a sub mesh or a group.
3595 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3596 # @param NbOfSteps the number of steps
3597 # @param MakeGroups forces the generation of new groups from existing ones
3598 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3599 # @ingroup l2_modif_extrurev
3600 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3601 if ( isinstance( theObject, Mesh )):
3602 theObject = theObject.GetMesh()
3603 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3604 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3605 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3606 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3607 Parameters = StepVectorParameters + var_separator + Parameters
3608 self.mesh.SetParameters(Parameters)
3610 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3611 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3616 ## Generates new elements by extrusion of the given elements
3617 # The path of extrusion must be a meshed edge.
3618 # @param Base mesh or group, or submesh, or list of ids of elements for extrusion
3619 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3620 # @param NodeStart the start node from Path. Defines the direction of extrusion
3621 # @param HasAngles allows the shape to be rotated around the path
3622 # to get the resulting mesh in a helical fashion
3623 # @param Angles list of angles in radians
3624 # @param LinearVariation forces the computation of rotation angles as linear
3625 # variation of the given Angles along path steps
3626 # @param HasRefPoint allows using the reference point
3627 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3628 # The User can specify any point as the Reference Point.
3629 # @param MakeGroups forces the generation of new groups from existing ones
3630 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3631 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3632 # only SMESH::Extrusion_Error otherwise
3633 # @ingroup l2_modif_extrurev
3634 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3635 HasAngles, Angles, LinearVariation,
3636 HasRefPoint, RefPoint, MakeGroups, ElemType):
3637 Angles,AnglesParameters = ParseAngles(Angles)
3638 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3639 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3640 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3642 Parameters = AnglesParameters + var_separator + RefPointParameters
3643 self.mesh.SetParameters(Parameters)
3645 if (isinstance(Path, Mesh)): Path = Path.GetMesh()
3647 if isinstance(Base, list):
3649 if Base == []: IDsOfElements = self.GetElementsId()
3650 else: IDsOfElements = Base
3651 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3652 HasAngles, Angles, LinearVariation,
3653 HasRefPoint, RefPoint, MakeGroups, ElemType)
3655 if isinstance(Base, Mesh): Base = Base.GetMesh()
3656 if isinstance(Base, SMESH._objref_SMESH_Mesh) or isinstance(Base, SMESH._objref_SMESH_Group) or isinstance(Base, SMESH._objref_SMESH_subMesh):
3657 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3658 HasAngles, Angles, LinearVariation,
3659 HasRefPoint, RefPoint, MakeGroups, ElemType)
3661 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3664 ## Generates new elements by extrusion of the given elements
3665 # The path of extrusion must be a meshed edge.
3666 # @param IDsOfElements ids of elements
3667 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3668 # @param PathShape shape(edge) defines the sub-mesh for the path
3669 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3670 # @param HasAngles allows the shape to be rotated around the path
3671 # to get the resulting mesh in a helical fashion
3672 # @param Angles list of angles in radians
3673 # @param HasRefPoint allows using the reference point
3674 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3675 # The User can specify any point as the Reference Point.
3676 # @param MakeGroups forces the generation of new groups from existing ones
3677 # @param LinearVariation forces the computation of rotation angles as linear
3678 # variation of the given Angles along path steps
3679 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3680 # only SMESH::Extrusion_Error otherwise
3681 # @ingroup l2_modif_extrurev
3682 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3683 HasAngles, Angles, HasRefPoint, RefPoint,
3684 MakeGroups=False, LinearVariation=False):
3685 Angles,AnglesParameters = ParseAngles(Angles)
3686 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3687 if IDsOfElements == []:
3688 IDsOfElements = self.GetElementsId()
3689 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3690 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3692 if ( isinstance( PathMesh, Mesh )):
3693 PathMesh = PathMesh.GetMesh()
3694 if HasAngles and Angles and LinearVariation:
3695 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3697 Parameters = AnglesParameters + var_separator + RefPointParameters
3698 self.mesh.SetParameters(Parameters)
3700 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3701 PathShape, NodeStart, HasAngles,
3702 Angles, HasRefPoint, RefPoint)
3703 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3704 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3706 ## Generates new elements by extrusion of the elements which belong to the object
3707 # The path of extrusion must be a meshed edge.
3708 # @param theObject the object which elements should be processed.
3709 # It can be a mesh, a sub mesh or a group.
3710 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3711 # @param PathShape shape(edge) defines the sub-mesh for the path
3712 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3713 # @param HasAngles allows the shape to be rotated around the path
3714 # to get the resulting mesh in a helical fashion
3715 # @param Angles list of angles
3716 # @param HasRefPoint allows using the reference point
3717 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3718 # The User can specify any point as the Reference Point.
3719 # @param MakeGroups forces the generation of new groups from existing ones
3720 # @param LinearVariation forces the computation of rotation angles as linear
3721 # variation of the given Angles along path steps
3722 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3723 # only SMESH::Extrusion_Error otherwise
3724 # @ingroup l2_modif_extrurev
3725 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3726 HasAngles, Angles, HasRefPoint, RefPoint,
3727 MakeGroups=False, LinearVariation=False):
3728 Angles,AnglesParameters = ParseAngles(Angles)
3729 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3730 if ( isinstance( theObject, Mesh )):
3731 theObject = theObject.GetMesh()
3732 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3733 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3734 if ( isinstance( PathMesh, Mesh )):
3735 PathMesh = PathMesh.GetMesh()
3736 if HasAngles and Angles and LinearVariation:
3737 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3739 Parameters = AnglesParameters + var_separator + RefPointParameters
3740 self.mesh.SetParameters(Parameters)
3742 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3743 PathShape, NodeStart, HasAngles,
3744 Angles, HasRefPoint, RefPoint)
3745 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3746 NodeStart, HasAngles, Angles, HasRefPoint,
3749 ## Generates new elements by extrusion of the elements which belong to the object
3750 # The path of extrusion must be a meshed edge.
3751 # @param theObject the object which elements should be processed.
3752 # It can be a mesh, a sub mesh or a group.
3753 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3754 # @param PathShape shape(edge) defines the sub-mesh for the path
3755 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3756 # @param HasAngles allows the shape to be rotated around the path
3757 # to get the resulting mesh in a helical fashion
3758 # @param Angles list of angles
3759 # @param HasRefPoint allows using the reference point
3760 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3761 # The User can specify any point as the Reference Point.
3762 # @param MakeGroups forces the generation of new groups from existing ones
3763 # @param LinearVariation forces the computation of rotation angles as linear
3764 # variation of the given Angles along path steps
3765 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3766 # only SMESH::Extrusion_Error otherwise
3767 # @ingroup l2_modif_extrurev
3768 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3769 HasAngles, Angles, HasRefPoint, RefPoint,
3770 MakeGroups=False, LinearVariation=False):
3771 Angles,AnglesParameters = ParseAngles(Angles)
3772 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3773 if ( isinstance( theObject, Mesh )):
3774 theObject = theObject.GetMesh()
3775 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3776 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3777 if ( isinstance( PathMesh, Mesh )):
3778 PathMesh = PathMesh.GetMesh()
3779 if HasAngles and Angles and LinearVariation:
3780 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3782 Parameters = AnglesParameters + var_separator + RefPointParameters
3783 self.mesh.SetParameters(Parameters)
3785 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3786 PathShape, NodeStart, HasAngles,
3787 Angles, HasRefPoint, RefPoint)
3788 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3789 NodeStart, HasAngles, Angles, HasRefPoint,
3792 ## Generates new elements by extrusion of the elements which belong to the object
3793 # The path of extrusion must be a meshed edge.
3794 # @param theObject the object which elements should be processed.
3795 # It can be a mesh, a sub mesh or a group.
3796 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3797 # @param PathShape shape(edge) defines the sub-mesh for the path
3798 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3799 # @param HasAngles allows the shape to be rotated around the path
3800 # to get the resulting mesh in a helical fashion
3801 # @param Angles list of angles
3802 # @param HasRefPoint allows using the reference point
3803 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3804 # The User can specify any point as the Reference Point.
3805 # @param MakeGroups forces the generation of new groups from existing ones
3806 # @param LinearVariation forces the computation of rotation angles as linear
3807 # variation of the given Angles along path steps
3808 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3809 # only SMESH::Extrusion_Error otherwise
3810 # @ingroup l2_modif_extrurev
3811 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3812 HasAngles, Angles, HasRefPoint, RefPoint,
3813 MakeGroups=False, LinearVariation=False):
3814 Angles,AnglesParameters = ParseAngles(Angles)
3815 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3816 if ( isinstance( theObject, Mesh )):
3817 theObject = theObject.GetMesh()
3818 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3819 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3820 if ( isinstance( PathMesh, Mesh )):
3821 PathMesh = PathMesh.GetMesh()
3822 if HasAngles and Angles and LinearVariation:
3823 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3825 Parameters = AnglesParameters + var_separator + RefPointParameters
3826 self.mesh.SetParameters(Parameters)
3828 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3829 PathShape, NodeStart, HasAngles,
3830 Angles, HasRefPoint, RefPoint)
3831 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3832 NodeStart, HasAngles, Angles, HasRefPoint,
3835 ## Creates a symmetrical copy of mesh elements
3836 # @param IDsOfElements list of elements ids
3837 # @param Mirror is AxisStruct or geom object(point, line, plane)
3838 # @param theMirrorType is POINT, AXIS or PLANE
3839 # If the Mirror is a geom object this parameter is unnecessary
3840 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3841 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3842 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3843 # @ingroup l2_modif_trsf
3844 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3845 if IDsOfElements == []:
3846 IDsOfElements = self.GetElementsId()
3847 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3848 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3849 Mirror,Parameters = ParseAxisStruct(Mirror)
3850 self.mesh.SetParameters(Parameters)
3851 if Copy and MakeGroups:
3852 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3853 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3856 ## Creates a new mesh by a symmetrical copy of mesh elements
3857 # @param IDsOfElements the list of elements ids
3858 # @param Mirror is AxisStruct or geom object (point, line, plane)
3859 # @param theMirrorType is POINT, AXIS or PLANE
3860 # If the Mirror is a geom object this parameter is unnecessary
3861 # @param MakeGroups to generate new groups from existing ones
3862 # @param NewMeshName a name of the new mesh to create
3863 # @return instance of Mesh class
3864 # @ingroup l2_modif_trsf
3865 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3866 if IDsOfElements == []:
3867 IDsOfElements = self.GetElementsId()
3868 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3869 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3870 Mirror,Parameters = ParseAxisStruct(Mirror)
3871 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3872 MakeGroups, NewMeshName)
3873 mesh.SetParameters(Parameters)
3874 return Mesh(self.smeshpyD,self.geompyD,mesh)
3876 ## Creates a symmetrical copy of the object
3877 # @param theObject mesh, submesh or group
3878 # @param Mirror AxisStruct or geom object (point, line, plane)
3879 # @param theMirrorType is POINT, AXIS or PLANE
3880 # If the Mirror is a geom object this parameter is unnecessary
3881 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3882 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3883 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3884 # @ingroup l2_modif_trsf
3885 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3886 if ( isinstance( theObject, Mesh )):
3887 theObject = theObject.GetMesh()
3888 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3889 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3890 Mirror,Parameters = ParseAxisStruct(Mirror)
3891 self.mesh.SetParameters(Parameters)
3892 if Copy and MakeGroups:
3893 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3894 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3897 ## Creates a new mesh by a symmetrical copy of the object
3898 # @param theObject mesh, submesh or group
3899 # @param Mirror AxisStruct or geom object (point, line, plane)
3900 # @param theMirrorType POINT, AXIS or PLANE
3901 # If the Mirror is a geom object this parameter is unnecessary
3902 # @param MakeGroups forces the generation of new groups from existing ones
3903 # @param NewMeshName the name of the new mesh to create
3904 # @return instance of Mesh class
3905 # @ingroup l2_modif_trsf
3906 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3907 if ( isinstance( theObject, Mesh )):
3908 theObject = theObject.GetMesh()
3909 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3910 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3911 Mirror,Parameters = ParseAxisStruct(Mirror)
3912 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3913 MakeGroups, NewMeshName)
3914 mesh.SetParameters(Parameters)
3915 return Mesh( self.smeshpyD,self.geompyD,mesh )
3917 ## Translates the elements
3918 # @param IDsOfElements list of elements ids
3919 # @param Vector the direction of translation (DirStruct or vector)
3920 # @param Copy allows copying the translated elements
3921 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3922 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3923 # @ingroup l2_modif_trsf
3924 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3925 if IDsOfElements == []:
3926 IDsOfElements = self.GetElementsId()
3927 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3928 Vector = self.smeshpyD.GetDirStruct(Vector)
3929 Vector,Parameters = ParseDirStruct(Vector)
3930 self.mesh.SetParameters(Parameters)
3931 if Copy and MakeGroups:
3932 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3933 self.editor.Translate(IDsOfElements, Vector, Copy)
3936 ## Creates a new mesh of translated elements
3937 # @param IDsOfElements list of elements ids
3938 # @param Vector the direction of translation (DirStruct or vector)
3939 # @param MakeGroups forces the generation of new groups from existing ones
3940 # @param NewMeshName the name of the newly created mesh
3941 # @return instance of Mesh class
3942 # @ingroup l2_modif_trsf
3943 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3944 if IDsOfElements == []:
3945 IDsOfElements = self.GetElementsId()
3946 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3947 Vector = self.smeshpyD.GetDirStruct(Vector)
3948 Vector,Parameters = ParseDirStruct(Vector)
3949 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3950 mesh.SetParameters(Parameters)
3951 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3953 ## Translates the object
3954 # @param theObject the object to translate (mesh, submesh, or group)
3955 # @param Vector direction of translation (DirStruct or geom vector)
3956 # @param Copy allows copying the translated elements
3957 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3958 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3959 # @ingroup l2_modif_trsf
3960 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3961 if ( isinstance( theObject, Mesh )):
3962 theObject = theObject.GetMesh()
3963 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3964 Vector = self.smeshpyD.GetDirStruct(Vector)
3965 Vector,Parameters = ParseDirStruct(Vector)
3966 self.mesh.SetParameters(Parameters)
3967 if Copy and MakeGroups:
3968 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3969 self.editor.TranslateObject(theObject, Vector, Copy)
3972 ## Creates a new mesh from the translated object
3973 # @param theObject the object to translate (mesh, submesh, or group)
3974 # @param Vector the direction of translation (DirStruct or geom vector)
3975 # @param MakeGroups forces the generation of new groups from existing ones
3976 # @param NewMeshName the name of the newly created mesh
3977 # @return instance of Mesh class
3978 # @ingroup l2_modif_trsf
3979 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3980 if (isinstance(theObject, Mesh)):
3981 theObject = theObject.GetMesh()
3982 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3983 Vector = self.smeshpyD.GetDirStruct(Vector)
3984 Vector,Parameters = ParseDirStruct(Vector)
3985 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3986 mesh.SetParameters(Parameters)
3987 return Mesh( self.smeshpyD, self.geompyD, mesh )
3991 ## Scales the object
3992 # @param theObject - the object to translate (mesh, submesh, or group)
3993 # @param thePoint - base point for scale
3994 # @param theScaleFact - list of 1-3 scale factors for axises
3995 # @param Copy - allows copying the translated elements
3996 # @param MakeGroups - forces the generation of new groups from existing
3998 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3999 # empty list otherwise
4000 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
4001 if ( isinstance( theObject, Mesh )):
4002 theObject = theObject.GetMesh()
4003 if ( isinstance( theObject, list )):
4004 theObject = self.GetIDSource(theObject, SMESH.ALL)
4006 thePoint, Parameters = ParsePointStruct(thePoint)
4007 self.mesh.SetParameters(Parameters)
4009 if Copy and MakeGroups:
4010 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
4011 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
4014 ## Creates a new mesh from the translated object
4015 # @param theObject - the object to translate (mesh, submesh, or group)
4016 # @param thePoint - base point for scale
4017 # @param theScaleFact - list of 1-3 scale factors for axises
4018 # @param MakeGroups - forces the generation of new groups from existing ones
4019 # @param NewMeshName - the name of the newly created mesh
4020 # @return instance of Mesh class
4021 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
4022 if (isinstance(theObject, Mesh)):
4023 theObject = theObject.GetMesh()
4024 if ( isinstance( theObject, list )):
4025 theObject = self.GetIDSource(theObject,SMESH.ALL)
4027 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
4028 MakeGroups, NewMeshName)
4029 #mesh.SetParameters(Parameters)
4030 return Mesh( self.smeshpyD, self.geompyD, mesh )
4034 ## Rotates the elements
4035 # @param IDsOfElements list of elements ids
4036 # @param Axis the axis of rotation (AxisStruct or geom line)
4037 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
4038 # @param Copy allows copying the rotated elements
4039 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
4040 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
4041 # @ingroup l2_modif_trsf
4042 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
4044 if isinstance(AngleInRadians,str):
4046 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
4048 AngleInRadians = DegreesToRadians(AngleInRadians)
4049 if IDsOfElements == []:
4050 IDsOfElements = self.GetElementsId()
4051 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
4052 Axis = self.smeshpyD.GetAxisStruct(Axis)
4053 Axis,AxisParameters = ParseAxisStruct(Axis)
4054 Parameters = AxisParameters + var_separator + Parameters
4055 self.mesh.SetParameters(Parameters)
4056 if Copy and MakeGroups:
4057 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
4058 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
4061 ## Creates a new mesh of rotated elements
4062 # @param IDsOfElements list of element ids
4063 # @param Axis the axis of rotation (AxisStruct or geom line)
4064 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
4065 # @param MakeGroups forces the generation of new groups from existing ones
4066 # @param NewMeshName the name of the newly created mesh
4067 # @return instance of Mesh class
4068 # @ingroup l2_modif_trsf
4069 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
4071 if isinstance(AngleInRadians,str):
4073 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
4075 AngleInRadians = DegreesToRadians(AngleInRadians)
4076 if IDsOfElements == []:
4077 IDsOfElements = self.GetElementsId()
4078 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
4079 Axis = self.smeshpyD.GetAxisStruct(Axis)
4080 Axis,AxisParameters = ParseAxisStruct(Axis)
4081 Parameters = AxisParameters + var_separator + Parameters
4082 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
4083 MakeGroups, NewMeshName)
4084 mesh.SetParameters(Parameters)
4085 return Mesh( self.smeshpyD, self.geompyD, mesh )
4087 ## Rotates the object
4088 # @param theObject the object to rotate( mesh, submesh, or group)
4089 # @param Axis the axis of rotation (AxisStruct or geom line)
4090 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
4091 # @param Copy allows copying the rotated elements
4092 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
4093 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
4094 # @ingroup l2_modif_trsf
4095 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
4097 if isinstance(AngleInRadians,str):
4099 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
4101 AngleInRadians = DegreesToRadians(AngleInRadians)
4102 if (isinstance(theObject, Mesh)):
4103 theObject = theObject.GetMesh()
4104 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
4105 Axis = self.smeshpyD.GetAxisStruct(Axis)
4106 Axis,AxisParameters = ParseAxisStruct(Axis)
4107 Parameters = AxisParameters + ":" + Parameters
4108 self.mesh.SetParameters(Parameters)
4109 if Copy and MakeGroups:
4110 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
4111 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
4114 ## Creates a new mesh from the rotated object
4115 # @param theObject the object to rotate (mesh, submesh, or group)
4116 # @param Axis the axis of rotation (AxisStruct or geom line)
4117 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
4118 # @param MakeGroups forces the generation of new groups from existing ones
4119 # @param NewMeshName the name of the newly created mesh
4120 # @return instance of Mesh class
4121 # @ingroup l2_modif_trsf
4122 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
4124 if isinstance(AngleInRadians,str):
4126 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
4128 AngleInRadians = DegreesToRadians(AngleInRadians)
4129 if (isinstance( theObject, Mesh )):
4130 theObject = theObject.GetMesh()
4131 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
4132 Axis = self.smeshpyD.GetAxisStruct(Axis)
4133 Axis,AxisParameters = ParseAxisStruct(Axis)
4134 Parameters = AxisParameters + ":" + Parameters
4135 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
4136 MakeGroups, NewMeshName)
4137 mesh.SetParameters(Parameters)
4138 return Mesh( self.smeshpyD, self.geompyD, mesh )
4140 ## Finds groups of ajacent nodes within Tolerance.
4141 # @param Tolerance the value of tolerance
4142 # @return the list of groups of nodes
4143 # @ingroup l2_modif_trsf
4144 def FindCoincidentNodes (self, Tolerance):
4145 return self.editor.FindCoincidentNodes(Tolerance)
4147 ## Finds groups of ajacent nodes within Tolerance.
4148 # @param Tolerance the value of tolerance
4149 # @param SubMeshOrGroup SubMesh or Group
4150 # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
4151 # @return the list of groups of nodes
4152 # @ingroup l2_modif_trsf
4153 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
4154 if (isinstance( SubMeshOrGroup, Mesh )):
4155 SubMeshOrGroup = SubMeshOrGroup.GetMesh()
4156 if not isinstance( exceptNodes, list):
4157 exceptNodes = [ exceptNodes ]
4158 if exceptNodes and isinstance( exceptNodes[0], int):
4159 exceptNodes = [ self.GetIDSource( exceptNodes, SMESH.NODE)]
4160 return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes)
4163 # @param GroupsOfNodes the list of groups of nodes
4164 # @ingroup l2_modif_trsf
4165 def MergeNodes (self, GroupsOfNodes):
4166 self.editor.MergeNodes(GroupsOfNodes)
4168 ## Finds the elements built on the same nodes.
4169 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
4170 # @return a list of groups of equal elements
4171 # @ingroup l2_modif_trsf
4172 def FindEqualElements (self, MeshOrSubMeshOrGroup):
4173 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
4174 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
4175 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
4177 ## Merges elements in each given group.
4178 # @param GroupsOfElementsID groups of elements for merging
4179 # @ingroup l2_modif_trsf
4180 def MergeElements(self, GroupsOfElementsID):
4181 self.editor.MergeElements(GroupsOfElementsID)
4183 ## Leaves one element and removes all other elements built on the same nodes.
4184 # @ingroup l2_modif_trsf
4185 def MergeEqualElements(self):
4186 self.editor.MergeEqualElements()
4188 ## Sews free borders
4189 # @return SMESH::Sew_Error
4190 # @ingroup l2_modif_trsf
4191 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
4192 FirstNodeID2, SecondNodeID2, LastNodeID2,
4193 CreatePolygons, CreatePolyedrs):
4194 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
4195 FirstNodeID2, SecondNodeID2, LastNodeID2,
4196 CreatePolygons, CreatePolyedrs)
4198 ## Sews conform free borders
4199 # @return SMESH::Sew_Error
4200 # @ingroup l2_modif_trsf
4201 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
4202 FirstNodeID2, SecondNodeID2):
4203 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
4204 FirstNodeID2, SecondNodeID2)
4206 ## Sews border to side
4207 # @return SMESH::Sew_Error
4208 # @ingroup l2_modif_trsf
4209 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
4210 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
4211 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
4212 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
4214 ## Sews two sides of a mesh. The nodes belonging to Side1 are
4215 # merged with the nodes of elements of Side2.
4216 # The number of elements in theSide1 and in theSide2 must be
4217 # equal and they should have similar nodal connectivity.
4218 # The nodes to merge should belong to side borders and
4219 # the first node should be linked to the second.
4220 # @return SMESH::Sew_Error
4221 # @ingroup l2_modif_trsf
4222 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
4223 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
4224 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
4225 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
4226 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
4227 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
4229 ## Sets new nodes for the given element.
4230 # @param ide the element id
4231 # @param newIDs nodes ids
4232 # @return If the number of nodes does not correspond to the type of element - returns false
4233 # @ingroup l2_modif_edit
4234 def ChangeElemNodes(self, ide, newIDs):
4235 return self.editor.ChangeElemNodes(ide, newIDs)
4237 ## If during the last operation of MeshEditor some nodes were
4238 # created, this method returns the list of their IDs, \n
4239 # if new nodes were not created - returns empty list
4240 # @return the list of integer values (can be empty)
4241 # @ingroup l1_auxiliary
4242 def GetLastCreatedNodes(self):
4243 return self.editor.GetLastCreatedNodes()
4245 ## If during the last operation of MeshEditor some elements were
4246 # created this method returns the list of their IDs, \n
4247 # if new elements were not created - returns empty list
4248 # @return the list of integer values (can be empty)
4249 # @ingroup l1_auxiliary
4250 def GetLastCreatedElems(self):
4251 return self.editor.GetLastCreatedElems()
4253 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4254 # @param theNodes identifiers of nodes to be doubled
4255 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
4256 # nodes. If list of element identifiers is empty then nodes are doubled but
4257 # they not assigned to elements
4258 # @return TRUE if operation has been completed successfully, FALSE otherwise
4259 # @ingroup l2_modif_edit
4260 def DoubleNodes(self, theNodes, theModifiedElems):
4261 return self.editor.DoubleNodes(theNodes, theModifiedElems)
4263 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4264 # This method provided for convenience works as DoubleNodes() described above.
4265 # @param theNodeId identifiers of node to be doubled
4266 # @param theModifiedElems identifiers of elements to be updated
4267 # @return TRUE if operation has been completed successfully, FALSE otherwise
4268 # @ingroup l2_modif_edit
4269 def DoubleNode(self, theNodeId, theModifiedElems):
4270 return self.editor.DoubleNode(theNodeId, theModifiedElems)
4272 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4273 # This method provided for convenience works as DoubleNodes() described above.
4274 # @param theNodes group of nodes to be doubled
4275 # @param theModifiedElems group of elements to be updated.
4276 # @param theMakeGroup forces the generation of a group containing new nodes.
4277 # @return TRUE or a created group if operation has been completed successfully,
4278 # FALSE or None otherwise
4279 # @ingroup l2_modif_edit
4280 def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
4282 return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
4283 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
4285 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4286 # This method provided for convenience works as DoubleNodes() described above.
4287 # @param theNodes list of groups of nodes to be doubled
4288 # @param theModifiedElems list of groups of elements to be updated.
4289 # @param theMakeGroup forces the generation of a group containing new nodes.
4290 # @return TRUE if operation has been completed successfully, FALSE otherwise
4291 # @ingroup l2_modif_edit
4292 def DoubleNodeGroups(self, theNodes, theModifiedElems, theMakeGroup=False):
4294 return self.editor.DoubleNodeGroupsNew(theNodes, theModifiedElems)
4295 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
4297 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4298 # @param theElems - the list of elements (edges or faces) to be replicated
4299 # The nodes for duplication could be found from these elements
4300 # @param theNodesNot - list of nodes to NOT replicate
4301 # @param theAffectedElems - the list of elements (cells and edges) to which the
4302 # replicated nodes should be associated to.
4303 # @return TRUE if operation has been completed successfully, FALSE otherwise
4304 # @ingroup l2_modif_edit
4305 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
4306 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
4308 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4309 # @param theElems - the list of elements (edges or faces) to be replicated
4310 # The nodes for duplication could be found from these elements
4311 # @param theNodesNot - list of nodes to NOT replicate
4312 # @param theShape - shape to detect affected elements (element which geometric center
4313 # located on or inside shape).
4314 # The replicated nodes should be associated to affected elements.
4315 # @return TRUE if operation has been completed successfully, FALSE otherwise
4316 # @ingroup l2_modif_edit
4317 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
4318 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
4320 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4321 # This method provided for convenience works as DoubleNodes() described above.
4322 # @param theElems - group of of elements (edges or faces) to be replicated
4323 # @param theNodesNot - group of nodes not to replicated
4324 # @param theAffectedElems - group of elements to which the replicated nodes
4325 # should be associated to.
4326 # @param theMakeGroup forces the generation of a group containing new elements.
4327 # @return TRUE or a created group if operation has been completed successfully,
4328 # FALSE or None otherwise
4329 # @ingroup l2_modif_edit
4330 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4332 return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
4333 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
4335 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4336 # This method provided for convenience works as DoubleNodes() described above.
4337 # @param theElems - group of of elements (edges or faces) to be replicated
4338 # @param theNodesNot - group of nodes not to replicated
4339 # @param theShape - shape to detect affected elements (element which geometric center
4340 # located on or inside shape).
4341 # The replicated nodes should be associated to affected elements.
4342 # @ingroup l2_modif_edit
4343 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
4344 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
4346 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4347 # This method provided for convenience works as DoubleNodes() described above.
4348 # @param theElems - list of groups of elements (edges or faces) to be replicated
4349 # @param theNodesNot - list of groups of nodes not to replicated
4350 # @param theAffectedElems - group of elements to which the replicated nodes
4351 # should be associated to.
4352 # @param theMakeGroup forces the generation of a group containing new elements.
4353 # @return TRUE or a created group if operation has been completed successfully,
4354 # FALSE or None otherwise
4355 # @ingroup l2_modif_edit
4356 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4358 return self.editor.DoubleNodeElemGroupsNew(theElems, theNodesNot, theAffectedElems)
4359 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
4361 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4362 # This method provided for convenience works as DoubleNodes() described above.
4363 # @param theElems - list of groups of elements (edges or faces) to be replicated
4364 # @param theNodesNot - list of groups of nodes not to replicated
4365 # @param theShape - shape to detect affected elements (element which geometric center
4366 # located on or inside shape).
4367 # The replicated nodes should be associated to affected elements.
4368 # @return TRUE if operation has been completed successfully, FALSE otherwise
4369 # @ingroup l2_modif_edit
4370 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
4371 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
4373 ## Double nodes on shared faces between groups of volumes and create flat elements on demand.
4374 # The list of groups must describe a partition of the mesh volumes.
4375 # The nodes of the internal faces at the boundaries of the groups are doubled.
4376 # In option, the internal faces are replaced by flat elements.
4377 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4378 # @param theDomains - list of groups of volumes
4379 # @param createJointElems - if TRUE, create the elements
4380 # @return TRUE if operation has been completed successfully, FALSE otherwise
4381 def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems ):
4382 return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems )
4384 ## Double nodes on some external faces and create flat elements.
4385 # Flat elements are mainly used by some types of mechanic calculations.
4387 # Each group of the list must be constituted of faces.
4388 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4389 # @param theGroupsOfFaces - list of groups of faces
4390 # @return TRUE if operation has been completed successfully, FALSE otherwise
4391 def CreateFlatElementsOnFacesGroups(self, theGroupsOfFaces ):
4392 return self.editor.CreateFlatElementsOnFacesGroups( theGroupsOfFaces )
4394 def _valueFromFunctor(self, funcType, elemId):
4395 fn = self.smeshpyD.GetFunctor(funcType)
4396 fn.SetMesh(self.mesh)
4397 if fn.GetElementType() == self.GetElementType(elemId, True):
4398 val = fn.GetValue(elemId)
4403 ## Get length of 1D element.
4404 # @param elemId mesh element ID
4405 # @return element's length value
4406 # @ingroup l1_measurements
4407 def GetLength(self, elemId):
4408 return self._valueFromFunctor(SMESH.FT_Length, elemId)
4410 ## Get area of 2D element.
4411 # @param elemId mesh element ID
4412 # @return element's area value
4413 # @ingroup l1_measurements
4414 def GetArea(self, elemId):
4415 return self._valueFromFunctor(SMESH.FT_Area, elemId)
4417 ## Get volume of 3D element.
4418 # @param elemId mesh element ID
4419 # @return element's volume value
4420 # @ingroup l1_measurements
4421 def GetVolume(self, elemId):
4422 return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
4424 ## Get maximum element length.
4425 # @param elemId mesh element ID
4426 # @return element's maximum length value
4427 # @ingroup l1_measurements
4428 def GetMaxElementLength(self, elemId):
4429 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4430 ftype = SMESH.FT_MaxElementLength3D
4432 ftype = SMESH.FT_MaxElementLength2D
4433 return self._valueFromFunctor(ftype, elemId)
4435 ## Get aspect ratio of 2D or 3D element.
4436 # @param elemId mesh element ID
4437 # @return element's aspect ratio value
4438 # @ingroup l1_measurements
4439 def GetAspectRatio(self, elemId):
4440 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4441 ftype = SMESH.FT_AspectRatio3D
4443 ftype = SMESH.FT_AspectRatio
4444 return self._valueFromFunctor(ftype, elemId)
4446 ## Get warping angle of 2D element.
4447 # @param elemId mesh element ID
4448 # @return element's warping angle value
4449 # @ingroup l1_measurements
4450 def GetWarping(self, elemId):
4451 return self._valueFromFunctor(SMESH.FT_Warping, elemId)
4453 ## Get minimum angle of 2D element.
4454 # @param elemId mesh element ID
4455 # @return element's minimum angle value
4456 # @ingroup l1_measurements
4457 def GetMinimumAngle(self, elemId):
4458 return self._valueFromFunctor(SMESH.FT_MinimumAngle, elemId)
4460 ## Get taper of 2D element.
4461 # @param elemId mesh element ID
4462 # @return element's taper value
4463 # @ingroup l1_measurements
4464 def GetTaper(self, elemId):
4465 return self._valueFromFunctor(SMESH.FT_Taper, elemId)
4467 ## Get skew of 2D element.
4468 # @param elemId mesh element ID
4469 # @return element's skew value
4470 # @ingroup l1_measurements
4471 def GetSkew(self, elemId):
4472 return self._valueFromFunctor(SMESH.FT_Skew, elemId)
4474 ## The mother class to define algorithm, it is not recommended to use it directly.
4477 # @ingroup l2_algorithms
4478 class Mesh_Algorithm:
4479 # @class Mesh_Algorithm
4480 # @brief Class Mesh_Algorithm
4482 #def __init__(self,smesh):
4490 ## Finds a hypothesis in the study by its type name and parameters.
4491 # Finds only the hypotheses created in smeshpyD engine.
4492 # @return SMESH.SMESH_Hypothesis
4493 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
4494 study = smeshpyD.GetCurrentStudy()
4495 #to do: find component by smeshpyD object, not by its data type
4496 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4497 if scomp is not None:
4498 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
4499 # Check if the root label of the hypotheses exists
4500 if res and hypRoot is not None:
4501 iter = study.NewChildIterator(hypRoot)
4502 # Check all published hypotheses
4504 hypo_so_i = iter.Value()
4505 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
4506 if attr is not None:
4507 anIOR = attr.Value()
4508 hypo_o_i = salome.orb.string_to_object(anIOR)
4509 if hypo_o_i is not None:
4510 # Check if this is a hypothesis
4511 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
4512 if hypo_i is not None:
4513 # Check if the hypothesis belongs to current engine
4514 if smeshpyD.GetObjectId(hypo_i) > 0:
4515 # Check if this is the required hypothesis
4516 if hypo_i.GetName() == hypname:
4518 if CompareMethod(hypo_i, args):
4532 ## Finds the algorithm in the study by its type name.
4533 # Finds only the algorithms, which have been created in smeshpyD engine.
4534 # @return SMESH.SMESH_Algo
4535 def FindAlgorithm (self, algoname, smeshpyD):
4536 study = smeshpyD.GetCurrentStudy()
4537 #to do: find component by smeshpyD object, not by its data type
4538 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4539 if scomp is not None:
4540 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
4541 # Check if the root label of the algorithms exists
4542 if res and hypRoot is not None:
4543 iter = study.NewChildIterator(hypRoot)
4544 # Check all published algorithms
4546 algo_so_i = iter.Value()
4547 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
4548 if attr is not None:
4549 anIOR = attr.Value()
4550 algo_o_i = salome.orb.string_to_object(anIOR)
4551 if algo_o_i is not None:
4552 # Check if this is an algorithm
4553 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
4554 if algo_i is not None:
4555 # Checks if the algorithm belongs to the current engine
4556 if smeshpyD.GetObjectId(algo_i) > 0:
4557 # Check if this is the required algorithm
4558 if algo_i.GetName() == algoname:
4571 ## If the algorithm is global, returns 0; \n
4572 # else returns the submesh associated to this algorithm.
4573 def GetSubMesh(self):
4576 ## Returns the wrapped mesher.
4577 def GetAlgorithm(self):
4580 ## Gets the list of hypothesis that can be used with this algorithm
4581 def GetCompatibleHypothesis(self):
4584 mylist = self.algo.GetCompatibleHypothesis()
4587 ## Gets the name of the algorithm
4591 ## Sets the name to the algorithm
4592 def SetName(self, name):
4593 self.mesh.smeshpyD.SetName(self.algo, name)
4595 ## Gets the id of the algorithm
4597 return self.algo.GetId()
4600 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
4602 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
4603 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
4605 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
4607 self.Assign(algo, mesh, geom)
4611 def Assign(self, algo, mesh, geom):
4613 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
4617 self.geom = mesh.geom
4620 AssureGeomPublished( mesh, geom )
4622 name = GetName(geom)
4626 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
4628 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
4629 TreatHypoStatus( status, algo.GetName(), name, True )
4632 def CompareHyp (self, hyp, args):
4633 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
4636 def CompareEqualHyp (self, hyp, args):
4640 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
4641 UseExisting=0, CompareMethod=""):
4644 if CompareMethod == "": CompareMethod = self.CompareHyp
4645 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
4648 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
4653 if isinstance( arg, geompyDC.GEOM._objref_GEOM_Object ):
4654 argStr = arg.GetStudyEntry()
4655 if not argStr: argStr = "GEOM_Obj_%s", arg.GetEntry()
4656 if len( argStr ) > 10:
4657 argStr = argStr[:7]+"..."
4658 if argStr[0] == '[': argStr += ']'
4664 self.mesh.smeshpyD.SetName(hypo, hyp + a)
4668 geomName = GetName(self.geom)
4669 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
4670 TreatHypoStatus( status, GetName(hypo), geomName, 0 )
4673 ## Returns entry of the shape to mesh in the study
4674 def MainShapeEntry(self):
4676 if not self.mesh or not self.mesh.GetMesh(): return entry
4677 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
4678 study = self.mesh.smeshpyD.GetCurrentStudy()
4679 ior = salome.orb.object_to_string( self.mesh.GetShape() )
4680 sobj = study.FindObjectIOR(ior)
4681 if sobj: entry = sobj.GetID()
4682 if not entry: return ""
4685 ## Defines "ViscousLayers" hypothesis to give parameters of layers of prisms to build
4686 # near mesh boundary. This hypothesis can be used by several 3D algorithms:
4687 # NETGEN 3D, GHS3D, Hexahedron(i,j,k)
4688 # @param thickness total thickness of layers of prisms
4689 # @param numberOfLayers number of layers of prisms
4690 # @param stretchFactor factor (>1.0) of growth of layer thickness towards inside of mesh
4691 # @param ignoreFaces list of geometrical faces (or their ids) not to generate layers on
4692 # @ingroup l3_hypos_additi
4693 def ViscousLayers(self, thickness, numberOfLayers, stretchFactor, ignoreFaces=[]):
4694 if not isinstance(self.algo, SMESH._objref_SMESH_3D_Algo):
4695 raise TypeError, "ViscousLayers are supported by 3D algorithms only"
4696 if not "ViscousLayers" in self.GetCompatibleHypothesis():
4697 raise TypeError, "ViscousLayers are not supported by %s"%self.algo.GetName()
4698 if ignoreFaces and isinstance( ignoreFaces[0], geompyDC.GEOM._objref_GEOM_Object ):
4699 ignoreFaces = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, f) for f in ignoreFaces ]
4700 hyp = self.Hypothesis("ViscousLayers",
4701 [thickness, numberOfLayers, stretchFactor, ignoreFaces])
4702 hyp.SetTotalThickness(thickness)
4703 hyp.SetNumberLayers(numberOfLayers)
4704 hyp.SetStretchFactor(stretchFactor)
4705 hyp.SetIgnoreFaces(ignoreFaces)
4708 ## Transform a list of ether edges or tuples (edge 1st_vertex_of_edge)
4709 # into a list acceptable to SetReversedEdges() of some 1D hypotheses
4710 # @ingroup l3_hypos_1dhyps
4711 def ReversedEdgeIndices(self, reverseList):
4713 geompy = self.mesh.geompyD
4714 for i in reverseList:
4715 if isinstance( i, int ):
4716 s = geompy.SubShapes(self.mesh.geom, [i])[0]
4717 if s.GetShapeType() != geompyDC.GEOM.EDGE:
4718 raise TypeError, "Not EDGE index given"
4720 elif isinstance( i, geompyDC.GEOM._objref_GEOM_Object ):
4721 if i.GetShapeType() != geompyDC.GEOM.EDGE:
4722 raise TypeError, "Not an EDGE given"
4723 resList.append( geompy.GetSubShapeID(self.mesh.geom, i ))
4727 if not isinstance( e, geompyDC.GEOM._objref_GEOM_Object ) or \
4728 not isinstance( v, geompyDC.GEOM._objref_GEOM_Object ):
4729 raise TypeError, "A list item must be a tuple (edge 1st_vertex_of_edge)"
4730 if v.GetShapeType() == geompyDC.GEOM.EDGE and \
4731 e.GetShapeType() == geompyDC.GEOM.VERTEX:
4733 if e.GetShapeType() != geompyDC.GEOM.EDGE or \
4734 v.GetShapeType() != geompyDC.GEOM.VERTEX:
4735 raise TypeError, "A list item must be a tuple (edge 1st_vertex_of_edge)"
4736 vFirst = FirstVertexOnCurve( e )
4737 tol = geompy.Tolerance( vFirst )[-1]
4738 if geompy.MinDistance( v, vFirst ) > 1.5*tol:
4739 resList.append( geompy.GetSubShapeID(self.mesh.geom, e ))
4741 raise TypeError, "Item must be either an edge or tuple (edge 1st_vertex_of_edge)"
4744 # Public class: Mesh_Segment
4745 # --------------------------
4747 ## Class to define a segment 1D algorithm for discretization
4750 # @ingroup l3_algos_basic
4751 class Mesh_Segment(Mesh_Algorithm):
4753 ## Private constructor.
4754 def __init__(self, mesh, geom=0):
4755 Mesh_Algorithm.__init__(self)
4756 self.Create(mesh, geom, "Regular_1D")
4758 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
4759 # @param l for the length of segments that cut an edge
4760 # @param UseExisting if ==true - searches for an existing hypothesis created with
4761 # the same parameters, else (default) - creates a new one
4762 # @param p precision, used for calculation of the number of segments.
4763 # The precision should be a positive, meaningful value within the range [0,1].
4764 # In general, the number of segments is calculated with the formula:
4765 # nb = ceil((edge_length / l) - p)
4766 # Function ceil rounds its argument to the higher integer.
4767 # So, p=0 means rounding of (edge_length / l) to the higher integer,
4768 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
4769 # p=1 means rounding of (edge_length / l) to the lower integer.
4770 # Default value is 1e-07.
4771 # @return an instance of StdMeshers_LocalLength hypothesis
4772 # @ingroup l3_hypos_1dhyps
4773 def LocalLength(self, l, UseExisting=0, p=1e-07):
4774 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
4775 CompareMethod=self.CompareLocalLength)
4781 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
4782 def CompareLocalLength(self, hyp, args):
4783 if IsEqual(hyp.GetLength(), args[0]):
4784 return IsEqual(hyp.GetPrecision(), args[1])
4787 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
4788 # @param length is optional maximal allowed length of segment, if it is omitted
4789 # the preestimated length is used that depends on geometry size
4790 # @param UseExisting if ==true - searches for an existing hypothesis created with
4791 # the same parameters, else (default) - create a new one
4792 # @return an instance of StdMeshers_MaxLength hypothesis
4793 # @ingroup l3_hypos_1dhyps
4794 def MaxSize(self, length=0.0, UseExisting=0):
4795 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
4798 hyp.SetLength(length)
4800 # set preestimated length
4801 gen = self.mesh.smeshpyD
4802 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
4803 self.mesh.GetMesh(), self.mesh.GetShape(),
4805 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
4807 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
4810 hyp.SetUsePreestimatedLength( length == 0.0 )
4813 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
4814 # @param n for the number of segments that cut an edge
4815 # @param s for the scale factor (optional)
4816 # @param reversedEdges is a list of edges to mesh using reversed orientation.
4817 # A list item can also be a tuple (edge 1st_vertex_of_edge)
4818 # @param UseExisting if ==true - searches for an existing hypothesis created with
4819 # the same parameters, else (default) - create a new one
4820 # @return an instance of StdMeshers_NumberOfSegments hypothesis
4821 # @ingroup l3_hypos_1dhyps
4822 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4823 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4824 reversedEdges, UseExisting = [], reversedEdges
4825 entry = self.MainShapeEntry()
4826 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
4828 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdgeInd, entry],
4829 UseExisting=UseExisting,
4830 CompareMethod=self.CompareNumberOfSegments)
4832 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdgeInd, entry],
4833 UseExisting=UseExisting,
4834 CompareMethod=self.CompareNumberOfSegments)
4835 hyp.SetDistrType( 1 )
4836 hyp.SetScaleFactor(s)
4837 hyp.SetNumberOfSegments(n)
4838 hyp.SetReversedEdges( reversedEdgeInd )
4839 hyp.SetObjectEntry( entry )
4843 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4844 def CompareNumberOfSegments(self, hyp, args):
4845 if hyp.GetNumberOfSegments() == args[0]:
4847 if hyp.GetReversedEdges() == args[1]:
4848 if not args[1] or hyp.GetObjectEntry() == args[2]:
4851 if hyp.GetReversedEdges() == args[2]:
4852 if not args[2] or hyp.GetObjectEntry() == args[3]:
4853 if hyp.GetDistrType() == 1:
4854 if IsEqual(hyp.GetScaleFactor(), args[1]):
4858 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4859 # @param start defines the length of the first segment
4860 # @param end defines the length of the last segment
4861 # @param reversedEdges is a list of edges to mesh using reversed orientation.
4862 # A list item can also be a tuple (edge 1st_vertex_of_edge)
4863 # @param UseExisting if ==true - searches for an existing hypothesis created with
4864 # the same parameters, else (default) - creates a new one
4865 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4866 # @ingroup l3_hypos_1dhyps
4867 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4868 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4869 reversedEdges, UseExisting = [], reversedEdges
4870 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
4871 entry = self.MainShapeEntry()
4872 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdgeInd, entry],
4873 UseExisting=UseExisting,
4874 CompareMethod=self.CompareArithmetic1D)
4875 hyp.SetStartLength(start)
4876 hyp.SetEndLength(end)
4877 hyp.SetReversedEdges( reversedEdgeInd )
4878 hyp.SetObjectEntry( entry )
4882 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4883 def CompareArithmetic1D(self, hyp, args):
4884 if IsEqual(hyp.GetLength(1), args[0]):
4885 if IsEqual(hyp.GetLength(0), args[1]):
4886 if hyp.GetReversedEdges() == args[2]:
4887 if not args[2] or hyp.GetObjectEntry() == args[3]:
4892 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4893 # on curve from 0 to 1 (additionally it is neecessary to check
4894 # orientation of edges and create list of reversed edges if it is
4895 # needed) and sets numbers of segments between given points (default
4896 # values are equals 1
4897 # @param points defines the list of parameters on curve
4898 # @param nbSegs defines the list of numbers of segments
4899 # @param reversedEdges is a list of edges to mesh using reversed orientation.
4900 # A list item can also be a tuple (edge 1st_vertex_of_edge)
4901 # @param UseExisting if ==true - searches for an existing hypothesis created with
4902 # the same parameters, else (default) - creates a new one
4903 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4904 # @ingroup l3_hypos_1dhyps
4905 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4906 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4907 reversedEdges, UseExisting = [], reversedEdges
4908 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
4909 entry = self.MainShapeEntry()
4910 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdgeInd, entry],
4911 UseExisting=UseExisting,
4912 CompareMethod=self.CompareFixedPoints1D)
4913 hyp.SetPoints(points)
4914 hyp.SetNbSegments(nbSegs)
4915 hyp.SetReversedEdges(reversedEdgeInd)
4916 hyp.SetObjectEntry(entry)
4920 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4921 ## as the given arguments
4922 def CompareFixedPoints1D(self, hyp, args):
4923 if hyp.GetPoints() == args[0]:
4924 if hyp.GetNbSegments() == args[1]:
4925 if hyp.GetReversedEdges() == args[2]:
4926 if not args[2] or hyp.GetObjectEntry() == args[3]:
4932 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4933 # @param start defines the length of the first segment
4934 # @param end defines the length of the last segment
4935 # @param reversedEdges is a list of edges to mesh using reversed orientation.
4936 # A list item can also be a tuple (edge 1st_vertex_of_edge)
4937 # @param UseExisting if ==true - searches for an existing hypothesis created with
4938 # the same parameters, else (default) - creates a new one
4939 # @return an instance of StdMeshers_StartEndLength hypothesis
4940 # @ingroup l3_hypos_1dhyps
4941 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4942 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4943 reversedEdges, UseExisting = [], reversedEdges
4944 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
4945 entry = self.MainShapeEntry()
4946 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdgeInd, entry],
4947 UseExisting=UseExisting,
4948 CompareMethod=self.CompareStartEndLength)
4949 hyp.SetStartLength(start)
4950 hyp.SetEndLength(end)
4951 hyp.SetReversedEdges( reversedEdgeInd )
4952 hyp.SetObjectEntry( entry )
4955 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4956 def CompareStartEndLength(self, hyp, args):
4957 if IsEqual(hyp.GetLength(1), args[0]):
4958 if IsEqual(hyp.GetLength(0), args[1]):
4959 if hyp.GetReversedEdges() == args[2]:
4960 if not args[2] or hyp.GetObjectEntry() == args[3]:
4964 ## Defines "Deflection1D" hypothesis
4965 # @param d for the deflection
4966 # @param UseExisting if ==true - searches for an existing hypothesis created with
4967 # the same parameters, else (default) - create a new one
4968 # @ingroup l3_hypos_1dhyps
4969 def Deflection1D(self, d, UseExisting=0):
4970 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4971 CompareMethod=self.CompareDeflection1D)
4972 hyp.SetDeflection(d)
4975 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4976 def CompareDeflection1D(self, hyp, args):
4977 return IsEqual(hyp.GetDeflection(), args[0])
4979 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4980 # the opposite side in case of quadrangular faces
4981 # @ingroup l3_hypos_additi
4982 def Propagation(self):
4983 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4985 ## Defines "AutomaticLength" hypothesis
4986 # @param fineness for the fineness [0-1]
4987 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4988 # same parameters, else (default) - create a new one
4989 # @ingroup l3_hypos_1dhyps
4990 def AutomaticLength(self, fineness=0, UseExisting=0):
4991 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4992 CompareMethod=self.CompareAutomaticLength)
4993 hyp.SetFineness( fineness )
4996 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4997 def CompareAutomaticLength(self, hyp, args):
4998 return IsEqual(hyp.GetFineness(), args[0])
5000 ## Defines "SegmentLengthAroundVertex" hypothesis
5001 # @param length for the segment length
5002 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
5003 # Any other integer value means that the hypothesis will be set on the
5004 # whole 1D shape, where Mesh_Segment algorithm is assigned.
5005 # @param UseExisting if ==true - searches for an existing hypothesis created with
5006 # the same parameters, else (default) - creates a new one
5007 # @ingroup l3_algos_segmarv
5008 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
5010 store_geom = self.geom
5011 if type(vertex) is types.IntType:
5012 if vertex == 0 or vertex == 1:
5013 vertex = self.mesh.geompyD.ExtractShapes(self.geom, geompyDC.ShapeType["VERTEX"],True)[vertex]
5021 if self.geom is None:
5022 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
5023 AssureGeomPublished( self.mesh, self.geom )
5024 name = GetName(self.geom)
5026 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
5028 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
5030 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
5031 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
5033 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
5034 CompareMethod=self.CompareLengthNearVertex)
5035 self.geom = store_geom
5036 hyp.SetLength( length )
5039 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
5040 # @ingroup l3_algos_segmarv
5041 def CompareLengthNearVertex(self, hyp, args):
5042 return IsEqual(hyp.GetLength(), args[0])
5044 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
5045 # If the 2D mesher sees that all boundary edges are quadratic,
5046 # it generates quadratic faces, else it generates linear faces using
5047 # medium nodes as if they are vertices.
5048 # The 3D mesher generates quadratic volumes only if all boundary faces
5049 # are quadratic, else it fails.
5051 # @ingroup l3_hypos_additi
5052 def QuadraticMesh(self):
5053 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
5056 # Public class: Mesh_CompositeSegment
5057 # --------------------------
5059 ## Defines a segment 1D algorithm for discretization
5061 # @ingroup l3_algos_basic
5062 class Mesh_CompositeSegment(Mesh_Segment):
5064 ## Private constructor.
5065 def __init__(self, mesh, geom=0):
5066 self.Create(mesh, geom, "CompositeSegment_1D")
5069 # Public class: Mesh_Segment_Python
5070 # ---------------------------------
5072 ## Defines a segment 1D algorithm for discretization with python function
5074 # @ingroup l3_algos_basic
5075 class Mesh_Segment_Python(Mesh_Segment):
5077 ## Private constructor.
5078 def __init__(self, mesh, geom=0):
5079 import Python1dPlugin
5080 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
5082 ## Defines "PythonSplit1D" hypothesis
5083 # @param n for the number of segments that cut an edge
5084 # @param func for the python function that calculates the length of all segments
5085 # @param UseExisting if ==true - searches for the existing hypothesis created with
5086 # the same parameters, else (default) - creates a new one
5087 # @ingroup l3_hypos_1dhyps
5088 def PythonSplit1D(self, n, func, UseExisting=0):
5089 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
5090 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
5091 hyp.SetNumberOfSegments(n)
5092 hyp.SetPythonLog10RatioFunction(func)
5095 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
5096 def ComparePythonSplit1D(self, hyp, args):
5097 #if hyp.GetNumberOfSegments() == args[0]:
5098 # if hyp.GetPythonLog10RatioFunction() == args[1]:
5102 # Public class: Mesh_Triangle
5103 # ---------------------------
5105 ## Defines a triangle 2D algorithm
5107 # @ingroup l3_algos_basic
5108 class Mesh_Triangle(Mesh_Algorithm):
5117 ## Private constructor.
5118 def __init__(self, mesh, algoType, geom=0):
5119 Mesh_Algorithm.__init__(self)
5121 if algoType == MEFISTO:
5122 self.Create(mesh, geom, "MEFISTO_2D")
5124 elif algoType == BLSURF:
5126 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
5127 #self.SetPhysicalMesh() - PAL19680
5128 elif algoType == NETGEN:
5130 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
5132 elif algoType == NETGEN_2D:
5134 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
5137 self.algoType = algoType
5139 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
5140 # @param area for the maximum area of each triangle
5141 # @param UseExisting if ==true - searches for an existing hypothesis created with the
5142 # same parameters, else (default) - creates a new one
5144 # Only for algoType == MEFISTO || NETGEN_2D
5145 # @ingroup l3_hypos_2dhyps
5146 def MaxElementArea(self, area, UseExisting=0):
5147 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
5148 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
5149 CompareMethod=self.CompareMaxElementArea)
5150 elif self.algoType == NETGEN:
5151 hyp = self.Parameters(SIMPLE)
5152 hyp.SetMaxElementArea(area)
5155 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
5156 def CompareMaxElementArea(self, hyp, args):
5157 return IsEqual(hyp.GetMaxElementArea(), args[0])
5159 ## Defines "LengthFromEdges" hypothesis to build triangles
5160 # based on the length of the edges taken from the wire
5162 # Only for algoType == MEFISTO || NETGEN_2D
5163 # @ingroup l3_hypos_2dhyps
5164 def LengthFromEdges(self):
5165 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
5166 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
5168 elif self.algoType == NETGEN:
5169 hyp = self.Parameters(SIMPLE)
5170 hyp.LengthFromEdges()
5173 ## Sets a way to define size of mesh elements to generate.
5174 # @param thePhysicalMesh is: DefaultSize, BLSURF_Custom or SizeMap.
5175 # @ingroup l3_hypos_blsurf
5176 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
5177 if self.Parameters():
5178 # Parameter of BLSURF algo
5179 self.params.SetPhysicalMesh(thePhysicalMesh)
5181 ## Sets size of mesh elements to generate.
5182 # @ingroup l3_hypos_blsurf
5183 def SetPhySize(self, theVal):
5184 if self.Parameters():
5185 # Parameter of BLSURF algo
5186 self.params.SetPhySize(theVal)
5188 ## Sets lower boundary of mesh element size (PhySize).
5189 # @ingroup l3_hypos_blsurf
5190 def SetPhyMin(self, theVal=-1):
5191 if self.Parameters():
5192 # Parameter of BLSURF algo
5193 self.params.SetPhyMin(theVal)
5195 ## Sets upper boundary of mesh element size (PhySize).
5196 # @ingroup l3_hypos_blsurf
5197 def SetPhyMax(self, theVal=-1):
5198 if self.Parameters():
5199 # Parameter of BLSURF algo
5200 self.params.SetPhyMax(theVal)
5202 ## Sets a way to define maximum angular deflection of mesh from CAD model.
5203 # @param theGeometricMesh is: 0 (None) or 1 (Custom)
5204 # @ingroup l3_hypos_blsurf
5205 def SetGeometricMesh(self, theGeometricMesh=0):
5206 if self.Parameters():
5207 # Parameter of BLSURF algo
5208 if self.params.GetPhysicalMesh() == 0: theGeometricMesh = 1
5209 self.params.SetGeometricMesh(theGeometricMesh)
5211 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
5212 # @ingroup l3_hypos_blsurf
5213 def SetAngleMeshS(self, theVal=_angleMeshS):
5214 if self.Parameters():
5215 # Parameter of BLSURF algo
5216 if self.params.GetGeometricMesh() == 0: theVal = self._angleMeshS
5217 self.params.SetAngleMeshS(theVal)
5219 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
5220 # @ingroup l3_hypos_blsurf
5221 def SetAngleMeshC(self, theVal=_angleMeshS):
5222 if self.Parameters():
5223 # Parameter of BLSURF algo
5224 if self.params.GetGeometricMesh() == 0: theVal = self._angleMeshS
5225 self.params.SetAngleMeshC(theVal)
5227 ## Sets lower boundary of mesh element size computed to respect angular deflection.
5228 # @ingroup l3_hypos_blsurf
5229 def SetGeoMin(self, theVal=-1):
5230 if self.Parameters():
5231 # Parameter of BLSURF algo
5232 self.params.SetGeoMin(theVal)
5234 ## Sets upper boundary of mesh element size computed to respect angular deflection.
5235 # @ingroup l3_hypos_blsurf
5236 def SetGeoMax(self, theVal=-1):
5237 if self.Parameters():
5238 # Parameter of BLSURF algo
5239 self.params.SetGeoMax(theVal)
5241 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
5242 # @ingroup l3_hypos_blsurf
5243 def SetGradation(self, theVal=_gradation):
5244 if self.Parameters():
5245 # Parameter of BLSURF algo
5246 if self.params.GetGeometricMesh() == 0: theVal = self._gradation
5247 self.params.SetGradation(theVal)
5249 ## Sets topology usage way.
5250 # @param way defines how mesh conformity is assured <ul>
5251 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
5252 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li>
5253 # <li>PreCAD - by pre-processing with PreCAD a CAD model</li></ul>
5254 # @ingroup l3_hypos_blsurf
5255 def SetTopology(self, way):
5256 if self.Parameters():
5257 # Parameter of BLSURF algo
5258 self.params.SetTopology(way)
5260 ## To respect geometrical edges or not.
5261 # @ingroup l3_hypos_blsurf
5262 def SetDecimesh(self, toIgnoreEdges=False):
5263 if self.Parameters():
5264 # Parameter of BLSURF algo
5265 self.params.SetDecimesh(toIgnoreEdges)
5267 ## Sets verbosity level in the range 0 to 100.
5268 # @ingroup l3_hypos_blsurf
5269 def SetVerbosity(self, level):
5270 if self.Parameters():
5271 # Parameter of BLSURF algo
5272 self.params.SetVerbosity(level)
5274 ## To optimize merges edges.
5275 # @ingroup l3_hypos_blsurf
5276 def SetPreCADMergeEdges(self, toMergeEdges=False):
5277 if self.Parameters():
5278 # Parameter of BLSURF algo
5279 self.params.SetPreCADMergeEdges(toMergeEdges)
5281 ## To remove nano edges.
5282 # @ingroup l3_hypos_blsurf
5283 def SetPreCADRemoveNanoEdges(self, toRemoveNanoEdges=False):
5284 if self.Parameters():
5285 # Parameter of BLSURF algo
5286 self.params.SetPreCADRemoveNanoEdges(toRemoveNanoEdges)
5288 ## To compute topology from scratch
5289 # @ingroup l3_hypos_blsurf
5290 def SetPreCADDiscardInput(self, toDiscardInput=False):
5291 if self.Parameters():
5292 # Parameter of BLSURF algo
5293 self.params.SetPreCADDiscardInput(toDiscardInput)
5295 ## Sets the length below which an edge is considered as nano
5296 # for the topology processing.
5297 # @ingroup l3_hypos_blsurf
5298 def SetPreCADEpsNano(self, epsNano):
5299 if self.Parameters():
5300 # Parameter of BLSURF algo
5301 self.params.SetPreCADEpsNano(epsNano)
5303 ## Sets advanced option value.
5304 # @ingroup l3_hypos_blsurf
5305 def SetOptionValue(self, optionName, level):
5306 if self.Parameters():
5307 # Parameter of BLSURF algo
5308 self.params.SetOptionValue(optionName,level)
5310 ## Sets advanced PreCAD option value.
5311 # Keyword arguments:
5312 # optionName: name of the option
5313 # optionValue: value of the option
5314 # @ingroup l3_hypos_blsurf
5315 def SetPreCADOptionValue(self, optionName, optionValue):
5316 if self.Parameters():
5317 # Parameter of BLSURF algo
5318 self.params.SetPreCADOptionValue(optionName,optionValue)
5320 ## Sets GMF file for export at computation
5321 # @ingroup l3_hypos_blsurf
5322 def SetGMFFile(self, fileName):
5323 if self.Parameters():
5324 # Parameter of BLSURF algo
5325 self.params.SetGMFFile(fileName)
5327 ## Enforced vertices (BLSURF)
5329 ## To get all the enforced vertices
5330 # @ingroup l3_hypos_blsurf
5331 def GetAllEnforcedVertices(self):
5332 if self.Parameters():
5333 # Parameter of BLSURF algo
5334 return self.params.GetAllEnforcedVertices()
5336 ## To get all the enforced vertices sorted by face (or group, compound)
5337 # @ingroup l3_hypos_blsurf
5338 def GetAllEnforcedVerticesByFace(self):
5339 if self.Parameters():
5340 # Parameter of BLSURF algo
5341 return self.params.GetAllEnforcedVerticesByFace()
5343 ## To get all the enforced vertices sorted by coords of input vertices
5344 # @ingroup l3_hypos_blsurf
5345 def GetAllEnforcedVerticesByCoords(self):
5346 if self.Parameters():
5347 # Parameter of BLSURF algo
5348 return self.params.GetAllEnforcedVerticesByCoords()
5350 ## To get all the coords of input vertices sorted by face (or group, compound)
5351 # @ingroup l3_hypos_blsurf
5352 def GetAllCoordsByFace(self):
5353 if self.Parameters():
5354 # Parameter of BLSURF algo
5355 return self.params.GetAllCoordsByFace()
5357 ## To get all the enforced vertices on a face (or group, compound)
5358 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
5359 # @ingroup l3_hypos_blsurf
5360 def GetEnforcedVertices(self, theFace):
5361 if self.Parameters():
5362 # Parameter of BLSURF algo
5363 AssureGeomPublished( self.mesh, theFace )
5364 return self.params.GetEnforcedVertices(theFace)
5366 ## To clear all the enforced vertices
5367 # @ingroup l3_hypos_blsurf
5368 def ClearAllEnforcedVertices(self):
5369 if self.Parameters():
5370 # Parameter of BLSURF algo
5371 return self.params.ClearAllEnforcedVertices()
5373 ## To set an enforced vertex on a face (or group, compound) given the coordinates of a point. If the point is not on the face, it will projected on it. If there is no projection, no enforced vertex is created.
5374 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
5375 # @param x : x coordinate
5376 # @param y : y coordinate
5377 # @param z : z coordinate
5378 # @param vertexName : name of the enforced vertex
5379 # @param groupName : name of the group
5380 # @ingroup l3_hypos_blsurf
5381 def SetEnforcedVertex(self, theFace, x, y, z, vertexName = "", groupName = ""):
5382 if self.Parameters():
5383 # Parameter of BLSURF algo
5384 AssureGeomPublished( self.mesh, theFace )
5385 if vertexName == "":
5387 return self.params.SetEnforcedVertex(theFace, x, y, z)
5389 return self.params.SetEnforcedVertexWithGroup(theFace, x, y, z, groupName)
5392 return self.params.SetEnforcedVertexNamed(theFace, x, y, z, vertexName)
5394 return self.params.SetEnforcedVertexNamedWithGroup(theFace, x, y, z, vertexName, groupName)
5396 ## To set an enforced vertex on a face (or group, compound) given a GEOM vertex, group or compound.
5397 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
5398 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
5399 # @param groupName : name of the group
5400 # @ingroup l3_hypos_blsurf
5401 def SetEnforcedVertexGeom(self, theFace, theVertex, groupName = ""):
5402 if self.Parameters():
5403 # Parameter of BLSURF algo
5404 AssureGeomPublished( self.mesh, theFace )
5405 AssureGeomPublished( self.mesh, theVertex )
5407 return self.params.SetEnforcedVertexGeom(theFace, theVertex)
5409 return self.params.SetEnforcedVertexGeomWithGroup(theFace, theVertex,groupName)
5411 ## To remove an enforced vertex on a given GEOM face (or group, compound) given the coordinates.
5412 # @param theFace : GEOM face (or group, compound) on which to remove the enforced vertex
5413 # @param x : x coordinate
5414 # @param y : y coordinate
5415 # @param z : z coordinate
5416 # @ingroup l3_hypos_blsurf
5417 def UnsetEnforcedVertex(self, theFace, x, y, z):
5418 if self.Parameters():
5419 # Parameter of BLSURF algo
5420 AssureGeomPublished( self.mesh, theFace )
5421 return self.params.UnsetEnforcedVertex(theFace, x, y, z)
5423 ## To remove an enforced vertex on a given GEOM face (or group, compound) given a GEOM vertex, group or compound.
5424 # @param theFace : GEOM face (or group, compound) on which to remove the enforced vertex
5425 # @param theVertex : GEOM vertex (or group, compound) to remove.
5426 # @ingroup l3_hypos_blsurf
5427 def UnsetEnforcedVertexGeom(self, theFace, theVertex):
5428 if self.Parameters():
5429 # Parameter of BLSURF algo
5430 AssureGeomPublished( self.mesh, theFace )
5431 AssureGeomPublished( self.mesh, theVertex )
5432 return self.params.UnsetEnforcedVertexGeom(theFace, theVertex)
5434 ## To remove all enforced vertices on a given face.
5435 # @param theFace : face (or group/compound of faces) on which to remove all enforced vertices
5436 # @ingroup l3_hypos_blsurf
5437 def UnsetEnforcedVertices(self, theFace):
5438 if self.Parameters():
5439 # Parameter of BLSURF algo
5440 AssureGeomPublished( self.mesh, theFace )
5441 return self.params.UnsetEnforcedVertices(theFace)
5443 ## To tell BLSURF to add a node on internal vertices
5444 # @param toEnforceInternalVertices : boolean; if True the internal vertices are added as enforced vertices
5445 # @ingroup l3_hypos_blsurf
5446 def SetInternalEnforcedVertexAllFaces(self, toEnforceInternalVertices):
5447 if self.Parameters():
5448 # Parameter of BLSURF algo
5449 return self.params.SetInternalEnforcedVertexAllFaces(toEnforceInternalVertices)
5451 ## To know if BLSURF will add a node on internal vertices
5452 # @ingroup l3_hypos_blsurf
5453 def GetInternalEnforcedVertexAllFaces(self):
5454 if self.Parameters():
5455 # Parameter of BLSURF algo
5456 return self.params.GetInternalEnforcedVertexAllFaces()
5458 ## To define a group for the nodes of internal vertices
5459 # @param groupName : string; name of the group
5460 # @ingroup l3_hypos_blsurf
5461 def SetInternalEnforcedVertexAllFacesGroup(self, groupName):
5462 if self.Parameters():
5463 # Parameter of BLSURF algo
5464 return self.params.SetInternalEnforcedVertexAllFacesGroup(groupName)
5466 ## To get the group name of the nodes of internal vertices
5467 # @ingroup l3_hypos_blsurf
5468 def GetInternalEnforcedVertexAllFacesGroup(self):
5469 if self.Parameters():
5470 # Parameter of BLSURF algo
5471 return self.params.GetInternalEnforcedVertexAllFacesGroup()
5473 ## Attractors (BLSURF)
5475 ## Sets an attractor on the chosen face. The mesh size will decrease exponentially with the distance from theAttractor, following the rule h(d) = theEndSize - (theEndSize - theStartSize) * exp [ - ( d / theInfluenceDistance ) ^ 2 ]
5476 # @param theFace : face on which the attractor will be defined
5477 # @param theAttractor : geometrical object from which the mesh size "h" decreases exponentially
5478 # @param theStartSize : mesh size on theAttractor
5479 # @param theEndSize : maximum size that will be reached on theFace
5480 # @param theInfluenceDistance : influence of the attractor ( the size grow slower on theFace if it's high)
5481 # @param theConstantSizeDistance : distance until which the mesh size will be kept constant on theFace
5482 # @ingroup l3_hypos_blsurf
5483 def SetAttractorGeom(self, theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance):
5484 if self.Parameters():
5485 # Parameter of BLSURF algo
5486 AssureGeomPublished( self.mesh, theFace )
5487 AssureGeomPublished( self.mesh, theAttractor )
5488 self.params.SetAttractorGeom(theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance)
5490 ## Unsets an attractor on the chosen face.
5491 # @param theFace : face on which the attractor has to be removed
5492 # @ingroup l3_hypos_blsurf
5493 def UnsetAttractorGeom(self, theFace):
5494 if self.Parameters():
5495 # Parameter of BLSURF algo
5496 AssureGeomPublished( self.mesh, theFace )
5497 self.params.SetAttractorGeom(theFace)
5499 ## Size maps (BLSURF)
5501 ## To set a size map on a face, edge or vertex (or group, compound) given Python function.
5502 # If theObject is a face, the function can be: def f(u,v): return u+v
5503 # If theObject is an edge, the function can be: def f(t): return t/2
5504 # If theObject is a vertex, the function can be: def f(): return 10
5505 # @param theObject : GEOM face, edge or vertex (or group, compound) on which to define a size map
5506 # @param theSizeMap : Size map defined as a string
5507 # @ingroup l3_hypos_blsurf
5508 def SetSizeMap(self, theObject, theSizeMap):
5509 if self.Parameters():
5510 # Parameter of BLSURF algo
5511 AssureGeomPublished( self.mesh, theObject )
5512 return self.params.SetSizeMap(theObject, theSizeMap)
5514 ## To remove a size map defined on a face, edge or vertex (or group, compound)
5515 # @param theObject : GEOM face, edge or vertex (or group, compound) on which to define a size map
5516 # @ingroup l3_hypos_blsurf
5517 def UnsetSizeMap(self, theObject):
5518 if self.Parameters():
5519 # Parameter of BLSURF algo
5520 AssureGeomPublished( self.mesh, theObject )
5521 return self.params.UnsetSizeMap(theObject)
5523 ## To remove all the size maps
5524 # @ingroup l3_hypos_blsurf
5525 def ClearSizeMaps(self):
5526 if self.Parameters():
5527 # Parameter of BLSURF algo
5528 return self.params.ClearSizeMaps()
5531 ## Sets QuadAllowed flag.
5532 # Only for algoType == NETGEN(NETGEN_1D2D) || NETGEN_2D || BLSURF
5533 # @ingroup l3_hypos_netgen l3_hypos_blsurf
5534 def SetQuadAllowed(self, toAllow=True):
5535 if self.algoType == NETGEN_2D:
5538 hasSimpleHyps = False
5539 simpleHyps = ["QuadranglePreference","LengthFromEdges","MaxElementArea"]
5540 for hyp in self.mesh.GetHypothesisList( self.geom ):
5541 if hyp.GetName() in simpleHyps:
5542 hasSimpleHyps = True
5543 if hyp.GetName() == "QuadranglePreference":
5544 if not toAllow: # remove QuadranglePreference
5545 self.mesh.RemoveHypothesis( self.geom, hyp )
5551 if toAllow: # add QuadranglePreference
5552 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
5557 if self.Parameters():
5558 self.params.SetQuadAllowed(toAllow)
5561 ## Defines hypothesis having several parameters
5563 # @ingroup l3_hypos_netgen
5564 def Parameters(self, which=SOLE):
5566 if self.algoType == NETGEN:
5568 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
5569 "libNETGENEngine.so", UseExisting=0)
5571 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
5572 "libNETGENEngine.so", UseExisting=0)
5573 elif self.algoType == MEFISTO:
5574 print "Mefisto algo support no multi-parameter hypothesis"
5575 elif self.algoType == NETGEN_2D:
5576 self.params = self.Hypothesis("NETGEN_Parameters_2D_ONLY", [],
5577 "libNETGENEngine.so", UseExisting=0)
5578 elif self.algoType == BLSURF:
5579 self.params = self.Hypothesis("BLSURF_Parameters", [],
5580 "libBLSURFEngine.so", UseExisting=0)
5582 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
5587 # Only for algoType == NETGEN
5588 # @ingroup l3_hypos_netgen
5589 def SetMaxSize(self, theSize):
5590 if self.Parameters():
5591 self.params.SetMaxSize(theSize)
5593 ## Sets SecondOrder flag
5595 # Only for algoType == NETGEN
5596 # @ingroup l3_hypos_netgen
5597 def SetSecondOrder(self, theVal):
5598 if self.Parameters():
5599 self.params.SetSecondOrder(theVal)
5601 ## Sets Optimize flag
5603 # Only for algoType == NETGEN
5604 # @ingroup l3_hypos_netgen
5605 def SetOptimize(self, theVal):
5606 if self.Parameters():
5607 self.params.SetOptimize(theVal)
5610 # @param theFineness is:
5611 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5613 # Only for algoType == NETGEN
5614 # @ingroup l3_hypos_netgen
5615 def SetFineness(self, theFineness):
5616 if self.Parameters():
5617 self.params.SetFineness(theFineness)
5621 # Only for algoType == NETGEN
5622 # @ingroup l3_hypos_netgen
5623 def SetGrowthRate(self, theRate):
5624 if self.Parameters():
5625 self.params.SetGrowthRate(theRate)
5627 ## Sets NbSegPerEdge
5629 # Only for algoType == NETGEN
5630 # @ingroup l3_hypos_netgen
5631 def SetNbSegPerEdge(self, theVal):
5632 if self.Parameters():
5633 self.params.SetNbSegPerEdge(theVal)
5635 ## Sets NbSegPerRadius
5637 # Only for algoType == NETGEN
5638 # @ingroup l3_hypos_netgen
5639 def SetNbSegPerRadius(self, theVal):
5640 if self.Parameters():
5641 self.params.SetNbSegPerRadius(theVal)
5643 ## Sets number of segments overriding value set by SetLocalLength()
5645 # Only for algoType == NETGEN
5646 # @ingroup l3_hypos_netgen
5647 def SetNumberOfSegments(self, theVal):
5648 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5650 ## Sets number of segments overriding value set by SetNumberOfSegments()
5652 # Only for algoType == NETGEN
5653 # @ingroup l3_hypos_netgen
5654 def SetLocalLength(self, theVal):
5655 self.Parameters(SIMPLE).SetLocalLength(theVal)
5660 # Public class: Mesh_Quadrangle
5661 # -----------------------------
5663 ## Defines a quadrangle 2D algorithm
5665 # @ingroup l3_algos_basic
5666 class Mesh_Quadrangle(Mesh_Algorithm):
5670 ## Private constructor.
5671 def __init__(self, mesh, geom=0):
5672 Mesh_Algorithm.__init__(self)
5673 self.Create(mesh, geom, "Quadrangle_2D")
5676 ## Defines "QuadrangleParameters" hypothesis
5677 # @param quadType defines the algorithm of transition between differently descretized
5678 # sides of a geometrical face:
5679 # - QUAD_STANDARD - both triangles and quadrangles are possible in the transition
5680 # area along the finer meshed sides.
5681 # - QUAD_TRIANGLE_PREF - only triangles are built in the transition area along the
5682 # finer meshed sides.
5683 # - QUAD_QUADRANGLE_PREF - only quadrangles are built in the transition area along
5684 # the finer meshed sides, iff the total quantity of segments on
5685 # all four sides of the face is even (divisible by 2).
5686 # - QUAD_QUADRANGLE_PREF_REVERSED - same as QUAD_QUADRANGLE_PREF but the transition
5687 # area is located along the coarser meshed sides.
5688 # - QUAD_REDUCED - only quadrangles are built and the transition between the sides
5689 # is made gradually, layer by layer. This type has a limitation on
5690 # the number of segments: one pair of opposite sides must have the
5691 # same number of segments, the other pair must have an even difference
5692 # between the numbers of segments on the sides.
5693 # @param triangleVertex: vertex of a trilateral geometrical face, around which triangles
5694 # will be created while other elements will be quadrangles.
5695 # Vertex can be either a GEOM_Object or a vertex ID within the
5697 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5698 # the same parameters, else (default) - creates a new one
5699 # @ingroup l3_hypos_quad
5700 def QuadrangleParameters(self, quadType=StdMeshers.QUAD_STANDARD, triangleVertex=0, UseExisting=0):
5701 vertexID = triangleVertex
5702 if isinstance( triangleVertex, geompyDC.GEOM._objref_GEOM_Object ):
5703 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, triangleVertex )
5705 compFun = lambda hyp,args: \
5706 hyp.GetQuadType() == args[0] and \
5707 ( hyp.GetTriaVertex()==args[1] or ( hyp.GetTriaVertex()<1 and args[1]<1))
5708 self.params = self.Hypothesis("QuadrangleParams", [quadType,vertexID],
5709 UseExisting = UseExisting, CompareMethod=compFun)
5711 if self.params.GetQuadType() != quadType:
5712 self.params.SetQuadType(quadType)
5714 self.params.SetTriaVertex( vertexID )
5717 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5718 # quadrangles are built in the transition area along the finer meshed sides,
5719 # iff the total quantity of segments on all four sides of the face is even.
5720 # @param reversed if True, transition area is located along the coarser meshed sides.
5721 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5722 # the same parameters, else (default) - creates a new one
5723 # @ingroup l3_hypos_quad
5724 def QuadranglePreference(self, reversed=False, UseExisting=0):
5726 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF_REVERSED,UseExisting=UseExisting)
5727 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF,UseExisting=UseExisting)
5729 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5730 # triangles are built in the transition area along the finer meshed sides.
5731 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5732 # the same parameters, else (default) - creates a new one
5733 # @ingroup l3_hypos_quad
5734 def TrianglePreference(self, UseExisting=0):
5735 return self.QuadrangleParameters(QUAD_TRIANGLE_PREF,UseExisting=UseExisting)
5737 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5738 # quadrangles are built and the transition between the sides is made gradually,
5739 # layer by layer. This type has a limitation on the number of segments: one pair
5740 # of opposite sides must have the same number of segments, the other pair must
5741 # have an even difference between the numbers of segments on the sides.
5742 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5743 # the same parameters, else (default) - creates a new one
5744 # @ingroup l3_hypos_quad
5745 def Reduced(self, UseExisting=0):
5746 return self.QuadrangleParameters(QUAD_REDUCED,UseExisting=UseExisting)
5748 ## Defines "QuadrangleParams" hypothesis with QUAD_STANDARD type of quadrangulation
5749 # @param vertex: vertex of a trilateral geometrical face, around which triangles
5750 # will be created while other elements will be quadrangles.
5751 # Vertex can be either a GEOM_Object or a vertex ID within the
5753 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5754 # the same parameters, else (default) - creates a new one
5755 # @ingroup l3_hypos_quad
5756 def TriangleVertex(self, vertex, UseExisting=0):
5757 return self.QuadrangleParameters(QUAD_STANDARD,vertex,UseExisting)
5760 # Public class: Mesh_Tetrahedron
5761 # ------------------------------
5763 ## Defines a tetrahedron 3D algorithm
5765 # @ingroup l3_algos_basic
5766 class Mesh_Tetrahedron(Mesh_Algorithm):
5771 ## Private constructor.
5772 def __init__(self, mesh, algoType, geom=0):
5773 Mesh_Algorithm.__init__(self)
5775 if algoType == NETGEN:
5777 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
5780 elif algoType == FULL_NETGEN:
5782 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5785 elif algoType == GHS3D:
5787 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
5790 elif algoType == GHS3DPRL:
5791 CheckPlugin(GHS3DPRL)
5792 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
5795 self.algoType = algoType
5797 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
5798 # @param vol for the maximum volume of each tetrahedron
5799 # @param UseExisting if ==true - searches for the existing hypothesis created with
5800 # the same parameters, else (default) - creates a new one
5801 # @ingroup l3_hypos_maxvol
5802 def MaxElementVolume(self, vol, UseExisting=0):
5803 if self.algoType == NETGEN:
5804 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
5805 CompareMethod=self.CompareMaxElementVolume)
5806 hyp.SetMaxElementVolume(vol)
5808 elif self.algoType == FULL_NETGEN:
5809 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
5812 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
5813 def CompareMaxElementVolume(self, hyp, args):
5814 return IsEqual(hyp.GetMaxElementVolume(), args[0])
5816 ## Defines hypothesis having several parameters
5818 # @ingroup l3_hypos_netgen
5819 def Parameters(self, which=SOLE):
5822 if self.algoType == FULL_NETGEN:
5824 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
5825 "libNETGENEngine.so", UseExisting=0)
5827 self.params = self.Hypothesis("NETGEN_Parameters", [],
5828 "libNETGENEngine.so", UseExisting=0)
5830 elif self.algoType == NETGEN:
5831 self.params = self.Hypothesis("NETGEN_Parameters_3D", [],
5832 "libNETGENEngine.so", UseExisting=0)
5834 elif self.algoType == GHS3D:
5835 self.params = self.Hypothesis("GHS3D_Parameters", [],
5836 "libGHS3DEngine.so", UseExisting=0)
5838 elif self.algoType == GHS3DPRL:
5839 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
5840 "libGHS3DPRLEngine.so", UseExisting=0)
5842 print "Warning: %s supports no multi-parameter hypothesis"%self.algo.GetName()
5847 # Parameter of FULL_NETGEN and NETGEN
5848 # @ingroup l3_hypos_netgen
5849 def SetMaxSize(self, theSize):
5850 self.Parameters().SetMaxSize(theSize)
5852 ## Sets SecondOrder flag
5853 # Parameter of FULL_NETGEN
5854 # @ingroup l3_hypos_netgen
5855 def SetSecondOrder(self, theVal):
5856 self.Parameters().SetSecondOrder(theVal)
5858 ## Sets Optimize flag
5859 # Parameter of FULL_NETGEN and NETGEN
5860 # @ingroup l3_hypos_netgen
5861 def SetOptimize(self, theVal):
5862 self.Parameters().SetOptimize(theVal)
5865 # @param theFineness is:
5866 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5867 # Parameter of FULL_NETGEN
5868 # @ingroup l3_hypos_netgen
5869 def SetFineness(self, theFineness):
5870 self.Parameters().SetFineness(theFineness)
5873 # Parameter of FULL_NETGEN
5874 # @ingroup l3_hypos_netgen
5875 def SetGrowthRate(self, theRate):
5876 self.Parameters().SetGrowthRate(theRate)
5878 ## Sets NbSegPerEdge
5879 # Parameter of FULL_NETGEN
5880 # @ingroup l3_hypos_netgen
5881 def SetNbSegPerEdge(self, theVal):
5882 self.Parameters().SetNbSegPerEdge(theVal)
5884 ## Sets NbSegPerRadius
5885 # Parameter of FULL_NETGEN
5886 # @ingroup l3_hypos_netgen
5887 def SetNbSegPerRadius(self, theVal):
5888 self.Parameters().SetNbSegPerRadius(theVal)
5890 ## Sets number of segments overriding value set by SetLocalLength()
5891 # Only for algoType == NETGEN_FULL
5892 # @ingroup l3_hypos_netgen
5893 def SetNumberOfSegments(self, theVal):
5894 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5896 ## Sets number of segments overriding value set by SetNumberOfSegments()
5897 # Only for algoType == NETGEN_FULL
5898 # @ingroup l3_hypos_netgen
5899 def SetLocalLength(self, theVal):
5900 self.Parameters(SIMPLE).SetLocalLength(theVal)
5902 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
5903 # Overrides value set by LengthFromEdges()
5904 # Only for algoType == NETGEN_FULL
5905 # @ingroup l3_hypos_netgen
5906 def MaxElementArea(self, area):
5907 self.Parameters(SIMPLE).SetMaxElementArea(area)
5909 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
5910 # Overrides value set by MaxElementArea()
5911 # Only for algoType == NETGEN_FULL
5912 # @ingroup l3_hypos_netgen
5913 def LengthFromEdges(self):
5914 self.Parameters(SIMPLE).LengthFromEdges()
5916 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
5917 # Overrides value set by MaxElementVolume()
5918 # Only for algoType == NETGEN_FULL
5919 # @ingroup l3_hypos_netgen
5920 def LengthFromFaces(self):
5921 self.Parameters(SIMPLE).LengthFromFaces()
5923 ## To mesh "holes" in a solid or not. Default is to mesh.
5924 # @ingroup l3_hypos_ghs3dh
5925 def SetToMeshHoles(self, toMesh):
5926 # Parameter of GHS3D
5927 if self.Parameters():
5928 self.params.SetToMeshHoles(toMesh)
5930 ## Set Optimization level:
5931 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
5932 # Strong_Optimization.
5933 # Default is Standard_Optimization
5934 # @ingroup l3_hypos_ghs3dh
5935 def SetOptimizationLevel(self, level):
5936 # Parameter of GHS3D
5937 if self.Parameters():
5938 self.params.SetOptimizationLevel(level)
5940 ## Maximal size of memory to be used by the algorithm (in Megabytes).
5941 # @ingroup l3_hypos_ghs3dh
5942 def SetMaximumMemory(self, MB):
5943 # Advanced parameter of GHS3D
5944 if self.Parameters():
5945 self.params.SetMaximumMemory(MB)
5947 ## Initial size of memory to be used by the algorithm (in Megabytes) in
5948 # automatic memory adjustment mode.
5949 # @ingroup l3_hypos_ghs3dh
5950 def SetInitialMemory(self, MB):
5951 # Advanced parameter of GHS3D
5952 if self.Parameters():
5953 self.params.SetInitialMemory(MB)
5955 ## Path to working directory.
5956 # @ingroup l3_hypos_ghs3dh
5957 def SetWorkingDirectory(self, path):
5958 # Advanced parameter of GHS3D
5959 if self.Parameters():
5960 self.params.SetWorkingDirectory(path)
5962 ## To keep working files or remove them. Log file remains in case of errors anyway.
5963 # @ingroup l3_hypos_ghs3dh
5964 def SetKeepFiles(self, toKeep):
5965 # Advanced parameter of GHS3D and GHS3DPRL
5966 if self.Parameters():
5967 self.params.SetKeepFiles(toKeep)
5969 ## To set verbose level [0-10]. <ul>
5970 #<li> 0 - no standard output,
5971 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
5972 # indicates when the final mesh is being saved. In addition the software
5973 # gives indication regarding the CPU time.
5974 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
5975 # histogram of the skin mesh, quality statistics histogram together with
5976 # the characteristics of the final mesh.</ul>
5977 # @ingroup l3_hypos_ghs3dh
5978 def SetVerboseLevel(self, level):
5979 # Advanced parameter of GHS3D
5980 if self.Parameters():
5981 self.params.SetVerboseLevel(level)
5983 ## To create new nodes.
5984 # @ingroup l3_hypos_ghs3dh
5985 def SetToCreateNewNodes(self, toCreate):
5986 # Advanced parameter of GHS3D
5987 if self.Parameters():
5988 self.params.SetToCreateNewNodes(toCreate)
5990 ## To use boundary recovery version which tries to create mesh on a very poor
5991 # quality surface mesh.
5992 # @ingroup l3_hypos_ghs3dh
5993 def SetToUseBoundaryRecoveryVersion(self, toUse):
5994 # Advanced parameter of GHS3D
5995 if self.Parameters():
5996 self.params.SetToUseBoundaryRecoveryVersion(toUse)
5998 ## Applies finite-element correction by replacing overconstrained elements where
5999 # it is possible. The process is cutting first the overconstrained edges and
6000 # second the overconstrained facets. This insure that no edges have two boundary
6001 # vertices and that no facets have three boundary vertices.
6002 # @ingroup l3_hypos_ghs3dh
6003 def SetFEMCorrection(self, toUseFem):
6004 # Advanced parameter of GHS3D
6005 if self.Parameters():
6006 self.params.SetFEMCorrection(toUseFem)
6008 ## To removes initial central point.
6009 # @ingroup l3_hypos_ghs3dh
6010 def SetToRemoveCentralPoint(self, toRemove):
6011 # Advanced parameter of GHS3D
6012 if self.Parameters():
6013 self.params.SetToRemoveCentralPoint(toRemove)
6015 ## To set an enforced vertex.
6016 # @param x : x coordinate
6017 # @param y : y coordinate
6018 # @param z : z coordinate
6019 # @param size : size of 1D element around enforced vertex
6020 # @param vertexName : name of the enforced vertex
6021 # @param groupName : name of the group
6022 # @ingroup l3_hypos_ghs3dh
6023 def SetEnforcedVertex(self, x, y, z, size, vertexName = "", groupName = ""):
6024 # Advanced parameter of GHS3D
6025 if self.Parameters():
6026 if vertexName == "":
6028 return self.params.SetEnforcedVertex(x, y, z, size)
6030 return self.params.SetEnforcedVertexWithGroup(x, y, z, size, groupName)
6033 return self.params.SetEnforcedVertexNamed(x, y, z, size, vertexName)
6035 return self.params.SetEnforcedVertexNamedWithGroup(x, y, z, size, vertexName, groupName)
6037 ## To set an enforced vertex given a GEOM vertex, group or compound.
6038 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
6039 # @param size : size of 1D element around enforced vertex
6040 # @param groupName : name of the group
6041 # @ingroup l3_hypos_ghs3dh
6042 def SetEnforcedVertexGeom(self, theVertex, size, groupName = ""):
6043 AssureGeomPublished( self.mesh, theVertex )
6044 # Advanced parameter of GHS3D
6045 if self.Parameters():
6047 return self.params.SetEnforcedVertexGeom(theVertex, size)
6049 return self.params.SetEnforcedVertexGeomWithGroup(theVertex, size, groupName)
6051 ## To remove an enforced vertex.
6052 # @param x : x coordinate
6053 # @param y : y coordinate
6054 # @param z : z coordinate
6055 # @ingroup l3_hypos_ghs3dh
6056 def RemoveEnforcedVertex(self, x, y, z):
6057 # Advanced parameter of GHS3D
6058 if self.Parameters():
6059 return self.params.RemoveEnforcedVertex(x, y, z)
6061 ## To remove an enforced vertex given a GEOM vertex, group or compound.
6062 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
6063 # @ingroup l3_hypos_ghs3dh
6064 def RemoveEnforcedVertexGeom(self, theVertex):
6065 AssureGeomPublished( self.mesh, theVertex )
6066 # Advanced parameter of GHS3D
6067 if self.Parameters():
6068 return self.params.RemoveEnforcedVertexGeom(theVertex)
6070 ## To set an enforced mesh with given size and add the enforced elements in the group "groupName".
6071 # @param theSource : source mesh which provides constraint elements/nodes
6072 # @param elementType : SMESH.ElementType (NODE, EDGE or FACE)
6073 # @param size : size of elements around enforced elements. Unused if -1.
6074 # @param groupName : group in which enforced elements will be added. Unused if "".
6075 # @ingroup l3_hypos_ghs3dh
6076 def SetEnforcedMesh(self, theSource, elementType, size = -1, groupName = ""):
6077 # Advanced parameter of GHS3D
6078 if self.Parameters():
6081 return self.params.SetEnforcedMesh(theSource, elementType)
6083 return self.params.SetEnforcedMeshWithGroup(theSource, elementType, groupName)
6086 return self.params.SetEnforcedMeshSize(theSource, elementType, size)
6088 return self.params.SetEnforcedMeshSizeWithGroup(theSource, elementType, size, groupName)
6090 ## Sets command line option as text.
6091 # @ingroup l3_hypos_ghs3dh
6092 def SetTextOption(self, option):
6093 # Advanced parameter of GHS3D
6094 if self.Parameters():
6095 self.params.SetTextOption(option)
6097 ## Sets MED files name and path.
6098 def SetMEDName(self, value):
6099 if self.Parameters():
6100 self.params.SetMEDName(value)
6102 ## Sets the number of partition of the initial mesh
6103 def SetNbPart(self, value):
6104 if self.Parameters():
6105 self.params.SetNbPart(value)
6107 ## When big mesh, start tepal in background
6108 def SetBackground(self, value):
6109 if self.Parameters():
6110 self.params.SetBackground(value)
6112 # Public class: Mesh_Hexahedron
6113 # ------------------------------
6115 ## Defines a hexahedron 3D algorithm
6117 # @ingroup l3_algos_basic
6118 class Mesh_Hexahedron(Mesh_Algorithm):
6123 ## Private constructor.
6124 def __init__(self, mesh, algoType=Hexa, geom=0):
6125 Mesh_Algorithm.__init__(self)
6127 self.algoType = algoType
6129 if algoType == Hexa:
6130 self.Create(mesh, geom, "Hexa_3D")
6133 elif algoType == Hexotic:
6134 CheckPlugin(Hexotic)
6135 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
6138 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
6139 # @ingroup l3_hypos_hexotic
6140 def MinMaxQuad(self, min=3, max=8, quad=True):
6141 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
6143 self.params.SetHexesMinLevel(min)
6144 self.params.SetHexesMaxLevel(max)
6145 self.params.SetHexoticQuadrangles(quad)
6148 # Deprecated, only for compatibility!
6149 # Public class: Mesh_Netgen
6150 # ------------------------------
6152 ## Defines a NETGEN-based 2D or 3D algorithm
6153 # that needs no discrete boundary (i.e. independent)
6155 # This class is deprecated, only for compatibility!
6158 # @ingroup l3_algos_basic
6159 class Mesh_Netgen(Mesh_Algorithm):
6163 ## Private constructor.
6164 def __init__(self, mesh, is3D, geom=0):
6165 Mesh_Algorithm.__init__(self)
6171 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
6175 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
6178 ## Defines the hypothesis containing parameters of the algorithm
6179 def Parameters(self):
6181 hyp = self.Hypothesis("NETGEN_Parameters", [],
6182 "libNETGENEngine.so", UseExisting=0)
6184 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
6185 "libNETGENEngine.so", UseExisting=0)
6188 # Public class: Mesh_Projection1D
6189 # ------------------------------
6191 ## Defines a projection 1D algorithm
6192 # @ingroup l3_algos_proj
6194 class Mesh_Projection1D(Mesh_Algorithm):
6196 ## Private constructor.
6197 def __init__(self, mesh, geom=0):
6198 Mesh_Algorithm.__init__(self)
6199 self.Create(mesh, geom, "Projection_1D")
6201 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
6202 # a mesh pattern is taken, and, optionally, the association of vertices
6203 # between the source edge and a target edge (to which a hypothesis is assigned)
6204 # @param edge from which nodes distribution is taken
6205 # @param mesh from which nodes distribution is taken (optional)
6206 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
6207 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
6208 # to associate with \a srcV (optional)
6209 # @param UseExisting if ==true - searches for the existing hypothesis created with
6210 # the same parameters, else (default) - creates a new one
6211 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
6212 AssureGeomPublished( self.mesh, edge )
6213 AssureGeomPublished( self.mesh, srcV )
6214 AssureGeomPublished( self.mesh, tgtV )
6215 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
6217 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
6218 hyp.SetSourceEdge( edge )
6219 if isinstance(mesh, Mesh):
6220 mesh = mesh.GetMesh()
6221 hyp.SetSourceMesh( mesh )
6222 hyp.SetVertexAssociation( srcV, tgtV )
6225 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
6226 #def CompareSourceEdge(self, hyp, args):
6227 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
6231 # Public class: Mesh_Projection2D
6232 # ------------------------------
6234 ## Defines a projection 2D algorithm
6235 # @ingroup l3_algos_proj
6237 class Mesh_Projection2D(Mesh_Algorithm):
6239 ## Private constructor.
6240 def __init__(self, mesh, geom=0, algoName="Projection_2D"):
6241 Mesh_Algorithm.__init__(self)
6242 self.Create(mesh, geom, algoName)
6244 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
6245 # a mesh pattern is taken, and, optionally, the association of vertices
6246 # between the source face and the target face (to which a hypothesis is assigned)
6247 # @param face from which the mesh pattern is taken
6248 # @param mesh from which the mesh pattern is taken (optional)
6249 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
6250 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
6251 # to associate with \a srcV1 (optional)
6252 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
6253 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
6254 # to associate with \a srcV2 (optional)
6255 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
6256 # the same parameters, else (default) - forces the creation a new one
6258 # Note: all association vertices must belong to one edge of a face
6259 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
6260 srcV2=None, tgtV2=None, UseExisting=0):
6261 for geom in [ face, srcV1, tgtV1, srcV2, tgtV2 ]:
6262 AssureGeomPublished( self.mesh, geom )
6263 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
6265 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
6266 hyp.SetSourceFace( face )
6267 if isinstance(mesh, Mesh):
6268 mesh = mesh.GetMesh()
6269 hyp.SetSourceMesh( mesh )
6270 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
6273 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
6274 #def CompareSourceFace(self, hyp, args):
6275 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
6278 # Public class: Mesh_Projection3D
6279 # ------------------------------
6281 ## Defines a projection 3D algorithm
6282 # @ingroup l3_algos_proj
6284 class Mesh_Projection3D(Mesh_Algorithm):
6286 ## Private constructor.
6287 def __init__(self, mesh, geom=0):
6288 Mesh_Algorithm.__init__(self)
6289 self.Create(mesh, geom, "Projection_3D")
6291 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
6292 # the mesh pattern is taken, and, optionally, the association of vertices
6293 # between the source and the target solid (to which a hipothesis is assigned)
6294 # @param solid from where the mesh pattern is taken
6295 # @param mesh from where the mesh pattern is taken (optional)
6296 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
6297 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
6298 # to associate with \a srcV1 (optional)
6299 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
6300 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
6301 # to associate with \a srcV2 (optional)
6302 # @param UseExisting - if ==true - searches for the existing hypothesis created with
6303 # the same parameters, else (default) - creates a new one
6305 # Note: association vertices must belong to one edge of a solid
6306 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
6307 srcV2=0, tgtV2=0, UseExisting=0):
6308 for geom in [ solid, srcV1, tgtV1, srcV2, tgtV2 ]:
6309 AssureGeomPublished( self.mesh, geom )
6310 hyp = self.Hypothesis("ProjectionSource3D",
6311 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
6313 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
6314 hyp.SetSource3DShape( solid )
6315 if isinstance(mesh, Mesh):
6316 mesh = mesh.GetMesh()
6317 hyp.SetSourceMesh( mesh )
6318 if srcV1 and srcV2 and tgtV1 and tgtV2:
6319 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
6320 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
6323 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
6324 #def CompareSourceShape3D(self, hyp, args):
6325 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
6329 # Public class: Mesh_Prism
6330 # ------------------------
6332 ## Defines a 3D extrusion algorithm
6333 # @ingroup l3_algos_3dextr
6335 class Mesh_Prism3D(Mesh_Algorithm):
6337 ## Private constructor.
6338 def __init__(self, mesh, geom=0):
6339 Mesh_Algorithm.__init__(self)
6340 self.Create(mesh, geom, "Prism_3D")
6342 # Public class: Mesh_RadialPrism
6343 # -------------------------------
6345 ## Defines a Radial Prism 3D algorithm
6346 # @ingroup l3_algos_radialp
6348 class Mesh_RadialPrism3D(Mesh_Algorithm):
6350 ## Private constructor.
6351 def __init__(self, mesh, geom=0):
6352 Mesh_Algorithm.__init__(self)
6353 self.Create(mesh, geom, "RadialPrism_3D")
6355 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
6356 self.nbLayers = None
6358 ## Return 3D hypothesis holding the 1D one
6359 def Get3DHypothesis(self):
6360 return self.distribHyp
6362 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
6363 # hypothesis. Returns the created hypothesis
6364 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
6365 #print "OwnHypothesis",hypType
6366 if not self.nbLayers is None:
6367 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
6368 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
6369 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
6370 self.mesh.smeshpyD.SetCurrentStudy( None )
6371 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
6372 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
6373 self.distribHyp.SetLayerDistribution( hyp )
6376 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
6377 # prisms to build between the inner and outer shells
6378 # @param n number of layers
6379 # @param UseExisting if ==true - searches for the existing hypothesis created with
6380 # the same parameters, else (default) - creates a new one
6381 def NumberOfLayers(self, n, UseExisting=0):
6382 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
6383 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
6384 CompareMethod=self.CompareNumberOfLayers)
6385 self.nbLayers.SetNumberOfLayers( n )
6386 return self.nbLayers
6388 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
6389 def CompareNumberOfLayers(self, hyp, args):
6390 return IsEqual(hyp.GetNumberOfLayers(), args[0])
6392 ## Defines "LocalLength" hypothesis, specifying the segment length
6393 # to build between the inner and the outer shells
6394 # @param l the length of segments
6395 # @param p the precision of rounding
6396 def LocalLength(self, l, p=1e-07):
6397 hyp = self.OwnHypothesis("LocalLength", [l,p])
6402 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
6403 # prisms to build between the inner and the outer shells.
6404 # @param n the number of layers
6405 # @param s the scale factor (optional)
6406 def NumberOfSegments(self, n, s=[]):
6408 hyp = self.OwnHypothesis("NumberOfSegments", [n])
6410 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
6411 hyp.SetDistrType( 1 )
6412 hyp.SetScaleFactor(s)
6413 hyp.SetNumberOfSegments(n)
6416 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
6417 # to build between the inner and the outer shells with a length that changes in arithmetic progression
6418 # @param start the length of the first segment
6419 # @param end the length of the last segment
6420 def Arithmetic1D(self, start, end ):
6421 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
6422 hyp.SetLength(start, 1)
6423 hyp.SetLength(end , 0)
6426 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
6427 # to build between the inner and the outer shells as geometric length increasing
6428 # @param start for the length of the first segment
6429 # @param end for the length of the last segment
6430 def StartEndLength(self, start, end):
6431 hyp = self.OwnHypothesis("StartEndLength", [start, end])
6432 hyp.SetLength(start, 1)
6433 hyp.SetLength(end , 0)
6436 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
6437 # to build between the inner and outer shells
6438 # @param fineness defines the quality of the mesh within the range [0-1]
6439 def AutomaticLength(self, fineness=0):
6440 hyp = self.OwnHypothesis("AutomaticLength")
6441 hyp.SetFineness( fineness )
6444 # Public class: Mesh_RadialQuadrangle1D2D
6445 # -------------------------------
6447 ## Defines a Radial Quadrangle 1D2D algorithm
6448 # @ingroup l2_algos_radialq
6450 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
6452 ## Private constructor.
6453 def __init__(self, mesh, geom=0):
6454 Mesh_Algorithm.__init__(self)
6455 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
6457 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
6458 self.nbLayers = None
6460 ## Return 2D hypothesis holding the 1D one
6461 def Get2DHypothesis(self):
6462 return self.distribHyp
6464 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
6465 # hypothesis. Returns the created hypothesis
6466 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
6467 #print "OwnHypothesis",hypType
6469 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
6470 if self.distribHyp is None:
6471 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
6473 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
6474 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
6475 self.mesh.smeshpyD.SetCurrentStudy( None )
6476 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
6477 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
6478 self.distribHyp.SetLayerDistribution( hyp )
6481 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
6482 # @param n number of layers
6483 # @param UseExisting if ==true - searches for the existing hypothesis created with
6484 # the same parameters, else (default) - creates a new one
6485 def NumberOfLayers(self, n, UseExisting=0):
6487 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
6488 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
6489 CompareMethod=self.CompareNumberOfLayers)
6490 self.nbLayers.SetNumberOfLayers( n )
6491 return self.nbLayers
6493 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
6494 def CompareNumberOfLayers(self, hyp, args):
6495 return IsEqual(hyp.GetNumberOfLayers(), args[0])
6497 ## Defines "LocalLength" hypothesis, specifying the segment length
6498 # @param l the length of segments
6499 # @param p the precision of rounding
6500 def LocalLength(self, l, p=1e-07):
6501 hyp = self.OwnHypothesis("LocalLength", [l,p])
6506 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
6507 # @param n the number of layers
6508 # @param s the scale factor (optional)
6509 def NumberOfSegments(self, n, s=[]):
6511 hyp = self.OwnHypothesis("NumberOfSegments", [n])
6513 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
6514 hyp.SetDistrType( 1 )
6515 hyp.SetScaleFactor(s)
6516 hyp.SetNumberOfSegments(n)
6519 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
6520 # with a length that changes in arithmetic progression
6521 # @param start the length of the first segment
6522 # @param end the length of the last segment
6523 def Arithmetic1D(self, start, end ):
6524 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
6525 hyp.SetLength(start, 1)
6526 hyp.SetLength(end , 0)
6529 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
6530 # as geometric length increasing
6531 # @param start for the length of the first segment
6532 # @param end for the length of the last segment
6533 def StartEndLength(self, start, end):
6534 hyp = self.OwnHypothesis("StartEndLength", [start, end])
6535 hyp.SetLength(start, 1)
6536 hyp.SetLength(end , 0)
6539 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
6540 # @param fineness defines the quality of the mesh within the range [0-1]
6541 def AutomaticLength(self, fineness=0):
6542 hyp = self.OwnHypothesis("AutomaticLength")
6543 hyp.SetFineness( fineness )
6547 # Public class: Mesh_UseExistingElements
6548 # --------------------------------------
6549 ## Defines a Radial Quadrangle 1D2D algorithm
6550 # @ingroup l3_algos_basic
6552 class Mesh_UseExistingElements(Mesh_Algorithm):
6554 def __init__(self, dim, mesh, geom=0):
6556 self.Create(mesh, geom, "Import_1D")
6558 self.Create(mesh, geom, "Import_1D2D")
6561 ## Defines "Source edges" hypothesis, specifying groups of edges to import
6562 # @param groups list of groups of edges
6563 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
6564 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
6565 # @param UseExisting if ==true - searches for the existing hypothesis created with
6566 # the same parameters, else (default) - creates a new one
6567 def SourceEdges(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
6568 if self.algo.GetName() != "Import_1D":
6569 raise ValueError, "algoritm dimension mismatch"
6570 for group in groups:
6571 AssureGeomPublished( self.mesh, group )
6572 hyp = self.Hypothesis("ImportSource1D", [groups, toCopyMesh, toCopyGroups],
6573 UseExisting=UseExisting, CompareMethod=self._compareHyp)
6574 hyp.SetSourceEdges(groups)
6575 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
6578 ## Defines "Source faces" hypothesis, specifying groups of faces to import
6579 # @param groups list of groups of faces
6580 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
6581 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
6582 # @param UseExisting if ==true - searches for the existing hypothesis created with
6583 # the same parameters, else (default) - creates a new one
6584 def SourceFaces(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
6585 if self.algo.GetName() == "Import_1D":
6586 raise ValueError, "algoritm dimension mismatch"
6587 for group in groups:
6588 AssureGeomPublished( self.mesh, group )
6589 hyp = self.Hypothesis("ImportSource2D", [groups, toCopyMesh, toCopyGroups],
6590 UseExisting=UseExisting, CompareMethod=self._compareHyp)
6591 hyp.SetSourceFaces(groups)
6592 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
6595 def _compareHyp(self,hyp,args):
6596 if hasattr( hyp, "GetSourceEdges"):
6597 entries = hyp.GetSourceEdges()
6599 entries = hyp.GetSourceFaces()
6601 toCopyMesh,toCopyGroups = hyp.GetCopySourceMesh()
6602 if len(entries)==len(groups) and toCopyMesh==args[1] and toCopyGroups==args[2]:
6604 study = self.mesh.smeshpyD.GetCurrentStudy()
6607 ior = salome.orb.object_to_string(g)
6608 sobj = study.FindObjectIOR(ior)
6609 if sobj: entries2.append( sobj.GetID() )
6614 return entries == entries2
6617 # Public class: Mesh_Cartesian_3D
6618 # --------------------------------------
6619 ## Defines a Body Fitting 3D algorithm
6620 # @ingroup l3_algos_basic
6622 class Mesh_Cartesian_3D(Mesh_Algorithm):
6624 def __init__(self, mesh, geom=0):
6625 self.Create(mesh, geom, "Cartesian_3D")
6629 ## Defines "Body Fitting parameters" hypothesis
6630 # @param xGridDef is definition of the grid along the X asix.
6631 # It can be in either of two following forms:
6632 # - Explicit coordinates of nodes, e.g. [-1.5, 0.0, 3.1] or range( -100,200,10)
6633 # - Functions f(t) defining grid spacing at each point on grid axis. If there are
6634 # several functions, they must be accompanied by relative coordinates of
6635 # points dividing the whole shape into ranges where the functions apply; points
6636 # coodrinates should vary within (0.0, 1.0) range. Parameter \a t of the spacing
6637 # function f(t) varies from 0.0 to 1.0 witin a shape range.
6639 # - "10.5" - defines a grid with a constant spacing
6640 # - [["1", "1+10*t", "11"] [0.1, 0.6]] - defines different spacing in 3 ranges.
6641 # @param yGridDef defines the grid along the Y asix the same way as \a xGridDef does
6642 # @param zGridDef defines the grid along the Z asix the same way as \a xGridDef does
6643 # @param sizeThreshold (> 1.0) defines a minimal size of a polyhedron so that
6644 # a polyhedron of size less than hexSize/sizeThreshold is not created
6645 # @param UseExisting if ==true - searches for the existing hypothesis created with
6646 # the same parameters, else (default) - creates a new one
6647 def SetGrid(self, xGridDef, yGridDef, zGridDef, sizeThreshold=4.0, UseExisting=False):
6649 self.hyp = self.Hypothesis("CartesianParameters3D",
6650 [xGridDef, yGridDef, zGridDef, sizeThreshold],
6651 UseExisting=UseExisting, CompareMethod=self._compareHyp)
6652 if not self.mesh.IsUsedHypothesis( self.hyp, self.geom ):
6653 self.mesh.AddHypothesis( self.hyp, self.geom )
6655 for axis, gridDef in enumerate( [xGridDef, yGridDef, zGridDef]):
6656 if not gridDef: raise ValueError, "Empty grid definition"
6657 if isinstance( gridDef, str ):
6658 self.hyp.SetGridSpacing( [gridDef], [], axis )
6659 elif isinstance( gridDef[0], str ):
6660 self.hyp.SetGridSpacing( gridDef, [], axis )
6661 elif isinstance( gridDef[0], int ) or \
6662 isinstance( gridDef[0], float ):
6663 self.hyp.SetGrid(gridDef, axis )
6665 self.hyp.SetGridSpacing( gridDef[0], gridDef[1], axis )
6666 self.hyp.SetSizeThreshold( sizeThreshold )
6669 def _compareHyp(self,hyp,args):
6670 # not implemented yet
6673 # Public class: Mesh_UseExisting
6674 # -------------------------------
6675 class Mesh_UseExisting(Mesh_Algorithm):
6677 def __init__(self, dim, mesh, geom=0):
6679 self.Create(mesh, geom, "UseExisting_1D")
6681 self.Create(mesh, geom, "UseExisting_2D")
6684 import salome_notebook
6685 notebook = salome_notebook.notebook
6687 ##Return values of the notebook variables
6688 def ParseParameters(last, nbParams,nbParam, value):
6692 listSize = len(last)
6693 for n in range(0,nbParams):
6695 if counter < listSize:
6696 strResult = strResult + last[counter]
6698 strResult = strResult + ""
6700 if isinstance(value, str):
6701 if notebook.isVariable(value):
6702 result = notebook.get(value)
6703 strResult=strResult+value
6705 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
6707 strResult=strResult+str(value)
6709 if nbParams - 1 != counter:
6710 strResult=strResult+var_separator #":"
6712 return result, strResult
6714 #Wrapper class for StdMeshers_LocalLength hypothesis
6715 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
6717 ## Set Length parameter value
6718 # @param length numerical value or name of variable from notebook
6719 def SetLength(self, length):
6720 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
6721 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6722 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
6724 ## Set Precision parameter value
6725 # @param precision numerical value or name of variable from notebook
6726 def SetPrecision(self, precision):
6727 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
6728 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6729 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
6731 #Registering the new proxy for LocalLength
6732 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
6735 #Wrapper class for StdMeshers_LayerDistribution hypothesis
6736 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
6738 def SetLayerDistribution(self, hypo):
6739 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
6740 hypo.ClearParameters();
6741 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
6743 #Registering the new proxy for LayerDistribution
6744 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
6746 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
6747 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
6749 ## Set Length parameter value
6750 # @param length numerical value or name of variable from notebook
6751 def SetLength(self, length):
6752 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
6753 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
6754 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
6756 #Registering the new proxy for SegmentLengthAroundVertex
6757 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
6760 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
6761 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
6763 ## Set Length parameter value
6764 # @param length numerical value or name of variable from notebook
6765 # @param isStart true is length is Start Length, otherwise false
6766 def SetLength(self, length, isStart):
6770 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
6771 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
6772 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
6774 #Registering the new proxy for Arithmetic1D
6775 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
6777 #Wrapper class for StdMeshers_Deflection1D hypothesis
6778 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
6780 ## Set Deflection parameter value
6781 # @param deflection numerical value or name of variable from notebook
6782 def SetDeflection(self, deflection):
6783 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
6784 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
6785 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
6787 #Registering the new proxy for Deflection1D
6788 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
6790 #Wrapper class for StdMeshers_StartEndLength hypothesis
6791 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
6793 ## Set Length parameter value
6794 # @param length numerical value or name of variable from notebook
6795 # @param isStart true is length is Start Length, otherwise false
6796 def SetLength(self, length, isStart):
6800 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
6801 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
6802 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
6804 #Registering the new proxy for StartEndLength
6805 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
6807 #Wrapper class for StdMeshers_MaxElementArea hypothesis
6808 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
6810 ## Set Max Element Area parameter value
6811 # @param area numerical value or name of variable from notebook
6812 def SetMaxElementArea(self, area):
6813 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
6814 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
6815 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
6817 #Registering the new proxy for MaxElementArea
6818 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
6821 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
6822 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
6824 ## Set Max Element Volume parameter value
6825 # @param volume numerical value or name of variable from notebook
6826 def SetMaxElementVolume(self, volume):
6827 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
6828 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
6829 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
6831 #Registering the new proxy for MaxElementVolume
6832 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
6835 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
6836 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
6838 ## Set Number Of Layers parameter value
6839 # @param nbLayers numerical value or name of variable from notebook
6840 def SetNumberOfLayers(self, nbLayers):
6841 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
6842 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
6843 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
6845 #Registering the new proxy for NumberOfLayers
6846 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
6848 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
6849 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
6851 ## Set Number Of Segments parameter value
6852 # @param nbSeg numerical value or name of variable from notebook
6853 def SetNumberOfSegments(self, nbSeg):
6854 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
6855 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
6856 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6857 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
6859 ## Set Scale Factor parameter value
6860 # @param factor numerical value or name of variable from notebook
6861 def SetScaleFactor(self, factor):
6862 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
6863 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6864 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
6866 #Registering the new proxy for NumberOfSegments
6867 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
6869 if not noNETGENPlugin:
6870 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
6871 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
6873 ## Set Max Size parameter value
6874 # @param maxsize numerical value or name of variable from notebook
6875 def SetMaxSize(self, maxsize):
6876 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6877 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
6878 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6879 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
6881 ## Set Growth Rate parameter value
6882 # @param value numerical value or name of variable from notebook
6883 def SetGrowthRate(self, value):
6884 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6885 value, parameters = ParseParameters(lastParameters,4,2,value)
6886 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6887 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
6889 ## Set Number of Segments per Edge parameter value
6890 # @param value numerical value or name of variable from notebook
6891 def SetNbSegPerEdge(self, value):
6892 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6893 value, parameters = ParseParameters(lastParameters,4,3,value)
6894 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6895 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
6897 ## Set Number of Segments per Radius parameter value
6898 # @param value numerical value or name of variable from notebook
6899 def SetNbSegPerRadius(self, value):
6900 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6901 value, parameters = ParseParameters(lastParameters,4,4,value)
6902 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6903 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
6905 #Registering the new proxy for NETGENPlugin_Hypothesis
6906 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
6909 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
6910 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
6913 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
6914 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
6916 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
6917 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
6919 ## Set Number of Segments parameter value
6920 # @param nbSeg numerical value or name of variable from notebook
6921 def SetNumberOfSegments(self, nbSeg):
6922 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6923 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
6924 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6925 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
6927 ## Set Local Length parameter value
6928 # @param length numerical value or name of variable from notebook
6929 def SetLocalLength(self, length):
6930 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6931 length, parameters = ParseParameters(lastParameters,2,1,length)
6932 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6933 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
6935 ## Set Max Element Area parameter value
6936 # @param area numerical value or name of variable from notebook
6937 def SetMaxElementArea(self, area):
6938 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6939 area, parameters = ParseParameters(lastParameters,2,2,area)
6940 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6941 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
6943 def LengthFromEdges(self):
6944 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6946 value, parameters = ParseParameters(lastParameters,2,2,value)
6947 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6948 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
6950 #Registering the new proxy for NETGEN_SimpleParameters_2D
6951 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
6954 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
6955 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
6956 ## Set Max Element Volume parameter value
6957 # @param volume numerical value or name of variable from notebook
6958 def SetMaxElementVolume(self, volume):
6959 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6960 volume, parameters = ParseParameters(lastParameters,3,3,volume)
6961 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6962 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
6964 def LengthFromFaces(self):
6965 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6967 value, parameters = ParseParameters(lastParameters,3,3,value)
6968 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6969 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
6971 #Registering the new proxy for NETGEN_SimpleParameters_3D
6972 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
6974 pass # if not noNETGENPlugin:
6976 class Pattern(SMESH._objref_SMESH_Pattern):
6978 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
6980 if isinstance(theNodeIndexOnKeyPoint1,str):
6982 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
6984 theNodeIndexOnKeyPoint1 -= 1
6985 theMesh.SetParameters(Parameters)
6986 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
6988 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
6991 if isinstance(theNode000Index,str):
6993 if isinstance(theNode001Index,str):
6995 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
6997 theNode000Index -= 1
6999 theNode001Index -= 1
7000 theMesh.SetParameters(Parameters)
7001 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
7003 #Registering the new proxy for Pattern
7004 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)