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 Treshold 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
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 treshold
864 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
865 aCriterion.ThresholdStr = GetName(aTreshold)
866 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
868 print "Error: The treshold 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 treshold
876 if isinstance(aTreshold, str):
877 aCriterion.ThresholdStr = aTreshold
879 print "Error: The treshold should be a string."
881 elif CritType == FT_CoplanarFaces:
882 # Checks the treshold
883 if isinstance(aTreshold, int):
884 aCriterion.ThresholdID = "%s"%aTreshold
885 elif isinstance(aTreshold, str):
888 raise ValueError, "Invalid ID of mesh face: '%s'"%aTreshold
889 aCriterion.ThresholdID = aTreshold
892 "The treshold should be an ID of mesh face and not '%s'"%aTreshold
893 elif CritType == FT_ElemGeomType:
894 # Checks the treshold
896 aCriterion.Threshold = self.EnumToLong(aTreshold)
897 assert( aTreshold in SMESH.GeometryType._items )
899 if isinstance(aTreshold, int):
900 aCriterion.Threshold = aTreshold
902 print "Error: The treshold should be an integer or SMESH.GeometryType."
906 elif CritType == FT_GroupColor:
907 # Checks the treshold
909 aCriterion.ThresholdStr = self.ColorToString(aTreshold)
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 treshold is unnecessary
920 if aTreshold == FT_LogicalNOT:
921 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
922 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
923 aCriterion.BinaryOp = aTreshold
927 aTreshold = float(aTreshold)
928 aCriterion.Threshold = aTreshold
930 print "Error: The treshold should be a number."
933 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
934 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
936 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
937 aCriterion.BinaryOp = self.EnumToLong(Treshold)
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 Treshold 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, Treshold, 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 ## Returns true if the hypotheses are defined well
1259 # @param theSubObject a sub-shape of a mesh shape
1260 # @return True or False
1261 # @ingroup l2_construct
1262 def IsReadyToCompute(self, theSubObject):
1263 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
1265 ## Returns errors of hypotheses definition.
1266 # The list of errors is empty if everything is OK.
1267 # @param theSubObject a sub-shape of a mesh shape
1268 # @return a list of errors
1269 # @ingroup l2_construct
1270 def GetAlgoState(self, theSubObject):
1271 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
1273 ## Returns a geometrical object on which the given element was built.
1274 # The returned geometrical object, if not nil, is either found in the
1275 # study or published by this method with the given name
1276 # @param theElementID the id of the mesh element
1277 # @param theGeomName the user-defined name of the geometrical object
1278 # @return GEOM::GEOM_Object instance
1279 # @ingroup l2_construct
1280 def GetGeometryByMeshElement(self, theElementID, theGeomName):
1281 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
1283 ## Returns the mesh dimension depending on the dimension of the underlying shape
1284 # @return mesh dimension as an integer value [0,3]
1285 # @ingroup l1_auxiliary
1286 def MeshDimension(self):
1287 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
1288 if len( shells ) > 0 :
1290 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
1292 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
1298 ## Creates a segment discretization 1D algorithm.
1299 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
1300 # \n If the optional \a geom parameter is not set, this algorithm is global.
1301 # Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1302 # @param algo the type of the required algorithm. Possible values are:
1304 # - smesh.PYTHON for discretization via a python function,
1305 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
1306 # @param geom If defined is the sub-shape to be meshed
1307 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
1308 # @ingroup l3_algos_basic
1309 def Segment(self, algo=REGULAR, geom=0):
1310 ## if Segment(geom) is called by mistake
1311 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
1312 algo, geom = geom, algo
1313 if not algo: algo = REGULAR
1316 return Mesh_Segment(self, geom)
1317 elif algo == PYTHON:
1318 return Mesh_Segment_Python(self, geom)
1319 elif algo == COMPOSITE:
1320 return Mesh_CompositeSegment(self, geom)
1322 return Mesh_Segment(self, geom)
1324 ## Creates 1D algorithm importing segments conatined in groups of other mesh.
1325 # If the optional \a geom parameter is not set, this algorithm is global.
1326 # Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1327 # @param geom If defined the subshape is to be meshed
1328 # @return an instance of Mesh_UseExistingElements class
1329 # @ingroup l3_algos_basic
1330 def UseExisting1DElements(self, geom=0):
1331 return Mesh_UseExistingElements(1,self, geom)
1333 ## Creates 2D algorithm importing faces conatined in groups of other mesh.
1334 # If the optional \a geom parameter is not set, this algorithm is global.
1335 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1336 # @param geom If defined the sub-shape is to be meshed
1337 # @return an instance of Mesh_UseExistingElements class
1338 # @ingroup l3_algos_basic
1339 def UseExisting2DElements(self, geom=0):
1340 return Mesh_UseExistingElements(2,self, geom)
1342 ## Enables creation of nodes and segments usable by 2D algoritms.
1343 # The added nodes and segments must be bound to edges and vertices by
1344 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
1345 # If the optional \a geom parameter is not set, this algorithm is global.
1346 # \n Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1347 # @param geom the sub-shape to be manually meshed
1348 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
1349 # @ingroup l3_algos_basic
1350 def UseExistingSegments(self, geom=0):
1351 algo = Mesh_UseExisting(1,self,geom)
1352 return algo.GetAlgorithm()
1354 ## Enables creation of nodes and faces usable by 3D algoritms.
1355 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
1356 # and SetMeshElementOnShape()
1357 # If the optional \a geom parameter is not set, this algorithm is global.
1358 # \n Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1359 # @param geom the sub-shape to be manually meshed
1360 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1361 # @ingroup l3_algos_basic
1362 def UseExistingFaces(self, geom=0):
1363 algo = Mesh_UseExisting(2,self,geom)
1364 return algo.GetAlgorithm()
1366 ## Creates a triangle 2D algorithm for faces.
1367 # If the optional \a geom parameter is not set, this algorithm is global.
1368 # \n Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1369 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1370 # @param geom If defined, the sub-shape to be meshed (GEOM_Object)
1371 # @return an instance of Mesh_Triangle algorithm
1372 # @ingroup l3_algos_basic
1373 def Triangle(self, algo=MEFISTO, geom=0):
1374 ## if Triangle(geom) is called by mistake
1375 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1378 return Mesh_Triangle(self, algo, geom)
1380 ## Creates a quadrangle 2D algorithm for faces.
1381 # If the optional \a geom parameter is not set, this algorithm is global.
1382 # \n Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1383 # @param geom If defined, the sub-shape to be meshed (GEOM_Object)
1384 # @param algo values are: smesh.QUADRANGLE || smesh.RADIAL_QUAD
1385 # @return an instance of Mesh_Quadrangle algorithm
1386 # @ingroup l3_algos_basic
1387 def Quadrangle(self, geom=0, algo=QUADRANGLE):
1388 if algo==RADIAL_QUAD:
1389 return Mesh_RadialQuadrangle1D2D(self,geom)
1391 return Mesh_Quadrangle(self, geom)
1393 ## Creates a tetrahedron 3D algorithm for solids.
1394 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1395 # If the optional \a geom parameter is not set, this algorithm is global.
1396 # \n Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1397 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1398 # @param geom If defined, the sub-shape to be meshed (GEOM_Object)
1399 # @return an instance of Mesh_Tetrahedron algorithm
1400 # @ingroup l3_algos_basic
1401 def Tetrahedron(self, algo=NETGEN, geom=0):
1402 ## if Tetrahedron(geom) is called by mistake
1403 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1404 algo, geom = geom, algo
1405 if not algo: algo = NETGEN
1407 return Mesh_Tetrahedron(self, algo, geom)
1409 ## Creates a hexahedron 3D algorithm for solids.
1410 # If the optional \a geom parameter is not set, this algorithm is global.
1411 # \n Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1412 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1413 # @param geom If defined, the sub-shape to be meshed (GEOM_Object)
1414 # @return an instance of Mesh_Hexahedron algorithm
1415 # @ingroup l3_algos_basic
1416 def Hexahedron(self, algo=Hexa, geom=0):
1417 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1418 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1419 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1420 elif geom == 0: algo, geom = Hexa, algo
1421 return Mesh_Hexahedron(self, algo, geom)
1423 ## Deprecated, used only for compatibility!
1424 # @return an instance of Mesh_Netgen algorithm
1425 # @ingroup l3_algos_basic
1426 def Netgen(self, is3D, geom=0):
1427 return Mesh_Netgen(self, is3D, geom)
1429 ## Creates a projection 1D algorithm for edges.
1430 # If the optional \a geom parameter is not set, this algorithm is global.
1431 # Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1432 # @param geom If defined, the sub-shape to be meshed
1433 # @return an instance of Mesh_Projection1D algorithm
1434 # @ingroup l3_algos_proj
1435 def Projection1D(self, geom=0):
1436 return Mesh_Projection1D(self, geom)
1438 ## Creates a projection 1D-2D algorithm for faces.
1439 # If the optional \a geom parameter is not set, this algorithm is global.
1440 # Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1441 # @param geom If defined, the sub-shape to be meshed
1442 # @return an instance of Mesh_Projection2D algorithm
1443 # @ingroup l3_algos_proj
1444 def Projection1D2D(self, geom=0):
1445 return Mesh_Projection2D(self, geom, "Projection_1D2D")
1447 ## Creates a projection 2D algorithm for faces.
1448 # If the optional \a geom parameter is not set, this algorithm is global.
1449 # Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1450 # @param geom If defined, the sub-shape to be meshed
1451 # @return an instance of Mesh_Projection2D algorithm
1452 # @ingroup l3_algos_proj
1453 def Projection2D(self, geom=0):
1454 return Mesh_Projection2D(self, geom, "Projection_2D")
1456 ## Creates a projection 3D algorithm for solids.
1457 # If the optional \a geom parameter is not set, this algorithm is global.
1458 # Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1459 # @param geom If defined, the sub-shape to be meshed
1460 # @return an instance of Mesh_Projection3D algorithm
1461 # @ingroup l3_algos_proj
1462 def Projection3D(self, geom=0):
1463 return Mesh_Projection3D(self, geom)
1465 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1466 # If the optional \a geom parameter is not set, this algorithm is global.
1467 # Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1468 # @param geom If defined, the sub-shape to be meshed
1469 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1470 # @ingroup l3_algos_radialp l3_algos_3dextr
1471 def Prism(self, geom=0):
1475 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1476 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1477 if nbSolids == 0 or nbSolids == nbShells:
1478 return Mesh_Prism3D(self, geom)
1479 return Mesh_RadialPrism3D(self, geom)
1481 ## Creates a "Body Fitted" 3D algorithm for solids, which generates
1482 # 3D structured Cartesian mesh in the internal part of a solid shape
1483 # and polyhedral volumes near the shape boundary.
1484 # If the optional \a geom parameter is not set, this algorithm is global.
1485 # Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1486 # The algorithm does not support submeshes.
1487 # Generally usage of this algorithm as a local one is useless since
1488 # it does not discretize 1D and 2D sub-shapes in a usual way acceptable
1489 # for other algorithms.
1490 # @param geom If defined, the sub-shape to be meshed
1491 # @return an instance of Mesh_Cartesian_3D algorithm
1492 # @ingroup l3_algos_basic
1493 def BodyFitted(self, geom=0):
1494 return Mesh_Cartesian_3D(self, geom)
1496 ## Evaluates size of prospective mesh on a shape
1497 # @return a list where i-th element is a number of elements of i-th SMESH.EntityType
1498 # To know predicted number of e.g. edges, inquire it this way
1499 # Evaluate()[ EnumToLong( Entity_Edge )]
1500 def Evaluate(self, geom=0):
1501 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1503 geom = self.mesh.GetShapeToMesh()
1506 return self.smeshpyD.Evaluate(self.mesh, geom)
1509 ## Computes the mesh and returns the status of the computation
1510 # @param geom geomtrical shape on which mesh data should be computed
1511 # @param discardModifs if True and the mesh has been edited since
1512 # a last total re-compute and that may prevent successful partial re-compute,
1513 # then the mesh is cleaned before Compute()
1514 # @return True or False
1515 # @ingroup l2_construct
1516 def Compute(self, geom=0, discardModifs=False):
1517 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1519 geom = self.mesh.GetShapeToMesh()
1524 if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693
1526 ok = self.smeshpyD.Compute(self.mesh, geom)
1527 except SALOME.SALOME_Exception, ex:
1528 print "Mesh computation failed, exception caught:"
1529 print " ", ex.details.text
1532 print "Mesh computation failed, exception caught:"
1533 traceback.print_exc()
1537 # Treat compute errors
1538 computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
1539 for err in computeErrors:
1541 if self.mesh.HasShapeToMesh():
1543 mainIOR = salome.orb.object_to_string(geom)
1544 for sname in salome.myStudyManager.GetOpenStudies():
1545 s = salome.myStudyManager.GetStudyByName(sname)
1547 mainSO = s.FindObjectIOR(mainIOR)
1548 if not mainSO: continue
1549 if err.subShapeID == 1:
1550 shapeText = ' on "%s"' % mainSO.GetName()
1551 subIt = s.NewChildIterator(mainSO)
1553 subSO = subIt.Value()
1555 obj = subSO.GetObject()
1556 if not obj: continue
1557 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
1559 ids = go.GetSubShapeIndices()
1560 if len(ids) == 1 and ids[0] == err.subShapeID:
1561 shapeText = ' on "%s"' % subSO.GetName()
1564 shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
1566 shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID)
1568 shapeText = " on subshape #%s" % (err.subShapeID)
1570 shapeText = " on subshape #%s" % (err.subShapeID)
1572 stdErrors = ["OK", #COMPERR_OK
1573 "Invalid input mesh", #COMPERR_BAD_INPUT_MESH
1574 "std::exception", #COMPERR_STD_EXCEPTION
1575 "OCC exception", #COMPERR_OCC_EXCEPTION
1576 "SALOME exception", #COMPERR_SLM_EXCEPTION
1577 "Unknown exception", #COMPERR_EXCEPTION
1578 "Memory allocation problem", #COMPERR_MEMORY_PB
1579 "Algorithm failed", #COMPERR_ALGO_FAILED
1580 "Unexpected geometry"]#COMPERR_BAD_SHAPE
1582 if err.code < len(stdErrors): errText = stdErrors[err.code]
1584 errText = "code %s" % -err.code
1585 if errText: errText += ". "
1586 errText += err.comment
1587 if allReasons != "":allReasons += "\n"
1588 allReasons += '"%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
1592 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1594 if err.isGlobalAlgo:
1602 reason = '%s %sD algorithm is missing' % (glob, dim)
1603 elif err.state == HYP_MISSING:
1604 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1605 % (glob, dim, name, dim))
1606 elif err.state == HYP_NOTCONFORM:
1607 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1608 elif err.state == HYP_BAD_PARAMETER:
1609 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1610 % ( glob, dim, name ))
1611 elif err.state == HYP_BAD_GEOMETRY:
1612 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1613 'geometry' % ( glob, dim, name ))
1615 reason = "For unknown reason."+\
1616 " Revise Mesh.Compute() implementation in smeshDC.py!"
1618 if allReasons != "":allReasons += "\n"
1619 allReasons += reason
1621 if allReasons != "":
1622 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1626 print '"' + GetName(self.mesh) + '"',"has not been computed."
1629 if salome.sg.hasDesktop():
1630 smeshgui = salome.ImportComponentGUI("SMESH")
1631 smeshgui.Init(self.mesh.GetStudyId())
1632 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1633 salome.sg.updateObjBrowser(1)
1637 ## Return submesh objects list in meshing order
1638 # @return list of list of submesh objects
1639 # @ingroup l2_construct
1640 def GetMeshOrder(self):
1641 return self.mesh.GetMeshOrder()
1643 ## Return submesh objects list in meshing order
1644 # @return list of list of submesh objects
1645 # @ingroup l2_construct
1646 def SetMeshOrder(self, submeshes):
1647 return self.mesh.SetMeshOrder(submeshes)
1649 ## Removes all nodes and elements
1650 # @ingroup l2_construct
1653 if salome.sg.hasDesktop():
1654 smeshgui = salome.ImportComponentGUI("SMESH")
1655 smeshgui.Init(self.mesh.GetStudyId())
1656 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1657 salome.sg.updateObjBrowser(1)
1659 ## Removes all nodes and elements of indicated shape
1660 # @ingroup l2_construct
1661 def ClearSubMesh(self, geomId):
1662 self.mesh.ClearSubMesh(geomId)
1663 if salome.sg.hasDesktop():
1664 smeshgui = salome.ImportComponentGUI("SMESH")
1665 smeshgui.Init(self.mesh.GetStudyId())
1666 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1667 salome.sg.updateObjBrowser(1)
1669 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1670 # @param fineness [0.0,1.0] defines mesh fineness
1671 # @return True or False
1672 # @ingroup l3_algos_basic
1673 def AutomaticTetrahedralization(self, fineness=0):
1674 dim = self.MeshDimension()
1676 self.RemoveGlobalHypotheses()
1677 self.Segment().AutomaticLength(fineness)
1679 self.Triangle().LengthFromEdges()
1682 self.Tetrahedron(NETGEN)
1684 return self.Compute()
1686 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1687 # @param fineness [0.0, 1.0] defines mesh fineness
1688 # @return True or False
1689 # @ingroup l3_algos_basic
1690 def AutomaticHexahedralization(self, fineness=0):
1691 dim = self.MeshDimension()
1692 # assign the hypotheses
1693 self.RemoveGlobalHypotheses()
1694 self.Segment().AutomaticLength(fineness)
1701 return self.Compute()
1703 ## Assigns a hypothesis
1704 # @param hyp a hypothesis to assign
1705 # @param geom a subhape of mesh geometry
1706 # @return SMESH.Hypothesis_Status
1707 # @ingroup l2_hypotheses
1708 def AddHypothesis(self, hyp, geom=0):
1709 if isinstance( hyp, Mesh_Algorithm ):
1710 hyp = hyp.GetAlgorithm()
1715 geom = self.mesh.GetShapeToMesh()
1717 status = self.mesh.AddHypothesis(geom, hyp)
1718 isAlgo = hyp._narrow( SMESH_Algo )
1719 hyp_name = GetName( hyp )
1722 geom_name = GetName( geom )
1723 TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1726 ## Return True if an algorithm of hypothesis is assigned to a given shape
1727 # @param hyp a hypothesis to check
1728 # @param geom a subhape of mesh geometry
1729 # @return True of False
1730 # @ingroup l2_hypotheses
1731 def IsUsedHypothesis(self, hyp, geom):
1732 if not hyp or not geom:
1734 if isinstance( hyp, Mesh_Algorithm ):
1735 hyp = hyp.GetAlgorithm()
1737 hyps = self.GetHypothesisList(geom)
1739 if h.GetId() == hyp.GetId():
1743 ## Unassigns a hypothesis
1744 # @param hyp a hypothesis to unassign
1745 # @param geom a sub-shape of mesh geometry
1746 # @return SMESH.Hypothesis_Status
1747 # @ingroup l2_hypotheses
1748 def RemoveHypothesis(self, hyp, geom=0):
1749 if isinstance( hyp, Mesh_Algorithm ):
1750 hyp = hyp.GetAlgorithm()
1755 status = self.mesh.RemoveHypothesis(geom, hyp)
1758 ## Gets the list of hypotheses added on a geometry
1759 # @param geom a sub-shape of mesh geometry
1760 # @return the sequence of SMESH_Hypothesis
1761 # @ingroup l2_hypotheses
1762 def GetHypothesisList(self, geom):
1763 return self.mesh.GetHypothesisList( geom )
1765 ## Removes all global hypotheses
1766 # @ingroup l2_hypotheses
1767 def RemoveGlobalHypotheses(self):
1768 current_hyps = self.mesh.GetHypothesisList( self.geom )
1769 for hyp in current_hyps:
1770 self.mesh.RemoveHypothesis( self.geom, hyp )
1774 ## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead.
1775 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1776 ## allowing to overwrite the file if it exists or add the exported data to its contents
1777 # @param f the file name
1778 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1779 # @param opt boolean parameter for creating/not creating
1780 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1781 # @param overwrite boolean parameter for overwriting/not overwriting the file
1782 # @ingroup l2_impexp
1783 def ExportToMED(self, f, version, opt=0, overwrite=1):
1784 self.mesh.ExportToMEDX(f, opt, version, overwrite)
1786 ## Exports the mesh in a file in MED format and chooses the \a version of MED format
1787 ## allowing to overwrite the file if it exists or add the exported data to its contents
1788 # @param f is the file name
1789 # @param auto_groups boolean parameter for creating/not creating
1790 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1791 # the typical use is auto_groups=false.
1792 # @param version MED format version(MED_V2_1 or MED_V2_2)
1793 # @param overwrite boolean parameter for overwriting/not overwriting the file
1794 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1795 # @ingroup l2_impexp
1796 def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1, meshPart=None):
1798 if isinstance( meshPart, list ):
1799 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1800 self.mesh.ExportPartToMED( meshPart, f, auto_groups, version, overwrite )
1802 self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
1804 ## Exports the mesh in a file in SAUV format
1805 # @param f is the file name
1806 # @param auto_groups boolean parameter for creating/not creating
1807 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1808 # the typical use is auto_groups=false.
1809 # @ingroup l2_impexp
1810 def ExportSAUV(self, f, auto_groups=0):
1811 self.mesh.ExportSAUV(f, auto_groups)
1813 ## Exports the mesh in a file in DAT format
1814 # @param f the file name
1815 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1816 # @ingroup l2_impexp
1817 def ExportDAT(self, f, meshPart=None):
1819 if isinstance( meshPart, list ):
1820 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1821 self.mesh.ExportPartToDAT( meshPart, f )
1823 self.mesh.ExportDAT(f)
1825 ## Exports the mesh in a file in UNV format
1826 # @param f the file name
1827 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1828 # @ingroup l2_impexp
1829 def ExportUNV(self, f, meshPart=None):
1831 if isinstance( meshPart, list ):
1832 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1833 self.mesh.ExportPartToUNV( meshPart, f )
1835 self.mesh.ExportUNV(f)
1837 ## Export the mesh in a file in STL format
1838 # @param f the file name
1839 # @param ascii defines the file encoding
1840 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1841 # @ingroup l2_impexp
1842 def ExportSTL(self, f, ascii=1, meshPart=None):
1844 if isinstance( meshPart, list ):
1845 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1846 self.mesh.ExportPartToSTL( meshPart, f, ascii )
1848 self.mesh.ExportSTL(f, ascii)
1850 ## Exports the mesh in a file in CGNS format
1851 # @param f is the file name
1852 # @param overwrite boolean parameter for overwriting/not overwriting the file
1853 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1854 # @ingroup l2_impexp
1855 def ExportCGNS(self, f, overwrite=1, meshPart=None):
1856 if isinstance( meshPart, list ):
1857 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1858 if isinstance( meshPart, Mesh ):
1859 meshPart = meshPart.mesh
1861 meshPart = self.mesh
1862 self.mesh.ExportCGNS(meshPart, f, overwrite)
1864 # Operations with groups:
1865 # ----------------------
1867 ## Creates an empty mesh group
1868 # @param elementType the type of elements in the group
1869 # @param name the name of the mesh group
1870 # @return SMESH_Group
1871 # @ingroup l2_grps_create
1872 def CreateEmptyGroup(self, elementType, name):
1873 return self.mesh.CreateGroup(elementType, name)
1875 ## Creates a mesh group based on the geometric object \a grp
1876 # and gives a \a name, \n if this parameter is not defined
1877 # the name is the same as the geometric group name \n
1878 # Note: Works like GroupOnGeom().
1879 # @param grp a geometric group, a vertex, an edge, a face or a solid
1880 # @param name the name of the mesh group
1881 # @return SMESH_GroupOnGeom
1882 # @ingroup l2_grps_create
1883 def Group(self, grp, name=""):
1884 return self.GroupOnGeom(grp, name)
1886 ## Creates a mesh group based on the geometrical object \a grp
1887 # and gives a \a name, \n if this parameter is not defined
1888 # the name is the same as the geometrical group name
1889 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1890 # @param name the name of the mesh group
1891 # @param typ the type of elements in the group. If not set, it is
1892 # automatically detected by the type of the geometry
1893 # @return SMESH_GroupOnGeom
1894 # @ingroup l2_grps_create
1895 def GroupOnGeom(self, grp, name="", typ=None):
1896 AssureGeomPublished( self, grp, name )
1898 name = grp.GetName()
1900 typ = self._groupTypeFromShape( grp )
1901 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1903 ## Pivate method to get a type of group on geometry
1904 def _groupTypeFromShape( self, shape ):
1905 tgeo = str(shape.GetShapeType())
1906 if tgeo == "VERTEX":
1908 elif tgeo == "EDGE":
1910 elif tgeo == "FACE" or tgeo == "SHELL":
1912 elif tgeo == "SOLID" or tgeo == "COMPSOLID":
1914 elif tgeo == "COMPOUND":
1915 sub = self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHAPE"])
1917 raise ValueError,"_groupTypeFromShape(): empty geometric group or compound '%s'" % GetName(shape)
1918 return self._groupTypeFromShape( sub[0] )
1921 "_groupTypeFromShape(): invalid geometry '%s'" % GetName(shape)
1924 ## Creates a mesh group with given \a name based on the \a filter which
1925 ## is a special type of group dynamically updating it's contents during
1926 ## mesh modification
1927 # @param typ the type of elements in the group
1928 # @param name the name of the mesh group
1929 # @param filter the filter defining group contents
1930 # @return SMESH_GroupOnFilter
1931 # @ingroup l2_grps_create
1932 def GroupOnFilter(self, typ, name, filter):
1933 return self.mesh.CreateGroupFromFilter(typ, name, filter)
1935 ## Creates a mesh group by the given ids of elements
1936 # @param groupName the name of the mesh group
1937 # @param elementType the type of elements in the group
1938 # @param elemIDs the list of ids
1939 # @return SMESH_Group
1940 # @ingroup l2_grps_create
1941 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1942 group = self.mesh.CreateGroup(elementType, groupName)
1946 ## Creates a mesh group by the given conditions
1947 # @param groupName the name of the mesh group
1948 # @param elementType the type of elements in the group
1949 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1950 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1951 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1952 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1953 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
1954 # FT_LyingOnGeom, FT_CoplanarFaces criteria
1955 # @return SMESH_Group
1956 # @ingroup l2_grps_create
1960 CritType=FT_Undefined,
1963 UnaryOp=FT_Undefined,
1965 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined,Tolerance)
1966 group = self.MakeGroupByCriterion(groupName, aCriterion)
1969 ## Creates a mesh group by the given criterion
1970 # @param groupName the name of the mesh group
1971 # @param Criterion the instance of Criterion class
1972 # @return SMESH_Group
1973 # @ingroup l2_grps_create
1974 def MakeGroupByCriterion(self, groupName, Criterion):
1975 aFilterMgr = self.smeshpyD.CreateFilterManager()
1976 aFilter = aFilterMgr.CreateFilter()
1978 aCriteria.append(Criterion)
1979 aFilter.SetCriteria(aCriteria)
1980 group = self.MakeGroupByFilter(groupName, aFilter)
1981 aFilterMgr.UnRegister()
1984 ## Creates a mesh group by the given criteria (list of criteria)
1985 # @param groupName the name of the mesh group
1986 # @param theCriteria the list of criteria
1987 # @return SMESH_Group
1988 # @ingroup l2_grps_create
1989 def MakeGroupByCriteria(self, groupName, theCriteria):
1990 aFilterMgr = self.smeshpyD.CreateFilterManager()
1991 aFilter = aFilterMgr.CreateFilter()
1992 aFilter.SetCriteria(theCriteria)
1993 group = self.MakeGroupByFilter(groupName, aFilter)
1994 aFilterMgr.UnRegister()
1997 ## Creates a mesh group by the given filter
1998 # @param groupName the name of the mesh group
1999 # @param theFilter the instance of Filter class
2000 # @return SMESH_Group
2001 # @ingroup l2_grps_create
2002 def MakeGroupByFilter(self, groupName, theFilter):
2003 group = self.CreateEmptyGroup(theFilter.GetElementType(), groupName)
2004 theFilter.SetMesh( self.mesh )
2005 group.AddFrom( theFilter )
2008 ## Passes mesh elements through the given filter and return IDs of fitting elements
2009 # @param theFilter SMESH_Filter
2010 # @return a list of ids
2011 # @ingroup l1_controls
2012 def GetIdsFromFilter(self, theFilter):
2013 theFilter.SetMesh( self.mesh )
2014 return theFilter.GetIDs()
2016 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
2017 # Returns a list of special structures (borders).
2018 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
2019 # @ingroup l1_controls
2020 def GetFreeBorders(self):
2021 aFilterMgr = self.smeshpyD.CreateFilterManager()
2022 aPredicate = aFilterMgr.CreateFreeEdges()
2023 aPredicate.SetMesh(self.mesh)
2024 aBorders = aPredicate.GetBorders()
2025 aFilterMgr.UnRegister()
2029 # @ingroup l2_grps_delete
2030 def RemoveGroup(self, group):
2031 self.mesh.RemoveGroup(group)
2033 ## Removes a group with its contents
2034 # @ingroup l2_grps_delete
2035 def RemoveGroupWithContents(self, group):
2036 self.mesh.RemoveGroupWithContents(group)
2038 ## Gets the list of groups existing in the mesh
2039 # @return a sequence of SMESH_GroupBase
2040 # @ingroup l2_grps_create
2041 def GetGroups(self):
2042 return self.mesh.GetGroups()
2044 ## Gets the number of groups existing in the mesh
2045 # @return the quantity of groups as an integer value
2046 # @ingroup l2_grps_create
2048 return self.mesh.NbGroups()
2050 ## Gets the list of names of groups existing in the mesh
2051 # @return list of strings
2052 # @ingroup l2_grps_create
2053 def GetGroupNames(self):
2054 groups = self.GetGroups()
2056 for group in groups:
2057 names.append(group.GetName())
2060 ## Produces a union of two groups
2061 # A new group is created. All mesh elements that are
2062 # present in the initial groups are added to the new one
2063 # @return an instance of SMESH_Group
2064 # @ingroup l2_grps_operon
2065 def UnionGroups(self, group1, group2, name):
2066 return self.mesh.UnionGroups(group1, group2, name)
2068 ## Produces a union list of groups
2069 # New group is created. All mesh elements that are present in
2070 # initial groups are added to the new one
2071 # @return an instance of SMESH_Group
2072 # @ingroup l2_grps_operon
2073 def UnionListOfGroups(self, groups, name):
2074 return self.mesh.UnionListOfGroups(groups, name)
2076 ## Prodices an intersection of two groups
2077 # A new group is created. All mesh elements that are common
2078 # for the two initial groups are added to the new one.
2079 # @return an instance of SMESH_Group
2080 # @ingroup l2_grps_operon
2081 def IntersectGroups(self, group1, group2, name):
2082 return self.mesh.IntersectGroups(group1, group2, name)
2084 ## Produces an intersection of groups
2085 # New group is created. All mesh elements that are present in all
2086 # initial groups simultaneously are added to the new one
2087 # @return an instance of SMESH_Group
2088 # @ingroup l2_grps_operon
2089 def IntersectListOfGroups(self, groups, name):
2090 return self.mesh.IntersectListOfGroups(groups, name)
2092 ## Produces a cut of two groups
2093 # A new group is created. All mesh elements that are present in
2094 # the main group but are not present in the tool group are added to the new one
2095 # @return an instance of SMESH_Group
2096 # @ingroup l2_grps_operon
2097 def CutGroups(self, main_group, tool_group, name):
2098 return self.mesh.CutGroups(main_group, tool_group, name)
2100 ## Produces a cut of groups
2101 # A new group is created. All mesh elements that are present in main groups
2102 # but do not present in tool groups are added to the new one
2103 # @return an instance of SMESH_Group
2104 # @ingroup l2_grps_operon
2105 def CutListOfGroups(self, main_groups, tool_groups, name):
2106 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
2108 ## Produces a group of elements of specified type using list of existing groups
2109 # A new group is created. System
2110 # 1) extracts all nodes on which groups elements are built
2111 # 2) combines all elements of specified dimension laying on these nodes
2112 # @return an instance of SMESH_Group
2113 # @ingroup l2_grps_operon
2114 def CreateDimGroup(self, groups, elem_type, name):
2115 return self.mesh.CreateDimGroup(groups, elem_type, name)
2118 ## Convert group on geom into standalone group
2119 # @ingroup l2_grps_delete
2120 def ConvertToStandalone(self, group):
2121 return self.mesh.ConvertToStandalone(group)
2123 # Get some info about mesh:
2124 # ------------------------
2126 ## Returns the log of nodes and elements added or removed
2127 # since the previous clear of the log.
2128 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
2129 # @return list of log_block structures:
2134 # @ingroup l1_auxiliary
2135 def GetLog(self, clearAfterGet):
2136 return self.mesh.GetLog(clearAfterGet)
2138 ## Clears the log of nodes and elements added or removed since the previous
2139 # clear. Must be used immediately after GetLog if clearAfterGet is false.
2140 # @ingroup l1_auxiliary
2142 self.mesh.ClearLog()
2144 ## Toggles auto color mode on the object.
2145 # @param theAutoColor the flag which toggles auto color mode.
2146 # @ingroup l1_auxiliary
2147 def SetAutoColor(self, theAutoColor):
2148 self.mesh.SetAutoColor(theAutoColor)
2150 ## Gets flag of object auto color mode.
2151 # @return True or False
2152 # @ingroup l1_auxiliary
2153 def GetAutoColor(self):
2154 return self.mesh.GetAutoColor()
2156 ## Gets the internal ID
2157 # @return integer value, which is the internal Id of the mesh
2158 # @ingroup l1_auxiliary
2160 return self.mesh.GetId()
2163 # @return integer value, which is the study Id of the mesh
2164 # @ingroup l1_auxiliary
2165 def GetStudyId(self):
2166 return self.mesh.GetStudyId()
2168 ## Checks the group names for duplications.
2169 # Consider the maximum group name length stored in MED file.
2170 # @return True or False
2171 # @ingroup l1_auxiliary
2172 def HasDuplicatedGroupNamesMED(self):
2173 return self.mesh.HasDuplicatedGroupNamesMED()
2175 ## Obtains the mesh editor tool
2176 # @return an instance of SMESH_MeshEditor
2177 # @ingroup l1_modifying
2178 def GetMeshEditor(self):
2179 return self.mesh.GetMeshEditor()
2181 ## Wrap a list of IDs of elements or nodes into SMESH_IDSource which
2182 # can be passed as argument to accepting mesh, group or sub-mesh
2183 # @return an instance of SMESH_IDSource
2184 # @ingroup l1_auxiliary
2185 def GetIDSource(self, ids, elemType):
2186 return self.GetMeshEditor().MakeIDSource(ids, elemType)
2189 # @return an instance of SALOME_MED::MESH
2190 # @ingroup l1_auxiliary
2191 def GetMEDMesh(self):
2192 return self.mesh.GetMEDMesh()
2195 # Get informations about mesh contents:
2196 # ------------------------------------
2198 ## Gets the mesh stattistic
2199 # @return dictionary type element - count of elements
2200 # @ingroup l1_meshinfo
2201 def GetMeshInfo(self, obj = None):
2202 if not obj: obj = self.mesh
2203 return self.smeshpyD.GetMeshInfo(obj)
2205 ## Returns the number of nodes in the mesh
2206 # @return an integer value
2207 # @ingroup l1_meshinfo
2209 return self.mesh.NbNodes()
2211 ## Returns the number of elements in the mesh
2212 # @return an integer value
2213 # @ingroup l1_meshinfo
2214 def NbElements(self):
2215 return self.mesh.NbElements()
2217 ## Returns the number of 0d elements in the mesh
2218 # @return an integer value
2219 # @ingroup l1_meshinfo
2220 def Nb0DElements(self):
2221 return self.mesh.Nb0DElements()
2223 ## Returns the number of edges in the mesh
2224 # @return an integer value
2225 # @ingroup l1_meshinfo
2227 return self.mesh.NbEdges()
2229 ## Returns the number of edges with the given order in the mesh
2230 # @param elementOrder the order of elements:
2231 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2232 # @return an integer value
2233 # @ingroup l1_meshinfo
2234 def NbEdgesOfOrder(self, elementOrder):
2235 return self.mesh.NbEdgesOfOrder(elementOrder)
2237 ## Returns the number of faces in the mesh
2238 # @return an integer value
2239 # @ingroup l1_meshinfo
2241 return self.mesh.NbFaces()
2243 ## Returns the number of faces with the given order in the mesh
2244 # @param elementOrder the order of elements:
2245 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2246 # @return an integer value
2247 # @ingroup l1_meshinfo
2248 def NbFacesOfOrder(self, elementOrder):
2249 return self.mesh.NbFacesOfOrder(elementOrder)
2251 ## Returns the number of triangles in the mesh
2252 # @return an integer value
2253 # @ingroup l1_meshinfo
2254 def NbTriangles(self):
2255 return self.mesh.NbTriangles()
2257 ## Returns the number of triangles with the given order in the mesh
2258 # @param elementOrder is the order of elements:
2259 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2260 # @return an integer value
2261 # @ingroup l1_meshinfo
2262 def NbTrianglesOfOrder(self, elementOrder):
2263 return self.mesh.NbTrianglesOfOrder(elementOrder)
2265 ## Returns the number of quadrangles in the mesh
2266 # @return an integer value
2267 # @ingroup l1_meshinfo
2268 def NbQuadrangles(self):
2269 return self.mesh.NbQuadrangles()
2271 ## Returns the number of quadrangles with the given order in the mesh
2272 # @param elementOrder the order of elements:
2273 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2274 # @return an integer value
2275 # @ingroup l1_meshinfo
2276 def NbQuadranglesOfOrder(self, elementOrder):
2277 return self.mesh.NbQuadranglesOfOrder(elementOrder)
2279 ## Returns the number of biquadratic quadrangles in the mesh
2280 # @return an integer value
2281 # @ingroup l1_meshinfo
2282 def NbBiQuadQuadrangles(self):
2283 return self.mesh.NbBiQuadQuadrangles()
2285 ## Returns the number of polygons in the mesh
2286 # @return an integer value
2287 # @ingroup l1_meshinfo
2288 def NbPolygons(self):
2289 return self.mesh.NbPolygons()
2291 ## Returns the number of volumes in the mesh
2292 # @return an integer value
2293 # @ingroup l1_meshinfo
2294 def NbVolumes(self):
2295 return self.mesh.NbVolumes()
2297 ## Returns the number of volumes with the given order in the mesh
2298 # @param elementOrder the order of elements:
2299 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2300 # @return an integer value
2301 # @ingroup l1_meshinfo
2302 def NbVolumesOfOrder(self, elementOrder):
2303 return self.mesh.NbVolumesOfOrder(elementOrder)
2305 ## Returns the number of tetrahedrons in the mesh
2306 # @return an integer value
2307 # @ingroup l1_meshinfo
2309 return self.mesh.NbTetras()
2311 ## Returns the number of tetrahedrons with the given order in the mesh
2312 # @param elementOrder the order of elements:
2313 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2314 # @return an integer value
2315 # @ingroup l1_meshinfo
2316 def NbTetrasOfOrder(self, elementOrder):
2317 return self.mesh.NbTetrasOfOrder(elementOrder)
2319 ## Returns the number of hexahedrons in the mesh
2320 # @return an integer value
2321 # @ingroup l1_meshinfo
2323 return self.mesh.NbHexas()
2325 ## Returns the number of hexahedrons with the given order in the mesh
2326 # @param elementOrder the order of elements:
2327 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2328 # @return an integer value
2329 # @ingroup l1_meshinfo
2330 def NbHexasOfOrder(self, elementOrder):
2331 return self.mesh.NbHexasOfOrder(elementOrder)
2333 ## Returns the number of triquadratic hexahedrons in the mesh
2334 # @return an integer value
2335 # @ingroup l1_meshinfo
2336 def NbTriQuadraticHexas(self):
2337 return self.mesh.NbTriQuadraticHexas()
2339 ## Returns the number of pyramids in the mesh
2340 # @return an integer value
2341 # @ingroup l1_meshinfo
2342 def NbPyramids(self):
2343 return self.mesh.NbPyramids()
2345 ## Returns the number of pyramids with the given order in the mesh
2346 # @param elementOrder the order of elements:
2347 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2348 # @return an integer value
2349 # @ingroup l1_meshinfo
2350 def NbPyramidsOfOrder(self, elementOrder):
2351 return self.mesh.NbPyramidsOfOrder(elementOrder)
2353 ## Returns the number of prisms in the mesh
2354 # @return an integer value
2355 # @ingroup l1_meshinfo
2357 return self.mesh.NbPrisms()
2359 ## Returns the number of prisms with the given order in the mesh
2360 # @param elementOrder the order of elements:
2361 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2362 # @return an integer value
2363 # @ingroup l1_meshinfo
2364 def NbPrismsOfOrder(self, elementOrder):
2365 return self.mesh.NbPrismsOfOrder(elementOrder)
2367 ## Returns the number of hexagonal prisms in the mesh
2368 # @return an integer value
2369 # @ingroup l1_meshinfo
2370 def NbHexagonalPrisms(self):
2371 return self.mesh.NbHexagonalPrisms()
2373 ## Returns the number of polyhedrons in the mesh
2374 # @return an integer value
2375 # @ingroup l1_meshinfo
2376 def NbPolyhedrons(self):
2377 return self.mesh.NbPolyhedrons()
2379 ## Returns the number of submeshes in the mesh
2380 # @return an integer value
2381 # @ingroup l1_meshinfo
2382 def NbSubMesh(self):
2383 return self.mesh.NbSubMesh()
2385 ## Returns the list of mesh elements IDs
2386 # @return the list of integer values
2387 # @ingroup l1_meshinfo
2388 def GetElementsId(self):
2389 return self.mesh.GetElementsId()
2391 ## Returns the list of IDs of mesh elements with the given type
2392 # @param elementType the required type of elements (SMESH.NODE, SMESH.EDGE, SMESH.FACE or SMESH.VOLUME)
2393 # @return list of integer values
2394 # @ingroup l1_meshinfo
2395 def GetElementsByType(self, elementType):
2396 return self.mesh.GetElementsByType(elementType)
2398 ## Returns the list of mesh nodes IDs
2399 # @return the list of integer values
2400 # @ingroup l1_meshinfo
2401 def GetNodesId(self):
2402 return self.mesh.GetNodesId()
2404 # Get the information about mesh elements:
2405 # ------------------------------------
2407 ## Returns the type of mesh element
2408 # @return the value from SMESH::ElementType enumeration
2409 # @ingroup l1_meshinfo
2410 def GetElementType(self, id, iselem):
2411 return self.mesh.GetElementType(id, iselem)
2413 ## Returns the geometric type of mesh element
2414 # @return the value from SMESH::EntityType enumeration
2415 # @ingroup l1_meshinfo
2416 def GetElementGeomType(self, id):
2417 return self.mesh.GetElementGeomType(id)
2419 ## Returns the list of submesh elements IDs
2420 # @param Shape a geom object(sub-shape) IOR
2421 # Shape must be the sub-shape of a ShapeToMesh()
2422 # @return the list of integer values
2423 # @ingroup l1_meshinfo
2424 def GetSubMeshElementsId(self, Shape):
2425 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2426 ShapeID = Shape.GetSubShapeIndices()[0]
2429 return self.mesh.GetSubMeshElementsId(ShapeID)
2431 ## Returns the list of submesh nodes IDs
2432 # @param Shape a geom object(sub-shape) IOR
2433 # Shape must be the sub-shape of a ShapeToMesh()
2434 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
2435 # @return the list of integer values
2436 # @ingroup l1_meshinfo
2437 def GetSubMeshNodesId(self, Shape, all):
2438 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2439 ShapeID = Shape.GetSubShapeIndices()[0]
2442 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2444 ## Returns type of elements on given shape
2445 # @param Shape a geom object(sub-shape) IOR
2446 # Shape must be a sub-shape of a ShapeToMesh()
2447 # @return element type
2448 # @ingroup l1_meshinfo
2449 def GetSubMeshElementType(self, Shape):
2450 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2451 ShapeID = Shape.GetSubShapeIndices()[0]
2454 return self.mesh.GetSubMeshElementType(ShapeID)
2456 ## Gets the mesh description
2457 # @return string value
2458 # @ingroup l1_meshinfo
2460 return self.mesh.Dump()
2463 # Get the information about nodes and elements of a mesh by its IDs:
2464 # -----------------------------------------------------------
2466 ## Gets XYZ coordinates of a node
2467 # \n If there is no nodes for the given ID - returns an empty list
2468 # @return a list of double precision values
2469 # @ingroup l1_meshinfo
2470 def GetNodeXYZ(self, id):
2471 return self.mesh.GetNodeXYZ(id)
2473 ## Returns list of IDs of inverse elements for the given node
2474 # \n If there is no node for the given ID - returns an empty list
2475 # @return a list of integer values
2476 # @ingroup l1_meshinfo
2477 def GetNodeInverseElements(self, id):
2478 return self.mesh.GetNodeInverseElements(id)
2480 ## @brief Returns the position of a node on the shape
2481 # @return SMESH::NodePosition
2482 # @ingroup l1_meshinfo
2483 def GetNodePosition(self,NodeID):
2484 return self.mesh.GetNodePosition(NodeID)
2486 ## If the given element is a node, returns the ID of shape
2487 # \n If there is no node for the given ID - returns -1
2488 # @return an integer value
2489 # @ingroup l1_meshinfo
2490 def GetShapeID(self, id):
2491 return self.mesh.GetShapeID(id)
2493 ## Returns the ID of the result shape after
2494 # FindShape() from SMESH_MeshEditor for the given element
2495 # \n If there is no element for the given ID - returns -1
2496 # @return an integer value
2497 # @ingroup l1_meshinfo
2498 def GetShapeIDForElem(self,id):
2499 return self.mesh.GetShapeIDForElem(id)
2501 ## Returns the number of nodes for the given element
2502 # \n If there is no element for the given ID - returns -1
2503 # @return an integer value
2504 # @ingroup l1_meshinfo
2505 def GetElemNbNodes(self, id):
2506 return self.mesh.GetElemNbNodes(id)
2508 ## Returns the node ID the given index for the given element
2509 # \n If there is no element for the given ID - returns -1
2510 # \n If there is no node for the given index - returns -2
2511 # @return an integer value
2512 # @ingroup l1_meshinfo
2513 def GetElemNode(self, id, index):
2514 return self.mesh.GetElemNode(id, index)
2516 ## Returns the IDs of nodes of the given element
2517 # @return a list of integer values
2518 # @ingroup l1_meshinfo
2519 def GetElemNodes(self, id):
2520 return self.mesh.GetElemNodes(id)
2522 ## Returns true if the given node is the medium node in the given quadratic element
2523 # @ingroup l1_meshinfo
2524 def IsMediumNode(self, elementID, nodeID):
2525 return self.mesh.IsMediumNode(elementID, nodeID)
2527 ## Returns true if the given node is the medium node in one of quadratic elements
2528 # @ingroup l1_meshinfo
2529 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2530 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2532 ## Returns the number of edges for the given element
2533 # @ingroup l1_meshinfo
2534 def ElemNbEdges(self, id):
2535 return self.mesh.ElemNbEdges(id)
2537 ## Returns the number of faces for the given element
2538 # @ingroup l1_meshinfo
2539 def ElemNbFaces(self, id):
2540 return self.mesh.ElemNbFaces(id)
2542 ## Returns nodes of given face (counted from zero) for given volumic element.
2543 # @ingroup l1_meshinfo
2544 def GetElemFaceNodes(self,elemId, faceIndex):
2545 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2547 ## Returns an element based on all given nodes.
2548 # @ingroup l1_meshinfo
2549 def FindElementByNodes(self,nodes):
2550 return self.mesh.FindElementByNodes(nodes)
2552 ## Returns true if the given element is a polygon
2553 # @ingroup l1_meshinfo
2554 def IsPoly(self, id):
2555 return self.mesh.IsPoly(id)
2557 ## Returns true if the given element is quadratic
2558 # @ingroup l1_meshinfo
2559 def IsQuadratic(self, id):
2560 return self.mesh.IsQuadratic(id)
2562 ## Returns XYZ coordinates of the barycenter of the given element
2563 # \n If there is no element for the given ID - returns an empty list
2564 # @return a list of three double values
2565 # @ingroup l1_meshinfo
2566 def BaryCenter(self, id):
2567 return self.mesh.BaryCenter(id)
2570 # Get mesh measurements information:
2571 # ------------------------------------
2573 ## Get minimum distance between two nodes, elements or distance to the origin
2574 # @param id1 first node/element id
2575 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2576 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2577 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2578 # @return minimum distance value
2579 # @sa GetMinDistance()
2580 def MinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2581 aMeasure = self.GetMinDistance(id1, id2, isElem1, isElem2)
2582 return aMeasure.value
2584 ## Get measure structure specifying minimum distance data between two objects
2585 # @param id1 first node/element id
2586 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2587 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2588 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2589 # @return Measure structure
2591 def GetMinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2593 id1 = self.editor.MakeIDSource([id1], SMESH.FACE)
2595 id1 = self.editor.MakeIDSource([id1], SMESH.NODE)
2598 id2 = self.editor.MakeIDSource([id2], SMESH.FACE)
2600 id2 = self.editor.MakeIDSource([id2], SMESH.NODE)
2605 aMeasurements = self.smeshpyD.CreateMeasurements()
2606 aMeasure = aMeasurements.MinDistance(id1, id2)
2607 aMeasurements.UnRegister()
2610 ## Get bounding box of the specified object(s)
2611 # @param objects single source object or list of source objects or list of nodes/elements IDs
2612 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2613 # @c False specifies that @a objects are nodes
2614 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
2615 # @sa GetBoundingBox()
2616 def BoundingBox(self, objects=None, isElem=False):
2617 result = self.GetBoundingBox(objects, isElem)
2621 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
2624 ## Get measure structure specifying bounding box data of the specified object(s)
2625 # @param IDs single source object or list of source objects or list of nodes/elements IDs
2626 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2627 # @c False specifies that @a objects are nodes
2628 # @return Measure structure
2630 def GetBoundingBox(self, IDs=None, isElem=False):
2633 elif isinstance(IDs, tuple):
2635 if not isinstance(IDs, list):
2637 if len(IDs) > 0 and isinstance(IDs[0], int):
2641 if isinstance(o, Mesh):
2642 srclist.append(o.mesh)
2643 elif hasattr(o, "_narrow"):
2644 src = o._narrow(SMESH.SMESH_IDSource)
2645 if src: srclist.append(src)
2647 elif isinstance(o, list):
2649 srclist.append(self.editor.MakeIDSource(o, SMESH.FACE))
2651 srclist.append(self.editor.MakeIDSource(o, SMESH.NODE))
2654 aMeasurements = self.smeshpyD.CreateMeasurements()
2655 aMeasure = aMeasurements.BoundingBox(srclist)
2656 aMeasurements.UnRegister()
2659 # Mesh edition (SMESH_MeshEditor functionality):
2660 # ---------------------------------------------
2662 ## Removes the elements from the mesh by ids
2663 # @param IDsOfElements is a list of ids of elements to remove
2664 # @return True or False
2665 # @ingroup l2_modif_del
2666 def RemoveElements(self, IDsOfElements):
2667 return self.editor.RemoveElements(IDsOfElements)
2669 ## Removes nodes from mesh by ids
2670 # @param IDsOfNodes is a list of ids of nodes to remove
2671 # @return True or False
2672 # @ingroup l2_modif_del
2673 def RemoveNodes(self, IDsOfNodes):
2674 return self.editor.RemoveNodes(IDsOfNodes)
2676 ## Removes all orphan (free) nodes from mesh
2677 # @return number of the removed nodes
2678 # @ingroup l2_modif_del
2679 def RemoveOrphanNodes(self):
2680 return self.editor.RemoveOrphanNodes()
2682 ## Add a node to the mesh by coordinates
2683 # @return Id of the new node
2684 # @ingroup l2_modif_add
2685 def AddNode(self, x, y, z):
2686 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2687 self.mesh.SetParameters(Parameters)
2688 return self.editor.AddNode( x, y, z)
2690 ## Creates a 0D element on a node with given number.
2691 # @param IDOfNode the ID of node for creation of the element.
2692 # @return the Id of the new 0D element
2693 # @ingroup l2_modif_add
2694 def Add0DElement(self, IDOfNode):
2695 return self.editor.Add0DElement(IDOfNode)
2697 ## Creates a linear or quadratic edge (this is determined
2698 # by the number of given nodes).
2699 # @param IDsOfNodes the list of node IDs for creation of the element.
2700 # The order of nodes in this list should correspond to the description
2701 # of MED. \n This description is located by the following link:
2702 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2703 # @return the Id of the new edge
2704 # @ingroup l2_modif_add
2705 def AddEdge(self, IDsOfNodes):
2706 return self.editor.AddEdge(IDsOfNodes)
2708 ## Creates a linear or quadratic face (this is determined
2709 # by the number of given nodes).
2710 # @param IDsOfNodes the list of node IDs for creation of the element.
2711 # The order of nodes in this list should correspond to the description
2712 # of MED. \n This description is located by the following link:
2713 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2714 # @return the Id of the new face
2715 # @ingroup l2_modif_add
2716 def AddFace(self, IDsOfNodes):
2717 return self.editor.AddFace(IDsOfNodes)
2719 ## Adds a polygonal face to the mesh by the list of node IDs
2720 # @param IdsOfNodes the list of node IDs for creation of the element.
2721 # @return the Id of the new face
2722 # @ingroup l2_modif_add
2723 def AddPolygonalFace(self, IdsOfNodes):
2724 return self.editor.AddPolygonalFace(IdsOfNodes)
2726 ## Creates both simple and quadratic volume (this is determined
2727 # by the number of given nodes).
2728 # @param IDsOfNodes the list of node IDs for creation of the element.
2729 # The order of nodes in this list should correspond to the description
2730 # of MED. \n This description is located by the following link:
2731 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2732 # @return the Id of the new volumic element
2733 # @ingroup l2_modif_add
2734 def AddVolume(self, IDsOfNodes):
2735 return self.editor.AddVolume(IDsOfNodes)
2737 ## Creates a volume of many faces, giving nodes for each face.
2738 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2739 # @param Quantities the list of integer values, Quantities[i]
2740 # gives the quantity of nodes in face number i.
2741 # @return the Id of the new volumic element
2742 # @ingroup l2_modif_add
2743 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2744 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2746 ## Creates a volume of many faces, giving the IDs of the existing faces.
2747 # @param IdsOfFaces the list of face IDs for volume creation.
2749 # Note: The created volume will refer only to the nodes
2750 # of the given faces, not to the faces themselves.
2751 # @return the Id of the new volumic element
2752 # @ingroup l2_modif_add
2753 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2754 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2757 ## @brief Binds a node to a vertex
2758 # @param NodeID a node ID
2759 # @param Vertex a vertex or vertex ID
2760 # @return True if succeed else raises an exception
2761 # @ingroup l2_modif_add
2762 def SetNodeOnVertex(self, NodeID, Vertex):
2763 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2764 VertexID = Vertex.GetSubShapeIndices()[0]
2768 self.editor.SetNodeOnVertex(NodeID, VertexID)
2769 except SALOME.SALOME_Exception, inst:
2770 raise ValueError, inst.details.text
2774 ## @brief Stores the node position on an edge
2775 # @param NodeID a node ID
2776 # @param Edge an edge or edge ID
2777 # @param paramOnEdge a parameter on the edge where the node is located
2778 # @return True if succeed else raises an exception
2779 # @ingroup l2_modif_add
2780 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2781 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2782 EdgeID = Edge.GetSubShapeIndices()[0]
2786 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2787 except SALOME.SALOME_Exception, inst:
2788 raise ValueError, inst.details.text
2791 ## @brief Stores node position on a face
2792 # @param NodeID a node ID
2793 # @param Face a face or face ID
2794 # @param u U parameter on the face where the node is located
2795 # @param v V parameter on the face where the node is located
2796 # @return True if succeed else raises an exception
2797 # @ingroup l2_modif_add
2798 def SetNodeOnFace(self, NodeID, Face, u, v):
2799 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2800 FaceID = Face.GetSubShapeIndices()[0]
2804 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2805 except SALOME.SALOME_Exception, inst:
2806 raise ValueError, inst.details.text
2809 ## @brief Binds a node to a solid
2810 # @param NodeID a node ID
2811 # @param Solid a solid or solid ID
2812 # @return True if succeed else raises an exception
2813 # @ingroup l2_modif_add
2814 def SetNodeInVolume(self, NodeID, Solid):
2815 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2816 SolidID = Solid.GetSubShapeIndices()[0]
2820 self.editor.SetNodeInVolume(NodeID, SolidID)
2821 except SALOME.SALOME_Exception, inst:
2822 raise ValueError, inst.details.text
2825 ## @brief Bind an element to a shape
2826 # @param ElementID an element ID
2827 # @param Shape a shape or shape ID
2828 # @return True if succeed else raises an exception
2829 # @ingroup l2_modif_add
2830 def SetMeshElementOnShape(self, ElementID, Shape):
2831 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2832 ShapeID = Shape.GetSubShapeIndices()[0]
2836 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2837 except SALOME.SALOME_Exception, inst:
2838 raise ValueError, inst.details.text
2842 ## Moves the node with the given id
2843 # @param NodeID the id of the node
2844 # @param x a new X coordinate
2845 # @param y a new Y coordinate
2846 # @param z a new Z coordinate
2847 # @return True if succeed else False
2848 # @ingroup l2_modif_movenode
2849 def MoveNode(self, NodeID, x, y, z):
2850 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2851 self.mesh.SetParameters(Parameters)
2852 return self.editor.MoveNode(NodeID, x, y, z)
2854 ## Finds the node closest to a point and moves it to a point location
2855 # @param x the X coordinate of a point
2856 # @param y the Y coordinate of a point
2857 # @param z the Z coordinate of a point
2858 # @param NodeID if specified (>0), the node with this ID is moved,
2859 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2860 # @return the ID of a node
2861 # @ingroup l2_modif_throughp
2862 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2863 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2864 self.mesh.SetParameters(Parameters)
2865 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2867 ## Finds the node closest to a point
2868 # @param x the X coordinate of a point
2869 # @param y the Y coordinate of a point
2870 # @param z the Z coordinate of a point
2871 # @return the ID of a node
2872 # @ingroup l2_modif_throughp
2873 def FindNodeClosestTo(self, x, y, z):
2874 #preview = self.mesh.GetMeshEditPreviewer()
2875 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2876 return self.editor.FindNodeClosestTo(x, y, z)
2878 ## Finds the elements where a point lays IN or ON
2879 # @param x the X coordinate of a point
2880 # @param y the Y coordinate of a point
2881 # @param z the Z coordinate of a point
2882 # @param elementType type of elements to find (SMESH.ALL type
2883 # means elements of any type excluding nodes and 0D elements)
2884 # @param meshPart a part of mesh (group, sub-mesh) to search within
2885 # @return list of IDs of found elements
2886 # @ingroup l2_modif_throughp
2887 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL, meshPart=None):
2889 return self.editor.FindAmongElementsByPoint( meshPart, x, y, z, elementType );
2891 return self.editor.FindElementsByPoint(x, y, z, elementType)
2893 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2894 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2896 def GetPointState(self, x, y, z):
2897 return self.editor.GetPointState(x, y, z)
2899 ## Finds the node closest to a point and moves it to a point location
2900 # @param x the X coordinate of a point
2901 # @param y the Y coordinate of a point
2902 # @param z the Z coordinate of a point
2903 # @return the ID of a moved node
2904 # @ingroup l2_modif_throughp
2905 def MeshToPassThroughAPoint(self, x, y, z):
2906 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2908 ## Replaces two neighbour triangles sharing Node1-Node2 link
2909 # with the triangles built on the same 4 nodes but having other common link.
2910 # @param NodeID1 the ID of the first node
2911 # @param NodeID2 the ID of the second node
2912 # @return false if proper faces were not found
2913 # @ingroup l2_modif_invdiag
2914 def InverseDiag(self, NodeID1, NodeID2):
2915 return self.editor.InverseDiag(NodeID1, NodeID2)
2917 ## Replaces two neighbour triangles sharing Node1-Node2 link
2918 # with a quadrangle built on the same 4 nodes.
2919 # @param NodeID1 the ID of the first node
2920 # @param NodeID2 the ID of the second node
2921 # @return false if proper faces were not found
2922 # @ingroup l2_modif_unitetri
2923 def DeleteDiag(self, NodeID1, NodeID2):
2924 return self.editor.DeleteDiag(NodeID1, NodeID2)
2926 ## Reorients elements by ids
2927 # @param IDsOfElements if undefined reorients all mesh elements
2928 # @return True if succeed else False
2929 # @ingroup l2_modif_changori
2930 def Reorient(self, IDsOfElements=None):
2931 if IDsOfElements == None:
2932 IDsOfElements = self.GetElementsId()
2933 return self.editor.Reorient(IDsOfElements)
2935 ## Reorients all elements of the object
2936 # @param theObject mesh, submesh or group
2937 # @return True if succeed else False
2938 # @ingroup l2_modif_changori
2939 def ReorientObject(self, theObject):
2940 if ( isinstance( theObject, Mesh )):
2941 theObject = theObject.GetMesh()
2942 return self.editor.ReorientObject(theObject)
2944 ## Fuses the neighbouring triangles into quadrangles.
2945 # @param IDsOfElements The triangles to be fused,
2946 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2947 # @param MaxAngle is the maximum angle between element normals at which the fusion
2948 # is still performed; theMaxAngle is mesured in radians.
2949 # Also it could be a name of variable which defines angle in degrees.
2950 # @return TRUE in case of success, FALSE otherwise.
2951 # @ingroup l2_modif_unitetri
2952 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2954 if isinstance(MaxAngle,str):
2956 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2958 MaxAngle = DegreesToRadians(MaxAngle)
2959 if IDsOfElements == []:
2960 IDsOfElements = self.GetElementsId()
2961 self.mesh.SetParameters(Parameters)
2963 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2964 Functor = theCriterion
2966 Functor = self.smeshpyD.GetFunctor(theCriterion)
2967 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2969 ## Fuses the neighbouring triangles of the object into quadrangles
2970 # @param theObject is mesh, submesh or group
2971 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2972 # @param MaxAngle a max angle between element normals at which the fusion
2973 # is still performed; theMaxAngle is mesured in radians.
2974 # @return TRUE in case of success, FALSE otherwise.
2975 # @ingroup l2_modif_unitetri
2976 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2977 if ( isinstance( theObject, Mesh )):
2978 theObject = theObject.GetMesh()
2979 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2981 ## Splits quadrangles into triangles.
2982 # @param IDsOfElements the faces to be splitted.
2983 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2984 # @return TRUE in case of success, FALSE otherwise.
2985 # @ingroup l2_modif_cutquadr
2986 def QuadToTri (self, IDsOfElements, theCriterion):
2987 if IDsOfElements == []:
2988 IDsOfElements = self.GetElementsId()
2989 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2991 ## Splits quadrangles into triangles.
2992 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2993 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2994 # @return TRUE in case of success, FALSE otherwise.
2995 # @ingroup l2_modif_cutquadr
2996 def QuadToTriObject (self, theObject, theCriterion):
2997 if ( isinstance( theObject, Mesh )):
2998 theObject = theObject.GetMesh()
2999 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
3001 ## Splits quadrangles into triangles.
3002 # @param IDsOfElements the faces to be splitted
3003 # @param Diag13 is used to choose a diagonal for splitting.
3004 # @return TRUE in case of success, FALSE otherwise.
3005 # @ingroup l2_modif_cutquadr
3006 def SplitQuad (self, IDsOfElements, Diag13):
3007 if IDsOfElements == []:
3008 IDsOfElements = self.GetElementsId()
3009 return self.editor.SplitQuad(IDsOfElements, Diag13)
3011 ## Splits quadrangles into triangles.
3012 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
3013 # @param Diag13 is used to choose a diagonal for splitting.
3014 # @return TRUE in case of success, FALSE otherwise.
3015 # @ingroup l2_modif_cutquadr
3016 def SplitQuadObject (self, theObject, Diag13):
3017 if ( isinstance( theObject, Mesh )):
3018 theObject = theObject.GetMesh()
3019 return self.editor.SplitQuadObject(theObject, Diag13)
3021 ## Finds a better splitting of the given quadrangle.
3022 # @param IDOfQuad the ID of the quadrangle to be splitted.
3023 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
3024 # @return 1 if 1-3 diagonal is better, 2 if 2-4
3025 # diagonal is better, 0 if error occurs.
3026 # @ingroup l2_modif_cutquadr
3027 def BestSplit (self, IDOfQuad, theCriterion):
3028 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
3030 ## Splits volumic elements into tetrahedrons
3031 # @param elemIDs either list of elements or mesh or group or submesh
3032 # @param method flags passing splitting method: Hex_5Tet, Hex_6Tet, Hex_24Tet
3033 # Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc
3034 # @ingroup l2_modif_cutquadr
3035 def SplitVolumesIntoTetra(self, elemIDs, method=Hex_5Tet ):
3036 if isinstance( elemIDs, Mesh ):
3037 elemIDs = elemIDs.GetMesh()
3038 if ( isinstance( elemIDs, list )):
3039 elemIDs = self.editor.MakeIDSource(elemIDs, SMESH.VOLUME)
3040 self.editor.SplitVolumesIntoTetra(elemIDs, method)
3042 ## Splits quadrangle faces near triangular facets of volumes
3044 # @ingroup l1_auxiliary
3045 def SplitQuadsNearTriangularFacets(self):
3046 faces_array = self.GetElementsByType(SMESH.FACE)
3047 for face_id in faces_array:
3048 if self.GetElemNbNodes(face_id) == 4: # quadrangle
3049 quad_nodes = self.mesh.GetElemNodes(face_id)
3050 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
3051 isVolumeFound = False
3052 for node1_elem in node1_elems:
3053 if not isVolumeFound:
3054 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
3055 nb_nodes = self.GetElemNbNodes(node1_elem)
3056 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
3057 volume_elem = node1_elem
3058 volume_nodes = self.mesh.GetElemNodes(volume_elem)
3059 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
3060 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
3061 isVolumeFound = True
3062 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
3063 self.SplitQuad([face_id], False) # diagonal 2-4
3064 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
3065 isVolumeFound = True
3066 self.SplitQuad([face_id], True) # diagonal 1-3
3067 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
3068 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
3069 isVolumeFound = True
3070 self.SplitQuad([face_id], True) # diagonal 1-3
3072 ## @brief Splits hexahedrons into tetrahedrons.
3074 # This operation uses pattern mapping functionality for splitting.
3075 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
3076 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
3077 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
3078 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
3079 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
3080 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
3081 # @return TRUE in case of success, FALSE otherwise.
3082 # @ingroup l1_auxiliary
3083 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
3084 # Pattern: 5.---------.6
3089 # (0,0,1) 4.---------.7 * |
3096 # (0,0,0) 0.---------.3
3097 pattern_tetra = "!!! Nb of points: \n 8 \n\
3107 !!! Indices of points of 6 tetras: \n\
3115 pattern = self.smeshpyD.GetPattern()
3116 isDone = pattern.LoadFromFile(pattern_tetra)
3118 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
3121 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
3122 isDone = pattern.MakeMesh(self.mesh, False, False)
3123 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
3125 # split quafrangle faces near triangular facets of volumes
3126 self.SplitQuadsNearTriangularFacets()
3130 ## @brief Split hexahedrons into prisms.
3132 # Uses the pattern mapping functionality for splitting.
3133 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
3134 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
3135 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
3136 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
3137 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
3138 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
3139 # @return TRUE in case of success, FALSE otherwise.
3140 # @ingroup l1_auxiliary
3141 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
3142 # Pattern: 5.---------.6
3147 # (0,0,1) 4.---------.7 |
3154 # (0,0,0) 0.---------.3
3155 pattern_prism = "!!! Nb of points: \n 8 \n\
3165 !!! Indices of points of 2 prisms: \n\
3169 pattern = self.smeshpyD.GetPattern()
3170 isDone = pattern.LoadFromFile(pattern_prism)
3172 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
3175 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
3176 isDone = pattern.MakeMesh(self.mesh, False, False)
3177 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
3179 # Splits quafrangle faces near triangular facets of volumes
3180 self.SplitQuadsNearTriangularFacets()
3184 ## Smoothes elements
3185 # @param IDsOfElements the list if ids of elements to smooth
3186 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3187 # Note that nodes built on edges and boundary nodes are always fixed.
3188 # @param MaxNbOfIterations the maximum number of iterations
3189 # @param MaxAspectRatio varies in range [1.0, inf]
3190 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3191 # @return TRUE in case of success, FALSE otherwise.
3192 # @ingroup l2_modif_smooth
3193 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
3194 MaxNbOfIterations, MaxAspectRatio, Method):
3195 if IDsOfElements == []:
3196 IDsOfElements = self.GetElementsId()
3197 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
3198 self.mesh.SetParameters(Parameters)
3199 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
3200 MaxNbOfIterations, MaxAspectRatio, Method)
3202 ## Smoothes elements which belong to the given object
3203 # @param theObject the object to smooth
3204 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3205 # Note that nodes built on edges and boundary nodes are always fixed.
3206 # @param MaxNbOfIterations the maximum number of iterations
3207 # @param MaxAspectRatio varies in range [1.0, inf]
3208 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3209 # @return TRUE in case of success, FALSE otherwise.
3210 # @ingroup l2_modif_smooth
3211 def SmoothObject(self, theObject, IDsOfFixedNodes,
3212 MaxNbOfIterations, MaxAspectRatio, Method):
3213 if ( isinstance( theObject, Mesh )):
3214 theObject = theObject.GetMesh()
3215 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
3216 MaxNbOfIterations, MaxAspectRatio, Method)
3218 ## Parametrically smoothes the given elements
3219 # @param IDsOfElements the list if ids of elements to smooth
3220 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3221 # Note that nodes built on edges and boundary nodes are always fixed.
3222 # @param MaxNbOfIterations the maximum number of iterations
3223 # @param MaxAspectRatio varies in range [1.0, inf]
3224 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3225 # @return TRUE in case of success, FALSE otherwise.
3226 # @ingroup l2_modif_smooth
3227 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
3228 MaxNbOfIterations, MaxAspectRatio, Method):
3229 if IDsOfElements == []:
3230 IDsOfElements = self.GetElementsId()
3231 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
3232 self.mesh.SetParameters(Parameters)
3233 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
3234 MaxNbOfIterations, MaxAspectRatio, Method)
3236 ## Parametrically smoothes the elements which belong to the given object
3237 # @param theObject the object to smooth
3238 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3239 # Note that nodes built on edges and boundary nodes are always fixed.
3240 # @param MaxNbOfIterations the maximum number of iterations
3241 # @param MaxAspectRatio varies in range [1.0, inf]
3242 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3243 # @return TRUE in case of success, FALSE otherwise.
3244 # @ingroup l2_modif_smooth
3245 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
3246 MaxNbOfIterations, MaxAspectRatio, Method):
3247 if ( isinstance( theObject, Mesh )):
3248 theObject = theObject.GetMesh()
3249 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
3250 MaxNbOfIterations, MaxAspectRatio, Method)
3252 ## Converts the mesh to quadratic, deletes old elements, replacing
3253 # them with quadratic with the same id.
3254 # @param theForce3d new node creation method:
3255 # 0 - the medium node lies at the geometrical entity from which the mesh element is built
3256 # 1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element
3257 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
3258 # @ingroup l2_modif_tofromqu
3259 def ConvertToQuadratic(self, theForce3d, theSubMesh=None):
3261 self.editor.ConvertToQuadraticObject(theForce3d,theSubMesh)
3263 self.editor.ConvertToQuadratic(theForce3d)
3265 ## Converts the mesh from quadratic to ordinary,
3266 # deletes old quadratic elements, \n replacing
3267 # them with ordinary mesh elements with the same id.
3268 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
3269 # @ingroup l2_modif_tofromqu
3270 def ConvertFromQuadratic(self, theSubMesh=None):
3272 self.editor.ConvertFromQuadraticObject(theSubMesh)
3274 return self.editor.ConvertFromQuadratic()
3276 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
3277 # @return TRUE if operation has been completed successfully, FALSE otherwise
3278 # @ingroup l2_modif_edit
3279 def Make2DMeshFrom3D(self):
3280 return self.editor. Make2DMeshFrom3D()
3282 ## Creates missing boundary elements
3283 # @param elements - elements whose boundary is to be checked:
3284 # mesh, group, sub-mesh or list of elements
3285 # if elements is mesh, it must be the mesh whose MakeBoundaryMesh() is called
3286 # @param dimension - defines type of boundary elements to create:
3287 # SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D
3288 # SMESH.BND_1DFROM3D creates mesh edges on all borders of free facets of 3D cells
3289 # @param groupName - a name of group to store created boundary elements in,
3290 # "" means not to create the group
3291 # @param meshName - a name of new mesh to store created boundary elements in,
3292 # "" means not to create the new mesh
3293 # @param toCopyElements - if true, the checked elements will be copied into
3294 # the new mesh else only boundary elements will be copied into the new mesh
3295 # @param toCopyExistingBondary - if true, not only new but also pre-existing
3296 # boundary elements will be copied into the new mesh
3297 # @return tuple (mesh, group) where bondary elements were added to
3298 # @ingroup l2_modif_edit
3299 def MakeBoundaryMesh(self, elements, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3300 toCopyElements=False, toCopyExistingBondary=False):
3301 if isinstance( elements, Mesh ):
3302 elements = elements.GetMesh()
3303 if ( isinstance( elements, list )):
3304 elemType = SMESH.ALL
3305 if elements: elemType = self.GetElementType( elements[0], iselem=True)
3306 elements = self.editor.MakeIDSource(elements, elemType)
3307 mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName,
3308 toCopyElements,toCopyExistingBondary)
3309 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3313 # @brief Creates missing boundary elements around either the whole mesh or
3314 # groups of 2D elements
3315 # @param dimension - defines type of boundary elements to create
3316 # @param groupName - a name of group to store all boundary elements in,
3317 # "" means not to create the group
3318 # @param meshName - a name of a new mesh, which is a copy of the initial
3319 # mesh + created boundary elements; "" means not to create the new mesh
3320 # @param toCopyAll - if true, the whole initial mesh will be copied into
3321 # the new mesh else only boundary elements will be copied into the new mesh
3322 # @param groups - groups of 2D elements to make boundary around
3323 # @retval tuple( long, mesh, groups )
3324 # long - number of added boundary elements
3325 # mesh - the mesh where elements were added to
3326 # group - the group of boundary elements or None
3328 def MakeBoundaryElements(self, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3329 toCopyAll=False, groups=[]):
3330 nb, mesh, group = self.editor.MakeBoundaryElements(dimension,groupName,meshName,
3332 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3333 return nb, mesh, group
3335 ## Renumber mesh nodes
3336 # @ingroup l2_modif_renumber
3337 def RenumberNodes(self):
3338 self.editor.RenumberNodes()
3340 ## Renumber mesh elements
3341 # @ingroup l2_modif_renumber
3342 def RenumberElements(self):
3343 self.editor.RenumberElements()
3345 ## Generates new elements by rotation of the elements around the axis
3346 # @param IDsOfElements the list of ids of elements to sweep
3347 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3348 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
3349 # @param NbOfSteps the number of steps
3350 # @param Tolerance tolerance
3351 # @param MakeGroups forces the generation of new groups from existing ones
3352 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3353 # of all steps, else - size of each step
3354 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3355 # @ingroup l2_modif_extrurev
3356 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
3357 MakeGroups=False, TotalAngle=False):
3359 if isinstance(AngleInRadians,str):
3361 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3363 AngleInRadians = DegreesToRadians(AngleInRadians)
3364 if IDsOfElements == []:
3365 IDsOfElements = self.GetElementsId()
3366 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3367 Axis = self.smeshpyD.GetAxisStruct(Axis)
3368 Axis,AxisParameters = ParseAxisStruct(Axis)
3369 if TotalAngle and NbOfSteps:
3370 AngleInRadians /= NbOfSteps
3371 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3372 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3373 self.mesh.SetParameters(Parameters)
3375 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
3376 AngleInRadians, NbOfSteps, Tolerance)
3377 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
3380 ## Generates new elements by rotation of the elements of object around the axis
3381 # @param theObject object which elements should be sweeped.
3382 # It can be a mesh, a sub mesh or a group.
3383 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3384 # @param AngleInRadians the angle of Rotation
3385 # @param NbOfSteps number of steps
3386 # @param Tolerance tolerance
3387 # @param MakeGroups forces the generation of new groups from existing ones
3388 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3389 # of all steps, else - size of each step
3390 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3391 # @ingroup l2_modif_extrurev
3392 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3393 MakeGroups=False, TotalAngle=False):
3395 if isinstance(AngleInRadians,str):
3397 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3399 AngleInRadians = DegreesToRadians(AngleInRadians)
3400 if ( isinstance( theObject, Mesh )):
3401 theObject = theObject.GetMesh()
3402 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3403 Axis = self.smeshpyD.GetAxisStruct(Axis)
3404 Axis,AxisParameters = ParseAxisStruct(Axis)
3405 if TotalAngle and NbOfSteps:
3406 AngleInRadians /= NbOfSteps
3407 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3408 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3409 self.mesh.SetParameters(Parameters)
3411 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
3412 NbOfSteps, Tolerance)
3413 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3416 ## Generates new elements by rotation of the elements of object around the axis
3417 # @param theObject object which elements should be sweeped.
3418 # It can be a mesh, a sub mesh or a group.
3419 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3420 # @param AngleInRadians the angle of Rotation
3421 # @param NbOfSteps number of steps
3422 # @param Tolerance tolerance
3423 # @param MakeGroups forces the generation of new groups from existing ones
3424 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3425 # of all steps, else - size of each step
3426 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3427 # @ingroup l2_modif_extrurev
3428 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3429 MakeGroups=False, TotalAngle=False):
3431 if isinstance(AngleInRadians,str):
3433 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3435 AngleInRadians = DegreesToRadians(AngleInRadians)
3436 if ( isinstance( theObject, Mesh )):
3437 theObject = theObject.GetMesh()
3438 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3439 Axis = self.smeshpyD.GetAxisStruct(Axis)
3440 Axis,AxisParameters = ParseAxisStruct(Axis)
3441 if TotalAngle and NbOfSteps:
3442 AngleInRadians /= NbOfSteps
3443 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3444 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3445 self.mesh.SetParameters(Parameters)
3447 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
3448 NbOfSteps, Tolerance)
3449 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3452 ## Generates new elements by rotation of the elements of object around the axis
3453 # @param theObject object which elements should be sweeped.
3454 # It can be a mesh, a sub mesh or a group.
3455 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3456 # @param AngleInRadians the angle of Rotation
3457 # @param NbOfSteps number of steps
3458 # @param Tolerance tolerance
3459 # @param MakeGroups forces the generation of new groups from existing ones
3460 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3461 # of all steps, else - size of each step
3462 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3463 # @ingroup l2_modif_extrurev
3464 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3465 MakeGroups=False, TotalAngle=False):
3467 if isinstance(AngleInRadians,str):
3469 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3471 AngleInRadians = DegreesToRadians(AngleInRadians)
3472 if ( isinstance( theObject, Mesh )):
3473 theObject = theObject.GetMesh()
3474 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3475 Axis = self.smeshpyD.GetAxisStruct(Axis)
3476 Axis,AxisParameters = ParseAxisStruct(Axis)
3477 if TotalAngle and NbOfSteps:
3478 AngleInRadians /= NbOfSteps
3479 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3480 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3481 self.mesh.SetParameters(Parameters)
3483 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
3484 NbOfSteps, Tolerance)
3485 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3488 ## Generates new elements by extrusion of the elements with given ids
3489 # @param IDsOfElements the list of elements ids for extrusion
3490 # @param StepVector vector or DirStruct, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3491 # @param NbOfSteps the number of steps
3492 # @param MakeGroups forces the generation of new groups from existing ones
3493 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3494 # @ingroup l2_modif_extrurev
3495 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
3496 if IDsOfElements == []:
3497 IDsOfElements = self.GetElementsId()
3498 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3499 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3500 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3501 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3502 Parameters = StepVectorParameters + var_separator + Parameters
3503 self.mesh.SetParameters(Parameters)
3505 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
3506 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
3509 ## Generates new elements by extrusion of the elements with given ids
3510 # @param IDsOfElements is ids of elements
3511 # @param StepVector vector, defining the direction and value of extrusion
3512 # @param NbOfSteps the number of steps
3513 # @param ExtrFlags sets flags for extrusion
3514 # @param SewTolerance uses for comparing locations of nodes if flag
3515 # EXTRUSION_FLAG_SEW is set
3516 # @param MakeGroups forces the generation of new groups from existing ones
3517 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3518 # @ingroup l2_modif_extrurev
3519 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
3520 ExtrFlags, SewTolerance, MakeGroups=False):
3521 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3522 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3524 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
3525 ExtrFlags, SewTolerance)
3526 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
3527 ExtrFlags, SewTolerance)
3530 ## Generates new elements by extrusion of the elements which belong to the object
3531 # @param theObject the object which elements should be processed.
3532 # It can be a mesh, a sub mesh or a group.
3533 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3534 # @param NbOfSteps the number of steps
3535 # @param MakeGroups forces the generation of new groups from existing ones
3536 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3537 # @ingroup l2_modif_extrurev
3538 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3539 if ( isinstance( theObject, Mesh )):
3540 theObject = theObject.GetMesh()
3541 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3542 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3543 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3544 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3545 Parameters = StepVectorParameters + var_separator + Parameters
3546 self.mesh.SetParameters(Parameters)
3548 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3549 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
3552 ## Generates new elements by extrusion of the elements which belong to the object
3553 # @param theObject object which elements should be processed.
3554 # It can be a mesh, a sub mesh or a group.
3555 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3556 # @param NbOfSteps the number of steps
3557 # @param MakeGroups to generate new groups from existing ones
3558 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3559 # @ingroup l2_modif_extrurev
3560 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3561 if ( isinstance( theObject, Mesh )):
3562 theObject = theObject.GetMesh()
3563 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3564 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3565 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3566 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3567 Parameters = StepVectorParameters + var_separator + Parameters
3568 self.mesh.SetParameters(Parameters)
3570 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3571 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3574 ## Generates new elements by extrusion of the elements which belong to the object
3575 # @param theObject object which elements should be processed.
3576 # It can be a mesh, a sub mesh or a group.
3577 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3578 # @param NbOfSteps the number of steps
3579 # @param MakeGroups forces the generation of new groups from existing ones
3580 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3581 # @ingroup l2_modif_extrurev
3582 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3583 if ( isinstance( theObject, Mesh )):
3584 theObject = theObject.GetMesh()
3585 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3586 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3587 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3588 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3589 Parameters = StepVectorParameters + var_separator + Parameters
3590 self.mesh.SetParameters(Parameters)
3592 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3593 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3598 ## Generates new elements by extrusion of the given elements
3599 # The path of extrusion must be a meshed edge.
3600 # @param Base mesh or group, or submesh, or list of ids of elements for extrusion
3601 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3602 # @param NodeStart the start node from Path. Defines the direction of extrusion
3603 # @param HasAngles allows the shape to be rotated around the path
3604 # to get the resulting mesh in a helical fashion
3605 # @param Angles list of angles in radians
3606 # @param LinearVariation forces the computation of rotation angles as linear
3607 # variation of the given Angles along path steps
3608 # @param HasRefPoint allows using the reference point
3609 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3610 # The User can specify any point as the Reference Point.
3611 # @param MakeGroups forces the generation of new groups from existing ones
3612 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3613 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3614 # only SMESH::Extrusion_Error otherwise
3615 # @ingroup l2_modif_extrurev
3616 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3617 HasAngles, Angles, LinearVariation,
3618 HasRefPoint, RefPoint, MakeGroups, ElemType):
3619 Angles,AnglesParameters = ParseAngles(Angles)
3620 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3621 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3622 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3624 Parameters = AnglesParameters + var_separator + RefPointParameters
3625 self.mesh.SetParameters(Parameters)
3627 if (isinstance(Path, Mesh)): Path = Path.GetMesh()
3629 if isinstance(Base, list):
3631 if Base == []: IDsOfElements = self.GetElementsId()
3632 else: IDsOfElements = Base
3633 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3634 HasAngles, Angles, LinearVariation,
3635 HasRefPoint, RefPoint, MakeGroups, ElemType)
3637 if isinstance(Base, Mesh): Base = Base.GetMesh()
3638 if isinstance(Base, SMESH._objref_SMESH_Mesh) or isinstance(Base, SMESH._objref_SMESH_Group) or isinstance(Base, SMESH._objref_SMESH_subMesh):
3639 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3640 HasAngles, Angles, LinearVariation,
3641 HasRefPoint, RefPoint, MakeGroups, ElemType)
3643 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3646 ## Generates new elements by extrusion of the given elements
3647 # The path of extrusion must be a meshed edge.
3648 # @param IDsOfElements ids of elements
3649 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3650 # @param PathShape shape(edge) defines the sub-mesh for the path
3651 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3652 # @param HasAngles allows the shape to be rotated around the path
3653 # to get the resulting mesh in a helical fashion
3654 # @param Angles list of angles in radians
3655 # @param HasRefPoint allows using the reference point
3656 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3657 # The User can specify any point as the Reference Point.
3658 # @param MakeGroups forces the generation of new groups from existing ones
3659 # @param LinearVariation forces the computation of rotation angles as linear
3660 # variation of the given Angles along path steps
3661 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3662 # only SMESH::Extrusion_Error otherwise
3663 # @ingroup l2_modif_extrurev
3664 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3665 HasAngles, Angles, HasRefPoint, RefPoint,
3666 MakeGroups=False, LinearVariation=False):
3667 Angles,AnglesParameters = ParseAngles(Angles)
3668 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3669 if IDsOfElements == []:
3670 IDsOfElements = self.GetElementsId()
3671 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3672 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3674 if ( isinstance( PathMesh, Mesh )):
3675 PathMesh = PathMesh.GetMesh()
3676 if HasAngles and Angles and LinearVariation:
3677 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3679 Parameters = AnglesParameters + var_separator + RefPointParameters
3680 self.mesh.SetParameters(Parameters)
3682 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3683 PathShape, NodeStart, HasAngles,
3684 Angles, HasRefPoint, RefPoint)
3685 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3686 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3688 ## Generates new elements by extrusion of the elements which belong to the object
3689 # The path of extrusion must be a meshed edge.
3690 # @param theObject the object which elements should be processed.
3691 # It can be a mesh, a sub mesh or a group.
3692 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3693 # @param PathShape shape(edge) defines the sub-mesh for the path
3694 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3695 # @param HasAngles allows the shape to be rotated around the path
3696 # to get the resulting mesh in a helical fashion
3697 # @param Angles list of angles
3698 # @param HasRefPoint allows using the reference point
3699 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3700 # The User can specify any point as the Reference Point.
3701 # @param MakeGroups forces the generation of new groups from existing ones
3702 # @param LinearVariation forces the computation of rotation angles as linear
3703 # variation of the given Angles along path steps
3704 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3705 # only SMESH::Extrusion_Error otherwise
3706 # @ingroup l2_modif_extrurev
3707 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3708 HasAngles, Angles, HasRefPoint, RefPoint,
3709 MakeGroups=False, LinearVariation=False):
3710 Angles,AnglesParameters = ParseAngles(Angles)
3711 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3712 if ( isinstance( theObject, Mesh )):
3713 theObject = theObject.GetMesh()
3714 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3715 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3716 if ( isinstance( PathMesh, Mesh )):
3717 PathMesh = PathMesh.GetMesh()
3718 if HasAngles and Angles and LinearVariation:
3719 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3721 Parameters = AnglesParameters + var_separator + RefPointParameters
3722 self.mesh.SetParameters(Parameters)
3724 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3725 PathShape, NodeStart, HasAngles,
3726 Angles, HasRefPoint, RefPoint)
3727 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3728 NodeStart, HasAngles, Angles, HasRefPoint,
3731 ## Generates new elements by extrusion of the elements which belong to the object
3732 # The path of extrusion must be a meshed edge.
3733 # @param theObject the object which elements should be processed.
3734 # It can be a mesh, a sub mesh or a group.
3735 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3736 # @param PathShape shape(edge) defines the sub-mesh for the path
3737 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3738 # @param HasAngles allows the shape to be rotated around the path
3739 # to get the resulting mesh in a helical fashion
3740 # @param Angles list of angles
3741 # @param HasRefPoint allows using the reference point
3742 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3743 # The User can specify any point as the Reference Point.
3744 # @param MakeGroups forces the generation of new groups from existing ones
3745 # @param LinearVariation forces the computation of rotation angles as linear
3746 # variation of the given Angles along path steps
3747 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3748 # only SMESH::Extrusion_Error otherwise
3749 # @ingroup l2_modif_extrurev
3750 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3751 HasAngles, Angles, HasRefPoint, RefPoint,
3752 MakeGroups=False, LinearVariation=False):
3753 Angles,AnglesParameters = ParseAngles(Angles)
3754 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3755 if ( isinstance( theObject, Mesh )):
3756 theObject = theObject.GetMesh()
3757 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3758 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3759 if ( isinstance( PathMesh, Mesh )):
3760 PathMesh = PathMesh.GetMesh()
3761 if HasAngles and Angles and LinearVariation:
3762 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3764 Parameters = AnglesParameters + var_separator + RefPointParameters
3765 self.mesh.SetParameters(Parameters)
3767 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3768 PathShape, NodeStart, HasAngles,
3769 Angles, HasRefPoint, RefPoint)
3770 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3771 NodeStart, HasAngles, Angles, HasRefPoint,
3774 ## Generates new elements by extrusion of the elements which belong to the object
3775 # The path of extrusion must be a meshed edge.
3776 # @param theObject the object which elements should be processed.
3777 # It can be a mesh, a sub mesh or a group.
3778 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3779 # @param PathShape shape(edge) defines the sub-mesh for the path
3780 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3781 # @param HasAngles allows the shape to be rotated around the path
3782 # to get the resulting mesh in a helical fashion
3783 # @param Angles list of angles
3784 # @param HasRefPoint allows using the reference point
3785 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3786 # The User can specify any point as the Reference Point.
3787 # @param MakeGroups forces the generation of new groups from existing ones
3788 # @param LinearVariation forces the computation of rotation angles as linear
3789 # variation of the given Angles along path steps
3790 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3791 # only SMESH::Extrusion_Error otherwise
3792 # @ingroup l2_modif_extrurev
3793 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3794 HasAngles, Angles, HasRefPoint, RefPoint,
3795 MakeGroups=False, LinearVariation=False):
3796 Angles,AnglesParameters = ParseAngles(Angles)
3797 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3798 if ( isinstance( theObject, Mesh )):
3799 theObject = theObject.GetMesh()
3800 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3801 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3802 if ( isinstance( PathMesh, Mesh )):
3803 PathMesh = PathMesh.GetMesh()
3804 if HasAngles and Angles and LinearVariation:
3805 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3807 Parameters = AnglesParameters + var_separator + RefPointParameters
3808 self.mesh.SetParameters(Parameters)
3810 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3811 PathShape, NodeStart, HasAngles,
3812 Angles, HasRefPoint, RefPoint)
3813 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3814 NodeStart, HasAngles, Angles, HasRefPoint,
3817 ## Creates a symmetrical copy of mesh elements
3818 # @param IDsOfElements list of elements ids
3819 # @param Mirror is AxisStruct or geom object(point, line, plane)
3820 # @param theMirrorType is POINT, AXIS or PLANE
3821 # If the Mirror is a geom object this parameter is unnecessary
3822 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3823 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3824 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3825 # @ingroup l2_modif_trsf
3826 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3827 if IDsOfElements == []:
3828 IDsOfElements = self.GetElementsId()
3829 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3830 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3831 Mirror,Parameters = ParseAxisStruct(Mirror)
3832 self.mesh.SetParameters(Parameters)
3833 if Copy and MakeGroups:
3834 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3835 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3838 ## Creates a new mesh by a symmetrical copy of mesh elements
3839 # @param IDsOfElements the list of elements ids
3840 # @param Mirror is AxisStruct or geom object (point, line, plane)
3841 # @param theMirrorType is POINT, AXIS or PLANE
3842 # If the Mirror is a geom object this parameter is unnecessary
3843 # @param MakeGroups to generate new groups from existing ones
3844 # @param NewMeshName a name of the new mesh to create
3845 # @return instance of Mesh class
3846 # @ingroup l2_modif_trsf
3847 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3848 if IDsOfElements == []:
3849 IDsOfElements = self.GetElementsId()
3850 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3851 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3852 Mirror,Parameters = ParseAxisStruct(Mirror)
3853 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3854 MakeGroups, NewMeshName)
3855 mesh.SetParameters(Parameters)
3856 return Mesh(self.smeshpyD,self.geompyD,mesh)
3858 ## Creates a symmetrical copy of the object
3859 # @param theObject mesh, submesh or group
3860 # @param Mirror AxisStruct or geom object (point, line, plane)
3861 # @param theMirrorType is POINT, AXIS or PLANE
3862 # If the Mirror is a geom object this parameter is unnecessary
3863 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3864 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3865 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3866 # @ingroup l2_modif_trsf
3867 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3868 if ( isinstance( theObject, Mesh )):
3869 theObject = theObject.GetMesh()
3870 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3871 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3872 Mirror,Parameters = ParseAxisStruct(Mirror)
3873 self.mesh.SetParameters(Parameters)
3874 if Copy and MakeGroups:
3875 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3876 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3879 ## Creates a new mesh by a symmetrical copy of the object
3880 # @param theObject mesh, submesh or group
3881 # @param Mirror AxisStruct or geom object (point, line, plane)
3882 # @param theMirrorType POINT, AXIS or PLANE
3883 # If the Mirror is a geom object this parameter is unnecessary
3884 # @param MakeGroups forces the generation of new groups from existing ones
3885 # @param NewMeshName the name of the new mesh to create
3886 # @return instance of Mesh class
3887 # @ingroup l2_modif_trsf
3888 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3889 if ( isinstance( theObject, Mesh )):
3890 theObject = theObject.GetMesh()
3891 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3892 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3893 Mirror,Parameters = ParseAxisStruct(Mirror)
3894 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3895 MakeGroups, NewMeshName)
3896 mesh.SetParameters(Parameters)
3897 return Mesh( self.smeshpyD,self.geompyD,mesh )
3899 ## Translates the elements
3900 # @param IDsOfElements list of elements ids
3901 # @param Vector the direction of translation (DirStruct or vector)
3902 # @param Copy allows copying the translated elements
3903 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3904 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3905 # @ingroup l2_modif_trsf
3906 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3907 if IDsOfElements == []:
3908 IDsOfElements = self.GetElementsId()
3909 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3910 Vector = self.smeshpyD.GetDirStruct(Vector)
3911 Vector,Parameters = ParseDirStruct(Vector)
3912 self.mesh.SetParameters(Parameters)
3913 if Copy and MakeGroups:
3914 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3915 self.editor.Translate(IDsOfElements, Vector, Copy)
3918 ## Creates a new mesh of translated elements
3919 # @param IDsOfElements list of elements ids
3920 # @param Vector the direction of translation (DirStruct or vector)
3921 # @param MakeGroups forces the generation of new groups from existing ones
3922 # @param NewMeshName the name of the newly created mesh
3923 # @return instance of Mesh class
3924 # @ingroup l2_modif_trsf
3925 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3926 if IDsOfElements == []:
3927 IDsOfElements = self.GetElementsId()
3928 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3929 Vector = self.smeshpyD.GetDirStruct(Vector)
3930 Vector,Parameters = ParseDirStruct(Vector)
3931 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3932 mesh.SetParameters(Parameters)
3933 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3935 ## Translates the object
3936 # @param theObject the object to translate (mesh, submesh, or group)
3937 # @param Vector direction of translation (DirStruct or geom vector)
3938 # @param Copy allows copying the translated elements
3939 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3940 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3941 # @ingroup l2_modif_trsf
3942 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3943 if ( isinstance( theObject, Mesh )):
3944 theObject = theObject.GetMesh()
3945 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3946 Vector = self.smeshpyD.GetDirStruct(Vector)
3947 Vector,Parameters = ParseDirStruct(Vector)
3948 self.mesh.SetParameters(Parameters)
3949 if Copy and MakeGroups:
3950 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3951 self.editor.TranslateObject(theObject, Vector, Copy)
3954 ## Creates a new mesh from the translated object
3955 # @param theObject the object to translate (mesh, submesh, or group)
3956 # @param Vector the direction of translation (DirStruct or geom vector)
3957 # @param MakeGroups forces the generation of new groups from existing ones
3958 # @param NewMeshName the name of the newly created mesh
3959 # @return instance of Mesh class
3960 # @ingroup l2_modif_trsf
3961 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3962 if (isinstance(theObject, Mesh)):
3963 theObject = theObject.GetMesh()
3964 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3965 Vector = self.smeshpyD.GetDirStruct(Vector)
3966 Vector,Parameters = ParseDirStruct(Vector)
3967 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3968 mesh.SetParameters(Parameters)
3969 return Mesh( self.smeshpyD, self.geompyD, mesh )
3973 ## Scales the object
3974 # @param theObject - the object to translate (mesh, submesh, or group)
3975 # @param thePoint - base point for scale
3976 # @param theScaleFact - list of 1-3 scale factors for axises
3977 # @param Copy - allows copying the translated elements
3978 # @param MakeGroups - forces the generation of new groups from existing
3980 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3981 # empty list otherwise
3982 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3983 if ( isinstance( theObject, Mesh )):
3984 theObject = theObject.GetMesh()
3985 if ( isinstance( theObject, list )):
3986 theObject = self.GetIDSource(theObject, SMESH.ALL)
3988 thePoint, Parameters = ParsePointStruct(thePoint)
3989 self.mesh.SetParameters(Parameters)
3991 if Copy and MakeGroups:
3992 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3993 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3996 ## Creates a new mesh from the translated object
3997 # @param theObject - the object to translate (mesh, submesh, or group)
3998 # @param thePoint - base point for scale
3999 # @param theScaleFact - list of 1-3 scale factors for axises
4000 # @param MakeGroups - forces the generation of new groups from existing ones
4001 # @param NewMeshName - the name of the newly created mesh
4002 # @return instance of Mesh class
4003 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
4004 if (isinstance(theObject, Mesh)):
4005 theObject = theObject.GetMesh()
4006 if ( isinstance( theObject, list )):
4007 theObject = self.GetIDSource(theObject,SMESH.ALL)
4009 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
4010 MakeGroups, NewMeshName)
4011 #mesh.SetParameters(Parameters)
4012 return Mesh( self.smeshpyD, self.geompyD, mesh )
4016 ## Rotates the elements
4017 # @param IDsOfElements list of elements ids
4018 # @param Axis the axis of rotation (AxisStruct or geom line)
4019 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
4020 # @param Copy allows copying the rotated elements
4021 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
4022 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
4023 # @ingroup l2_modif_trsf
4024 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
4026 if isinstance(AngleInRadians,str):
4028 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
4030 AngleInRadians = DegreesToRadians(AngleInRadians)
4031 if IDsOfElements == []:
4032 IDsOfElements = self.GetElementsId()
4033 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
4034 Axis = self.smeshpyD.GetAxisStruct(Axis)
4035 Axis,AxisParameters = ParseAxisStruct(Axis)
4036 Parameters = AxisParameters + var_separator + Parameters
4037 self.mesh.SetParameters(Parameters)
4038 if Copy and MakeGroups:
4039 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
4040 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
4043 ## Creates a new mesh of rotated elements
4044 # @param IDsOfElements list of element ids
4045 # @param Axis the axis of rotation (AxisStruct or geom line)
4046 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
4047 # @param MakeGroups forces the generation of new groups from existing ones
4048 # @param NewMeshName the name of the newly created mesh
4049 # @return instance of Mesh class
4050 # @ingroup l2_modif_trsf
4051 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
4053 if isinstance(AngleInRadians,str):
4055 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
4057 AngleInRadians = DegreesToRadians(AngleInRadians)
4058 if IDsOfElements == []:
4059 IDsOfElements = self.GetElementsId()
4060 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
4061 Axis = self.smeshpyD.GetAxisStruct(Axis)
4062 Axis,AxisParameters = ParseAxisStruct(Axis)
4063 Parameters = AxisParameters + var_separator + Parameters
4064 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
4065 MakeGroups, NewMeshName)
4066 mesh.SetParameters(Parameters)
4067 return Mesh( self.smeshpyD, self.geompyD, mesh )
4069 ## Rotates the object
4070 # @param theObject the object to rotate( mesh, submesh, or group)
4071 # @param Axis the axis of rotation (AxisStruct or geom line)
4072 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
4073 # @param Copy allows copying the rotated elements
4074 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
4075 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
4076 # @ingroup l2_modif_trsf
4077 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
4079 if isinstance(AngleInRadians,str):
4081 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
4083 AngleInRadians = DegreesToRadians(AngleInRadians)
4084 if (isinstance(theObject, Mesh)):
4085 theObject = theObject.GetMesh()
4086 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
4087 Axis = self.smeshpyD.GetAxisStruct(Axis)
4088 Axis,AxisParameters = ParseAxisStruct(Axis)
4089 Parameters = AxisParameters + ":" + Parameters
4090 self.mesh.SetParameters(Parameters)
4091 if Copy and MakeGroups:
4092 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
4093 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
4096 ## Creates a new mesh from the rotated object
4097 # @param theObject the object to rotate (mesh, submesh, or group)
4098 # @param Axis the axis of rotation (AxisStruct or geom line)
4099 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
4100 # @param MakeGroups forces the generation of new groups from existing ones
4101 # @param NewMeshName the name of the newly created mesh
4102 # @return instance of Mesh class
4103 # @ingroup l2_modif_trsf
4104 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
4106 if isinstance(AngleInRadians,str):
4108 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
4110 AngleInRadians = DegreesToRadians(AngleInRadians)
4111 if (isinstance( theObject, Mesh )):
4112 theObject = theObject.GetMesh()
4113 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
4114 Axis = self.smeshpyD.GetAxisStruct(Axis)
4115 Axis,AxisParameters = ParseAxisStruct(Axis)
4116 Parameters = AxisParameters + ":" + Parameters
4117 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
4118 MakeGroups, NewMeshName)
4119 mesh.SetParameters(Parameters)
4120 return Mesh( self.smeshpyD, self.geompyD, mesh )
4122 ## Finds groups of ajacent nodes within Tolerance.
4123 # @param Tolerance the value of tolerance
4124 # @return the list of groups of nodes
4125 # @ingroup l2_modif_trsf
4126 def FindCoincidentNodes (self, Tolerance):
4127 return self.editor.FindCoincidentNodes(Tolerance)
4129 ## Finds groups of ajacent nodes within Tolerance.
4130 # @param Tolerance the value of tolerance
4131 # @param SubMeshOrGroup SubMesh or Group
4132 # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
4133 # @return the list of groups of nodes
4134 # @ingroup l2_modif_trsf
4135 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
4136 if (isinstance( SubMeshOrGroup, Mesh )):
4137 SubMeshOrGroup = SubMeshOrGroup.GetMesh()
4138 if not isinstance( exceptNodes, list):
4139 exceptNodes = [ exceptNodes ]
4140 if exceptNodes and isinstance( exceptNodes[0], int):
4141 exceptNodes = [ self.GetIDSource( exceptNodes, SMESH.NODE)]
4142 return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes)
4145 # @param GroupsOfNodes the list of groups of nodes
4146 # @ingroup l2_modif_trsf
4147 def MergeNodes (self, GroupsOfNodes):
4148 self.editor.MergeNodes(GroupsOfNodes)
4150 ## Finds the elements built on the same nodes.
4151 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
4152 # @return a list of groups of equal elements
4153 # @ingroup l2_modif_trsf
4154 def FindEqualElements (self, MeshOrSubMeshOrGroup):
4155 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
4156 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
4157 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
4159 ## Merges elements in each given group.
4160 # @param GroupsOfElementsID groups of elements for merging
4161 # @ingroup l2_modif_trsf
4162 def MergeElements(self, GroupsOfElementsID):
4163 self.editor.MergeElements(GroupsOfElementsID)
4165 ## Leaves one element and removes all other elements built on the same nodes.
4166 # @ingroup l2_modif_trsf
4167 def MergeEqualElements(self):
4168 self.editor.MergeEqualElements()
4170 ## Sews free borders
4171 # @return SMESH::Sew_Error
4172 # @ingroup l2_modif_trsf
4173 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
4174 FirstNodeID2, SecondNodeID2, LastNodeID2,
4175 CreatePolygons, CreatePolyedrs):
4176 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
4177 FirstNodeID2, SecondNodeID2, LastNodeID2,
4178 CreatePolygons, CreatePolyedrs)
4180 ## Sews conform free borders
4181 # @return SMESH::Sew_Error
4182 # @ingroup l2_modif_trsf
4183 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
4184 FirstNodeID2, SecondNodeID2):
4185 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
4186 FirstNodeID2, SecondNodeID2)
4188 ## Sews border to side
4189 # @return SMESH::Sew_Error
4190 # @ingroup l2_modif_trsf
4191 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
4192 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
4193 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
4194 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
4196 ## Sews two sides of a mesh. The nodes belonging to Side1 are
4197 # merged with the nodes of elements of Side2.
4198 # The number of elements in theSide1 and in theSide2 must be
4199 # equal and they should have similar nodal connectivity.
4200 # The nodes to merge should belong to side borders and
4201 # the first node should be linked to the second.
4202 # @return SMESH::Sew_Error
4203 # @ingroup l2_modif_trsf
4204 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
4205 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
4206 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
4207 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
4208 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
4209 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
4211 ## Sets new nodes for the given element.
4212 # @param ide the element id
4213 # @param newIDs nodes ids
4214 # @return If the number of nodes does not correspond to the type of element - returns false
4215 # @ingroup l2_modif_edit
4216 def ChangeElemNodes(self, ide, newIDs):
4217 return self.editor.ChangeElemNodes(ide, newIDs)
4219 ## If during the last operation of MeshEditor some nodes were
4220 # created, this method returns the list of their IDs, \n
4221 # if new nodes were not created - returns empty list
4222 # @return the list of integer values (can be empty)
4223 # @ingroup l1_auxiliary
4224 def GetLastCreatedNodes(self):
4225 return self.editor.GetLastCreatedNodes()
4227 ## If during the last operation of MeshEditor some elements were
4228 # created this method returns the list of their IDs, \n
4229 # if new elements were not created - returns empty list
4230 # @return the list of integer values (can be empty)
4231 # @ingroup l1_auxiliary
4232 def GetLastCreatedElems(self):
4233 return self.editor.GetLastCreatedElems()
4235 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4236 # @param theNodes identifiers of nodes to be doubled
4237 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
4238 # nodes. If list of element identifiers is empty then nodes are doubled but
4239 # they not assigned to elements
4240 # @return TRUE if operation has been completed successfully, FALSE otherwise
4241 # @ingroup l2_modif_edit
4242 def DoubleNodes(self, theNodes, theModifiedElems):
4243 return self.editor.DoubleNodes(theNodes, theModifiedElems)
4245 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4246 # This method provided for convenience works as DoubleNodes() described above.
4247 # @param theNodeId identifiers of node to be doubled
4248 # @param theModifiedElems identifiers of elements to be updated
4249 # @return TRUE if operation has been completed successfully, FALSE otherwise
4250 # @ingroup l2_modif_edit
4251 def DoubleNode(self, theNodeId, theModifiedElems):
4252 return self.editor.DoubleNode(theNodeId, theModifiedElems)
4254 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4255 # This method provided for convenience works as DoubleNodes() described above.
4256 # @param theNodes group of nodes to be doubled
4257 # @param theModifiedElems group of elements to be updated.
4258 # @param theMakeGroup forces the generation of a group containing new nodes.
4259 # @return TRUE or a created group if operation has been completed successfully,
4260 # FALSE or None otherwise
4261 # @ingroup l2_modif_edit
4262 def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
4264 return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
4265 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
4267 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4268 # This method provided for convenience works as DoubleNodes() described above.
4269 # @param theNodes list of groups of nodes to be doubled
4270 # @param theModifiedElems list of groups of elements to be updated.
4271 # @param theMakeGroup forces the generation of a group containing new nodes.
4272 # @return TRUE if operation has been completed successfully, FALSE otherwise
4273 # @ingroup l2_modif_edit
4274 def DoubleNodeGroups(self, theNodes, theModifiedElems, theMakeGroup=False):
4276 return self.editor.DoubleNodeGroupsNew(theNodes, theModifiedElems)
4277 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
4279 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4280 # @param theElems - the list of elements (edges or faces) to be replicated
4281 # The nodes for duplication could be found from these elements
4282 # @param theNodesNot - list of nodes to NOT replicate
4283 # @param theAffectedElems - the list of elements (cells and edges) to which the
4284 # replicated nodes should be associated to.
4285 # @return TRUE if operation has been completed successfully, FALSE otherwise
4286 # @ingroup l2_modif_edit
4287 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
4288 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
4290 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4291 # @param theElems - the list of elements (edges or faces) to be replicated
4292 # The nodes for duplication could be found from these elements
4293 # @param theNodesNot - list of nodes to NOT replicate
4294 # @param theShape - shape to detect affected elements (element which geometric center
4295 # located on or inside shape).
4296 # The replicated nodes should be associated to affected elements.
4297 # @return TRUE if operation has been completed successfully, FALSE otherwise
4298 # @ingroup l2_modif_edit
4299 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
4300 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
4302 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4303 # This method provided for convenience works as DoubleNodes() described above.
4304 # @param theElems - group of of elements (edges or faces) to be replicated
4305 # @param theNodesNot - group of nodes not to replicated
4306 # @param theAffectedElems - group of elements to which the replicated nodes
4307 # should be associated to.
4308 # @param theMakeGroup forces the generation of a group containing new elements.
4309 # @return TRUE or a created group if operation has been completed successfully,
4310 # FALSE or None otherwise
4311 # @ingroup l2_modif_edit
4312 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4314 return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
4315 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
4317 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4318 # This method provided for convenience works as DoubleNodes() described above.
4319 # @param theElems - group of of elements (edges or faces) to be replicated
4320 # @param theNodesNot - group of nodes not to replicated
4321 # @param theShape - shape to detect affected elements (element which geometric center
4322 # located on or inside shape).
4323 # The replicated nodes should be associated to affected elements.
4324 # @ingroup l2_modif_edit
4325 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
4326 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
4328 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4329 # This method provided for convenience works as DoubleNodes() described above.
4330 # @param theElems - list of groups of elements (edges or faces) to be replicated
4331 # @param theNodesNot - list of groups of nodes not to replicated
4332 # @param theAffectedElems - group of elements to which the replicated nodes
4333 # should be associated to.
4334 # @param theMakeGroup forces the generation of a group containing new elements.
4335 # @return TRUE or a created group if operation has been completed successfully,
4336 # FALSE or None otherwise
4337 # @ingroup l2_modif_edit
4338 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4340 return self.editor.DoubleNodeElemGroupsNew(theElems, theNodesNot, theAffectedElems)
4341 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
4343 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4344 # This method provided for convenience works as DoubleNodes() described above.
4345 # @param theElems - list of groups of elements (edges or faces) to be replicated
4346 # @param theNodesNot - list of groups of nodes not to replicated
4347 # @param theShape - shape to detect affected elements (element which geometric center
4348 # located on or inside shape).
4349 # The replicated nodes should be associated to affected elements.
4350 # @return TRUE if operation has been completed successfully, FALSE otherwise
4351 # @ingroup l2_modif_edit
4352 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
4353 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
4355 ## Double nodes on shared faces between groups of volumes and create flat elements on demand.
4356 # The list of groups must describe a partition of the mesh volumes.
4357 # The nodes of the internal faces at the boundaries of the groups are doubled.
4358 # In option, the internal faces are replaced by flat elements.
4359 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4360 # @param theDomains - list of groups of volumes
4361 # @param createJointElems - if TRUE, create the elements
4362 # @return TRUE if operation has been completed successfully, FALSE otherwise
4363 def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems ):
4364 return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems )
4366 ## Double nodes on some external faces and create flat elements.
4367 # Flat elements are mainly used by some types of mechanic calculations.
4369 # Each group of the list must be constituted of faces.
4370 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4371 # @param theGroupsOfFaces - list of groups of faces
4372 # @return TRUE if operation has been completed successfully, FALSE otherwise
4373 def CreateFlatElementsOnFacesGroups(self, theGroupsOfFaces ):
4374 return self.editor.CreateFlatElementsOnFacesGroups( theGroupsOfFaces )
4376 def _valueFromFunctor(self, funcType, elemId):
4377 fn = self.smeshpyD.GetFunctor(funcType)
4378 fn.SetMesh(self.mesh)
4379 if fn.GetElementType() == self.GetElementType(elemId, True):
4380 val = fn.GetValue(elemId)
4385 ## Get length of 1D element.
4386 # @param elemId mesh element ID
4387 # @return element's length value
4388 # @ingroup l1_measurements
4389 def GetLength(self, elemId):
4390 return self._valueFromFunctor(SMESH.FT_Length, elemId)
4392 ## Get area of 2D element.
4393 # @param elemId mesh element ID
4394 # @return element's area value
4395 # @ingroup l1_measurements
4396 def GetArea(self, elemId):
4397 return self._valueFromFunctor(SMESH.FT_Area, elemId)
4399 ## Get volume of 3D element.
4400 # @param elemId mesh element ID
4401 # @return element's volume value
4402 # @ingroup l1_measurements
4403 def GetVolume(self, elemId):
4404 return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
4406 ## Get maximum element length.
4407 # @param elemId mesh element ID
4408 # @return element's maximum length value
4409 # @ingroup l1_measurements
4410 def GetMaxElementLength(self, elemId):
4411 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4412 ftype = SMESH.FT_MaxElementLength3D
4414 ftype = SMESH.FT_MaxElementLength2D
4415 return self._valueFromFunctor(ftype, elemId)
4417 ## Get aspect ratio of 2D or 3D element.
4418 # @param elemId mesh element ID
4419 # @return element's aspect ratio value
4420 # @ingroup l1_measurements
4421 def GetAspectRatio(self, elemId):
4422 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4423 ftype = SMESH.FT_AspectRatio3D
4425 ftype = SMESH.FT_AspectRatio
4426 return self._valueFromFunctor(ftype, elemId)
4428 ## Get warping angle of 2D element.
4429 # @param elemId mesh element ID
4430 # @return element's warping angle value
4431 # @ingroup l1_measurements
4432 def GetWarping(self, elemId):
4433 return self._valueFromFunctor(SMESH.FT_Warping, elemId)
4435 ## Get minimum angle of 2D element.
4436 # @param elemId mesh element ID
4437 # @return element's minimum angle value
4438 # @ingroup l1_measurements
4439 def GetMinimumAngle(self, elemId):
4440 return self._valueFromFunctor(SMESH.FT_MinimumAngle, elemId)
4442 ## Get taper of 2D element.
4443 # @param elemId mesh element ID
4444 # @return element's taper value
4445 # @ingroup l1_measurements
4446 def GetTaper(self, elemId):
4447 return self._valueFromFunctor(SMESH.FT_Taper, elemId)
4449 ## Get skew of 2D element.
4450 # @param elemId mesh element ID
4451 # @return element's skew value
4452 # @ingroup l1_measurements
4453 def GetSkew(self, elemId):
4454 return self._valueFromFunctor(SMESH.FT_Skew, elemId)
4456 ## The mother class to define algorithm, it is not recommended to use it directly.
4459 # @ingroup l2_algorithms
4460 class Mesh_Algorithm:
4461 # @class Mesh_Algorithm
4462 # @brief Class Mesh_Algorithm
4464 #def __init__(self,smesh):
4472 ## Finds a hypothesis in the study by its type name and parameters.
4473 # Finds only the hypotheses created in smeshpyD engine.
4474 # @return SMESH.SMESH_Hypothesis
4475 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
4476 study = smeshpyD.GetCurrentStudy()
4477 #to do: find component by smeshpyD object, not by its data type
4478 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4479 if scomp is not None:
4480 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
4481 # Check if the root label of the hypotheses exists
4482 if res and hypRoot is not None:
4483 iter = study.NewChildIterator(hypRoot)
4484 # Check all published hypotheses
4486 hypo_so_i = iter.Value()
4487 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
4488 if attr is not None:
4489 anIOR = attr.Value()
4490 hypo_o_i = salome.orb.string_to_object(anIOR)
4491 if hypo_o_i is not None:
4492 # Check if this is a hypothesis
4493 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
4494 if hypo_i is not None:
4495 # Check if the hypothesis belongs to current engine
4496 if smeshpyD.GetObjectId(hypo_i) > 0:
4497 # Check if this is the required hypothesis
4498 if hypo_i.GetName() == hypname:
4500 if CompareMethod(hypo_i, args):
4514 ## Finds the algorithm in the study by its type name.
4515 # Finds only the algorithms, which have been created in smeshpyD engine.
4516 # @return SMESH.SMESH_Algo
4517 def FindAlgorithm (self, algoname, smeshpyD):
4518 study = smeshpyD.GetCurrentStudy()
4519 #to do: find component by smeshpyD object, not by its data type
4520 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4521 if scomp is not None:
4522 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
4523 # Check if the root label of the algorithms exists
4524 if res and hypRoot is not None:
4525 iter = study.NewChildIterator(hypRoot)
4526 # Check all published algorithms
4528 algo_so_i = iter.Value()
4529 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
4530 if attr is not None:
4531 anIOR = attr.Value()
4532 algo_o_i = salome.orb.string_to_object(anIOR)
4533 if algo_o_i is not None:
4534 # Check if this is an algorithm
4535 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
4536 if algo_i is not None:
4537 # Checks if the algorithm belongs to the current engine
4538 if smeshpyD.GetObjectId(algo_i) > 0:
4539 # Check if this is the required algorithm
4540 if algo_i.GetName() == algoname:
4553 ## If the algorithm is global, returns 0; \n
4554 # else returns the submesh associated to this algorithm.
4555 def GetSubMesh(self):
4558 ## Returns the wrapped mesher.
4559 def GetAlgorithm(self):
4562 ## Gets the list of hypothesis that can be used with this algorithm
4563 def GetCompatibleHypothesis(self):
4566 mylist = self.algo.GetCompatibleHypothesis()
4569 ## Gets the name of the algorithm
4573 ## Sets the name to the algorithm
4574 def SetName(self, name):
4575 self.mesh.smeshpyD.SetName(self.algo, name)
4577 ## Gets the id of the algorithm
4579 return self.algo.GetId()
4582 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
4584 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
4585 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
4587 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
4589 self.Assign(algo, mesh, geom)
4593 def Assign(self, algo, mesh, geom):
4595 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
4599 self.geom = mesh.geom
4602 AssureGeomPublished( mesh, geom )
4604 name = GetName(geom)
4608 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
4610 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
4611 TreatHypoStatus( status, algo.GetName(), name, True )
4614 def CompareHyp (self, hyp, args):
4615 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
4618 def CompareEqualHyp (self, hyp, args):
4622 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
4623 UseExisting=0, CompareMethod=""):
4626 if CompareMethod == "": CompareMethod = self.CompareHyp
4627 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
4630 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
4635 if isinstance( arg, geompyDC.GEOM._objref_GEOM_Object ):
4636 argStr = arg.GetStudyEntry()
4637 if not argStr: argStr = "GEOM_Obj_%s", arg.GetEntry()
4638 if len( argStr ) > 10:
4639 argStr = argStr[:7]+"..."
4640 if argStr[0] == '[': argStr += ']'
4646 self.mesh.smeshpyD.SetName(hypo, hyp + a)
4650 geomName = GetName(self.geom)
4651 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
4652 TreatHypoStatus( status, GetName(hypo), geomName, 0 )
4655 ## Returns entry of the shape to mesh in the study
4656 def MainShapeEntry(self):
4658 if not self.mesh or not self.mesh.GetMesh(): return entry
4659 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
4660 study = self.mesh.smeshpyD.GetCurrentStudy()
4661 ior = salome.orb.object_to_string( self.mesh.GetShape() )
4662 sobj = study.FindObjectIOR(ior)
4663 if sobj: entry = sobj.GetID()
4664 if not entry: return ""
4667 ## Defines "ViscousLayers" hypothesis to give parameters of layers of prisms to build
4668 # near mesh boundary. This hypothesis can be used by several 3D algorithms:
4669 # NETGEN 3D, GHS3D, Hexahedron(i,j,k)
4670 # @param thickness total thickness of layers of prisms
4671 # @param numberOfLayers number of layers of prisms
4672 # @param stretchFactor factor (>1.0) of growth of layer thickness towards inside of mesh
4673 # @param ignoreFaces list of geometrical faces (or their ids) not to generate layers on
4674 # @ingroup l3_hypos_additi
4675 def ViscousLayers(self, thickness, numberOfLayers, stretchFactor, ignoreFaces=[]):
4676 if not isinstance(self.algo, SMESH._objref_SMESH_3D_Algo):
4677 raise TypeError, "ViscousLayers are supported by 3D algorithms only"
4678 if not "ViscousLayers" in self.GetCompatibleHypothesis():
4679 raise TypeError, "ViscousLayers are not supported by %s"%self.algo.GetName()
4680 if ignoreFaces and isinstance( ignoreFaces[0], geompyDC.GEOM._objref_GEOM_Object ):
4681 ignoreFaces = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, f) for f in ignoreFaces ]
4682 hyp = self.Hypothesis("ViscousLayers",
4683 [thickness, numberOfLayers, stretchFactor, ignoreFaces])
4684 hyp.SetTotalThickness(thickness)
4685 hyp.SetNumberLayers(numberOfLayers)
4686 hyp.SetStretchFactor(stretchFactor)
4687 hyp.SetIgnoreFaces(ignoreFaces)
4690 ## Transform a list of ether edges or tuples (edge 1st_vertex_of_edge)
4691 # into a list acceptable to SetReversedEdges() of some 1D hypotheses
4692 # @ingroup l3_hypos_1dhyps
4693 def ReversedEdgeIndices(self, reverseList):
4695 geompy = self.mesh.geompyD
4696 for i in reverseList:
4697 if isinstance( i, int ):
4698 s = geompy.SubShapes(self.mesh.geom, [i])[0]
4699 if s.GetShapeType() != geompyDC.GEOM.EDGE:
4700 raise TypeError, "Not EDGE index given"
4702 elif isinstance( i, geompyDC.GEOM._objref_GEOM_Object ):
4703 if i.GetShapeType() != geompyDC.GEOM.EDGE:
4704 raise TypeError, "Not an EDGE given"
4705 resList.append( geompy.GetSubShapeID(self.mesh.geom, i ))
4709 if not isinstance( e, geompyDC.GEOM._objref_GEOM_Object ) or \
4710 not isinstance( v, geompyDC.GEOM._objref_GEOM_Object ):
4711 raise TypeError, "A list item must be a tuple (edge 1st_vertex_of_edge)"
4712 if v.GetShapeType() == geompyDC.GEOM.EDGE and \
4713 e.GetShapeType() == geompyDC.GEOM.VERTEX:
4715 if e.GetShapeType() != geompyDC.GEOM.EDGE or \
4716 v.GetShapeType() != geompyDC.GEOM.VERTEX:
4717 raise TypeError, "A list item must be a tuple (edge 1st_vertex_of_edge)"
4718 vFirst = FirstVertexOnCurve( e )
4719 tol = geompy.Tolerance( vFirst )[-1]
4720 if geompy.MinDistance( v, vFirst ) > 1.5*tol:
4721 resList.append( geompy.GetSubShapeID(self.mesh.geom, e ))
4723 raise TypeError, "Item must be either an edge or tuple (edge 1st_vertex_of_edge)"
4726 # Public class: Mesh_Segment
4727 # --------------------------
4729 ## Class to define a segment 1D algorithm for discretization
4732 # @ingroup l3_algos_basic
4733 class Mesh_Segment(Mesh_Algorithm):
4735 ## Private constructor.
4736 def __init__(self, mesh, geom=0):
4737 Mesh_Algorithm.__init__(self)
4738 self.Create(mesh, geom, "Regular_1D")
4740 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
4741 # @param l for the length of segments that cut an edge
4742 # @param UseExisting if ==true - searches for an existing hypothesis created with
4743 # the same parameters, else (default) - creates a new one
4744 # @param p precision, used for calculation of the number of segments.
4745 # The precision should be a positive, meaningful value within the range [0,1].
4746 # In general, the number of segments is calculated with the formula:
4747 # nb = ceil((edge_length / l) - p)
4748 # Function ceil rounds its argument to the higher integer.
4749 # So, p=0 means rounding of (edge_length / l) to the higher integer,
4750 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
4751 # p=1 means rounding of (edge_length / l) to the lower integer.
4752 # Default value is 1e-07.
4753 # @return an instance of StdMeshers_LocalLength hypothesis
4754 # @ingroup l3_hypos_1dhyps
4755 def LocalLength(self, l, UseExisting=0, p=1e-07):
4756 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
4757 CompareMethod=self.CompareLocalLength)
4763 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
4764 def CompareLocalLength(self, hyp, args):
4765 if IsEqual(hyp.GetLength(), args[0]):
4766 return IsEqual(hyp.GetPrecision(), args[1])
4769 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
4770 # @param length is optional maximal allowed length of segment, if it is omitted
4771 # the preestimated length is used that depends on geometry size
4772 # @param UseExisting if ==true - searches for an existing hypothesis created with
4773 # the same parameters, else (default) - create a new one
4774 # @return an instance of StdMeshers_MaxLength hypothesis
4775 # @ingroup l3_hypos_1dhyps
4776 def MaxSize(self, length=0.0, UseExisting=0):
4777 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
4780 hyp.SetLength(length)
4782 # set preestimated length
4783 gen = self.mesh.smeshpyD
4784 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
4785 self.mesh.GetMesh(), self.mesh.GetShape(),
4787 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
4789 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
4792 hyp.SetUsePreestimatedLength( length == 0.0 )
4795 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
4796 # @param n for the number of segments that cut an edge
4797 # @param s for the scale factor (optional)
4798 # @param reversedEdges is a list of edges to mesh using reversed orientation.
4799 # A list item can also be a tuple (edge 1st_vertex_of_edge)
4800 # @param UseExisting if ==true - searches for an existing hypothesis created with
4801 # the same parameters, else (default) - create a new one
4802 # @return an instance of StdMeshers_NumberOfSegments hypothesis
4803 # @ingroup l3_hypos_1dhyps
4804 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4805 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4806 reversedEdges, UseExisting = [], reversedEdges
4807 entry = self.MainShapeEntry()
4808 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
4810 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdgeInd, entry],
4811 UseExisting=UseExisting,
4812 CompareMethod=self.CompareNumberOfSegments)
4814 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdgeInd, entry],
4815 UseExisting=UseExisting,
4816 CompareMethod=self.CompareNumberOfSegments)
4817 hyp.SetDistrType( 1 )
4818 hyp.SetScaleFactor(s)
4819 hyp.SetNumberOfSegments(n)
4820 hyp.SetReversedEdges( reversedEdgeInd )
4821 hyp.SetObjectEntry( entry )
4825 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4826 def CompareNumberOfSegments(self, hyp, args):
4827 if hyp.GetNumberOfSegments() == args[0]:
4829 if hyp.GetReversedEdges() == args[1]:
4830 if not args[1] or hyp.GetObjectEntry() == args[2]:
4833 if hyp.GetReversedEdges() == args[2]:
4834 if not args[2] or hyp.GetObjectEntry() == args[3]:
4835 if hyp.GetDistrType() == 1:
4836 if IsEqual(hyp.GetScaleFactor(), args[1]):
4840 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4841 # @param start defines the length of the first segment
4842 # @param end defines the length of the last segment
4843 # @param reversedEdges is a list of edges to mesh using reversed orientation.
4844 # A list item can also be a tuple (edge 1st_vertex_of_edge)
4845 # @param UseExisting if ==true - searches for an existing hypothesis created with
4846 # the same parameters, else (default) - creates a new one
4847 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4848 # @ingroup l3_hypos_1dhyps
4849 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4850 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4851 reversedEdges, UseExisting = [], reversedEdges
4852 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
4853 entry = self.MainShapeEntry()
4854 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdgeInd, entry],
4855 UseExisting=UseExisting,
4856 CompareMethod=self.CompareArithmetic1D)
4857 hyp.SetStartLength(start)
4858 hyp.SetEndLength(end)
4859 hyp.SetReversedEdges( reversedEdgeInd )
4860 hyp.SetObjectEntry( entry )
4864 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4865 def CompareArithmetic1D(self, hyp, args):
4866 if IsEqual(hyp.GetLength(1), args[0]):
4867 if IsEqual(hyp.GetLength(0), args[1]):
4868 if hyp.GetReversedEdges() == args[2]:
4869 if not args[2] or hyp.GetObjectEntry() == args[3]:
4874 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4875 # on curve from 0 to 1 (additionally it is neecessary to check
4876 # orientation of edges and create list of reversed edges if it is
4877 # needed) and sets numbers of segments between given points (default
4878 # values are equals 1
4879 # @param points defines the list of parameters on curve
4880 # @param nbSegs defines the list of numbers of segments
4881 # @param reversedEdges is a list of edges to mesh using reversed orientation.
4882 # A list item can also be a tuple (edge 1st_vertex_of_edge)
4883 # @param UseExisting if ==true - searches for an existing hypothesis created with
4884 # the same parameters, else (default) - creates a new one
4885 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4886 # @ingroup l3_hypos_1dhyps
4887 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4888 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4889 reversedEdges, UseExisting = [], reversedEdges
4890 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
4891 entry = self.MainShapeEntry()
4892 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdgeInd, entry],
4893 UseExisting=UseExisting,
4894 CompareMethod=self.CompareFixedPoints1D)
4895 hyp.SetPoints(points)
4896 hyp.SetNbSegments(nbSegs)
4897 hyp.SetReversedEdges(reversedEdgeInd)
4898 hyp.SetObjectEntry(entry)
4902 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4903 ## as the given arguments
4904 def CompareFixedPoints1D(self, hyp, args):
4905 if hyp.GetPoints() == args[0]:
4906 if hyp.GetNbSegments() == args[1]:
4907 if hyp.GetReversedEdges() == args[2]:
4908 if not args[2] or hyp.GetObjectEntry() == args[3]:
4914 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4915 # @param start defines the length of the first segment
4916 # @param end defines the length of the last segment
4917 # @param reversedEdges is a list of edges to mesh using reversed orientation.
4918 # A list item can also be a tuple (edge 1st_vertex_of_edge)
4919 # @param UseExisting if ==true - searches for an existing hypothesis created with
4920 # the same parameters, else (default) - creates a new one
4921 # @return an instance of StdMeshers_StartEndLength hypothesis
4922 # @ingroup l3_hypos_1dhyps
4923 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4924 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4925 reversedEdges, UseExisting = [], reversedEdges
4926 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
4927 entry = self.MainShapeEntry()
4928 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdgeInd, entry],
4929 UseExisting=UseExisting,
4930 CompareMethod=self.CompareStartEndLength)
4931 hyp.SetStartLength(start)
4932 hyp.SetEndLength(end)
4933 hyp.SetReversedEdges( reversedEdgeInd )
4934 hyp.SetObjectEntry( entry )
4937 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4938 def CompareStartEndLength(self, hyp, args):
4939 if IsEqual(hyp.GetLength(1), args[0]):
4940 if IsEqual(hyp.GetLength(0), args[1]):
4941 if hyp.GetReversedEdges() == args[2]:
4942 if not args[2] or hyp.GetObjectEntry() == args[3]:
4946 ## Defines "Deflection1D" hypothesis
4947 # @param d for the deflection
4948 # @param UseExisting if ==true - searches for an existing hypothesis created with
4949 # the same parameters, else (default) - create a new one
4950 # @ingroup l3_hypos_1dhyps
4951 def Deflection1D(self, d, UseExisting=0):
4952 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4953 CompareMethod=self.CompareDeflection1D)
4954 hyp.SetDeflection(d)
4957 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4958 def CompareDeflection1D(self, hyp, args):
4959 return IsEqual(hyp.GetDeflection(), args[0])
4961 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4962 # the opposite side in case of quadrangular faces
4963 # @ingroup l3_hypos_additi
4964 def Propagation(self):
4965 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4967 ## Defines "AutomaticLength" hypothesis
4968 # @param fineness for the fineness [0-1]
4969 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4970 # same parameters, else (default) - create a new one
4971 # @ingroup l3_hypos_1dhyps
4972 def AutomaticLength(self, fineness=0, UseExisting=0):
4973 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4974 CompareMethod=self.CompareAutomaticLength)
4975 hyp.SetFineness( fineness )
4978 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4979 def CompareAutomaticLength(self, hyp, args):
4980 return IsEqual(hyp.GetFineness(), args[0])
4982 ## Defines "SegmentLengthAroundVertex" hypothesis
4983 # @param length for the segment length
4984 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4985 # Any other integer value means that the hypothesis will be set on the
4986 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4987 # @param UseExisting if ==true - searches for an existing hypothesis created with
4988 # the same parameters, else (default) - creates a new one
4989 # @ingroup l3_algos_segmarv
4990 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4992 store_geom = self.geom
4993 if type(vertex) is types.IntType:
4994 if vertex == 0 or vertex == 1:
4995 vertex = self.mesh.geompyD.ExtractShapes(self.geom, geompyDC.ShapeType["VERTEX"],True)[vertex]
5003 if self.geom is None:
5004 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
5005 AssureGeomPublished( self.mesh, self.geom )
5006 name = GetName(self.geom)
5008 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
5010 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
5012 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
5013 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
5015 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
5016 CompareMethod=self.CompareLengthNearVertex)
5017 self.geom = store_geom
5018 hyp.SetLength( length )
5021 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
5022 # @ingroup l3_algos_segmarv
5023 def CompareLengthNearVertex(self, hyp, args):
5024 return IsEqual(hyp.GetLength(), args[0])
5026 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
5027 # If the 2D mesher sees that all boundary edges are quadratic,
5028 # it generates quadratic faces, else it generates linear faces using
5029 # medium nodes as if they are vertices.
5030 # The 3D mesher generates quadratic volumes only if all boundary faces
5031 # are quadratic, else it fails.
5033 # @ingroup l3_hypos_additi
5034 def QuadraticMesh(self):
5035 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
5038 # Public class: Mesh_CompositeSegment
5039 # --------------------------
5041 ## Defines a segment 1D algorithm for discretization
5043 # @ingroup l3_algos_basic
5044 class Mesh_CompositeSegment(Mesh_Segment):
5046 ## Private constructor.
5047 def __init__(self, mesh, geom=0):
5048 self.Create(mesh, geom, "CompositeSegment_1D")
5051 # Public class: Mesh_Segment_Python
5052 # ---------------------------------
5054 ## Defines a segment 1D algorithm for discretization with python function
5056 # @ingroup l3_algos_basic
5057 class Mesh_Segment_Python(Mesh_Segment):
5059 ## Private constructor.
5060 def __init__(self, mesh, geom=0):
5061 import Python1dPlugin
5062 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
5064 ## Defines "PythonSplit1D" hypothesis
5065 # @param n for the number of segments that cut an edge
5066 # @param func for the python function that calculates the length of all segments
5067 # @param UseExisting if ==true - searches for the existing hypothesis created with
5068 # the same parameters, else (default) - creates a new one
5069 # @ingroup l3_hypos_1dhyps
5070 def PythonSplit1D(self, n, func, UseExisting=0):
5071 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
5072 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
5073 hyp.SetNumberOfSegments(n)
5074 hyp.SetPythonLog10RatioFunction(func)
5077 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
5078 def ComparePythonSplit1D(self, hyp, args):
5079 #if hyp.GetNumberOfSegments() == args[0]:
5080 # if hyp.GetPythonLog10RatioFunction() == args[1]:
5084 # Public class: Mesh_Triangle
5085 # ---------------------------
5087 ## Defines a triangle 2D algorithm
5089 # @ingroup l3_algos_basic
5090 class Mesh_Triangle(Mesh_Algorithm):
5099 ## Private constructor.
5100 def __init__(self, mesh, algoType, geom=0):
5101 Mesh_Algorithm.__init__(self)
5103 if algoType == MEFISTO:
5104 self.Create(mesh, geom, "MEFISTO_2D")
5106 elif algoType == BLSURF:
5108 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
5109 #self.SetPhysicalMesh() - PAL19680
5110 elif algoType == NETGEN:
5112 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
5114 elif algoType == NETGEN_2D:
5116 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
5119 self.algoType = algoType
5121 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
5122 # @param area for the maximum area of each triangle
5123 # @param UseExisting if ==true - searches for an existing hypothesis created with the
5124 # same parameters, else (default) - creates a new one
5126 # Only for algoType == MEFISTO || NETGEN_2D
5127 # @ingroup l3_hypos_2dhyps
5128 def MaxElementArea(self, area, UseExisting=0):
5129 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
5130 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
5131 CompareMethod=self.CompareMaxElementArea)
5132 elif self.algoType == NETGEN:
5133 hyp = self.Parameters(SIMPLE)
5134 hyp.SetMaxElementArea(area)
5137 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
5138 def CompareMaxElementArea(self, hyp, args):
5139 return IsEqual(hyp.GetMaxElementArea(), args[0])
5141 ## Defines "LengthFromEdges" hypothesis to build triangles
5142 # based on the length of the edges taken from the wire
5144 # Only for algoType == MEFISTO || NETGEN_2D
5145 # @ingroup l3_hypos_2dhyps
5146 def LengthFromEdges(self):
5147 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
5148 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
5150 elif self.algoType == NETGEN:
5151 hyp = self.Parameters(SIMPLE)
5152 hyp.LengthFromEdges()
5155 ## Sets a way to define size of mesh elements to generate.
5156 # @param thePhysicalMesh is: DefaultSize, BLSURF_Custom or SizeMap.
5157 # @ingroup l3_hypos_blsurf
5158 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
5159 if self.Parameters():
5160 # Parameter of BLSURF algo
5161 self.params.SetPhysicalMesh(thePhysicalMesh)
5163 ## Sets size of mesh elements to generate.
5164 # @ingroup l3_hypos_blsurf
5165 def SetPhySize(self, theVal):
5166 if self.Parameters():
5167 # Parameter of BLSURF algo
5168 self.params.SetPhySize(theVal)
5170 ## Sets lower boundary of mesh element size (PhySize).
5171 # @ingroup l3_hypos_blsurf
5172 def SetPhyMin(self, theVal=-1):
5173 if self.Parameters():
5174 # Parameter of BLSURF algo
5175 self.params.SetPhyMin(theVal)
5177 ## Sets upper boundary of mesh element size (PhySize).
5178 # @ingroup l3_hypos_blsurf
5179 def SetPhyMax(self, theVal=-1):
5180 if self.Parameters():
5181 # Parameter of BLSURF algo
5182 self.params.SetPhyMax(theVal)
5184 ## Sets a way to define maximum angular deflection of mesh from CAD model.
5185 # @param theGeometricMesh is: 0 (None) or 1 (Custom)
5186 # @ingroup l3_hypos_blsurf
5187 def SetGeometricMesh(self, theGeometricMesh=0):
5188 if self.Parameters():
5189 # Parameter of BLSURF algo
5190 if self.params.GetPhysicalMesh() == 0: theGeometricMesh = 1
5191 self.params.SetGeometricMesh(theGeometricMesh)
5193 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
5194 # @ingroup l3_hypos_blsurf
5195 def SetAngleMeshS(self, theVal=_angleMeshS):
5196 if self.Parameters():
5197 # Parameter of BLSURF algo
5198 if self.params.GetGeometricMesh() == 0: theVal = self._angleMeshS
5199 self.params.SetAngleMeshS(theVal)
5201 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
5202 # @ingroup l3_hypos_blsurf
5203 def SetAngleMeshC(self, theVal=_angleMeshS):
5204 if self.Parameters():
5205 # Parameter of BLSURF algo
5206 if self.params.GetGeometricMesh() == 0: theVal = self._angleMeshS
5207 self.params.SetAngleMeshC(theVal)
5209 ## Sets lower boundary of mesh element size computed to respect angular deflection.
5210 # @ingroup l3_hypos_blsurf
5211 def SetGeoMin(self, theVal=-1):
5212 if self.Parameters():
5213 # Parameter of BLSURF algo
5214 self.params.SetGeoMin(theVal)
5216 ## Sets upper boundary of mesh element size computed to respect angular deflection.
5217 # @ingroup l3_hypos_blsurf
5218 def SetGeoMax(self, theVal=-1):
5219 if self.Parameters():
5220 # Parameter of BLSURF algo
5221 self.params.SetGeoMax(theVal)
5223 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
5224 # @ingroup l3_hypos_blsurf
5225 def SetGradation(self, theVal=_gradation):
5226 if self.Parameters():
5227 # Parameter of BLSURF algo
5228 if self.params.GetGeometricMesh() == 0: theVal = self._gradation
5229 self.params.SetGradation(theVal)
5231 ## Sets topology usage way.
5232 # @param way defines how mesh conformity is assured <ul>
5233 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
5234 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li>
5235 # <li>PreCAD - by pre-processing with PreCAD a CAD model</li></ul>
5236 # @ingroup l3_hypos_blsurf
5237 def SetTopology(self, way):
5238 if self.Parameters():
5239 # Parameter of BLSURF algo
5240 self.params.SetTopology(way)
5242 ## To respect geometrical edges or not.
5243 # @ingroup l3_hypos_blsurf
5244 def SetDecimesh(self, toIgnoreEdges=False):
5245 if self.Parameters():
5246 # Parameter of BLSURF algo
5247 self.params.SetDecimesh(toIgnoreEdges)
5249 ## Sets verbosity level in the range 0 to 100.
5250 # @ingroup l3_hypos_blsurf
5251 def SetVerbosity(self, level):
5252 if self.Parameters():
5253 # Parameter of BLSURF algo
5254 self.params.SetVerbosity(level)
5256 ## To optimize merges edges.
5257 # @ingroup l3_hypos_blsurf
5258 def SetPreCADMergeEdges(self, toMergeEdges=False):
5259 if self.Parameters():
5260 # Parameter of BLSURF algo
5261 self.params.SetPreCADMergeEdges(toMergeEdges)
5263 ## To remove nano edges.
5264 # @ingroup l3_hypos_blsurf
5265 def SetPreCADRemoveNanoEdges(self, toRemoveNanoEdges=False):
5266 if self.Parameters():
5267 # Parameter of BLSURF algo
5268 self.params.SetPreCADRemoveNanoEdges(toRemoveNanoEdges)
5270 ## To compute topology from scratch
5271 # @ingroup l3_hypos_blsurf
5272 def SetPreCADDiscardInput(self, toDiscardInput=False):
5273 if self.Parameters():
5274 # Parameter of BLSURF algo
5275 self.params.SetPreCADDiscardInput(toDiscardInput)
5277 ## Sets the length below which an edge is considered as nano
5278 # for the topology processing.
5279 # @ingroup l3_hypos_blsurf
5280 def SetPreCADEpsNano(self, epsNano):
5281 if self.Parameters():
5282 # Parameter of BLSURF algo
5283 self.params.SetPreCADEpsNano(epsNano)
5285 ## Sets advanced option value.
5286 # @ingroup l3_hypos_blsurf
5287 def SetOptionValue(self, optionName, level):
5288 if self.Parameters():
5289 # Parameter of BLSURF algo
5290 self.params.SetOptionValue(optionName,level)
5292 ## Sets advanced PreCAD option value.
5293 # Keyword arguments:
5294 # optionName: name of the option
5295 # optionValue: value of the option
5296 # @ingroup l3_hypos_blsurf
5297 def SetPreCADOptionValue(self, optionName, optionValue):
5298 if self.Parameters():
5299 # Parameter of BLSURF algo
5300 self.params.SetPreCADOptionValue(optionName,optionValue)
5302 ## Sets GMF file for export at computation
5303 # @ingroup l3_hypos_blsurf
5304 def SetGMFFile(self, fileName):
5305 if self.Parameters():
5306 # Parameter of BLSURF algo
5307 self.params.SetGMFFile(fileName)
5309 ## Enforced vertices (BLSURF)
5311 ## To get all the enforced vertices
5312 # @ingroup l3_hypos_blsurf
5313 def GetAllEnforcedVertices(self):
5314 if self.Parameters():
5315 # Parameter of BLSURF algo
5316 return self.params.GetAllEnforcedVertices()
5318 ## To get all the enforced vertices sorted by face (or group, compound)
5319 # @ingroup l3_hypos_blsurf
5320 def GetAllEnforcedVerticesByFace(self):
5321 if self.Parameters():
5322 # Parameter of BLSURF algo
5323 return self.params.GetAllEnforcedVerticesByFace()
5325 ## To get all the enforced vertices sorted by coords of input vertices
5326 # @ingroup l3_hypos_blsurf
5327 def GetAllEnforcedVerticesByCoords(self):
5328 if self.Parameters():
5329 # Parameter of BLSURF algo
5330 return self.params.GetAllEnforcedVerticesByCoords()
5332 ## To get all the coords of input vertices sorted by face (or group, compound)
5333 # @ingroup l3_hypos_blsurf
5334 def GetAllCoordsByFace(self):
5335 if self.Parameters():
5336 # Parameter of BLSURF algo
5337 return self.params.GetAllCoordsByFace()
5339 ## To get all the enforced vertices on a face (or group, compound)
5340 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
5341 # @ingroup l3_hypos_blsurf
5342 def GetEnforcedVertices(self, theFace):
5343 if self.Parameters():
5344 # Parameter of BLSURF algo
5345 AssureGeomPublished( self.mesh, theFace )
5346 return self.params.GetEnforcedVertices(theFace)
5348 ## To clear all the enforced vertices
5349 # @ingroup l3_hypos_blsurf
5350 def ClearAllEnforcedVertices(self):
5351 if self.Parameters():
5352 # Parameter of BLSURF algo
5353 return self.params.ClearAllEnforcedVertices()
5355 ## 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.
5356 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
5357 # @param x : x coordinate
5358 # @param y : y coordinate
5359 # @param z : z coordinate
5360 # @param vertexName : name of the enforced vertex
5361 # @param groupName : name of the group
5362 # @ingroup l3_hypos_blsurf
5363 def SetEnforcedVertex(self, theFace, x, y, z, vertexName = "", groupName = ""):
5364 if self.Parameters():
5365 # Parameter of BLSURF algo
5366 AssureGeomPublished( self.mesh, theFace )
5367 if vertexName == "":
5369 return self.params.SetEnforcedVertex(theFace, x, y, z)
5371 return self.params.SetEnforcedVertexWithGroup(theFace, x, y, z, groupName)
5374 return self.params.SetEnforcedVertexNamed(theFace, x, y, z, vertexName)
5376 return self.params.SetEnforcedVertexNamedWithGroup(theFace, x, y, z, vertexName, groupName)
5378 ## To set an enforced vertex on a face (or group, compound) given a GEOM vertex, group or compound.
5379 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
5380 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
5381 # @param groupName : name of the group
5382 # @ingroup l3_hypos_blsurf
5383 def SetEnforcedVertexGeom(self, theFace, theVertex, groupName = ""):
5384 if self.Parameters():
5385 # Parameter of BLSURF algo
5386 AssureGeomPublished( self.mesh, theFace )
5387 AssureGeomPublished( self.mesh, theVertex )
5389 return self.params.SetEnforcedVertexGeom(theFace, theVertex)
5391 return self.params.SetEnforcedVertexGeomWithGroup(theFace, theVertex,groupName)
5393 ## To remove an enforced vertex on a given GEOM face (or group, compound) given the coordinates.
5394 # @param theFace : GEOM face (or group, compound) on which to remove the enforced vertex
5395 # @param x : x coordinate
5396 # @param y : y coordinate
5397 # @param z : z coordinate
5398 # @ingroup l3_hypos_blsurf
5399 def UnsetEnforcedVertex(self, theFace, x, y, z):
5400 if self.Parameters():
5401 # Parameter of BLSURF algo
5402 AssureGeomPublished( self.mesh, theFace )
5403 return self.params.UnsetEnforcedVertex(theFace, x, y, z)
5405 ## To remove an enforced vertex on a given GEOM face (or group, compound) given a GEOM vertex, group or compound.
5406 # @param theFace : GEOM face (or group, compound) on which to remove the enforced vertex
5407 # @param theVertex : GEOM vertex (or group, compound) to remove.
5408 # @ingroup l3_hypos_blsurf
5409 def UnsetEnforcedVertexGeom(self, theFace, theVertex):
5410 if self.Parameters():
5411 # Parameter of BLSURF algo
5412 AssureGeomPublished( self.mesh, theFace )
5413 AssureGeomPublished( self.mesh, theVertex )
5414 return self.params.UnsetEnforcedVertexGeom(theFace, theVertex)
5416 ## To remove all enforced vertices on a given face.
5417 # @param theFace : face (or group/compound of faces) on which to remove all enforced vertices
5418 # @ingroup l3_hypos_blsurf
5419 def UnsetEnforcedVertices(self, theFace):
5420 if self.Parameters():
5421 # Parameter of BLSURF algo
5422 AssureGeomPublished( self.mesh, theFace )
5423 return self.params.UnsetEnforcedVertices(theFace)
5425 ## Attractors (BLSURF)
5427 ## 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 ]
5428 # @param theFace : face on which the attractor will be defined
5429 # @param theAttractor : geometrical object from which the mesh size "h" decreases exponentially
5430 # @param theStartSize : mesh size on theAttractor
5431 # @param theEndSize : maximum size that will be reached on theFace
5432 # @param theInfluenceDistance : influence of the attractor ( the size grow slower on theFace if it's high)
5433 # @param theConstantSizeDistance : distance until which the mesh size will be kept constant on theFace
5434 # @ingroup l3_hypos_blsurf
5435 def SetAttractorGeom(self, theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance):
5436 if self.Parameters():
5437 # Parameter of BLSURF algo
5438 AssureGeomPublished( self.mesh, theFace )
5439 AssureGeomPublished( self.mesh, theAttractor )
5440 self.params.SetAttractorGeom(theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance)
5442 ## Unsets an attractor on the chosen face.
5443 # @param theFace : face on which the attractor has to be removed
5444 # @ingroup l3_hypos_blsurf
5445 def UnsetAttractorGeom(self, theFace):
5446 if self.Parameters():
5447 # Parameter of BLSURF algo
5448 AssureGeomPublished( self.mesh, theFace )
5449 self.params.SetAttractorGeom(theFace)
5451 ## Size maps (BLSURF)
5453 ## To set a size map on a face, edge or vertex (or group, compound) given Python function.
5454 # If theObject is a face, the function can be: def f(u,v): return u+v
5455 # If theObject is an edge, the function can be: def f(t): return t/2
5456 # If theObject is a vertex, the function can be: def f(): return 10
5457 # @param theObject : GEOM face, edge or vertex (or group, compound) on which to define a size map
5458 # @param theSizeMap : Size map defined as a string
5459 # @ingroup l3_hypos_blsurf
5460 def SetSizeMap(self, theObject, theSizeMap):
5461 if self.Parameters():
5462 # Parameter of BLSURF algo
5463 AssureGeomPublished( self.mesh, theObject )
5464 return self.params.SetSizeMap(theObject, theSizeMap)
5466 ## To remove a size map defined on a face, edge or vertex (or group, compound)
5467 # @param theObject : GEOM face, edge or vertex (or group, compound) on which to define a size map
5468 # @ingroup l3_hypos_blsurf
5469 def UnsetSizeMap(self, theObject):
5470 if self.Parameters():
5471 # Parameter of BLSURF algo
5472 AssureGeomPublished( self.mesh, theObject )
5473 return self.params.UnsetSizeMap(theObject)
5475 ## To remove all the size maps
5476 # @ingroup l3_hypos_blsurf
5477 def ClearSizeMaps(self):
5478 if self.Parameters():
5479 # Parameter of BLSURF algo
5480 return self.params.ClearSizeMaps()
5483 ## Sets QuadAllowed flag.
5484 # Only for algoType == NETGEN(NETGEN_1D2D) || NETGEN_2D || BLSURF
5485 # @ingroup l3_hypos_netgen l3_hypos_blsurf
5486 def SetQuadAllowed(self, toAllow=True):
5487 if self.algoType == NETGEN_2D:
5490 hasSimpleHyps = False
5491 simpleHyps = ["QuadranglePreference","LengthFromEdges","MaxElementArea"]
5492 for hyp in self.mesh.GetHypothesisList( self.geom ):
5493 if hyp.GetName() in simpleHyps:
5494 hasSimpleHyps = True
5495 if hyp.GetName() == "QuadranglePreference":
5496 if not toAllow: # remove QuadranglePreference
5497 self.mesh.RemoveHypothesis( self.geom, hyp )
5503 if toAllow: # add QuadranglePreference
5504 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
5509 if self.Parameters():
5510 self.params.SetQuadAllowed(toAllow)
5513 ## Defines hypothesis having several parameters
5515 # @ingroup l3_hypos_netgen
5516 def Parameters(self, which=SOLE):
5518 if self.algoType == NETGEN:
5520 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
5521 "libNETGENEngine.so", UseExisting=0)
5523 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
5524 "libNETGENEngine.so", UseExisting=0)
5525 elif self.algoType == MEFISTO:
5526 print "Mefisto algo support no multi-parameter hypothesis"
5527 elif self.algoType == NETGEN_2D:
5528 self.params = self.Hypothesis("NETGEN_Parameters_2D_ONLY", [],
5529 "libNETGENEngine.so", UseExisting=0)
5530 elif self.algoType == BLSURF:
5531 self.params = self.Hypothesis("BLSURF_Parameters", [],
5532 "libBLSURFEngine.so", UseExisting=0)
5534 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
5539 # Only for algoType == NETGEN
5540 # @ingroup l3_hypos_netgen
5541 def SetMaxSize(self, theSize):
5542 if self.Parameters():
5543 self.params.SetMaxSize(theSize)
5545 ## Sets SecondOrder flag
5547 # Only for algoType == NETGEN
5548 # @ingroup l3_hypos_netgen
5549 def SetSecondOrder(self, theVal):
5550 if self.Parameters():
5551 self.params.SetSecondOrder(theVal)
5553 ## Sets Optimize flag
5555 # Only for algoType == NETGEN
5556 # @ingroup l3_hypos_netgen
5557 def SetOptimize(self, theVal):
5558 if self.Parameters():
5559 self.params.SetOptimize(theVal)
5562 # @param theFineness is:
5563 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5565 # Only for algoType == NETGEN
5566 # @ingroup l3_hypos_netgen
5567 def SetFineness(self, theFineness):
5568 if self.Parameters():
5569 self.params.SetFineness(theFineness)
5573 # Only for algoType == NETGEN
5574 # @ingroup l3_hypos_netgen
5575 def SetGrowthRate(self, theRate):
5576 if self.Parameters():
5577 self.params.SetGrowthRate(theRate)
5579 ## Sets NbSegPerEdge
5581 # Only for algoType == NETGEN
5582 # @ingroup l3_hypos_netgen
5583 def SetNbSegPerEdge(self, theVal):
5584 if self.Parameters():
5585 self.params.SetNbSegPerEdge(theVal)
5587 ## Sets NbSegPerRadius
5589 # Only for algoType == NETGEN
5590 # @ingroup l3_hypos_netgen
5591 def SetNbSegPerRadius(self, theVal):
5592 if self.Parameters():
5593 self.params.SetNbSegPerRadius(theVal)
5595 ## Sets number of segments overriding value set by SetLocalLength()
5597 # Only for algoType == NETGEN
5598 # @ingroup l3_hypos_netgen
5599 def SetNumberOfSegments(self, theVal):
5600 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5602 ## Sets number of segments overriding value set by SetNumberOfSegments()
5604 # Only for algoType == NETGEN
5605 # @ingroup l3_hypos_netgen
5606 def SetLocalLength(self, theVal):
5607 self.Parameters(SIMPLE).SetLocalLength(theVal)
5612 # Public class: Mesh_Quadrangle
5613 # -----------------------------
5615 ## Defines a quadrangle 2D algorithm
5617 # @ingroup l3_algos_basic
5618 class Mesh_Quadrangle(Mesh_Algorithm):
5622 ## Private constructor.
5623 def __init__(self, mesh, geom=0):
5624 Mesh_Algorithm.__init__(self)
5625 self.Create(mesh, geom, "Quadrangle_2D")
5628 ## Defines "QuadrangleParameters" hypothesis
5629 # @param quadType defines the algorithm of transition between differently descretized
5630 # sides of a geometrical face:
5631 # - QUAD_STANDARD - both triangles and quadrangles are possible in the transition
5632 # area along the finer meshed sides.
5633 # - QUAD_TRIANGLE_PREF - only triangles are built in the transition area along the
5634 # finer meshed sides.
5635 # - QUAD_QUADRANGLE_PREF - only quadrangles are built in the transition area along
5636 # the finer meshed sides, iff the total quantity of segments on
5637 # all four sides of the face is even (divisible by 2).
5638 # - QUAD_QUADRANGLE_PREF_REVERSED - same as QUAD_QUADRANGLE_PREF but the transition
5639 # area is located along the coarser meshed sides.
5640 # - QUAD_REDUCED - only quadrangles are built and the transition between the sides
5641 # is made gradually, layer by layer. This type has a limitation on
5642 # the number of segments: one pair of opposite sides must have the
5643 # same number of segments, the other pair must have an even difference
5644 # between the numbers of segments on the sides.
5645 # @param triangleVertex: vertex of a trilateral geometrical face, around which triangles
5646 # will be created while other elements will be quadrangles.
5647 # Vertex can be either a GEOM_Object or a vertex ID within the
5649 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5650 # the same parameters, else (default) - creates a new one
5651 # @ingroup l3_hypos_quad
5652 def QuadrangleParameters(self, quadType=StdMeshers.QUAD_STANDARD, triangleVertex=0, UseExisting=0):
5653 vertexID = triangleVertex
5654 if isinstance( triangleVertex, geompyDC.GEOM._objref_GEOM_Object ):
5655 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, triangleVertex )
5657 compFun = lambda hyp,args: \
5658 hyp.GetQuadType() == args[0] and \
5659 ( hyp.GetTriaVertex()==args[1] or ( hyp.GetTriaVertex()<1 and args[1]<1))
5660 self.params = self.Hypothesis("QuadrangleParams", [quadType,vertexID],
5661 UseExisting = UseExisting, CompareMethod=compFun)
5663 if self.params.GetQuadType() != quadType:
5664 self.params.SetQuadType(quadType)
5666 self.params.SetTriaVertex( vertexID )
5669 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5670 # quadrangles are built in the transition area along the finer meshed sides,
5671 # iff the total quantity of segments on all four sides of the face is even.
5672 # @param reversed if True, transition area is located along the coarser meshed sides.
5673 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5674 # the same parameters, else (default) - creates a new one
5675 # @ingroup l3_hypos_quad
5676 def QuadranglePreference(self, reversed=False, UseExisting=0):
5678 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF_REVERSED,UseExisting=UseExisting)
5679 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF,UseExisting=UseExisting)
5681 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5682 # triangles are built in the transition area along the finer meshed sides.
5683 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5684 # the same parameters, else (default) - creates a new one
5685 # @ingroup l3_hypos_quad
5686 def TrianglePreference(self, UseExisting=0):
5687 return self.QuadrangleParameters(QUAD_TRIANGLE_PREF,UseExisting=UseExisting)
5689 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5690 # quadrangles are built and the transition between the sides is made gradually,
5691 # layer by layer. This type has a limitation on the number of segments: one pair
5692 # of opposite sides must have the same number of segments, the other pair must
5693 # have an even difference between the numbers of segments on the sides.
5694 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5695 # the same parameters, else (default) - creates a new one
5696 # @ingroup l3_hypos_quad
5697 def Reduced(self, UseExisting=0):
5698 return self.QuadrangleParameters(QUAD_REDUCED,UseExisting=UseExisting)
5700 ## Defines "QuadrangleParams" hypothesis with QUAD_STANDARD type of quadrangulation
5701 # @param vertex: vertex of a trilateral geometrical face, around which triangles
5702 # will be created while other elements will be quadrangles.
5703 # Vertex can be either a GEOM_Object or a vertex ID within the
5705 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5706 # the same parameters, else (default) - creates a new one
5707 # @ingroup l3_hypos_quad
5708 def TriangleVertex(self, vertex, UseExisting=0):
5709 return self.QuadrangleParameters(QUAD_STANDARD,vertex,UseExisting)
5712 # Public class: Mesh_Tetrahedron
5713 # ------------------------------
5715 ## Defines a tetrahedron 3D algorithm
5717 # @ingroup l3_algos_basic
5718 class Mesh_Tetrahedron(Mesh_Algorithm):
5723 ## Private constructor.
5724 def __init__(self, mesh, algoType, geom=0):
5725 Mesh_Algorithm.__init__(self)
5727 if algoType == NETGEN:
5729 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
5732 elif algoType == FULL_NETGEN:
5734 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5737 elif algoType == GHS3D:
5739 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
5742 elif algoType == GHS3DPRL:
5743 CheckPlugin(GHS3DPRL)
5744 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
5747 self.algoType = algoType
5749 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
5750 # @param vol for the maximum volume of each tetrahedron
5751 # @param UseExisting if ==true - searches for the existing hypothesis created with
5752 # the same parameters, else (default) - creates a new one
5753 # @ingroup l3_hypos_maxvol
5754 def MaxElementVolume(self, vol, UseExisting=0):
5755 if self.algoType == NETGEN:
5756 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
5757 CompareMethod=self.CompareMaxElementVolume)
5758 hyp.SetMaxElementVolume(vol)
5760 elif self.algoType == FULL_NETGEN:
5761 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
5764 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
5765 def CompareMaxElementVolume(self, hyp, args):
5766 return IsEqual(hyp.GetMaxElementVolume(), args[0])
5768 ## Defines hypothesis having several parameters
5770 # @ingroup l3_hypos_netgen
5771 def Parameters(self, which=SOLE):
5774 if self.algoType == FULL_NETGEN:
5776 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
5777 "libNETGENEngine.so", UseExisting=0)
5779 self.params = self.Hypothesis("NETGEN_Parameters", [],
5780 "libNETGENEngine.so", UseExisting=0)
5782 elif self.algoType == NETGEN:
5783 self.params = self.Hypothesis("NETGEN_Parameters_3D", [],
5784 "libNETGENEngine.so", UseExisting=0)
5786 elif self.algoType == GHS3D:
5787 self.params = self.Hypothesis("GHS3D_Parameters", [],
5788 "libGHS3DEngine.so", UseExisting=0)
5790 elif self.algoType == GHS3DPRL:
5791 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
5792 "libGHS3DPRLEngine.so", UseExisting=0)
5794 print "Warning: %s supports no multi-parameter hypothesis"%self.algo.GetName()
5799 # Parameter of FULL_NETGEN and NETGEN
5800 # @ingroup l3_hypos_netgen
5801 def SetMaxSize(self, theSize):
5802 self.Parameters().SetMaxSize(theSize)
5804 ## Sets SecondOrder flag
5805 # Parameter of FULL_NETGEN
5806 # @ingroup l3_hypos_netgen
5807 def SetSecondOrder(self, theVal):
5808 self.Parameters().SetSecondOrder(theVal)
5810 ## Sets Optimize flag
5811 # Parameter of FULL_NETGEN and NETGEN
5812 # @ingroup l3_hypos_netgen
5813 def SetOptimize(self, theVal):
5814 self.Parameters().SetOptimize(theVal)
5817 # @param theFineness is:
5818 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5819 # Parameter of FULL_NETGEN
5820 # @ingroup l3_hypos_netgen
5821 def SetFineness(self, theFineness):
5822 self.Parameters().SetFineness(theFineness)
5825 # Parameter of FULL_NETGEN
5826 # @ingroup l3_hypos_netgen
5827 def SetGrowthRate(self, theRate):
5828 self.Parameters().SetGrowthRate(theRate)
5830 ## Sets NbSegPerEdge
5831 # Parameter of FULL_NETGEN
5832 # @ingroup l3_hypos_netgen
5833 def SetNbSegPerEdge(self, theVal):
5834 self.Parameters().SetNbSegPerEdge(theVal)
5836 ## Sets NbSegPerRadius
5837 # Parameter of FULL_NETGEN
5838 # @ingroup l3_hypos_netgen
5839 def SetNbSegPerRadius(self, theVal):
5840 self.Parameters().SetNbSegPerRadius(theVal)
5842 ## Sets number of segments overriding value set by SetLocalLength()
5843 # Only for algoType == NETGEN_FULL
5844 # @ingroup l3_hypos_netgen
5845 def SetNumberOfSegments(self, theVal):
5846 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5848 ## Sets number of segments overriding value set by SetNumberOfSegments()
5849 # Only for algoType == NETGEN_FULL
5850 # @ingroup l3_hypos_netgen
5851 def SetLocalLength(self, theVal):
5852 self.Parameters(SIMPLE).SetLocalLength(theVal)
5854 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
5855 # Overrides value set by LengthFromEdges()
5856 # Only for algoType == NETGEN_FULL
5857 # @ingroup l3_hypos_netgen
5858 def MaxElementArea(self, area):
5859 self.Parameters(SIMPLE).SetMaxElementArea(area)
5861 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
5862 # Overrides value set by MaxElementArea()
5863 # Only for algoType == NETGEN_FULL
5864 # @ingroup l3_hypos_netgen
5865 def LengthFromEdges(self):
5866 self.Parameters(SIMPLE).LengthFromEdges()
5868 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
5869 # Overrides value set by MaxElementVolume()
5870 # Only for algoType == NETGEN_FULL
5871 # @ingroup l3_hypos_netgen
5872 def LengthFromFaces(self):
5873 self.Parameters(SIMPLE).LengthFromFaces()
5875 ## To mesh "holes" in a solid or not. Default is to mesh.
5876 # @ingroup l3_hypos_ghs3dh
5877 def SetToMeshHoles(self, toMesh):
5878 # Parameter of GHS3D
5879 if self.Parameters():
5880 self.params.SetToMeshHoles(toMesh)
5882 ## Set Optimization level:
5883 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
5884 # Strong_Optimization.
5885 # Default is Standard_Optimization
5886 # @ingroup l3_hypos_ghs3dh
5887 def SetOptimizationLevel(self, level):
5888 # Parameter of GHS3D
5889 if self.Parameters():
5890 self.params.SetOptimizationLevel(level)
5892 ## Maximal size of memory to be used by the algorithm (in Megabytes).
5893 # @ingroup l3_hypos_ghs3dh
5894 def SetMaximumMemory(self, MB):
5895 # Advanced parameter of GHS3D
5896 if self.Parameters():
5897 self.params.SetMaximumMemory(MB)
5899 ## Initial size of memory to be used by the algorithm (in Megabytes) in
5900 # automatic memory adjustment mode.
5901 # @ingroup l3_hypos_ghs3dh
5902 def SetInitialMemory(self, MB):
5903 # Advanced parameter of GHS3D
5904 if self.Parameters():
5905 self.params.SetInitialMemory(MB)
5907 ## Path to working directory.
5908 # @ingroup l3_hypos_ghs3dh
5909 def SetWorkingDirectory(self, path):
5910 # Advanced parameter of GHS3D
5911 if self.Parameters():
5912 self.params.SetWorkingDirectory(path)
5914 ## To keep working files or remove them. Log file remains in case of errors anyway.
5915 # @ingroup l3_hypos_ghs3dh
5916 def SetKeepFiles(self, toKeep):
5917 # Advanced parameter of GHS3D and GHS3DPRL
5918 if self.Parameters():
5919 self.params.SetKeepFiles(toKeep)
5921 ## To set verbose level [0-10]. <ul>
5922 #<li> 0 - no standard output,
5923 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
5924 # indicates when the final mesh is being saved. In addition the software
5925 # gives indication regarding the CPU time.
5926 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
5927 # histogram of the skin mesh, quality statistics histogram together with
5928 # the characteristics of the final mesh.</ul>
5929 # @ingroup l3_hypos_ghs3dh
5930 def SetVerboseLevel(self, level):
5931 # Advanced parameter of GHS3D
5932 if self.Parameters():
5933 self.params.SetVerboseLevel(level)
5935 ## To create new nodes.
5936 # @ingroup l3_hypos_ghs3dh
5937 def SetToCreateNewNodes(self, toCreate):
5938 # Advanced parameter of GHS3D
5939 if self.Parameters():
5940 self.params.SetToCreateNewNodes(toCreate)
5942 ## To use boundary recovery version which tries to create mesh on a very poor
5943 # quality surface mesh.
5944 # @ingroup l3_hypos_ghs3dh
5945 def SetToUseBoundaryRecoveryVersion(self, toUse):
5946 # Advanced parameter of GHS3D
5947 if self.Parameters():
5948 self.params.SetToUseBoundaryRecoveryVersion(toUse)
5950 ## Applies finite-element correction by replacing overconstrained elements where
5951 # it is possible. The process is cutting first the overconstrained edges and
5952 # second the overconstrained facets. This insure that no edges have two boundary
5953 # vertices and that no facets have three boundary vertices.
5954 # @ingroup l3_hypos_ghs3dh
5955 def SetFEMCorrection(self, toUseFem):
5956 # Advanced parameter of GHS3D
5957 if self.Parameters():
5958 self.params.SetFEMCorrection(toUseFem)
5960 ## To removes initial central point.
5961 # @ingroup l3_hypos_ghs3dh
5962 def SetToRemoveCentralPoint(self, toRemove):
5963 # Advanced parameter of GHS3D
5964 if self.Parameters():
5965 self.params.SetToRemoveCentralPoint(toRemove)
5967 ## To set an enforced vertex.
5968 # @param x : x coordinate
5969 # @param y : y coordinate
5970 # @param z : z coordinate
5971 # @param size : size of 1D element around enforced vertex
5972 # @param vertexName : name of the enforced vertex
5973 # @param groupName : name of the group
5974 # @ingroup l3_hypos_ghs3dh
5975 def SetEnforcedVertex(self, x, y, z, size, vertexName = "", groupName = ""):
5976 # Advanced parameter of GHS3D
5977 if self.Parameters():
5978 if vertexName == "":
5980 return self.params.SetEnforcedVertex(x, y, z, size)
5982 return self.params.SetEnforcedVertexWithGroup(x, y, z, size, groupName)
5985 return self.params.SetEnforcedVertexNamed(x, y, z, size, vertexName)
5987 return self.params.SetEnforcedVertexNamedWithGroup(x, y, z, size, vertexName, groupName)
5989 ## To set an enforced vertex given a GEOM vertex, group or compound.
5990 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
5991 # @param size : size of 1D element around enforced vertex
5992 # @param groupName : name of the group
5993 # @ingroup l3_hypos_ghs3dh
5994 def SetEnforcedVertexGeom(self, theVertex, size, groupName = ""):
5995 AssureGeomPublished( self.mesh, theVertex )
5996 # Advanced parameter of GHS3D
5997 if self.Parameters():
5999 return self.params.SetEnforcedVertexGeom(theVertex, size)
6001 return self.params.SetEnforcedVertexGeomWithGroup(theVertex, size, groupName)
6003 ## To remove an enforced vertex.
6004 # @param x : x coordinate
6005 # @param y : y coordinate
6006 # @param z : z coordinate
6007 # @ingroup l3_hypos_ghs3dh
6008 def RemoveEnforcedVertex(self, x, y, z):
6009 # Advanced parameter of GHS3D
6010 if self.Parameters():
6011 return self.params.RemoveEnforcedVertex(x, y, z)
6013 ## To remove an enforced vertex given a GEOM vertex, group or compound.
6014 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
6015 # @ingroup l3_hypos_ghs3dh
6016 def RemoveEnforcedVertexGeom(self, theVertex):
6017 AssureGeomPublished( self.mesh, theVertex )
6018 # Advanced parameter of GHS3D
6019 if self.Parameters():
6020 return self.params.RemoveEnforcedVertexGeom(theVertex)
6022 ## To set an enforced mesh with given size and add the enforced elements in the group "groupName".
6023 # @param theSource : source mesh which provides constraint elements/nodes
6024 # @param elementType : SMESH.ElementType (NODE, EDGE or FACE)
6025 # @param size : size of elements around enforced elements. Unused if -1.
6026 # @param groupName : group in which enforced elements will be added. Unused if "".
6027 # @ingroup l3_hypos_ghs3dh
6028 def SetEnforcedMesh(self, theSource, elementType, size = -1, groupName = ""):
6029 # Advanced parameter of GHS3D
6030 if self.Parameters():
6033 return self.params.SetEnforcedMesh(theSource, elementType)
6035 return self.params.SetEnforcedMeshWithGroup(theSource, elementType, groupName)
6038 return self.params.SetEnforcedMeshSize(theSource, elementType, size)
6040 return self.params.SetEnforcedMeshSizeWithGroup(theSource, elementType, size, groupName)
6042 ## Sets command line option as text.
6043 # @ingroup l3_hypos_ghs3dh
6044 def SetTextOption(self, option):
6045 # Advanced parameter of GHS3D
6046 if self.Parameters():
6047 self.params.SetTextOption(option)
6049 ## Sets MED files name and path.
6050 def SetMEDName(self, value):
6051 if self.Parameters():
6052 self.params.SetMEDName(value)
6054 ## Sets the number of partition of the initial mesh
6055 def SetNbPart(self, value):
6056 if self.Parameters():
6057 self.params.SetNbPart(value)
6059 ## When big mesh, start tepal in background
6060 def SetBackground(self, value):
6061 if self.Parameters():
6062 self.params.SetBackground(value)
6064 # Public class: Mesh_Hexahedron
6065 # ------------------------------
6067 ## Defines a hexahedron 3D algorithm
6069 # @ingroup l3_algos_basic
6070 class Mesh_Hexahedron(Mesh_Algorithm):
6075 ## Private constructor.
6076 def __init__(self, mesh, algoType=Hexa, geom=0):
6077 Mesh_Algorithm.__init__(self)
6079 self.algoType = algoType
6081 if algoType == Hexa:
6082 self.Create(mesh, geom, "Hexa_3D")
6085 elif algoType == Hexotic:
6086 CheckPlugin(Hexotic)
6087 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
6090 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
6091 # @ingroup l3_hypos_hexotic
6092 def MinMaxQuad(self, min=3, max=8, quad=True):
6093 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
6095 self.params.SetHexesMinLevel(min)
6096 self.params.SetHexesMaxLevel(max)
6097 self.params.SetHexoticQuadrangles(quad)
6100 # Deprecated, only for compatibility!
6101 # Public class: Mesh_Netgen
6102 # ------------------------------
6104 ## Defines a NETGEN-based 2D or 3D algorithm
6105 # that needs no discrete boundary (i.e. independent)
6107 # This class is deprecated, only for compatibility!
6110 # @ingroup l3_algos_basic
6111 class Mesh_Netgen(Mesh_Algorithm):
6115 ## Private constructor.
6116 def __init__(self, mesh, is3D, geom=0):
6117 Mesh_Algorithm.__init__(self)
6123 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
6127 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
6130 ## Defines the hypothesis containing parameters of the algorithm
6131 def Parameters(self):
6133 hyp = self.Hypothesis("NETGEN_Parameters", [],
6134 "libNETGENEngine.so", UseExisting=0)
6136 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
6137 "libNETGENEngine.so", UseExisting=0)
6140 # Public class: Mesh_Projection1D
6141 # ------------------------------
6143 ## Defines a projection 1D algorithm
6144 # @ingroup l3_algos_proj
6146 class Mesh_Projection1D(Mesh_Algorithm):
6148 ## Private constructor.
6149 def __init__(self, mesh, geom=0):
6150 Mesh_Algorithm.__init__(self)
6151 self.Create(mesh, geom, "Projection_1D")
6153 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
6154 # a mesh pattern is taken, and, optionally, the association of vertices
6155 # between the source edge and a target edge (to which a hypothesis is assigned)
6156 # @param edge from which nodes distribution is taken
6157 # @param mesh from which nodes distribution is taken (optional)
6158 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
6159 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
6160 # to associate with \a srcV (optional)
6161 # @param UseExisting if ==true - searches for the existing hypothesis created with
6162 # the same parameters, else (default) - creates a new one
6163 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
6164 AssureGeomPublished( self.mesh, edge )
6165 AssureGeomPublished( self.mesh, srcV )
6166 AssureGeomPublished( self.mesh, tgtV )
6167 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
6169 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
6170 hyp.SetSourceEdge( edge )
6171 if not mesh is None and isinstance(mesh, Mesh):
6172 mesh = mesh.GetMesh()
6173 hyp.SetSourceMesh( mesh )
6174 hyp.SetVertexAssociation( srcV, tgtV )
6177 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
6178 #def CompareSourceEdge(self, hyp, args):
6179 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
6183 # Public class: Mesh_Projection2D
6184 # ------------------------------
6186 ## Defines a projection 2D algorithm
6187 # @ingroup l3_algos_proj
6189 class Mesh_Projection2D(Mesh_Algorithm):
6191 ## Private constructor.
6192 def __init__(self, mesh, geom=0, algoName="Projection_2D"):
6193 Mesh_Algorithm.__init__(self)
6194 self.Create(mesh, geom, algoName)
6196 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
6197 # a mesh pattern is taken, and, optionally, the association of vertices
6198 # between the source face and the target face (to which a hypothesis is assigned)
6199 # @param face from which the mesh pattern is taken
6200 # @param mesh from which the mesh pattern is taken (optional)
6201 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
6202 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
6203 # to associate with \a srcV1 (optional)
6204 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
6205 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
6206 # to associate with \a srcV2 (optional)
6207 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
6208 # the same parameters, else (default) - forces the creation a new one
6210 # Note: all association vertices must belong to one edge of a face
6211 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
6212 srcV2=None, tgtV2=None, UseExisting=0):
6213 for geom in [ face, srcV1, tgtV1, srcV2, tgtV2 ]:
6214 AssureGeomPublished( self.mesh, geom )
6215 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
6217 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
6218 hyp.SetSourceFace( face )
6219 if isinstance(mesh, Mesh):
6220 mesh = mesh.GetMesh()
6221 hyp.SetSourceMesh( mesh )
6222 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
6225 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
6226 #def CompareSourceFace(self, hyp, args):
6227 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
6230 # Public class: Mesh_Projection3D
6231 # ------------------------------
6233 ## Defines a projection 3D algorithm
6234 # @ingroup l3_algos_proj
6236 class Mesh_Projection3D(Mesh_Algorithm):
6238 ## Private constructor.
6239 def __init__(self, mesh, geom=0):
6240 Mesh_Algorithm.__init__(self)
6241 self.Create(mesh, geom, "Projection_3D")
6243 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
6244 # the mesh pattern is taken, and, optionally, the association of vertices
6245 # between the source and the target solid (to which a hipothesis is assigned)
6246 # @param solid from where the mesh pattern is taken
6247 # @param mesh from where the mesh pattern is taken (optional)
6248 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
6249 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
6250 # to associate with \a srcV1 (optional)
6251 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
6252 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
6253 # to associate with \a srcV2 (optional)
6254 # @param UseExisting - if ==true - searches for the existing hypothesis created with
6255 # the same parameters, else (default) - creates a new one
6257 # Note: association vertices must belong to one edge of a solid
6258 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
6259 srcV2=0, tgtV2=0, UseExisting=0):
6260 for geom in [ solid, srcV1, tgtV1, srcV2, tgtV2 ]:
6261 AssureGeomPublished( self.mesh, geom )
6262 hyp = self.Hypothesis("ProjectionSource3D",
6263 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
6265 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
6266 hyp.SetSource3DShape( solid )
6267 if not mesh is None and isinstance(mesh, Mesh):
6268 mesh = mesh.GetMesh()
6269 hyp.SetSourceMesh( mesh )
6270 if srcV1 and srcV2 and tgtV1 and tgtV2:
6271 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
6272 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
6275 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
6276 #def CompareSourceShape3D(self, hyp, args):
6277 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
6281 # Public class: Mesh_Prism
6282 # ------------------------
6284 ## Defines a 3D extrusion algorithm
6285 # @ingroup l3_algos_3dextr
6287 class Mesh_Prism3D(Mesh_Algorithm):
6289 ## Private constructor.
6290 def __init__(self, mesh, geom=0):
6291 Mesh_Algorithm.__init__(self)
6292 self.Create(mesh, geom, "Prism_3D")
6294 # Public class: Mesh_RadialPrism
6295 # -------------------------------
6297 ## Defines a Radial Prism 3D algorithm
6298 # @ingroup l3_algos_radialp
6300 class Mesh_RadialPrism3D(Mesh_Algorithm):
6302 ## Private constructor.
6303 def __init__(self, mesh, geom=0):
6304 Mesh_Algorithm.__init__(self)
6305 self.Create(mesh, geom, "RadialPrism_3D")
6307 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
6308 self.nbLayers = None
6310 ## Return 3D hypothesis holding the 1D one
6311 def Get3DHypothesis(self):
6312 return self.distribHyp
6314 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
6315 # hypothesis. Returns the created hypothesis
6316 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
6317 #print "OwnHypothesis",hypType
6318 if not self.nbLayers is None:
6319 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
6320 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
6321 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
6322 self.mesh.smeshpyD.SetCurrentStudy( None )
6323 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
6324 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
6325 self.distribHyp.SetLayerDistribution( hyp )
6328 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
6329 # prisms to build between the inner and outer shells
6330 # @param n number of layers
6331 # @param UseExisting if ==true - searches for the existing hypothesis created with
6332 # the same parameters, else (default) - creates a new one
6333 def NumberOfLayers(self, n, UseExisting=0):
6334 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
6335 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
6336 CompareMethod=self.CompareNumberOfLayers)
6337 self.nbLayers.SetNumberOfLayers( n )
6338 return self.nbLayers
6340 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
6341 def CompareNumberOfLayers(self, hyp, args):
6342 return IsEqual(hyp.GetNumberOfLayers(), args[0])
6344 ## Defines "LocalLength" hypothesis, specifying the segment length
6345 # to build between the inner and the outer shells
6346 # @param l the length of segments
6347 # @param p the precision of rounding
6348 def LocalLength(self, l, p=1e-07):
6349 hyp = self.OwnHypothesis("LocalLength", [l,p])
6354 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
6355 # prisms to build between the inner and the outer shells.
6356 # @param n the number of layers
6357 # @param s the scale factor (optional)
6358 def NumberOfSegments(self, n, s=[]):
6360 hyp = self.OwnHypothesis("NumberOfSegments", [n])
6362 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
6363 hyp.SetDistrType( 1 )
6364 hyp.SetScaleFactor(s)
6365 hyp.SetNumberOfSegments(n)
6368 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
6369 # to build between the inner and the outer shells with a length that changes in arithmetic progression
6370 # @param start the length of the first segment
6371 # @param end the length of the last segment
6372 def Arithmetic1D(self, start, end ):
6373 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
6374 hyp.SetLength(start, 1)
6375 hyp.SetLength(end , 0)
6378 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
6379 # to build between the inner and the outer shells as geometric length increasing
6380 # @param start for the length of the first segment
6381 # @param end for the length of the last segment
6382 def StartEndLength(self, start, end):
6383 hyp = self.OwnHypothesis("StartEndLength", [start, end])
6384 hyp.SetLength(start, 1)
6385 hyp.SetLength(end , 0)
6388 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
6389 # to build between the inner and outer shells
6390 # @param fineness defines the quality of the mesh within the range [0-1]
6391 def AutomaticLength(self, fineness=0):
6392 hyp = self.OwnHypothesis("AutomaticLength")
6393 hyp.SetFineness( fineness )
6396 # Public class: Mesh_RadialQuadrangle1D2D
6397 # -------------------------------
6399 ## Defines a Radial Quadrangle 1D2D algorithm
6400 # @ingroup l2_algos_radialq
6402 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
6404 ## Private constructor.
6405 def __init__(self, mesh, geom=0):
6406 Mesh_Algorithm.__init__(self)
6407 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
6409 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
6410 self.nbLayers = None
6412 ## Return 2D hypothesis holding the 1D one
6413 def Get2DHypothesis(self):
6414 return self.distribHyp
6416 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
6417 # hypothesis. Returns the created hypothesis
6418 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
6419 #print "OwnHypothesis",hypType
6421 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
6422 if self.distribHyp is None:
6423 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
6425 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
6426 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
6427 self.mesh.smeshpyD.SetCurrentStudy( None )
6428 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
6429 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
6430 self.distribHyp.SetLayerDistribution( hyp )
6433 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
6434 # @param n number of layers
6435 # @param UseExisting if ==true - searches for the existing hypothesis created with
6436 # the same parameters, else (default) - creates a new one
6437 def NumberOfLayers(self, n, UseExisting=0):
6439 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
6440 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
6441 CompareMethod=self.CompareNumberOfLayers)
6442 self.nbLayers.SetNumberOfLayers( n )
6443 return self.nbLayers
6445 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
6446 def CompareNumberOfLayers(self, hyp, args):
6447 return IsEqual(hyp.GetNumberOfLayers(), args[0])
6449 ## Defines "LocalLength" hypothesis, specifying the segment length
6450 # @param l the length of segments
6451 # @param p the precision of rounding
6452 def LocalLength(self, l, p=1e-07):
6453 hyp = self.OwnHypothesis("LocalLength", [l,p])
6458 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
6459 # @param n the number of layers
6460 # @param s the scale factor (optional)
6461 def NumberOfSegments(self, n, s=[]):
6463 hyp = self.OwnHypothesis("NumberOfSegments", [n])
6465 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
6466 hyp.SetDistrType( 1 )
6467 hyp.SetScaleFactor(s)
6468 hyp.SetNumberOfSegments(n)
6471 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
6472 # with a length that changes in arithmetic progression
6473 # @param start the length of the first segment
6474 # @param end the length of the last segment
6475 def Arithmetic1D(self, start, end ):
6476 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
6477 hyp.SetLength(start, 1)
6478 hyp.SetLength(end , 0)
6481 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
6482 # as geometric length increasing
6483 # @param start for the length of the first segment
6484 # @param end for the length of the last segment
6485 def StartEndLength(self, start, end):
6486 hyp = self.OwnHypothesis("StartEndLength", [start, end])
6487 hyp.SetLength(start, 1)
6488 hyp.SetLength(end , 0)
6491 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
6492 # @param fineness defines the quality of the mesh within the range [0-1]
6493 def AutomaticLength(self, fineness=0):
6494 hyp = self.OwnHypothesis("AutomaticLength")
6495 hyp.SetFineness( fineness )
6499 # Public class: Mesh_UseExistingElements
6500 # --------------------------------------
6501 ## Defines a Radial Quadrangle 1D2D algorithm
6502 # @ingroup l3_algos_basic
6504 class Mesh_UseExistingElements(Mesh_Algorithm):
6506 def __init__(self, dim, mesh, geom=0):
6508 self.Create(mesh, geom, "Import_1D")
6510 self.Create(mesh, geom, "Import_1D2D")
6513 ## Defines "Source edges" hypothesis, specifying groups of edges to import
6514 # @param groups list of groups of edges
6515 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
6516 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
6517 # @param UseExisting if ==true - searches for the existing hypothesis created with
6518 # the same parameters, else (default) - creates a new one
6519 def SourceEdges(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
6520 if self.algo.GetName() != "Import_1D":
6521 raise ValueError, "algoritm dimension mismatch"
6522 for group in groups:
6523 AssureGeomPublished( self.mesh, group )
6524 hyp = self.Hypothesis("ImportSource1D", [groups, toCopyMesh, toCopyGroups],
6525 UseExisting=UseExisting, CompareMethod=self._compareHyp)
6526 hyp.SetSourceEdges(groups)
6527 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
6530 ## Defines "Source faces" hypothesis, specifying groups of faces to import
6531 # @param groups list of groups of faces
6532 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
6533 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
6534 # @param UseExisting if ==true - searches for the existing hypothesis created with
6535 # the same parameters, else (default) - creates a new one
6536 def SourceFaces(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
6537 if self.algo.GetName() == "Import_1D":
6538 raise ValueError, "algoritm dimension mismatch"
6539 for group in groups:
6540 AssureGeomPublished( self.mesh, group )
6541 hyp = self.Hypothesis("ImportSource2D", [groups, toCopyMesh, toCopyGroups],
6542 UseExisting=UseExisting, CompareMethod=self._compareHyp)
6543 hyp.SetSourceFaces(groups)
6544 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
6547 def _compareHyp(self,hyp,args):
6548 if hasattr( hyp, "GetSourceEdges"):
6549 entries = hyp.GetSourceEdges()
6551 entries = hyp.GetSourceFaces()
6553 toCopyMesh,toCopyGroups = hyp.GetCopySourceMesh()
6554 if len(entries)==len(groups) and toCopyMesh==args[1] and toCopyGroups==args[2]:
6556 study = self.mesh.smeshpyD.GetCurrentStudy()
6559 ior = salome.orb.object_to_string(g)
6560 sobj = study.FindObjectIOR(ior)
6561 if sobj: entries2.append( sobj.GetID() )
6566 return entries == entries2
6569 # Public class: Mesh_Cartesian_3D
6570 # --------------------------------------
6571 ## Defines a Body Fitting 3D algorithm
6572 # @ingroup l3_algos_basic
6574 class Mesh_Cartesian_3D(Mesh_Algorithm):
6576 def __init__(self, mesh, geom=0):
6577 self.Create(mesh, geom, "Cartesian_3D")
6581 ## Defines "Body Fitting parameters" hypothesis
6582 # @param xGridDef is definition of the grid along the X asix.
6583 # It can be in either of two following forms:
6584 # - Explicit coordinates of nodes, e.g. [-1.5, 0.0, 3.1] or range( -100,200,10)
6585 # - Functions f(t) defining grid spacing at each point on grid axis. If there are
6586 # several functions, they must be accompanied by relative coordinates of
6587 # points dividing the whole shape into ranges where the functions apply; points
6588 # coodrinates should vary within (0.0, 1.0) range. Parameter \a t of the spacing
6589 # function f(t) varies from 0.0 to 1.0 witin a shape range.
6591 # - "10.5" - defines a grid with a constant spacing
6592 # - [["1", "1+10*t", "11"] [0.1, 0.6]] - defines different spacing in 3 ranges.
6593 # @param yGridDef defines the grid along the Y asix the same way as \a xGridDef does
6594 # @param zGridDef defines the grid along the Z asix the same way as \a xGridDef does
6595 # @param sizeThreshold (> 1.0) defines a minimal size of a polyhedron so that
6596 # a polyhedron of size less than hexSize/sizeThreshold is not created
6597 # @param UseExisting if ==true - searches for the existing hypothesis created with
6598 # the same parameters, else (default) - creates a new one
6599 def SetGrid(self, xGridDef, yGridDef, zGridDef, sizeThreshold=4.0, UseExisting=False):
6601 self.hyp = self.Hypothesis("CartesianParameters3D",
6602 [xGridDef, yGridDef, zGridDef, sizeThreshold],
6603 UseExisting=UseExisting, CompareMethod=self._compareHyp)
6604 if not self.mesh.IsUsedHypothesis( self.hyp, self.geom ):
6605 self.mesh.AddHypothesis( self.hyp, self.geom )
6607 for axis, gridDef in enumerate( [xGridDef, yGridDef, zGridDef]):
6608 if not gridDef: raise ValueError, "Empty grid definition"
6609 if isinstance( gridDef, str ):
6610 self.hyp.SetGridSpacing( [gridDef], [], axis )
6611 elif isinstance( gridDef[0], str ):
6612 self.hyp.SetGridSpacing( gridDef, [], axis )
6613 elif isinstance( gridDef[0], int ) or \
6614 isinstance( gridDef[0], float ):
6615 self.hyp.SetGrid(gridDef, axis )
6617 self.hyp.SetGridSpacing( gridDef[0], gridDef[1], axis )
6618 self.hyp.SetSizeThreshold( sizeThreshold )
6621 def _compareHyp(self,hyp,args):
6622 # not implemented yet
6625 # Public class: Mesh_UseExisting
6626 # -------------------------------
6627 class Mesh_UseExisting(Mesh_Algorithm):
6629 def __init__(self, dim, mesh, geom=0):
6631 self.Create(mesh, geom, "UseExisting_1D")
6633 self.Create(mesh, geom, "UseExisting_2D")
6636 import salome_notebook
6637 notebook = salome_notebook.notebook
6639 ##Return values of the notebook variables
6640 def ParseParameters(last, nbParams,nbParam, value):
6644 listSize = len(last)
6645 for n in range(0,nbParams):
6647 if counter < listSize:
6648 strResult = strResult + last[counter]
6650 strResult = strResult + ""
6652 if isinstance(value, str):
6653 if notebook.isVariable(value):
6654 result = notebook.get(value)
6655 strResult=strResult+value
6657 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
6659 strResult=strResult+str(value)
6661 if nbParams - 1 != counter:
6662 strResult=strResult+var_separator #":"
6664 return result, strResult
6666 #Wrapper class for StdMeshers_LocalLength hypothesis
6667 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
6669 ## Set Length parameter value
6670 # @param length numerical value or name of variable from notebook
6671 def SetLength(self, length):
6672 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
6673 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6674 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
6676 ## Set Precision parameter value
6677 # @param precision numerical value or name of variable from notebook
6678 def SetPrecision(self, precision):
6679 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
6680 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6681 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
6683 #Registering the new proxy for LocalLength
6684 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
6687 #Wrapper class for StdMeshers_LayerDistribution hypothesis
6688 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
6690 def SetLayerDistribution(self, hypo):
6691 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
6692 hypo.ClearParameters();
6693 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
6695 #Registering the new proxy for LayerDistribution
6696 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
6698 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
6699 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
6701 ## Set Length parameter value
6702 # @param length numerical value or name of variable from notebook
6703 def SetLength(self, length):
6704 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
6705 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
6706 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
6708 #Registering the new proxy for SegmentLengthAroundVertex
6709 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
6712 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
6713 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
6715 ## Set Length parameter value
6716 # @param length numerical value or name of variable from notebook
6717 # @param isStart true is length is Start Length, otherwise false
6718 def SetLength(self, length, isStart):
6722 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
6723 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
6724 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
6726 #Registering the new proxy for Arithmetic1D
6727 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
6729 #Wrapper class for StdMeshers_Deflection1D hypothesis
6730 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
6732 ## Set Deflection parameter value
6733 # @param deflection numerical value or name of variable from notebook
6734 def SetDeflection(self, deflection):
6735 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
6736 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
6737 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
6739 #Registering the new proxy for Deflection1D
6740 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
6742 #Wrapper class for StdMeshers_StartEndLength hypothesis
6743 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
6745 ## Set Length parameter value
6746 # @param length numerical value or name of variable from notebook
6747 # @param isStart true is length is Start Length, otherwise false
6748 def SetLength(self, length, isStart):
6752 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
6753 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
6754 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
6756 #Registering the new proxy for StartEndLength
6757 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
6759 #Wrapper class for StdMeshers_MaxElementArea hypothesis
6760 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
6762 ## Set Max Element Area parameter value
6763 # @param area numerical value or name of variable from notebook
6764 def SetMaxElementArea(self, area):
6765 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
6766 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
6767 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
6769 #Registering the new proxy for MaxElementArea
6770 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
6773 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
6774 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
6776 ## Set Max Element Volume parameter value
6777 # @param volume numerical value or name of variable from notebook
6778 def SetMaxElementVolume(self, volume):
6779 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
6780 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
6781 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
6783 #Registering the new proxy for MaxElementVolume
6784 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
6787 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
6788 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
6790 ## Set Number Of Layers parameter value
6791 # @param nbLayers numerical value or name of variable from notebook
6792 def SetNumberOfLayers(self, nbLayers):
6793 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
6794 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
6795 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
6797 #Registering the new proxy for NumberOfLayers
6798 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
6800 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
6801 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
6803 ## Set Number Of Segments parameter value
6804 # @param nbSeg numerical value or name of variable from notebook
6805 def SetNumberOfSegments(self, nbSeg):
6806 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
6807 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
6808 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6809 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
6811 ## Set Scale Factor parameter value
6812 # @param factor numerical value or name of variable from notebook
6813 def SetScaleFactor(self, factor):
6814 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
6815 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6816 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
6818 #Registering the new proxy for NumberOfSegments
6819 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
6821 if not noNETGENPlugin:
6822 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
6823 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
6825 ## Set Max Size parameter value
6826 # @param maxsize numerical value or name of variable from notebook
6827 def SetMaxSize(self, maxsize):
6828 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6829 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
6830 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6831 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
6833 ## Set Growth Rate parameter value
6834 # @param value numerical value or name of variable from notebook
6835 def SetGrowthRate(self, value):
6836 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6837 value, parameters = ParseParameters(lastParameters,4,2,value)
6838 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6839 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
6841 ## Set Number of Segments per Edge parameter value
6842 # @param value numerical value or name of variable from notebook
6843 def SetNbSegPerEdge(self, value):
6844 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6845 value, parameters = ParseParameters(lastParameters,4,3,value)
6846 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6847 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
6849 ## Set Number of Segments per Radius parameter value
6850 # @param value numerical value or name of variable from notebook
6851 def SetNbSegPerRadius(self, value):
6852 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6853 value, parameters = ParseParameters(lastParameters,4,4,value)
6854 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6855 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
6857 #Registering the new proxy for NETGENPlugin_Hypothesis
6858 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
6861 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
6862 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
6865 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
6866 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
6868 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
6869 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
6871 ## Set Number of Segments parameter value
6872 # @param nbSeg numerical value or name of variable from notebook
6873 def SetNumberOfSegments(self, nbSeg):
6874 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6875 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
6876 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6877 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
6879 ## Set Local Length parameter value
6880 # @param length numerical value or name of variable from notebook
6881 def SetLocalLength(self, length):
6882 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6883 length, parameters = ParseParameters(lastParameters,2,1,length)
6884 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6885 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
6887 ## Set Max Element Area parameter value
6888 # @param area numerical value or name of variable from notebook
6889 def SetMaxElementArea(self, area):
6890 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6891 area, parameters = ParseParameters(lastParameters,2,2,area)
6892 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6893 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
6895 def LengthFromEdges(self):
6896 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6898 value, parameters = ParseParameters(lastParameters,2,2,value)
6899 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6900 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
6902 #Registering the new proxy for NETGEN_SimpleParameters_2D
6903 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
6906 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
6907 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
6908 ## Set Max Element Volume parameter value
6909 # @param volume numerical value or name of variable from notebook
6910 def SetMaxElementVolume(self, volume):
6911 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6912 volume, parameters = ParseParameters(lastParameters,3,3,volume)
6913 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6914 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
6916 def LengthFromFaces(self):
6917 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6919 value, parameters = ParseParameters(lastParameters,3,3,value)
6920 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6921 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
6923 #Registering the new proxy for NETGEN_SimpleParameters_3D
6924 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
6926 pass # if not noNETGENPlugin:
6928 class Pattern(SMESH._objref_SMESH_Pattern):
6930 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
6932 if isinstance(theNodeIndexOnKeyPoint1,str):
6934 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
6936 theNodeIndexOnKeyPoint1 -= 1
6937 theMesh.SetParameters(Parameters)
6938 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
6940 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
6943 if isinstance(theNode000Index,str):
6945 if isinstance(theNode001Index,str):
6947 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
6949 theNode000Index -= 1
6951 theNode001Index -= 1
6952 theMesh.SetParameters(Parameters)
6953 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
6955 #Registering the new proxy for Pattern
6956 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)