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 # @param IsNodes is True if elements with given ids are nodes
3494 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3495 # @ingroup l2_modif_extrurev
3496 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False, IsNodes = False):
3497 if IDsOfElements == []:
3498 IDsOfElements = self.GetElementsId()
3499 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3500 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3501 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3502 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3503 Parameters = StepVectorParameters + var_separator + Parameters
3504 self.mesh.SetParameters(Parameters)
3507 return self.editor.ExtrusionSweepMakeGroups0D(IDsOfElements, StepVector, NbOfSteps)
3509 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
3511 self.editor.ExtrusionSweep0D(IDsOfElements, StepVector, NbOfSteps)
3513 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
3516 ## Generates new elements by extrusion of the elements with given ids
3517 # @param IDsOfElements is ids of elements
3518 # @param StepVector vector, defining the direction and value of extrusion
3519 # @param NbOfSteps the number of steps
3520 # @param ExtrFlags sets flags for extrusion
3521 # @param SewTolerance uses for comparing locations of nodes if flag
3522 # EXTRUSION_FLAG_SEW is set
3523 # @param MakeGroups forces the generation of new groups from existing ones
3524 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3525 # @ingroup l2_modif_extrurev
3526 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
3527 ExtrFlags, SewTolerance, MakeGroups=False):
3528 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3529 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3531 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
3532 ExtrFlags, SewTolerance)
3533 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
3534 ExtrFlags, SewTolerance)
3537 ## Generates new elements by extrusion of the elements which belong to the object
3538 # @param theObject the object which elements should be processed.
3539 # It can be a mesh, a sub mesh or a group.
3540 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3541 # @param NbOfSteps the number of steps
3542 # @param MakeGroups forces the generation of new groups from existing ones
3543 # @param IsNodes is True if elements which belong to the object are nodes
3544 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3545 # @ingroup l2_modif_extrurev
3546 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False, IsNodes=False):
3547 if ( isinstance( theObject, Mesh )):
3548 theObject = theObject.GetMesh()
3549 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3550 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3551 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3552 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3553 Parameters = StepVectorParameters + var_separator + Parameters
3554 self.mesh.SetParameters(Parameters)
3557 return self.editor.ExtrusionSweepObject0DMakeGroups(theObject, StepVector, NbOfSteps)
3559 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3561 self.editor.ExtrusionSweepObject0D(theObject, StepVector, NbOfSteps)
3563 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
3566 ## Generates new elements by extrusion of the elements which belong to the object
3567 # @param theObject object which elements should be processed.
3568 # It can be a mesh, a sub mesh or a group.
3569 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3570 # @param NbOfSteps the number of steps
3571 # @param MakeGroups to generate new groups from existing ones
3572 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3573 # @ingroup l2_modif_extrurev
3574 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3575 if ( isinstance( theObject, Mesh )):
3576 theObject = theObject.GetMesh()
3577 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3578 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3579 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3580 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3581 Parameters = StepVectorParameters + var_separator + Parameters
3582 self.mesh.SetParameters(Parameters)
3584 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3585 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3588 ## Generates new elements by extrusion of the elements which belong to the object
3589 # @param theObject object which elements should be processed.
3590 # It can be a mesh, a sub mesh or a group.
3591 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3592 # @param NbOfSteps the number of steps
3593 # @param MakeGroups forces the generation of new groups from existing ones
3594 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3595 # @ingroup l2_modif_extrurev
3596 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3597 if ( isinstance( theObject, Mesh )):
3598 theObject = theObject.GetMesh()
3599 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3600 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3601 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3602 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3603 Parameters = StepVectorParameters + var_separator + Parameters
3604 self.mesh.SetParameters(Parameters)
3606 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3607 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3612 ## Generates new elements by extrusion of the given elements
3613 # The path of extrusion must be a meshed edge.
3614 # @param Base mesh or group, or submesh, or list of ids of elements for extrusion
3615 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3616 # @param NodeStart the start node from Path. Defines the direction of extrusion
3617 # @param HasAngles allows the shape to be rotated around the path
3618 # to get the resulting mesh in a helical fashion
3619 # @param Angles list of angles in radians
3620 # @param LinearVariation forces the computation of rotation angles as linear
3621 # variation of the given Angles along path steps
3622 # @param HasRefPoint allows using the reference point
3623 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3624 # The User can specify any point as the Reference Point.
3625 # @param MakeGroups forces the generation of new groups from existing ones
3626 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3627 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3628 # only SMESH::Extrusion_Error otherwise
3629 # @ingroup l2_modif_extrurev
3630 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3631 HasAngles, Angles, LinearVariation,
3632 HasRefPoint, RefPoint, MakeGroups, ElemType):
3633 Angles,AnglesParameters = ParseAngles(Angles)
3634 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3635 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3636 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3638 Parameters = AnglesParameters + var_separator + RefPointParameters
3639 self.mesh.SetParameters(Parameters)
3641 if (isinstance(Path, Mesh)): Path = Path.GetMesh()
3643 if isinstance(Base, list):
3645 if Base == []: IDsOfElements = self.GetElementsId()
3646 else: IDsOfElements = Base
3647 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3648 HasAngles, Angles, LinearVariation,
3649 HasRefPoint, RefPoint, MakeGroups, ElemType)
3651 if isinstance(Base, Mesh): Base = Base.GetMesh()
3652 if isinstance(Base, SMESH._objref_SMESH_Mesh) or isinstance(Base, SMESH._objref_SMESH_Group) or isinstance(Base, SMESH._objref_SMESH_subMesh):
3653 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3654 HasAngles, Angles, LinearVariation,
3655 HasRefPoint, RefPoint, MakeGroups, ElemType)
3657 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3660 ## Generates new elements by extrusion of the given elements
3661 # The path of extrusion must be a meshed edge.
3662 # @param IDsOfElements ids of elements
3663 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3664 # @param PathShape shape(edge) defines the sub-mesh for the path
3665 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3666 # @param HasAngles allows the shape to be rotated around the path
3667 # to get the resulting mesh in a helical fashion
3668 # @param Angles list of angles in radians
3669 # @param HasRefPoint allows using the reference point
3670 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3671 # The User can specify any point as the Reference Point.
3672 # @param MakeGroups forces the generation of new groups from existing ones
3673 # @param LinearVariation forces the computation of rotation angles as linear
3674 # variation of the given Angles along path steps
3675 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3676 # only SMESH::Extrusion_Error otherwise
3677 # @ingroup l2_modif_extrurev
3678 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3679 HasAngles, Angles, HasRefPoint, RefPoint,
3680 MakeGroups=False, LinearVariation=False):
3681 Angles,AnglesParameters = ParseAngles(Angles)
3682 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3683 if IDsOfElements == []:
3684 IDsOfElements = self.GetElementsId()
3685 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3686 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3688 if ( isinstance( PathMesh, Mesh )):
3689 PathMesh = PathMesh.GetMesh()
3690 if HasAngles and Angles and LinearVariation:
3691 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3693 Parameters = AnglesParameters + var_separator + RefPointParameters
3694 self.mesh.SetParameters(Parameters)
3696 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3697 PathShape, NodeStart, HasAngles,
3698 Angles, HasRefPoint, RefPoint)
3699 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3700 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3702 ## Generates new elements by extrusion of the elements which belong to the object
3703 # The path of extrusion must be a meshed edge.
3704 # @param theObject the object which elements should be processed.
3705 # It can be a mesh, a sub mesh or a group.
3706 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3707 # @param PathShape shape(edge) defines the sub-mesh for the path
3708 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3709 # @param HasAngles allows the shape to be rotated around the path
3710 # to get the resulting mesh in a helical fashion
3711 # @param Angles list of angles
3712 # @param HasRefPoint allows using the reference point
3713 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3714 # The User can specify any point as the Reference Point.
3715 # @param MakeGroups forces the generation of new groups from existing ones
3716 # @param LinearVariation forces the computation of rotation angles as linear
3717 # variation of the given Angles along path steps
3718 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3719 # only SMESH::Extrusion_Error otherwise
3720 # @ingroup l2_modif_extrurev
3721 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3722 HasAngles, Angles, HasRefPoint, RefPoint,
3723 MakeGroups=False, LinearVariation=False):
3724 Angles,AnglesParameters = ParseAngles(Angles)
3725 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3726 if ( isinstance( theObject, Mesh )):
3727 theObject = theObject.GetMesh()
3728 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3729 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3730 if ( isinstance( PathMesh, Mesh )):
3731 PathMesh = PathMesh.GetMesh()
3732 if HasAngles and Angles and LinearVariation:
3733 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3735 Parameters = AnglesParameters + var_separator + RefPointParameters
3736 self.mesh.SetParameters(Parameters)
3738 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3739 PathShape, NodeStart, HasAngles,
3740 Angles, HasRefPoint, RefPoint)
3741 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3742 NodeStart, HasAngles, Angles, HasRefPoint,
3745 ## Generates new elements by extrusion of the elements which belong to the object
3746 # The path of extrusion must be a meshed edge.
3747 # @param theObject the object which elements should be processed.
3748 # It can be a mesh, a sub mesh or a group.
3749 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3750 # @param PathShape shape(edge) defines the sub-mesh for the path
3751 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3752 # @param HasAngles allows the shape to be rotated around the path
3753 # to get the resulting mesh in a helical fashion
3754 # @param Angles list of angles
3755 # @param HasRefPoint allows using the reference point
3756 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3757 # The User can specify any point as the Reference Point.
3758 # @param MakeGroups forces the generation of new groups from existing ones
3759 # @param LinearVariation forces the computation of rotation angles as linear
3760 # variation of the given Angles along path steps
3761 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3762 # only SMESH::Extrusion_Error otherwise
3763 # @ingroup l2_modif_extrurev
3764 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3765 HasAngles, Angles, HasRefPoint, RefPoint,
3766 MakeGroups=False, LinearVariation=False):
3767 Angles,AnglesParameters = ParseAngles(Angles)
3768 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3769 if ( isinstance( theObject, Mesh )):
3770 theObject = theObject.GetMesh()
3771 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3772 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3773 if ( isinstance( PathMesh, Mesh )):
3774 PathMesh = PathMesh.GetMesh()
3775 if HasAngles and Angles and LinearVariation:
3776 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3778 Parameters = AnglesParameters + var_separator + RefPointParameters
3779 self.mesh.SetParameters(Parameters)
3781 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3782 PathShape, NodeStart, HasAngles,
3783 Angles, HasRefPoint, RefPoint)
3784 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3785 NodeStart, HasAngles, Angles, HasRefPoint,
3788 ## Generates new elements by extrusion of the elements which belong to the object
3789 # The path of extrusion must be a meshed edge.
3790 # @param theObject the object which elements should be processed.
3791 # It can be a mesh, a sub mesh or a group.
3792 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3793 # @param PathShape shape(edge) defines the sub-mesh for the path
3794 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3795 # @param HasAngles allows the shape to be rotated around the path
3796 # to get the resulting mesh in a helical fashion
3797 # @param Angles list of angles
3798 # @param HasRefPoint allows using the reference point
3799 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3800 # The User can specify any point as the Reference Point.
3801 # @param MakeGroups forces the generation of new groups from existing ones
3802 # @param LinearVariation forces the computation of rotation angles as linear
3803 # variation of the given Angles along path steps
3804 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3805 # only SMESH::Extrusion_Error otherwise
3806 # @ingroup l2_modif_extrurev
3807 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3808 HasAngles, Angles, HasRefPoint, RefPoint,
3809 MakeGroups=False, LinearVariation=False):
3810 Angles,AnglesParameters = ParseAngles(Angles)
3811 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3812 if ( isinstance( theObject, Mesh )):
3813 theObject = theObject.GetMesh()
3814 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3815 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3816 if ( isinstance( PathMesh, Mesh )):
3817 PathMesh = PathMesh.GetMesh()
3818 if HasAngles and Angles and LinearVariation:
3819 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3821 Parameters = AnglesParameters + var_separator + RefPointParameters
3822 self.mesh.SetParameters(Parameters)
3824 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3825 PathShape, NodeStart, HasAngles,
3826 Angles, HasRefPoint, RefPoint)
3827 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3828 NodeStart, HasAngles, Angles, HasRefPoint,
3831 ## Creates a symmetrical copy of mesh elements
3832 # @param IDsOfElements list of elements ids
3833 # @param Mirror is AxisStruct or geom object(point, line, plane)
3834 # @param theMirrorType is POINT, AXIS or PLANE
3835 # If the Mirror is a geom object this parameter is unnecessary
3836 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3837 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3838 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3839 # @ingroup l2_modif_trsf
3840 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3841 if IDsOfElements == []:
3842 IDsOfElements = self.GetElementsId()
3843 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3844 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3845 Mirror,Parameters = ParseAxisStruct(Mirror)
3846 self.mesh.SetParameters(Parameters)
3847 if Copy and MakeGroups:
3848 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3849 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3852 ## Creates a new mesh by a symmetrical copy of mesh elements
3853 # @param IDsOfElements the list of elements ids
3854 # @param Mirror is AxisStruct or geom object (point, line, plane)
3855 # @param theMirrorType is POINT, AXIS or PLANE
3856 # If the Mirror is a geom object this parameter is unnecessary
3857 # @param MakeGroups to generate new groups from existing ones
3858 # @param NewMeshName a name of the new mesh to create
3859 # @return instance of Mesh class
3860 # @ingroup l2_modif_trsf
3861 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3862 if IDsOfElements == []:
3863 IDsOfElements = self.GetElementsId()
3864 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3865 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3866 Mirror,Parameters = ParseAxisStruct(Mirror)
3867 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3868 MakeGroups, NewMeshName)
3869 mesh.SetParameters(Parameters)
3870 return Mesh(self.smeshpyD,self.geompyD,mesh)
3872 ## Creates a symmetrical copy of the object
3873 # @param theObject mesh, submesh or group
3874 # @param Mirror AxisStruct or geom object (point, line, plane)
3875 # @param theMirrorType is POINT, AXIS or PLANE
3876 # If the Mirror is a geom object this parameter is unnecessary
3877 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3878 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3879 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3880 # @ingroup l2_modif_trsf
3881 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3882 if ( isinstance( theObject, Mesh )):
3883 theObject = theObject.GetMesh()
3884 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3885 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3886 Mirror,Parameters = ParseAxisStruct(Mirror)
3887 self.mesh.SetParameters(Parameters)
3888 if Copy and MakeGroups:
3889 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3890 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3893 ## Creates a new mesh by a symmetrical copy of the object
3894 # @param theObject mesh, submesh or group
3895 # @param Mirror AxisStruct or geom object (point, line, plane)
3896 # @param theMirrorType POINT, AXIS or PLANE
3897 # If the Mirror is a geom object this parameter is unnecessary
3898 # @param MakeGroups forces the generation of new groups from existing ones
3899 # @param NewMeshName the name of the new mesh to create
3900 # @return instance of Mesh class
3901 # @ingroup l2_modif_trsf
3902 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3903 if ( isinstance( theObject, Mesh )):
3904 theObject = theObject.GetMesh()
3905 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3906 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3907 Mirror,Parameters = ParseAxisStruct(Mirror)
3908 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3909 MakeGroups, NewMeshName)
3910 mesh.SetParameters(Parameters)
3911 return Mesh( self.smeshpyD,self.geompyD,mesh )
3913 ## Translates the elements
3914 # @param IDsOfElements list of elements ids
3915 # @param Vector the direction of translation (DirStruct or vector)
3916 # @param Copy allows copying the translated elements
3917 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3918 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3919 # @ingroup l2_modif_trsf
3920 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3921 if IDsOfElements == []:
3922 IDsOfElements = self.GetElementsId()
3923 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3924 Vector = self.smeshpyD.GetDirStruct(Vector)
3925 Vector,Parameters = ParseDirStruct(Vector)
3926 self.mesh.SetParameters(Parameters)
3927 if Copy and MakeGroups:
3928 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3929 self.editor.Translate(IDsOfElements, Vector, Copy)
3932 ## Creates a new mesh of translated elements
3933 # @param IDsOfElements list of elements ids
3934 # @param Vector the direction of translation (DirStruct or vector)
3935 # @param MakeGroups forces the generation of new groups from existing ones
3936 # @param NewMeshName the name of the newly created mesh
3937 # @return instance of Mesh class
3938 # @ingroup l2_modif_trsf
3939 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3940 if IDsOfElements == []:
3941 IDsOfElements = self.GetElementsId()
3942 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3943 Vector = self.smeshpyD.GetDirStruct(Vector)
3944 Vector,Parameters = ParseDirStruct(Vector)
3945 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3946 mesh.SetParameters(Parameters)
3947 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3949 ## Translates the object
3950 # @param theObject the object to translate (mesh, submesh, or group)
3951 # @param Vector direction of translation (DirStruct or geom vector)
3952 # @param Copy allows copying the translated elements
3953 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3954 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3955 # @ingroup l2_modif_trsf
3956 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3957 if ( isinstance( theObject, Mesh )):
3958 theObject = theObject.GetMesh()
3959 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3960 Vector = self.smeshpyD.GetDirStruct(Vector)
3961 Vector,Parameters = ParseDirStruct(Vector)
3962 self.mesh.SetParameters(Parameters)
3963 if Copy and MakeGroups:
3964 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3965 self.editor.TranslateObject(theObject, Vector, Copy)
3968 ## Creates a new mesh from the translated object
3969 # @param theObject the object to translate (mesh, submesh, or group)
3970 # @param Vector the direction of translation (DirStruct or geom vector)
3971 # @param MakeGroups forces the generation of new groups from existing ones
3972 # @param NewMeshName the name of the newly created mesh
3973 # @return instance of Mesh class
3974 # @ingroup l2_modif_trsf
3975 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3976 if (isinstance(theObject, Mesh)):
3977 theObject = theObject.GetMesh()
3978 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3979 Vector = self.smeshpyD.GetDirStruct(Vector)
3980 Vector,Parameters = ParseDirStruct(Vector)
3981 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3982 mesh.SetParameters(Parameters)
3983 return Mesh( self.smeshpyD, self.geompyD, mesh )
3987 ## Scales the object
3988 # @param theObject - the object to translate (mesh, submesh, or group)
3989 # @param thePoint - base point for scale
3990 # @param theScaleFact - list of 1-3 scale factors for axises
3991 # @param Copy - allows copying the translated elements
3992 # @param MakeGroups - forces the generation of new groups from existing
3994 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3995 # empty list otherwise
3996 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3997 if ( isinstance( theObject, Mesh )):
3998 theObject = theObject.GetMesh()
3999 if ( isinstance( theObject, list )):
4000 theObject = self.GetIDSource(theObject, SMESH.ALL)
4002 thePoint, Parameters = ParsePointStruct(thePoint)
4003 self.mesh.SetParameters(Parameters)
4005 if Copy and MakeGroups:
4006 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
4007 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
4010 ## Creates a new mesh from the translated object
4011 # @param theObject - the object to translate (mesh, submesh, or group)
4012 # @param thePoint - base point for scale
4013 # @param theScaleFact - list of 1-3 scale factors for axises
4014 # @param MakeGroups - forces the generation of new groups from existing ones
4015 # @param NewMeshName - the name of the newly created mesh
4016 # @return instance of Mesh class
4017 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
4018 if (isinstance(theObject, Mesh)):
4019 theObject = theObject.GetMesh()
4020 if ( isinstance( theObject, list )):
4021 theObject = self.GetIDSource(theObject,SMESH.ALL)
4023 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
4024 MakeGroups, NewMeshName)
4025 #mesh.SetParameters(Parameters)
4026 return Mesh( self.smeshpyD, self.geompyD, mesh )
4030 ## Rotates the elements
4031 # @param IDsOfElements list of elements ids
4032 # @param Axis the axis of rotation (AxisStruct or geom line)
4033 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
4034 # @param Copy allows copying the rotated elements
4035 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
4036 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
4037 # @ingroup l2_modif_trsf
4038 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
4040 if isinstance(AngleInRadians,str):
4042 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
4044 AngleInRadians = DegreesToRadians(AngleInRadians)
4045 if IDsOfElements == []:
4046 IDsOfElements = self.GetElementsId()
4047 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
4048 Axis = self.smeshpyD.GetAxisStruct(Axis)
4049 Axis,AxisParameters = ParseAxisStruct(Axis)
4050 Parameters = AxisParameters + var_separator + Parameters
4051 self.mesh.SetParameters(Parameters)
4052 if Copy and MakeGroups:
4053 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
4054 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
4057 ## Creates a new mesh of rotated elements
4058 # @param IDsOfElements list of element ids
4059 # @param Axis the axis of rotation (AxisStruct or geom line)
4060 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
4061 # @param MakeGroups forces the generation of new groups from existing ones
4062 # @param NewMeshName the name of the newly created mesh
4063 # @return instance of Mesh class
4064 # @ingroup l2_modif_trsf
4065 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
4067 if isinstance(AngleInRadians,str):
4069 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
4071 AngleInRadians = DegreesToRadians(AngleInRadians)
4072 if IDsOfElements == []:
4073 IDsOfElements = self.GetElementsId()
4074 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
4075 Axis = self.smeshpyD.GetAxisStruct(Axis)
4076 Axis,AxisParameters = ParseAxisStruct(Axis)
4077 Parameters = AxisParameters + var_separator + Parameters
4078 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
4079 MakeGroups, NewMeshName)
4080 mesh.SetParameters(Parameters)
4081 return Mesh( self.smeshpyD, self.geompyD, mesh )
4083 ## Rotates the object
4084 # @param theObject the object to rotate( mesh, submesh, or group)
4085 # @param Axis the axis of rotation (AxisStruct or geom line)
4086 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
4087 # @param Copy allows copying the rotated elements
4088 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
4089 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
4090 # @ingroup l2_modif_trsf
4091 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
4093 if isinstance(AngleInRadians,str):
4095 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
4097 AngleInRadians = DegreesToRadians(AngleInRadians)
4098 if (isinstance(theObject, Mesh)):
4099 theObject = theObject.GetMesh()
4100 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
4101 Axis = self.smeshpyD.GetAxisStruct(Axis)
4102 Axis,AxisParameters = ParseAxisStruct(Axis)
4103 Parameters = AxisParameters + ":" + Parameters
4104 self.mesh.SetParameters(Parameters)
4105 if Copy and MakeGroups:
4106 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
4107 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
4110 ## Creates a new mesh from the rotated object
4111 # @param theObject the object to rotate (mesh, submesh, or group)
4112 # @param Axis the axis of rotation (AxisStruct or geom line)
4113 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
4114 # @param MakeGroups forces the generation of new groups from existing ones
4115 # @param NewMeshName the name of the newly created mesh
4116 # @return instance of Mesh class
4117 # @ingroup l2_modif_trsf
4118 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
4120 if isinstance(AngleInRadians,str):
4122 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
4124 AngleInRadians = DegreesToRadians(AngleInRadians)
4125 if (isinstance( theObject, Mesh )):
4126 theObject = theObject.GetMesh()
4127 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
4128 Axis = self.smeshpyD.GetAxisStruct(Axis)
4129 Axis,AxisParameters = ParseAxisStruct(Axis)
4130 Parameters = AxisParameters + ":" + Parameters
4131 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
4132 MakeGroups, NewMeshName)
4133 mesh.SetParameters(Parameters)
4134 return Mesh( self.smeshpyD, self.geompyD, mesh )
4136 ## Finds groups of ajacent nodes within Tolerance.
4137 # @param Tolerance the value of tolerance
4138 # @return the list of groups of nodes
4139 # @ingroup l2_modif_trsf
4140 def FindCoincidentNodes (self, Tolerance):
4141 return self.editor.FindCoincidentNodes(Tolerance)
4143 ## Finds groups of ajacent nodes within Tolerance.
4144 # @param Tolerance the value of tolerance
4145 # @param SubMeshOrGroup SubMesh or Group
4146 # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
4147 # @return the list of groups of nodes
4148 # @ingroup l2_modif_trsf
4149 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
4150 if (isinstance( SubMeshOrGroup, Mesh )):
4151 SubMeshOrGroup = SubMeshOrGroup.GetMesh()
4152 if not isinstance( exceptNodes, list):
4153 exceptNodes = [ exceptNodes ]
4154 if exceptNodes and isinstance( exceptNodes[0], int):
4155 exceptNodes = [ self.GetIDSource( exceptNodes, SMESH.NODE)]
4156 return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes)
4159 # @param GroupsOfNodes the list of groups of nodes
4160 # @ingroup l2_modif_trsf
4161 def MergeNodes (self, GroupsOfNodes):
4162 self.editor.MergeNodes(GroupsOfNodes)
4164 ## Finds the elements built on the same nodes.
4165 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
4166 # @return a list of groups of equal elements
4167 # @ingroup l2_modif_trsf
4168 def FindEqualElements (self, MeshOrSubMeshOrGroup):
4169 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
4170 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
4171 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
4173 ## Merges elements in each given group.
4174 # @param GroupsOfElementsID groups of elements for merging
4175 # @ingroup l2_modif_trsf
4176 def MergeElements(self, GroupsOfElementsID):
4177 self.editor.MergeElements(GroupsOfElementsID)
4179 ## Leaves one element and removes all other elements built on the same nodes.
4180 # @ingroup l2_modif_trsf
4181 def MergeEqualElements(self):
4182 self.editor.MergeEqualElements()
4184 ## Sews free borders
4185 # @return SMESH::Sew_Error
4186 # @ingroup l2_modif_trsf
4187 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
4188 FirstNodeID2, SecondNodeID2, LastNodeID2,
4189 CreatePolygons, CreatePolyedrs):
4190 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
4191 FirstNodeID2, SecondNodeID2, LastNodeID2,
4192 CreatePolygons, CreatePolyedrs)
4194 ## Sews conform free borders
4195 # @return SMESH::Sew_Error
4196 # @ingroup l2_modif_trsf
4197 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
4198 FirstNodeID2, SecondNodeID2):
4199 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
4200 FirstNodeID2, SecondNodeID2)
4202 ## Sews border to side
4203 # @return SMESH::Sew_Error
4204 # @ingroup l2_modif_trsf
4205 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
4206 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
4207 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
4208 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
4210 ## Sews two sides of a mesh. The nodes belonging to Side1 are
4211 # merged with the nodes of elements of Side2.
4212 # The number of elements in theSide1 and in theSide2 must be
4213 # equal and they should have similar nodal connectivity.
4214 # The nodes to merge should belong to side borders and
4215 # the first node should be linked to the second.
4216 # @return SMESH::Sew_Error
4217 # @ingroup l2_modif_trsf
4218 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
4219 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
4220 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
4221 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
4222 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
4223 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
4225 ## Sets new nodes for the given element.
4226 # @param ide the element id
4227 # @param newIDs nodes ids
4228 # @return If the number of nodes does not correspond to the type of element - returns false
4229 # @ingroup l2_modif_edit
4230 def ChangeElemNodes(self, ide, newIDs):
4231 return self.editor.ChangeElemNodes(ide, newIDs)
4233 ## If during the last operation of MeshEditor some nodes were
4234 # created, this method returns the list of their IDs, \n
4235 # if new nodes were not created - returns empty list
4236 # @return the list of integer values (can be empty)
4237 # @ingroup l1_auxiliary
4238 def GetLastCreatedNodes(self):
4239 return self.editor.GetLastCreatedNodes()
4241 ## If during the last operation of MeshEditor some elements were
4242 # created this method returns the list of their IDs, \n
4243 # if new elements were not created - returns empty list
4244 # @return the list of integer values (can be empty)
4245 # @ingroup l1_auxiliary
4246 def GetLastCreatedElems(self):
4247 return self.editor.GetLastCreatedElems()
4249 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4250 # @param theNodes identifiers of nodes to be doubled
4251 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
4252 # nodes. If list of element identifiers is empty then nodes are doubled but
4253 # they not assigned to elements
4254 # @return TRUE if operation has been completed successfully, FALSE otherwise
4255 # @ingroup l2_modif_edit
4256 def DoubleNodes(self, theNodes, theModifiedElems):
4257 return self.editor.DoubleNodes(theNodes, theModifiedElems)
4259 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4260 # This method provided for convenience works as DoubleNodes() described above.
4261 # @param theNodeId identifiers of node to be doubled
4262 # @param theModifiedElems identifiers of elements to be updated
4263 # @return TRUE if operation has been completed successfully, FALSE otherwise
4264 # @ingroup l2_modif_edit
4265 def DoubleNode(self, theNodeId, theModifiedElems):
4266 return self.editor.DoubleNode(theNodeId, theModifiedElems)
4268 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4269 # This method provided for convenience works as DoubleNodes() described above.
4270 # @param theNodes group of nodes to be doubled
4271 # @param theModifiedElems group of elements to be updated.
4272 # @param theMakeGroup forces the generation of a group containing new nodes.
4273 # @return TRUE or a created group if operation has been completed successfully,
4274 # FALSE or None otherwise
4275 # @ingroup l2_modif_edit
4276 def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
4278 return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
4279 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
4281 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4282 # This method provided for convenience works as DoubleNodes() described above.
4283 # @param theNodes list of groups of nodes to be doubled
4284 # @param theModifiedElems list of groups of elements to be updated.
4285 # @param theMakeGroup forces the generation of a group containing new nodes.
4286 # @return TRUE if operation has been completed successfully, FALSE otherwise
4287 # @ingroup l2_modif_edit
4288 def DoubleNodeGroups(self, theNodes, theModifiedElems, theMakeGroup=False):
4290 return self.editor.DoubleNodeGroupsNew(theNodes, theModifiedElems)
4291 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
4293 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4294 # @param theElems - the list of elements (edges or faces) to be replicated
4295 # The nodes for duplication could be found from these elements
4296 # @param theNodesNot - list of nodes to NOT replicate
4297 # @param theAffectedElems - the list of elements (cells and edges) to which the
4298 # replicated nodes should be associated to.
4299 # @return TRUE if operation has been completed successfully, FALSE otherwise
4300 # @ingroup l2_modif_edit
4301 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
4302 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
4304 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4305 # @param theElems - the list of elements (edges or faces) to be replicated
4306 # The nodes for duplication could be found from these elements
4307 # @param theNodesNot - list of nodes to NOT replicate
4308 # @param theShape - shape to detect affected elements (element which geometric center
4309 # located on or inside shape).
4310 # The replicated nodes should be associated to affected elements.
4311 # @return TRUE if operation has been completed successfully, FALSE otherwise
4312 # @ingroup l2_modif_edit
4313 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
4314 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
4316 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4317 # This method provided for convenience works as DoubleNodes() described above.
4318 # @param theElems - group of of elements (edges or faces) to be replicated
4319 # @param theNodesNot - group of nodes not to replicated
4320 # @param theAffectedElems - group of elements to which the replicated nodes
4321 # should be associated to.
4322 # @param theMakeGroup forces the generation of a group containing new elements.
4323 # @return TRUE or a created group if operation has been completed successfully,
4324 # FALSE or None otherwise
4325 # @ingroup l2_modif_edit
4326 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4328 return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
4329 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
4331 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4332 # This method provided for convenience works as DoubleNodes() described above.
4333 # @param theElems - group of of elements (edges or faces) to be replicated
4334 # @param theNodesNot - group of nodes not to replicated
4335 # @param theShape - shape to detect affected elements (element which geometric center
4336 # located on or inside shape).
4337 # The replicated nodes should be associated to affected elements.
4338 # @ingroup l2_modif_edit
4339 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
4340 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
4342 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4343 # This method provided for convenience works as DoubleNodes() described above.
4344 # @param theElems - list of groups of elements (edges or faces) to be replicated
4345 # @param theNodesNot - list of groups of nodes not to replicated
4346 # @param theAffectedElems - group of elements to which the replicated nodes
4347 # should be associated to.
4348 # @param theMakeGroup forces the generation of a group containing new elements.
4349 # @return TRUE or a created group if operation has been completed successfully,
4350 # FALSE or None otherwise
4351 # @ingroup l2_modif_edit
4352 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4354 return self.editor.DoubleNodeElemGroupsNew(theElems, theNodesNot, theAffectedElems)
4355 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
4357 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4358 # This method provided for convenience works as DoubleNodes() described above.
4359 # @param theElems - list of groups of elements (edges or faces) to be replicated
4360 # @param theNodesNot - list of groups of nodes not to replicated
4361 # @param theShape - shape to detect affected elements (element which geometric center
4362 # located on or inside shape).
4363 # The replicated nodes should be associated to affected elements.
4364 # @return TRUE if operation has been completed successfully, FALSE otherwise
4365 # @ingroup l2_modif_edit
4366 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
4367 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
4369 ## Double nodes on shared faces between groups of volumes and create flat elements on demand.
4370 # The list of groups must describe a partition of the mesh volumes.
4371 # The nodes of the internal faces at the boundaries of the groups are doubled.
4372 # In option, the internal faces are replaced by flat elements.
4373 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4374 # @param theDomains - list of groups of volumes
4375 # @param createJointElems - if TRUE, create the elements
4376 # @return TRUE if operation has been completed successfully, FALSE otherwise
4377 def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems ):
4378 return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems )
4380 ## Double nodes on some external faces and create flat elements.
4381 # Flat elements are mainly used by some types of mechanic calculations.
4383 # Each group of the list must be constituted of faces.
4384 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4385 # @param theGroupsOfFaces - list of groups of faces
4386 # @return TRUE if operation has been completed successfully, FALSE otherwise
4387 def CreateFlatElementsOnFacesGroups(self, theGroupsOfFaces ):
4388 return self.editor.CreateFlatElementsOnFacesGroups( theGroupsOfFaces )
4390 def _valueFromFunctor(self, funcType, elemId):
4391 fn = self.smeshpyD.GetFunctor(funcType)
4392 fn.SetMesh(self.mesh)
4393 if fn.GetElementType() == self.GetElementType(elemId, True):
4394 val = fn.GetValue(elemId)
4399 ## Get length of 1D element.
4400 # @param elemId mesh element ID
4401 # @return element's length value
4402 # @ingroup l1_measurements
4403 def GetLength(self, elemId):
4404 return self._valueFromFunctor(SMESH.FT_Length, elemId)
4406 ## Get area of 2D element.
4407 # @param elemId mesh element ID
4408 # @return element's area value
4409 # @ingroup l1_measurements
4410 def GetArea(self, elemId):
4411 return self._valueFromFunctor(SMESH.FT_Area, elemId)
4413 ## Get volume of 3D element.
4414 # @param elemId mesh element ID
4415 # @return element's volume value
4416 # @ingroup l1_measurements
4417 def GetVolume(self, elemId):
4418 return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
4420 ## Get maximum element length.
4421 # @param elemId mesh element ID
4422 # @return element's maximum length value
4423 # @ingroup l1_measurements
4424 def GetMaxElementLength(self, elemId):
4425 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4426 ftype = SMESH.FT_MaxElementLength3D
4428 ftype = SMESH.FT_MaxElementLength2D
4429 return self._valueFromFunctor(ftype, elemId)
4431 ## Get aspect ratio of 2D or 3D element.
4432 # @param elemId mesh element ID
4433 # @return element's aspect ratio value
4434 # @ingroup l1_measurements
4435 def GetAspectRatio(self, elemId):
4436 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4437 ftype = SMESH.FT_AspectRatio3D
4439 ftype = SMESH.FT_AspectRatio
4440 return self._valueFromFunctor(ftype, elemId)
4442 ## Get warping angle of 2D element.
4443 # @param elemId mesh element ID
4444 # @return element's warping angle value
4445 # @ingroup l1_measurements
4446 def GetWarping(self, elemId):
4447 return self._valueFromFunctor(SMESH.FT_Warping, elemId)
4449 ## Get minimum angle of 2D element.
4450 # @param elemId mesh element ID
4451 # @return element's minimum angle value
4452 # @ingroup l1_measurements
4453 def GetMinimumAngle(self, elemId):
4454 return self._valueFromFunctor(SMESH.FT_MinimumAngle, elemId)
4456 ## Get taper of 2D element.
4457 # @param elemId mesh element ID
4458 # @return element's taper value
4459 # @ingroup l1_measurements
4460 def GetTaper(self, elemId):
4461 return self._valueFromFunctor(SMESH.FT_Taper, elemId)
4463 ## Get skew of 2D element.
4464 # @param elemId mesh element ID
4465 # @return element's skew value
4466 # @ingroup l1_measurements
4467 def GetSkew(self, elemId):
4468 return self._valueFromFunctor(SMESH.FT_Skew, elemId)
4470 ## The mother class to define algorithm, it is not recommended to use it directly.
4473 # @ingroup l2_algorithms
4474 class Mesh_Algorithm:
4475 # @class Mesh_Algorithm
4476 # @brief Class Mesh_Algorithm
4478 #def __init__(self,smesh):
4486 ## Finds a hypothesis in the study by its type name and parameters.
4487 # Finds only the hypotheses created in smeshpyD engine.
4488 # @return SMESH.SMESH_Hypothesis
4489 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
4490 study = smeshpyD.GetCurrentStudy()
4491 #to do: find component by smeshpyD object, not by its data type
4492 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4493 if scomp is not None:
4494 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
4495 # Check if the root label of the hypotheses exists
4496 if res and hypRoot is not None:
4497 iter = study.NewChildIterator(hypRoot)
4498 # Check all published hypotheses
4500 hypo_so_i = iter.Value()
4501 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
4502 if attr is not None:
4503 anIOR = attr.Value()
4504 hypo_o_i = salome.orb.string_to_object(anIOR)
4505 if hypo_o_i is not None:
4506 # Check if this is a hypothesis
4507 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
4508 if hypo_i is not None:
4509 # Check if the hypothesis belongs to current engine
4510 if smeshpyD.GetObjectId(hypo_i) > 0:
4511 # Check if this is the required hypothesis
4512 if hypo_i.GetName() == hypname:
4514 if CompareMethod(hypo_i, args):
4528 ## Finds the algorithm in the study by its type name.
4529 # Finds only the algorithms, which have been created in smeshpyD engine.
4530 # @return SMESH.SMESH_Algo
4531 def FindAlgorithm (self, algoname, smeshpyD):
4532 study = smeshpyD.GetCurrentStudy()
4533 #to do: find component by smeshpyD object, not by its data type
4534 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4535 if scomp is not None:
4536 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
4537 # Check if the root label of the algorithms exists
4538 if res and hypRoot is not None:
4539 iter = study.NewChildIterator(hypRoot)
4540 # Check all published algorithms
4542 algo_so_i = iter.Value()
4543 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
4544 if attr is not None:
4545 anIOR = attr.Value()
4546 algo_o_i = salome.orb.string_to_object(anIOR)
4547 if algo_o_i is not None:
4548 # Check if this is an algorithm
4549 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
4550 if algo_i is not None:
4551 # Checks if the algorithm belongs to the current engine
4552 if smeshpyD.GetObjectId(algo_i) > 0:
4553 # Check if this is the required algorithm
4554 if algo_i.GetName() == algoname:
4567 ## If the algorithm is global, returns 0; \n
4568 # else returns the submesh associated to this algorithm.
4569 def GetSubMesh(self):
4572 ## Returns the wrapped mesher.
4573 def GetAlgorithm(self):
4576 ## Gets the list of hypothesis that can be used with this algorithm
4577 def GetCompatibleHypothesis(self):
4580 mylist = self.algo.GetCompatibleHypothesis()
4583 ## Gets the name of the algorithm
4587 ## Sets the name to the algorithm
4588 def SetName(self, name):
4589 self.mesh.smeshpyD.SetName(self.algo, name)
4591 ## Gets the id of the algorithm
4593 return self.algo.GetId()
4596 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
4598 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
4599 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
4601 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
4603 self.Assign(algo, mesh, geom)
4607 def Assign(self, algo, mesh, geom):
4609 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
4613 self.geom = mesh.geom
4616 AssureGeomPublished( mesh, geom )
4618 name = GetName(geom)
4622 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
4624 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
4625 TreatHypoStatus( status, algo.GetName(), name, True )
4628 def CompareHyp (self, hyp, args):
4629 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
4632 def CompareEqualHyp (self, hyp, args):
4636 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
4637 UseExisting=0, CompareMethod=""):
4640 if CompareMethod == "": CompareMethod = self.CompareHyp
4641 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
4644 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
4649 if isinstance( arg, geompyDC.GEOM._objref_GEOM_Object ):
4650 argStr = arg.GetStudyEntry()
4651 if not argStr: argStr = "GEOM_Obj_%s", arg.GetEntry()
4652 if len( argStr ) > 10:
4653 argStr = argStr[:7]+"..."
4654 if argStr[0] == '[': argStr += ']'
4660 self.mesh.smeshpyD.SetName(hypo, hyp + a)
4664 geomName = GetName(self.geom)
4665 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
4666 TreatHypoStatus( status, GetName(hypo), geomName, 0 )
4669 ## Returns entry of the shape to mesh in the study
4670 def MainShapeEntry(self):
4672 if not self.mesh or not self.mesh.GetMesh(): return entry
4673 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
4674 study = self.mesh.smeshpyD.GetCurrentStudy()
4675 ior = salome.orb.object_to_string( self.mesh.GetShape() )
4676 sobj = study.FindObjectIOR(ior)
4677 if sobj: entry = sobj.GetID()
4678 if not entry: return ""
4681 ## Defines "ViscousLayers" hypothesis to give parameters of layers of prisms to build
4682 # near mesh boundary. This hypothesis can be used by several 3D algorithms:
4683 # NETGEN 3D, GHS3D, Hexahedron(i,j,k)
4684 # @param thickness total thickness of layers of prisms
4685 # @param numberOfLayers number of layers of prisms
4686 # @param stretchFactor factor (>1.0) of growth of layer thickness towards inside of mesh
4687 # @param ignoreFaces list of geometrical faces (or their ids) not to generate layers on
4688 # @ingroup l3_hypos_additi
4689 def ViscousLayers(self, thickness, numberOfLayers, stretchFactor, ignoreFaces=[]):
4690 if not isinstance(self.algo, SMESH._objref_SMESH_3D_Algo):
4691 raise TypeError, "ViscousLayers are supported by 3D algorithms only"
4692 if not "ViscousLayers" in self.GetCompatibleHypothesis():
4693 raise TypeError, "ViscousLayers are not supported by %s"%self.algo.GetName()
4694 if ignoreFaces and isinstance( ignoreFaces[0], geompyDC.GEOM._objref_GEOM_Object ):
4695 ignoreFaces = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, f) for f in ignoreFaces ]
4696 hyp = self.Hypothesis("ViscousLayers",
4697 [thickness, numberOfLayers, stretchFactor, ignoreFaces])
4698 hyp.SetTotalThickness(thickness)
4699 hyp.SetNumberLayers(numberOfLayers)
4700 hyp.SetStretchFactor(stretchFactor)
4701 hyp.SetIgnoreFaces(ignoreFaces)
4704 ## Transform a list of ether edges or tuples (edge 1st_vertex_of_edge)
4705 # into a list acceptable to SetReversedEdges() of some 1D hypotheses
4706 # @ingroup l3_hypos_1dhyps
4707 def ReversedEdgeIndices(self, reverseList):
4709 geompy = self.mesh.geompyD
4710 for i in reverseList:
4711 if isinstance( i, int ):
4712 s = geompy.SubShapes(self.mesh.geom, [i])[0]
4713 if s.GetShapeType() != geompyDC.GEOM.EDGE:
4714 raise TypeError, "Not EDGE index given"
4716 elif isinstance( i, geompyDC.GEOM._objref_GEOM_Object ):
4717 if i.GetShapeType() != geompyDC.GEOM.EDGE:
4718 raise TypeError, "Not an EDGE given"
4719 resList.append( geompy.GetSubShapeID(self.mesh.geom, i ))
4723 if not isinstance( e, geompyDC.GEOM._objref_GEOM_Object ) or \
4724 not isinstance( v, geompyDC.GEOM._objref_GEOM_Object ):
4725 raise TypeError, "A list item must be a tuple (edge 1st_vertex_of_edge)"
4726 if v.GetShapeType() == geompyDC.GEOM.EDGE and \
4727 e.GetShapeType() == geompyDC.GEOM.VERTEX:
4729 if e.GetShapeType() != geompyDC.GEOM.EDGE or \
4730 v.GetShapeType() != geompyDC.GEOM.VERTEX:
4731 raise TypeError, "A list item must be a tuple (edge 1st_vertex_of_edge)"
4732 vFirst = FirstVertexOnCurve( e )
4733 tol = geompy.Tolerance( vFirst )[-1]
4734 if geompy.MinDistance( v, vFirst ) > 1.5*tol:
4735 resList.append( geompy.GetSubShapeID(self.mesh.geom, e ))
4737 raise TypeError, "Item must be either an edge or tuple (edge 1st_vertex_of_edge)"
4740 # Public class: Mesh_Segment
4741 # --------------------------
4743 ## Class to define a segment 1D algorithm for discretization
4746 # @ingroup l3_algos_basic
4747 class Mesh_Segment(Mesh_Algorithm):
4749 ## Private constructor.
4750 def __init__(self, mesh, geom=0):
4751 Mesh_Algorithm.__init__(self)
4752 self.Create(mesh, geom, "Regular_1D")
4754 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
4755 # @param l for the length of segments that cut an edge
4756 # @param UseExisting if ==true - searches for an existing hypothesis created with
4757 # the same parameters, else (default) - creates a new one
4758 # @param p precision, used for calculation of the number of segments.
4759 # The precision should be a positive, meaningful value within the range [0,1].
4760 # In general, the number of segments is calculated with the formula:
4761 # nb = ceil((edge_length / l) - p)
4762 # Function ceil rounds its argument to the higher integer.
4763 # So, p=0 means rounding of (edge_length / l) to the higher integer,
4764 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
4765 # p=1 means rounding of (edge_length / l) to the lower integer.
4766 # Default value is 1e-07.
4767 # @return an instance of StdMeshers_LocalLength hypothesis
4768 # @ingroup l3_hypos_1dhyps
4769 def LocalLength(self, l, UseExisting=0, p=1e-07):
4770 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
4771 CompareMethod=self.CompareLocalLength)
4777 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
4778 def CompareLocalLength(self, hyp, args):
4779 if IsEqual(hyp.GetLength(), args[0]):
4780 return IsEqual(hyp.GetPrecision(), args[1])
4783 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
4784 # @param length is optional maximal allowed length of segment, if it is omitted
4785 # the preestimated length is used that depends on geometry size
4786 # @param UseExisting if ==true - searches for an existing hypothesis created with
4787 # the same parameters, else (default) - create a new one
4788 # @return an instance of StdMeshers_MaxLength hypothesis
4789 # @ingroup l3_hypos_1dhyps
4790 def MaxSize(self, length=0.0, UseExisting=0):
4791 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
4794 hyp.SetLength(length)
4796 # set preestimated length
4797 gen = self.mesh.smeshpyD
4798 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
4799 self.mesh.GetMesh(), self.mesh.GetShape(),
4801 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
4803 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
4806 hyp.SetUsePreestimatedLength( length == 0.0 )
4809 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
4810 # @param n for the number of segments that cut an edge
4811 # @param s for the scale factor (optional)
4812 # @param reversedEdges is a list of edges to mesh using reversed orientation.
4813 # A list item can also be a tuple (edge 1st_vertex_of_edge)
4814 # @param UseExisting if ==true - searches for an existing hypothesis created with
4815 # the same parameters, else (default) - create a new one
4816 # @return an instance of StdMeshers_NumberOfSegments hypothesis
4817 # @ingroup l3_hypos_1dhyps
4818 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4819 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4820 reversedEdges, UseExisting = [], reversedEdges
4821 entry = self.MainShapeEntry()
4822 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
4824 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdgeInd, entry],
4825 UseExisting=UseExisting,
4826 CompareMethod=self.CompareNumberOfSegments)
4828 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdgeInd, entry],
4829 UseExisting=UseExisting,
4830 CompareMethod=self.CompareNumberOfSegments)
4831 hyp.SetDistrType( 1 )
4832 hyp.SetScaleFactor(s)
4833 hyp.SetNumberOfSegments(n)
4834 hyp.SetReversedEdges( reversedEdgeInd )
4835 hyp.SetObjectEntry( entry )
4839 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4840 def CompareNumberOfSegments(self, hyp, args):
4841 if hyp.GetNumberOfSegments() == args[0]:
4843 if hyp.GetReversedEdges() == args[1]:
4844 if not args[1] or hyp.GetObjectEntry() == args[2]:
4847 if hyp.GetReversedEdges() == args[2]:
4848 if not args[2] or hyp.GetObjectEntry() == args[3]:
4849 if hyp.GetDistrType() == 1:
4850 if IsEqual(hyp.GetScaleFactor(), args[1]):
4854 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4855 # @param start defines the length of the first segment
4856 # @param end defines the length of the last segment
4857 # @param reversedEdges is a list of edges to mesh using reversed orientation.
4858 # A list item can also be a tuple (edge 1st_vertex_of_edge)
4859 # @param UseExisting if ==true - searches for an existing hypothesis created with
4860 # the same parameters, else (default) - creates a new one
4861 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4862 # @ingroup l3_hypos_1dhyps
4863 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4864 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4865 reversedEdges, UseExisting = [], reversedEdges
4866 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
4867 entry = self.MainShapeEntry()
4868 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdgeInd, entry],
4869 UseExisting=UseExisting,
4870 CompareMethod=self.CompareArithmetic1D)
4871 hyp.SetStartLength(start)
4872 hyp.SetEndLength(end)
4873 hyp.SetReversedEdges( reversedEdgeInd )
4874 hyp.SetObjectEntry( entry )
4878 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4879 def CompareArithmetic1D(self, hyp, args):
4880 if IsEqual(hyp.GetLength(1), args[0]):
4881 if IsEqual(hyp.GetLength(0), args[1]):
4882 if hyp.GetReversedEdges() == args[2]:
4883 if not args[2] or hyp.GetObjectEntry() == args[3]:
4888 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4889 # on curve from 0 to 1 (additionally it is neecessary to check
4890 # orientation of edges and create list of reversed edges if it is
4891 # needed) and sets numbers of segments between given points (default
4892 # values are equals 1
4893 # @param points defines the list of parameters on curve
4894 # @param nbSegs defines the list of numbers of segments
4895 # @param reversedEdges is a list of edges to mesh using reversed orientation.
4896 # A list item can also be a tuple (edge 1st_vertex_of_edge)
4897 # @param UseExisting if ==true - searches for an existing hypothesis created with
4898 # the same parameters, else (default) - creates a new one
4899 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4900 # @ingroup l3_hypos_1dhyps
4901 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4902 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4903 reversedEdges, UseExisting = [], reversedEdges
4904 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
4905 entry = self.MainShapeEntry()
4906 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdgeInd, entry],
4907 UseExisting=UseExisting,
4908 CompareMethod=self.CompareFixedPoints1D)
4909 hyp.SetPoints(points)
4910 hyp.SetNbSegments(nbSegs)
4911 hyp.SetReversedEdges(reversedEdgeInd)
4912 hyp.SetObjectEntry(entry)
4916 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4917 ## as the given arguments
4918 def CompareFixedPoints1D(self, hyp, args):
4919 if hyp.GetPoints() == args[0]:
4920 if hyp.GetNbSegments() == args[1]:
4921 if hyp.GetReversedEdges() == args[2]:
4922 if not args[2] or hyp.GetObjectEntry() == args[3]:
4928 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4929 # @param start defines the length of the first segment
4930 # @param end defines the length of the last segment
4931 # @param reversedEdges is a list of edges to mesh using reversed orientation.
4932 # A list item can also be a tuple (edge 1st_vertex_of_edge)
4933 # @param UseExisting if ==true - searches for an existing hypothesis created with
4934 # the same parameters, else (default) - creates a new one
4935 # @return an instance of StdMeshers_StartEndLength hypothesis
4936 # @ingroup l3_hypos_1dhyps
4937 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4938 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4939 reversedEdges, UseExisting = [], reversedEdges
4940 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
4941 entry = self.MainShapeEntry()
4942 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdgeInd, entry],
4943 UseExisting=UseExisting,
4944 CompareMethod=self.CompareStartEndLength)
4945 hyp.SetStartLength(start)
4946 hyp.SetEndLength(end)
4947 hyp.SetReversedEdges( reversedEdgeInd )
4948 hyp.SetObjectEntry( entry )
4951 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4952 def CompareStartEndLength(self, hyp, args):
4953 if IsEqual(hyp.GetLength(1), args[0]):
4954 if IsEqual(hyp.GetLength(0), args[1]):
4955 if hyp.GetReversedEdges() == args[2]:
4956 if not args[2] or hyp.GetObjectEntry() == args[3]:
4960 ## Defines "Deflection1D" hypothesis
4961 # @param d for the deflection
4962 # @param UseExisting if ==true - searches for an existing hypothesis created with
4963 # the same parameters, else (default) - create a new one
4964 # @ingroup l3_hypos_1dhyps
4965 def Deflection1D(self, d, UseExisting=0):
4966 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4967 CompareMethod=self.CompareDeflection1D)
4968 hyp.SetDeflection(d)
4971 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4972 def CompareDeflection1D(self, hyp, args):
4973 return IsEqual(hyp.GetDeflection(), args[0])
4975 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4976 # the opposite side in case of quadrangular faces
4977 # @ingroup l3_hypos_additi
4978 def Propagation(self):
4979 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4981 ## Defines "AutomaticLength" hypothesis
4982 # @param fineness for the fineness [0-1]
4983 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4984 # same parameters, else (default) - create a new one
4985 # @ingroup l3_hypos_1dhyps
4986 def AutomaticLength(self, fineness=0, UseExisting=0):
4987 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4988 CompareMethod=self.CompareAutomaticLength)
4989 hyp.SetFineness( fineness )
4992 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4993 def CompareAutomaticLength(self, hyp, args):
4994 return IsEqual(hyp.GetFineness(), args[0])
4996 ## Defines "SegmentLengthAroundVertex" hypothesis
4997 # @param length for the segment length
4998 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4999 # Any other integer value means that the hypothesis will be set on the
5000 # whole 1D shape, where Mesh_Segment algorithm is assigned.
5001 # @param UseExisting if ==true - searches for an existing hypothesis created with
5002 # the same parameters, else (default) - creates a new one
5003 # @ingroup l3_algos_segmarv
5004 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
5006 store_geom = self.geom
5007 if type(vertex) is types.IntType:
5008 if vertex == 0 or vertex == 1:
5009 vertex = self.mesh.geompyD.ExtractShapes(self.geom, geompyDC.ShapeType["VERTEX"],True)[vertex]
5017 if self.geom is None:
5018 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
5019 AssureGeomPublished( self.mesh, self.geom )
5020 name = GetName(self.geom)
5022 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
5024 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
5026 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
5027 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
5029 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
5030 CompareMethod=self.CompareLengthNearVertex)
5031 self.geom = store_geom
5032 hyp.SetLength( length )
5035 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
5036 # @ingroup l3_algos_segmarv
5037 def CompareLengthNearVertex(self, hyp, args):
5038 return IsEqual(hyp.GetLength(), args[0])
5040 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
5041 # If the 2D mesher sees that all boundary edges are quadratic,
5042 # it generates quadratic faces, else it generates linear faces using
5043 # medium nodes as if they are vertices.
5044 # The 3D mesher generates quadratic volumes only if all boundary faces
5045 # are quadratic, else it fails.
5047 # @ingroup l3_hypos_additi
5048 def QuadraticMesh(self):
5049 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
5052 # Public class: Mesh_CompositeSegment
5053 # --------------------------
5055 ## Defines a segment 1D algorithm for discretization
5057 # @ingroup l3_algos_basic
5058 class Mesh_CompositeSegment(Mesh_Segment):
5060 ## Private constructor.
5061 def __init__(self, mesh, geom=0):
5062 self.Create(mesh, geom, "CompositeSegment_1D")
5065 # Public class: Mesh_Segment_Python
5066 # ---------------------------------
5068 ## Defines a segment 1D algorithm for discretization with python function
5070 # @ingroup l3_algos_basic
5071 class Mesh_Segment_Python(Mesh_Segment):
5073 ## Private constructor.
5074 def __init__(self, mesh, geom=0):
5075 import Python1dPlugin
5076 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
5078 ## Defines "PythonSplit1D" hypothesis
5079 # @param n for the number of segments that cut an edge
5080 # @param func for the python function that calculates the length of all segments
5081 # @param UseExisting if ==true - searches for the existing hypothesis created with
5082 # the same parameters, else (default) - creates a new one
5083 # @ingroup l3_hypos_1dhyps
5084 def PythonSplit1D(self, n, func, UseExisting=0):
5085 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
5086 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
5087 hyp.SetNumberOfSegments(n)
5088 hyp.SetPythonLog10RatioFunction(func)
5091 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
5092 def ComparePythonSplit1D(self, hyp, args):
5093 #if hyp.GetNumberOfSegments() == args[0]:
5094 # if hyp.GetPythonLog10RatioFunction() == args[1]:
5098 # Public class: Mesh_Triangle
5099 # ---------------------------
5101 ## Defines a triangle 2D algorithm
5103 # @ingroup l3_algos_basic
5104 class Mesh_Triangle(Mesh_Algorithm):
5113 ## Private constructor.
5114 def __init__(self, mesh, algoType, geom=0):
5115 Mesh_Algorithm.__init__(self)
5117 if algoType == MEFISTO:
5118 self.Create(mesh, geom, "MEFISTO_2D")
5120 elif algoType == BLSURF:
5122 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
5123 #self.SetPhysicalMesh() - PAL19680
5124 elif algoType == NETGEN:
5126 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
5128 elif algoType == NETGEN_2D:
5130 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
5133 self.algoType = algoType
5135 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
5136 # @param area for the maximum area of each triangle
5137 # @param UseExisting if ==true - searches for an existing hypothesis created with the
5138 # same parameters, else (default) - creates a new one
5140 # Only for algoType == MEFISTO || NETGEN_2D
5141 # @ingroup l3_hypos_2dhyps
5142 def MaxElementArea(self, area, UseExisting=0):
5143 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
5144 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
5145 CompareMethod=self.CompareMaxElementArea)
5146 elif self.algoType == NETGEN:
5147 hyp = self.Parameters(SIMPLE)
5148 hyp.SetMaxElementArea(area)
5151 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
5152 def CompareMaxElementArea(self, hyp, args):
5153 return IsEqual(hyp.GetMaxElementArea(), args[0])
5155 ## Defines "LengthFromEdges" hypothesis to build triangles
5156 # based on the length of the edges taken from the wire
5158 # Only for algoType == MEFISTO || NETGEN_2D
5159 # @ingroup l3_hypos_2dhyps
5160 def LengthFromEdges(self):
5161 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
5162 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
5164 elif self.algoType == NETGEN:
5165 hyp = self.Parameters(SIMPLE)
5166 hyp.LengthFromEdges()
5169 ## Sets a way to define size of mesh elements to generate.
5170 # @param thePhysicalMesh is: DefaultSize, BLSURF_Custom or SizeMap.
5171 # @ingroup l3_hypos_blsurf
5172 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
5173 if self.Parameters():
5174 # Parameter of BLSURF algo
5175 self.params.SetPhysicalMesh(thePhysicalMesh)
5177 ## Sets size of mesh elements to generate.
5178 # @ingroup l3_hypos_blsurf
5179 def SetPhySize(self, theVal):
5180 if self.Parameters():
5181 # Parameter of BLSURF algo
5182 self.params.SetPhySize(theVal)
5184 ## Sets lower boundary of mesh element size (PhySize).
5185 # @ingroup l3_hypos_blsurf
5186 def SetPhyMin(self, theVal=-1):
5187 if self.Parameters():
5188 # Parameter of BLSURF algo
5189 self.params.SetPhyMin(theVal)
5191 ## Sets upper boundary of mesh element size (PhySize).
5192 # @ingroup l3_hypos_blsurf
5193 def SetPhyMax(self, theVal=-1):
5194 if self.Parameters():
5195 # Parameter of BLSURF algo
5196 self.params.SetPhyMax(theVal)
5198 ## Sets a way to define maximum angular deflection of mesh from CAD model.
5199 # @param theGeometricMesh is: 0 (None) or 1 (Custom)
5200 # @ingroup l3_hypos_blsurf
5201 def SetGeometricMesh(self, theGeometricMesh=0):
5202 if self.Parameters():
5203 # Parameter of BLSURF algo
5204 if self.params.GetPhysicalMesh() == 0: theGeometricMesh = 1
5205 self.params.SetGeometricMesh(theGeometricMesh)
5207 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
5208 # @ingroup l3_hypos_blsurf
5209 def SetAngleMeshS(self, theVal=_angleMeshS):
5210 if self.Parameters():
5211 # Parameter of BLSURF algo
5212 if self.params.GetGeometricMesh() == 0: theVal = self._angleMeshS
5213 self.params.SetAngleMeshS(theVal)
5215 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
5216 # @ingroup l3_hypos_blsurf
5217 def SetAngleMeshC(self, theVal=_angleMeshS):
5218 if self.Parameters():
5219 # Parameter of BLSURF algo
5220 if self.params.GetGeometricMesh() == 0: theVal = self._angleMeshS
5221 self.params.SetAngleMeshC(theVal)
5223 ## Sets lower boundary of mesh element size computed to respect angular deflection.
5224 # @ingroup l3_hypos_blsurf
5225 def SetGeoMin(self, theVal=-1):
5226 if self.Parameters():
5227 # Parameter of BLSURF algo
5228 self.params.SetGeoMin(theVal)
5230 ## Sets upper boundary of mesh element size computed to respect angular deflection.
5231 # @ingroup l3_hypos_blsurf
5232 def SetGeoMax(self, theVal=-1):
5233 if self.Parameters():
5234 # Parameter of BLSURF algo
5235 self.params.SetGeoMax(theVal)
5237 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
5238 # @ingroup l3_hypos_blsurf
5239 def SetGradation(self, theVal=_gradation):
5240 if self.Parameters():
5241 # Parameter of BLSURF algo
5242 if self.params.GetGeometricMesh() == 0: theVal = self._gradation
5243 self.params.SetGradation(theVal)
5245 ## Sets topology usage way.
5246 # @param way defines how mesh conformity is assured <ul>
5247 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
5248 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li>
5249 # <li>PreCAD - by pre-processing with PreCAD a CAD model</li></ul>
5250 # @ingroup l3_hypos_blsurf
5251 def SetTopology(self, way):
5252 if self.Parameters():
5253 # Parameter of BLSURF algo
5254 self.params.SetTopology(way)
5256 ## To respect geometrical edges or not.
5257 # @ingroup l3_hypos_blsurf
5258 def SetDecimesh(self, toIgnoreEdges=False):
5259 if self.Parameters():
5260 # Parameter of BLSURF algo
5261 self.params.SetDecimesh(toIgnoreEdges)
5263 ## Sets verbosity level in the range 0 to 100.
5264 # @ingroup l3_hypos_blsurf
5265 def SetVerbosity(self, level):
5266 if self.Parameters():
5267 # Parameter of BLSURF algo
5268 self.params.SetVerbosity(level)
5270 ## To optimize merges edges.
5271 # @ingroup l3_hypos_blsurf
5272 def SetPreCADMergeEdges(self, toMergeEdges=False):
5273 if self.Parameters():
5274 # Parameter of BLSURF algo
5275 self.params.SetPreCADMergeEdges(toMergeEdges)
5277 ## To remove nano edges.
5278 # @ingroup l3_hypos_blsurf
5279 def SetPreCADRemoveNanoEdges(self, toRemoveNanoEdges=False):
5280 if self.Parameters():
5281 # Parameter of BLSURF algo
5282 self.params.SetPreCADRemoveNanoEdges(toRemoveNanoEdges)
5284 ## To compute topology from scratch
5285 # @ingroup l3_hypos_blsurf
5286 def SetPreCADDiscardInput(self, toDiscardInput=False):
5287 if self.Parameters():
5288 # Parameter of BLSURF algo
5289 self.params.SetPreCADDiscardInput(toDiscardInput)
5291 ## Sets the length below which an edge is considered as nano
5292 # for the topology processing.
5293 # @ingroup l3_hypos_blsurf
5294 def SetPreCADEpsNano(self, epsNano):
5295 if self.Parameters():
5296 # Parameter of BLSURF algo
5297 self.params.SetPreCADEpsNano(epsNano)
5299 ## Sets advanced option value.
5300 # @ingroup l3_hypos_blsurf
5301 def SetOptionValue(self, optionName, level):
5302 if self.Parameters():
5303 # Parameter of BLSURF algo
5304 self.params.SetOptionValue(optionName,level)
5306 ## Sets advanced PreCAD option value.
5307 # Keyword arguments:
5308 # optionName: name of the option
5309 # optionValue: value of the option
5310 # @ingroup l3_hypos_blsurf
5311 def SetPreCADOptionValue(self, optionName, optionValue):
5312 if self.Parameters():
5313 # Parameter of BLSURF algo
5314 self.params.SetPreCADOptionValue(optionName,optionValue)
5316 ## Sets GMF file for export at computation
5317 # @ingroup l3_hypos_blsurf
5318 def SetGMFFile(self, fileName):
5319 if self.Parameters():
5320 # Parameter of BLSURF algo
5321 self.params.SetGMFFile(fileName)
5323 ## Enforced vertices (BLSURF)
5325 ## To get all the enforced vertices
5326 # @ingroup l3_hypos_blsurf
5327 def GetAllEnforcedVertices(self):
5328 if self.Parameters():
5329 # Parameter of BLSURF algo
5330 return self.params.GetAllEnforcedVertices()
5332 ## To get all the enforced vertices sorted by face (or group, compound)
5333 # @ingroup l3_hypos_blsurf
5334 def GetAllEnforcedVerticesByFace(self):
5335 if self.Parameters():
5336 # Parameter of BLSURF algo
5337 return self.params.GetAllEnforcedVerticesByFace()
5339 ## To get all the enforced vertices sorted by coords of input vertices
5340 # @ingroup l3_hypos_blsurf
5341 def GetAllEnforcedVerticesByCoords(self):
5342 if self.Parameters():
5343 # Parameter of BLSURF algo
5344 return self.params.GetAllEnforcedVerticesByCoords()
5346 ## To get all the coords of input vertices sorted by face (or group, compound)
5347 # @ingroup l3_hypos_blsurf
5348 def GetAllCoordsByFace(self):
5349 if self.Parameters():
5350 # Parameter of BLSURF algo
5351 return self.params.GetAllCoordsByFace()
5353 ## To get all the enforced vertices on a face (or group, compound)
5354 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
5355 # @ingroup l3_hypos_blsurf
5356 def GetEnforcedVertices(self, theFace):
5357 if self.Parameters():
5358 # Parameter of BLSURF algo
5359 AssureGeomPublished( self.mesh, theFace )
5360 return self.params.GetEnforcedVertices(theFace)
5362 ## To clear all the enforced vertices
5363 # @ingroup l3_hypos_blsurf
5364 def ClearAllEnforcedVertices(self):
5365 if self.Parameters():
5366 # Parameter of BLSURF algo
5367 return self.params.ClearAllEnforcedVertices()
5369 ## 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.
5370 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
5371 # @param x : x coordinate
5372 # @param y : y coordinate
5373 # @param z : z coordinate
5374 # @param vertexName : name of the enforced vertex
5375 # @param groupName : name of the group
5376 # @ingroup l3_hypos_blsurf
5377 def SetEnforcedVertex(self, theFace, x, y, z, vertexName = "", groupName = ""):
5378 if self.Parameters():
5379 # Parameter of BLSURF algo
5380 AssureGeomPublished( self.mesh, theFace )
5381 if vertexName == "":
5383 return self.params.SetEnforcedVertex(theFace, x, y, z)
5385 return self.params.SetEnforcedVertexWithGroup(theFace, x, y, z, groupName)
5388 return self.params.SetEnforcedVertexNamed(theFace, x, y, z, vertexName)
5390 return self.params.SetEnforcedVertexNamedWithGroup(theFace, x, y, z, vertexName, groupName)
5392 ## To set an enforced vertex on a face (or group, compound) given a GEOM vertex, group or compound.
5393 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
5394 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
5395 # @param groupName : name of the group
5396 # @ingroup l3_hypos_blsurf
5397 def SetEnforcedVertexGeom(self, theFace, theVertex, groupName = ""):
5398 if self.Parameters():
5399 # Parameter of BLSURF algo
5400 AssureGeomPublished( self.mesh, theFace )
5401 AssureGeomPublished( self.mesh, theVertex )
5403 return self.params.SetEnforcedVertexGeom(theFace, theVertex)
5405 return self.params.SetEnforcedVertexGeomWithGroup(theFace, theVertex,groupName)
5407 ## To remove an enforced vertex on a given GEOM face (or group, compound) given the coordinates.
5408 # @param theFace : GEOM face (or group, compound) on which to remove the enforced vertex
5409 # @param x : x coordinate
5410 # @param y : y coordinate
5411 # @param z : z coordinate
5412 # @ingroup l3_hypos_blsurf
5413 def UnsetEnforcedVertex(self, theFace, x, y, z):
5414 if self.Parameters():
5415 # Parameter of BLSURF algo
5416 AssureGeomPublished( self.mesh, theFace )
5417 return self.params.UnsetEnforcedVertex(theFace, x, y, z)
5419 ## To remove an enforced vertex on a given GEOM face (or group, compound) given a GEOM vertex, group or compound.
5420 # @param theFace : GEOM face (or group, compound) on which to remove the enforced vertex
5421 # @param theVertex : GEOM vertex (or group, compound) to remove.
5422 # @ingroup l3_hypos_blsurf
5423 def UnsetEnforcedVertexGeom(self, theFace, theVertex):
5424 if self.Parameters():
5425 # Parameter of BLSURF algo
5426 AssureGeomPublished( self.mesh, theFace )
5427 AssureGeomPublished( self.mesh, theVertex )
5428 return self.params.UnsetEnforcedVertexGeom(theFace, theVertex)
5430 ## To remove all enforced vertices on a given face.
5431 # @param theFace : face (or group/compound of faces) on which to remove all enforced vertices
5432 # @ingroup l3_hypos_blsurf
5433 def UnsetEnforcedVertices(self, theFace):
5434 if self.Parameters():
5435 # Parameter of BLSURF algo
5436 AssureGeomPublished( self.mesh, theFace )
5437 return self.params.UnsetEnforcedVertices(theFace)
5439 ## Attractors (BLSURF)
5441 ## 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 ]
5442 # @param theFace : face on which the attractor will be defined
5443 # @param theAttractor : geometrical object from which the mesh size "h" decreases exponentially
5444 # @param theStartSize : mesh size on theAttractor
5445 # @param theEndSize : maximum size that will be reached on theFace
5446 # @param theInfluenceDistance : influence of the attractor ( the size grow slower on theFace if it's high)
5447 # @param theConstantSizeDistance : distance until which the mesh size will be kept constant on theFace
5448 # @ingroup l3_hypos_blsurf
5449 def SetAttractorGeom(self, theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance):
5450 if self.Parameters():
5451 # Parameter of BLSURF algo
5452 AssureGeomPublished( self.mesh, theFace )
5453 AssureGeomPublished( self.mesh, theAttractor )
5454 self.params.SetAttractorGeom(theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance)
5456 ## Unsets an attractor on the chosen face.
5457 # @param theFace : face on which the attractor has to be removed
5458 # @ingroup l3_hypos_blsurf
5459 def UnsetAttractorGeom(self, theFace):
5460 if self.Parameters():
5461 # Parameter of BLSURF algo
5462 AssureGeomPublished( self.mesh, theFace )
5463 self.params.SetAttractorGeom(theFace)
5465 ## Size maps (BLSURF)
5467 ## To set a size map on a face, edge or vertex (or group, compound) given Python function.
5468 # If theObject is a face, the function can be: def f(u,v): return u+v
5469 # If theObject is an edge, the function can be: def f(t): return t/2
5470 # If theObject is a vertex, the function can be: def f(): return 10
5471 # @param theObject : GEOM face, edge or vertex (or group, compound) on which to define a size map
5472 # @param theSizeMap : Size map defined as a string
5473 # @ingroup l3_hypos_blsurf
5474 def SetSizeMap(self, theObject, theSizeMap):
5475 if self.Parameters():
5476 # Parameter of BLSURF algo
5477 AssureGeomPublished( self.mesh, theObject )
5478 return self.params.SetSizeMap(theObject, theSizeMap)
5480 ## To remove a size map defined on a face, edge or vertex (or group, compound)
5481 # @param theObject : GEOM face, edge or vertex (or group, compound) on which to define a size map
5482 # @ingroup l3_hypos_blsurf
5483 def UnsetSizeMap(self, theObject):
5484 if self.Parameters():
5485 # Parameter of BLSURF algo
5486 AssureGeomPublished( self.mesh, theObject )
5487 return self.params.UnsetSizeMap(theObject)
5489 ## To remove all the size maps
5490 # @ingroup l3_hypos_blsurf
5491 def ClearSizeMaps(self):
5492 if self.Parameters():
5493 # Parameter of BLSURF algo
5494 return self.params.ClearSizeMaps()
5497 ## Sets QuadAllowed flag.
5498 # Only for algoType == NETGEN(NETGEN_1D2D) || NETGEN_2D || BLSURF
5499 # @ingroup l3_hypos_netgen l3_hypos_blsurf
5500 def SetQuadAllowed(self, toAllow=True):
5501 if self.algoType == NETGEN_2D:
5504 hasSimpleHyps = False
5505 simpleHyps = ["QuadranglePreference","LengthFromEdges","MaxElementArea"]
5506 for hyp in self.mesh.GetHypothesisList( self.geom ):
5507 if hyp.GetName() in simpleHyps:
5508 hasSimpleHyps = True
5509 if hyp.GetName() == "QuadranglePreference":
5510 if not toAllow: # remove QuadranglePreference
5511 self.mesh.RemoveHypothesis( self.geom, hyp )
5517 if toAllow: # add QuadranglePreference
5518 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
5523 if self.Parameters():
5524 self.params.SetQuadAllowed(toAllow)
5527 ## Defines hypothesis having several parameters
5529 # @ingroup l3_hypos_netgen
5530 def Parameters(self, which=SOLE):
5532 if self.algoType == NETGEN:
5534 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
5535 "libNETGENEngine.so", UseExisting=0)
5537 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
5538 "libNETGENEngine.so", UseExisting=0)
5539 elif self.algoType == MEFISTO:
5540 print "Mefisto algo support no multi-parameter hypothesis"
5541 elif self.algoType == NETGEN_2D:
5542 self.params = self.Hypothesis("NETGEN_Parameters_2D_ONLY", [],
5543 "libNETGENEngine.so", UseExisting=0)
5544 elif self.algoType == BLSURF:
5545 self.params = self.Hypothesis("BLSURF_Parameters", [],
5546 "libBLSURFEngine.so", UseExisting=0)
5548 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
5553 # Only for algoType == NETGEN
5554 # @ingroup l3_hypos_netgen
5555 def SetMaxSize(self, theSize):
5556 if self.Parameters():
5557 self.params.SetMaxSize(theSize)
5559 ## Sets SecondOrder flag
5561 # Only for algoType == NETGEN
5562 # @ingroup l3_hypos_netgen
5563 def SetSecondOrder(self, theVal):
5564 if self.Parameters():
5565 self.params.SetSecondOrder(theVal)
5567 ## Sets Optimize flag
5569 # Only for algoType == NETGEN
5570 # @ingroup l3_hypos_netgen
5571 def SetOptimize(self, theVal):
5572 if self.Parameters():
5573 self.params.SetOptimize(theVal)
5576 # @param theFineness is:
5577 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5579 # Only for algoType == NETGEN
5580 # @ingroup l3_hypos_netgen
5581 def SetFineness(self, theFineness):
5582 if self.Parameters():
5583 self.params.SetFineness(theFineness)
5587 # Only for algoType == NETGEN
5588 # @ingroup l3_hypos_netgen
5589 def SetGrowthRate(self, theRate):
5590 if self.Parameters():
5591 self.params.SetGrowthRate(theRate)
5593 ## Sets NbSegPerEdge
5595 # Only for algoType == NETGEN
5596 # @ingroup l3_hypos_netgen
5597 def SetNbSegPerEdge(self, theVal):
5598 if self.Parameters():
5599 self.params.SetNbSegPerEdge(theVal)
5601 ## Sets NbSegPerRadius
5603 # Only for algoType == NETGEN
5604 # @ingroup l3_hypos_netgen
5605 def SetNbSegPerRadius(self, theVal):
5606 if self.Parameters():
5607 self.params.SetNbSegPerRadius(theVal)
5609 ## Sets number of segments overriding value set by SetLocalLength()
5611 # Only for algoType == NETGEN
5612 # @ingroup l3_hypos_netgen
5613 def SetNumberOfSegments(self, theVal):
5614 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5616 ## Sets number of segments overriding value set by SetNumberOfSegments()
5618 # Only for algoType == NETGEN
5619 # @ingroup l3_hypos_netgen
5620 def SetLocalLength(self, theVal):
5621 self.Parameters(SIMPLE).SetLocalLength(theVal)
5626 # Public class: Mesh_Quadrangle
5627 # -----------------------------
5629 ## Defines a quadrangle 2D algorithm
5631 # @ingroup l3_algos_basic
5632 class Mesh_Quadrangle(Mesh_Algorithm):
5636 ## Private constructor.
5637 def __init__(self, mesh, geom=0):
5638 Mesh_Algorithm.__init__(self)
5639 self.Create(mesh, geom, "Quadrangle_2D")
5642 ## Defines "QuadrangleParameters" hypothesis
5643 # @param quadType defines the algorithm of transition between differently descretized
5644 # sides of a geometrical face:
5645 # - QUAD_STANDARD - both triangles and quadrangles are possible in the transition
5646 # area along the finer meshed sides.
5647 # - QUAD_TRIANGLE_PREF - only triangles are built in the transition area along the
5648 # finer meshed sides.
5649 # - QUAD_QUADRANGLE_PREF - only quadrangles are built in the transition area along
5650 # the finer meshed sides, iff the total quantity of segments on
5651 # all four sides of the face is even (divisible by 2).
5652 # - QUAD_QUADRANGLE_PREF_REVERSED - same as QUAD_QUADRANGLE_PREF but the transition
5653 # area is located along the coarser meshed sides.
5654 # - QUAD_REDUCED - only quadrangles are built and the transition between the sides
5655 # is made gradually, layer by layer. This type has a limitation on
5656 # the number of segments: one pair of opposite sides must have the
5657 # same number of segments, the other pair must have an even difference
5658 # between the numbers of segments on the sides.
5659 # @param triangleVertex: vertex of a trilateral geometrical face, around which triangles
5660 # will be created while other elements will be quadrangles.
5661 # Vertex can be either a GEOM_Object or a vertex ID within the
5663 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5664 # the same parameters, else (default) - creates a new one
5665 # @ingroup l3_hypos_quad
5666 def QuadrangleParameters(self, quadType=StdMeshers.QUAD_STANDARD, triangleVertex=0, UseExisting=0):
5667 vertexID = triangleVertex
5668 if isinstance( triangleVertex, geompyDC.GEOM._objref_GEOM_Object ):
5669 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, triangleVertex )
5671 compFun = lambda hyp,args: \
5672 hyp.GetQuadType() == args[0] and \
5673 ( hyp.GetTriaVertex()==args[1] or ( hyp.GetTriaVertex()<1 and args[1]<1))
5674 self.params = self.Hypothesis("QuadrangleParams", [quadType,vertexID],
5675 UseExisting = UseExisting, CompareMethod=compFun)
5677 if self.params.GetQuadType() != quadType:
5678 self.params.SetQuadType(quadType)
5680 self.params.SetTriaVertex( vertexID )
5683 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5684 # quadrangles are built in the transition area along the finer meshed sides,
5685 # iff the total quantity of segments on all four sides of the face is even.
5686 # @param reversed if True, transition area is located along the coarser meshed sides.
5687 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5688 # the same parameters, else (default) - creates a new one
5689 # @ingroup l3_hypos_quad
5690 def QuadranglePreference(self, reversed=False, UseExisting=0):
5692 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF_REVERSED,UseExisting=UseExisting)
5693 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF,UseExisting=UseExisting)
5695 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5696 # triangles are built in the transition area along the finer meshed sides.
5697 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5698 # the same parameters, else (default) - creates a new one
5699 # @ingroup l3_hypos_quad
5700 def TrianglePreference(self, UseExisting=0):
5701 return self.QuadrangleParameters(QUAD_TRIANGLE_PREF,UseExisting=UseExisting)
5703 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5704 # quadrangles are built and the transition between the sides is made gradually,
5705 # layer by layer. This type has a limitation on the number of segments: one pair
5706 # of opposite sides must have the same number of segments, the other pair must
5707 # have an even difference between the numbers of segments on the sides.
5708 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5709 # the same parameters, else (default) - creates a new one
5710 # @ingroup l3_hypos_quad
5711 def Reduced(self, UseExisting=0):
5712 return self.QuadrangleParameters(QUAD_REDUCED,UseExisting=UseExisting)
5714 ## Defines "QuadrangleParams" hypothesis with QUAD_STANDARD type of quadrangulation
5715 # @param vertex: vertex of a trilateral geometrical face, around which triangles
5716 # will be created while other elements will be quadrangles.
5717 # Vertex can be either a GEOM_Object or a vertex ID within the
5719 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5720 # the same parameters, else (default) - creates a new one
5721 # @ingroup l3_hypos_quad
5722 def TriangleVertex(self, vertex, UseExisting=0):
5723 return self.QuadrangleParameters(QUAD_STANDARD,vertex,UseExisting)
5726 # Public class: Mesh_Tetrahedron
5727 # ------------------------------
5729 ## Defines a tetrahedron 3D algorithm
5731 # @ingroup l3_algos_basic
5732 class Mesh_Tetrahedron(Mesh_Algorithm):
5737 ## Private constructor.
5738 def __init__(self, mesh, algoType, geom=0):
5739 Mesh_Algorithm.__init__(self)
5741 if algoType == NETGEN:
5743 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
5746 elif algoType == FULL_NETGEN:
5748 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5751 elif algoType == GHS3D:
5753 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
5756 elif algoType == GHS3DPRL:
5757 CheckPlugin(GHS3DPRL)
5758 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
5761 self.algoType = algoType
5763 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
5764 # @param vol for the maximum volume of each tetrahedron
5765 # @param UseExisting if ==true - searches for the existing hypothesis created with
5766 # the same parameters, else (default) - creates a new one
5767 # @ingroup l3_hypos_maxvol
5768 def MaxElementVolume(self, vol, UseExisting=0):
5769 if self.algoType == NETGEN:
5770 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
5771 CompareMethod=self.CompareMaxElementVolume)
5772 hyp.SetMaxElementVolume(vol)
5774 elif self.algoType == FULL_NETGEN:
5775 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
5778 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
5779 def CompareMaxElementVolume(self, hyp, args):
5780 return IsEqual(hyp.GetMaxElementVolume(), args[0])
5782 ## Defines hypothesis having several parameters
5784 # @ingroup l3_hypos_netgen
5785 def Parameters(self, which=SOLE):
5788 if self.algoType == FULL_NETGEN:
5790 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
5791 "libNETGENEngine.so", UseExisting=0)
5793 self.params = self.Hypothesis("NETGEN_Parameters", [],
5794 "libNETGENEngine.so", UseExisting=0)
5796 elif self.algoType == NETGEN:
5797 self.params = self.Hypothesis("NETGEN_Parameters_3D", [],
5798 "libNETGENEngine.so", UseExisting=0)
5800 elif self.algoType == GHS3D:
5801 self.params = self.Hypothesis("GHS3D_Parameters", [],
5802 "libGHS3DEngine.so", UseExisting=0)
5804 elif self.algoType == GHS3DPRL:
5805 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
5806 "libGHS3DPRLEngine.so", UseExisting=0)
5808 print "Warning: %s supports no multi-parameter hypothesis"%self.algo.GetName()
5813 # Parameter of FULL_NETGEN and NETGEN
5814 # @ingroup l3_hypos_netgen
5815 def SetMaxSize(self, theSize):
5816 self.Parameters().SetMaxSize(theSize)
5818 ## Sets SecondOrder flag
5819 # Parameter of FULL_NETGEN
5820 # @ingroup l3_hypos_netgen
5821 def SetSecondOrder(self, theVal):
5822 self.Parameters().SetSecondOrder(theVal)
5824 ## Sets Optimize flag
5825 # Parameter of FULL_NETGEN and NETGEN
5826 # @ingroup l3_hypos_netgen
5827 def SetOptimize(self, theVal):
5828 self.Parameters().SetOptimize(theVal)
5831 # @param theFineness is:
5832 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5833 # Parameter of FULL_NETGEN
5834 # @ingroup l3_hypos_netgen
5835 def SetFineness(self, theFineness):
5836 self.Parameters().SetFineness(theFineness)
5839 # Parameter of FULL_NETGEN
5840 # @ingroup l3_hypos_netgen
5841 def SetGrowthRate(self, theRate):
5842 self.Parameters().SetGrowthRate(theRate)
5844 ## Sets NbSegPerEdge
5845 # Parameter of FULL_NETGEN
5846 # @ingroup l3_hypos_netgen
5847 def SetNbSegPerEdge(self, theVal):
5848 self.Parameters().SetNbSegPerEdge(theVal)
5850 ## Sets NbSegPerRadius
5851 # Parameter of FULL_NETGEN
5852 # @ingroup l3_hypos_netgen
5853 def SetNbSegPerRadius(self, theVal):
5854 self.Parameters().SetNbSegPerRadius(theVal)
5856 ## Sets number of segments overriding value set by SetLocalLength()
5857 # Only for algoType == NETGEN_FULL
5858 # @ingroup l3_hypos_netgen
5859 def SetNumberOfSegments(self, theVal):
5860 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5862 ## Sets number of segments overriding value set by SetNumberOfSegments()
5863 # Only for algoType == NETGEN_FULL
5864 # @ingroup l3_hypos_netgen
5865 def SetLocalLength(self, theVal):
5866 self.Parameters(SIMPLE).SetLocalLength(theVal)
5868 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
5869 # Overrides value set by LengthFromEdges()
5870 # Only for algoType == NETGEN_FULL
5871 # @ingroup l3_hypos_netgen
5872 def MaxElementArea(self, area):
5873 self.Parameters(SIMPLE).SetMaxElementArea(area)
5875 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
5876 # Overrides value set by MaxElementArea()
5877 # Only for algoType == NETGEN_FULL
5878 # @ingroup l3_hypos_netgen
5879 def LengthFromEdges(self):
5880 self.Parameters(SIMPLE).LengthFromEdges()
5882 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
5883 # Overrides value set by MaxElementVolume()
5884 # Only for algoType == NETGEN_FULL
5885 # @ingroup l3_hypos_netgen
5886 def LengthFromFaces(self):
5887 self.Parameters(SIMPLE).LengthFromFaces()
5889 ## To mesh "holes" in a solid or not. Default is to mesh.
5890 # @ingroup l3_hypos_ghs3dh
5891 def SetToMeshHoles(self, toMesh):
5892 # Parameter of GHS3D
5893 if self.Parameters():
5894 self.params.SetToMeshHoles(toMesh)
5896 ## Set Optimization level:
5897 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
5898 # Strong_Optimization.
5899 # Default is Standard_Optimization
5900 # @ingroup l3_hypos_ghs3dh
5901 def SetOptimizationLevel(self, level):
5902 # Parameter of GHS3D
5903 if self.Parameters():
5904 self.params.SetOptimizationLevel(level)
5906 ## Maximal size of memory to be used by the algorithm (in Megabytes).
5907 # @ingroup l3_hypos_ghs3dh
5908 def SetMaximumMemory(self, MB):
5909 # Advanced parameter of GHS3D
5910 if self.Parameters():
5911 self.params.SetMaximumMemory(MB)
5913 ## Initial size of memory to be used by the algorithm (in Megabytes) in
5914 # automatic memory adjustment mode.
5915 # @ingroup l3_hypos_ghs3dh
5916 def SetInitialMemory(self, MB):
5917 # Advanced parameter of GHS3D
5918 if self.Parameters():
5919 self.params.SetInitialMemory(MB)
5921 ## Path to working directory.
5922 # @ingroup l3_hypos_ghs3dh
5923 def SetWorkingDirectory(self, path):
5924 # Advanced parameter of GHS3D
5925 if self.Parameters():
5926 self.params.SetWorkingDirectory(path)
5928 ## To keep working files or remove them. Log file remains in case of errors anyway.
5929 # @ingroup l3_hypos_ghs3dh
5930 def SetKeepFiles(self, toKeep):
5931 # Advanced parameter of GHS3D and GHS3DPRL
5932 if self.Parameters():
5933 self.params.SetKeepFiles(toKeep)
5935 ## To set verbose level [0-10]. <ul>
5936 #<li> 0 - no standard output,
5937 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
5938 # indicates when the final mesh is being saved. In addition the software
5939 # gives indication regarding the CPU time.
5940 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
5941 # histogram of the skin mesh, quality statistics histogram together with
5942 # the characteristics of the final mesh.</ul>
5943 # @ingroup l3_hypos_ghs3dh
5944 def SetVerboseLevel(self, level):
5945 # Advanced parameter of GHS3D
5946 if self.Parameters():
5947 self.params.SetVerboseLevel(level)
5949 ## To create new nodes.
5950 # @ingroup l3_hypos_ghs3dh
5951 def SetToCreateNewNodes(self, toCreate):
5952 # Advanced parameter of GHS3D
5953 if self.Parameters():
5954 self.params.SetToCreateNewNodes(toCreate)
5956 ## To use boundary recovery version which tries to create mesh on a very poor
5957 # quality surface mesh.
5958 # @ingroup l3_hypos_ghs3dh
5959 def SetToUseBoundaryRecoveryVersion(self, toUse):
5960 # Advanced parameter of GHS3D
5961 if self.Parameters():
5962 self.params.SetToUseBoundaryRecoveryVersion(toUse)
5964 ## Applies finite-element correction by replacing overconstrained elements where
5965 # it is possible. The process is cutting first the overconstrained edges and
5966 # second the overconstrained facets. This insure that no edges have two boundary
5967 # vertices and that no facets have three boundary vertices.
5968 # @ingroup l3_hypos_ghs3dh
5969 def SetFEMCorrection(self, toUseFem):
5970 # Advanced parameter of GHS3D
5971 if self.Parameters():
5972 self.params.SetFEMCorrection(toUseFem)
5974 ## To removes initial central point.
5975 # @ingroup l3_hypos_ghs3dh
5976 def SetToRemoveCentralPoint(self, toRemove):
5977 # Advanced parameter of GHS3D
5978 if self.Parameters():
5979 self.params.SetToRemoveCentralPoint(toRemove)
5981 ## To set an enforced vertex.
5982 # @param x : x coordinate
5983 # @param y : y coordinate
5984 # @param z : z coordinate
5985 # @param size : size of 1D element around enforced vertex
5986 # @param vertexName : name of the enforced vertex
5987 # @param groupName : name of the group
5988 # @ingroup l3_hypos_ghs3dh
5989 def SetEnforcedVertex(self, x, y, z, size, vertexName = "", groupName = ""):
5990 # Advanced parameter of GHS3D
5991 if self.Parameters():
5992 if vertexName == "":
5994 return self.params.SetEnforcedVertex(x, y, z, size)
5996 return self.params.SetEnforcedVertexWithGroup(x, y, z, size, groupName)
5999 return self.params.SetEnforcedVertexNamed(x, y, z, size, vertexName)
6001 return self.params.SetEnforcedVertexNamedWithGroup(x, y, z, size, vertexName, groupName)
6003 ## To set an enforced vertex given a GEOM vertex, group or compound.
6004 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
6005 # @param size : size of 1D element around enforced vertex
6006 # @param groupName : name of the group
6007 # @ingroup l3_hypos_ghs3dh
6008 def SetEnforcedVertexGeom(self, theVertex, size, groupName = ""):
6009 AssureGeomPublished( self.mesh, theVertex )
6010 # Advanced parameter of GHS3D
6011 if self.Parameters():
6013 return self.params.SetEnforcedVertexGeom(theVertex, size)
6015 return self.params.SetEnforcedVertexGeomWithGroup(theVertex, size, groupName)
6017 ## To remove an enforced vertex.
6018 # @param x : x coordinate
6019 # @param y : y coordinate
6020 # @param z : z coordinate
6021 # @ingroup l3_hypos_ghs3dh
6022 def RemoveEnforcedVertex(self, x, y, z):
6023 # Advanced parameter of GHS3D
6024 if self.Parameters():
6025 return self.params.RemoveEnforcedVertex(x, y, z)
6027 ## To remove an enforced vertex given a GEOM vertex, group or compound.
6028 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
6029 # @ingroup l3_hypos_ghs3dh
6030 def RemoveEnforcedVertexGeom(self, theVertex):
6031 AssureGeomPublished( self.mesh, theVertex )
6032 # Advanced parameter of GHS3D
6033 if self.Parameters():
6034 return self.params.RemoveEnforcedVertexGeom(theVertex)
6036 ## To set an enforced mesh with given size and add the enforced elements in the group "groupName".
6037 # @param theSource : source mesh which provides constraint elements/nodes
6038 # @param elementType : SMESH.ElementType (NODE, EDGE or FACE)
6039 # @param size : size of elements around enforced elements. Unused if -1.
6040 # @param groupName : group in which enforced elements will be added. Unused if "".
6041 # @ingroup l3_hypos_ghs3dh
6042 def SetEnforcedMesh(self, theSource, elementType, size = -1, groupName = ""):
6043 # Advanced parameter of GHS3D
6044 if self.Parameters():
6047 return self.params.SetEnforcedMesh(theSource, elementType)
6049 return self.params.SetEnforcedMeshWithGroup(theSource, elementType, groupName)
6052 return self.params.SetEnforcedMeshSize(theSource, elementType, size)
6054 return self.params.SetEnforcedMeshSizeWithGroup(theSource, elementType, size, groupName)
6056 ## Sets command line option as text.
6057 # @ingroup l3_hypos_ghs3dh
6058 def SetTextOption(self, option):
6059 # Advanced parameter of GHS3D
6060 if self.Parameters():
6061 self.params.SetTextOption(option)
6063 ## Sets MED files name and path.
6064 def SetMEDName(self, value):
6065 if self.Parameters():
6066 self.params.SetMEDName(value)
6068 ## Sets the number of partition of the initial mesh
6069 def SetNbPart(self, value):
6070 if self.Parameters():
6071 self.params.SetNbPart(value)
6073 ## When big mesh, start tepal in background
6074 def SetBackground(self, value):
6075 if self.Parameters():
6076 self.params.SetBackground(value)
6078 # Public class: Mesh_Hexahedron
6079 # ------------------------------
6081 ## Defines a hexahedron 3D algorithm
6083 # @ingroup l3_algos_basic
6084 class Mesh_Hexahedron(Mesh_Algorithm):
6089 ## Private constructor.
6090 def __init__(self, mesh, algoType=Hexa, geom=0):
6091 Mesh_Algorithm.__init__(self)
6093 self.algoType = algoType
6095 if algoType == Hexa:
6096 self.Create(mesh, geom, "Hexa_3D")
6099 elif algoType == Hexotic:
6100 CheckPlugin(Hexotic)
6101 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
6104 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
6105 # @ingroup l3_hypos_hexotic
6106 def MinMaxQuad(self, min=3, max=8, quad=True):
6107 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
6109 self.params.SetHexesMinLevel(min)
6110 self.params.SetHexesMaxLevel(max)
6111 self.params.SetHexoticQuadrangles(quad)
6114 # Deprecated, only for compatibility!
6115 # Public class: Mesh_Netgen
6116 # ------------------------------
6118 ## Defines a NETGEN-based 2D or 3D algorithm
6119 # that needs no discrete boundary (i.e. independent)
6121 # This class is deprecated, only for compatibility!
6124 # @ingroup l3_algos_basic
6125 class Mesh_Netgen(Mesh_Algorithm):
6129 ## Private constructor.
6130 def __init__(self, mesh, is3D, geom=0):
6131 Mesh_Algorithm.__init__(self)
6137 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
6141 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
6144 ## Defines the hypothesis containing parameters of the algorithm
6145 def Parameters(self):
6147 hyp = self.Hypothesis("NETGEN_Parameters", [],
6148 "libNETGENEngine.so", UseExisting=0)
6150 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
6151 "libNETGENEngine.so", UseExisting=0)
6154 # Public class: Mesh_Projection1D
6155 # ------------------------------
6157 ## Defines a projection 1D algorithm
6158 # @ingroup l3_algos_proj
6160 class Mesh_Projection1D(Mesh_Algorithm):
6162 ## Private constructor.
6163 def __init__(self, mesh, geom=0):
6164 Mesh_Algorithm.__init__(self)
6165 self.Create(mesh, geom, "Projection_1D")
6167 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
6168 # a mesh pattern is taken, and, optionally, the association of vertices
6169 # between the source edge and a target edge (to which a hypothesis is assigned)
6170 # @param edge from which nodes distribution is taken
6171 # @param mesh from which nodes distribution is taken (optional)
6172 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
6173 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
6174 # to associate with \a srcV (optional)
6175 # @param UseExisting if ==true - searches for the existing hypothesis created with
6176 # the same parameters, else (default) - creates a new one
6177 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
6178 AssureGeomPublished( self.mesh, edge )
6179 AssureGeomPublished( self.mesh, srcV )
6180 AssureGeomPublished( self.mesh, tgtV )
6181 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
6183 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
6184 hyp.SetSourceEdge( edge )
6185 if not mesh is None and isinstance(mesh, Mesh):
6186 mesh = mesh.GetMesh()
6187 hyp.SetSourceMesh( mesh )
6188 hyp.SetVertexAssociation( srcV, tgtV )
6191 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
6192 #def CompareSourceEdge(self, hyp, args):
6193 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
6197 # Public class: Mesh_Projection2D
6198 # ------------------------------
6200 ## Defines a projection 2D algorithm
6201 # @ingroup l3_algos_proj
6203 class Mesh_Projection2D(Mesh_Algorithm):
6205 ## Private constructor.
6206 def __init__(self, mesh, geom=0, algoName="Projection_2D"):
6207 Mesh_Algorithm.__init__(self)
6208 self.Create(mesh, geom, algoName)
6210 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
6211 # a mesh pattern is taken, and, optionally, the association of vertices
6212 # between the source face and the target face (to which a hypothesis is assigned)
6213 # @param face from which the mesh pattern is taken
6214 # @param mesh from which the mesh pattern is taken (optional)
6215 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
6216 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
6217 # to associate with \a srcV1 (optional)
6218 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
6219 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
6220 # to associate with \a srcV2 (optional)
6221 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
6222 # the same parameters, else (default) - forces the creation a new one
6224 # Note: all association vertices must belong to one edge of a face
6225 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
6226 srcV2=None, tgtV2=None, UseExisting=0):
6227 for geom in [ face, srcV1, tgtV1, srcV2, tgtV2 ]:
6228 AssureGeomPublished( self.mesh, geom )
6229 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
6231 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
6232 hyp.SetSourceFace( face )
6233 if isinstance(mesh, Mesh):
6234 mesh = mesh.GetMesh()
6235 hyp.SetSourceMesh( mesh )
6236 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
6239 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
6240 #def CompareSourceFace(self, hyp, args):
6241 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
6244 # Public class: Mesh_Projection3D
6245 # ------------------------------
6247 ## Defines a projection 3D algorithm
6248 # @ingroup l3_algos_proj
6250 class Mesh_Projection3D(Mesh_Algorithm):
6252 ## Private constructor.
6253 def __init__(self, mesh, geom=0):
6254 Mesh_Algorithm.__init__(self)
6255 self.Create(mesh, geom, "Projection_3D")
6257 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
6258 # the mesh pattern is taken, and, optionally, the association of vertices
6259 # between the source and the target solid (to which a hipothesis is assigned)
6260 # @param solid from where the mesh pattern is taken
6261 # @param mesh from where the mesh pattern is taken (optional)
6262 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
6263 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
6264 # to associate with \a srcV1 (optional)
6265 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
6266 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
6267 # to associate with \a srcV2 (optional)
6268 # @param UseExisting - if ==true - searches for the existing hypothesis created with
6269 # the same parameters, else (default) - creates a new one
6271 # Note: association vertices must belong to one edge of a solid
6272 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
6273 srcV2=0, tgtV2=0, UseExisting=0):
6274 for geom in [ solid, srcV1, tgtV1, srcV2, tgtV2 ]:
6275 AssureGeomPublished( self.mesh, geom )
6276 hyp = self.Hypothesis("ProjectionSource3D",
6277 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
6279 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
6280 hyp.SetSource3DShape( solid )
6281 if not mesh is None and isinstance(mesh, Mesh):
6282 mesh = mesh.GetMesh()
6283 hyp.SetSourceMesh( mesh )
6284 if srcV1 and srcV2 and tgtV1 and tgtV2:
6285 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
6286 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
6289 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
6290 #def CompareSourceShape3D(self, hyp, args):
6291 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
6295 # Public class: Mesh_Prism
6296 # ------------------------
6298 ## Defines a 3D extrusion algorithm
6299 # @ingroup l3_algos_3dextr
6301 class Mesh_Prism3D(Mesh_Algorithm):
6303 ## Private constructor.
6304 def __init__(self, mesh, geom=0):
6305 Mesh_Algorithm.__init__(self)
6306 self.Create(mesh, geom, "Prism_3D")
6308 # Public class: Mesh_RadialPrism
6309 # -------------------------------
6311 ## Defines a Radial Prism 3D algorithm
6312 # @ingroup l3_algos_radialp
6314 class Mesh_RadialPrism3D(Mesh_Algorithm):
6316 ## Private constructor.
6317 def __init__(self, mesh, geom=0):
6318 Mesh_Algorithm.__init__(self)
6319 self.Create(mesh, geom, "RadialPrism_3D")
6321 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
6322 self.nbLayers = None
6324 ## Return 3D hypothesis holding the 1D one
6325 def Get3DHypothesis(self):
6326 return self.distribHyp
6328 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
6329 # hypothesis. Returns the created hypothesis
6330 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
6331 #print "OwnHypothesis",hypType
6332 if not self.nbLayers is None:
6333 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
6334 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
6335 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
6336 self.mesh.smeshpyD.SetCurrentStudy( None )
6337 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
6338 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
6339 self.distribHyp.SetLayerDistribution( hyp )
6342 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
6343 # prisms to build between the inner and outer shells
6344 # @param n number of layers
6345 # @param UseExisting if ==true - searches for the existing hypothesis created with
6346 # the same parameters, else (default) - creates a new one
6347 def NumberOfLayers(self, n, UseExisting=0):
6348 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
6349 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
6350 CompareMethod=self.CompareNumberOfLayers)
6351 self.nbLayers.SetNumberOfLayers( n )
6352 return self.nbLayers
6354 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
6355 def CompareNumberOfLayers(self, hyp, args):
6356 return IsEqual(hyp.GetNumberOfLayers(), args[0])
6358 ## Defines "LocalLength" hypothesis, specifying the segment length
6359 # to build between the inner and the outer shells
6360 # @param l the length of segments
6361 # @param p the precision of rounding
6362 def LocalLength(self, l, p=1e-07):
6363 hyp = self.OwnHypothesis("LocalLength", [l,p])
6368 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
6369 # prisms to build between the inner and the outer shells.
6370 # @param n the number of layers
6371 # @param s the scale factor (optional)
6372 def NumberOfSegments(self, n, s=[]):
6374 hyp = self.OwnHypothesis("NumberOfSegments", [n])
6376 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
6377 hyp.SetDistrType( 1 )
6378 hyp.SetScaleFactor(s)
6379 hyp.SetNumberOfSegments(n)
6382 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
6383 # to build between the inner and the outer shells with a length that changes in arithmetic progression
6384 # @param start the length of the first segment
6385 # @param end the length of the last segment
6386 def Arithmetic1D(self, start, end ):
6387 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
6388 hyp.SetLength(start, 1)
6389 hyp.SetLength(end , 0)
6392 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
6393 # to build between the inner and the outer shells as geometric length increasing
6394 # @param start for the length of the first segment
6395 # @param end for the length of the last segment
6396 def StartEndLength(self, start, end):
6397 hyp = self.OwnHypothesis("StartEndLength", [start, end])
6398 hyp.SetLength(start, 1)
6399 hyp.SetLength(end , 0)
6402 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
6403 # to build between the inner and outer shells
6404 # @param fineness defines the quality of the mesh within the range [0-1]
6405 def AutomaticLength(self, fineness=0):
6406 hyp = self.OwnHypothesis("AutomaticLength")
6407 hyp.SetFineness( fineness )
6410 # Public class: Mesh_RadialQuadrangle1D2D
6411 # -------------------------------
6413 ## Defines a Radial Quadrangle 1D2D algorithm
6414 # @ingroup l2_algos_radialq
6416 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
6418 ## Private constructor.
6419 def __init__(self, mesh, geom=0):
6420 Mesh_Algorithm.__init__(self)
6421 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
6423 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
6424 self.nbLayers = None
6426 ## Return 2D hypothesis holding the 1D one
6427 def Get2DHypothesis(self):
6428 return self.distribHyp
6430 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
6431 # hypothesis. Returns the created hypothesis
6432 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
6433 #print "OwnHypothesis",hypType
6435 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
6436 if self.distribHyp is None:
6437 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
6439 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
6440 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
6441 self.mesh.smeshpyD.SetCurrentStudy( None )
6442 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
6443 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
6444 self.distribHyp.SetLayerDistribution( hyp )
6447 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
6448 # @param n number of layers
6449 # @param UseExisting if ==true - searches for the existing hypothesis created with
6450 # the same parameters, else (default) - creates a new one
6451 def NumberOfLayers(self, n, UseExisting=0):
6453 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
6454 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
6455 CompareMethod=self.CompareNumberOfLayers)
6456 self.nbLayers.SetNumberOfLayers( n )
6457 return self.nbLayers
6459 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
6460 def CompareNumberOfLayers(self, hyp, args):
6461 return IsEqual(hyp.GetNumberOfLayers(), args[0])
6463 ## Defines "LocalLength" hypothesis, specifying the segment length
6464 # @param l the length of segments
6465 # @param p the precision of rounding
6466 def LocalLength(self, l, p=1e-07):
6467 hyp = self.OwnHypothesis("LocalLength", [l,p])
6472 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
6473 # @param n the number of layers
6474 # @param s the scale factor (optional)
6475 def NumberOfSegments(self, n, s=[]):
6477 hyp = self.OwnHypothesis("NumberOfSegments", [n])
6479 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
6480 hyp.SetDistrType( 1 )
6481 hyp.SetScaleFactor(s)
6482 hyp.SetNumberOfSegments(n)
6485 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
6486 # with a length that changes in arithmetic progression
6487 # @param start the length of the first segment
6488 # @param end the length of the last segment
6489 def Arithmetic1D(self, start, end ):
6490 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
6491 hyp.SetLength(start, 1)
6492 hyp.SetLength(end , 0)
6495 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
6496 # as geometric length increasing
6497 # @param start for the length of the first segment
6498 # @param end for the length of the last segment
6499 def StartEndLength(self, start, end):
6500 hyp = self.OwnHypothesis("StartEndLength", [start, end])
6501 hyp.SetLength(start, 1)
6502 hyp.SetLength(end , 0)
6505 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
6506 # @param fineness defines the quality of the mesh within the range [0-1]
6507 def AutomaticLength(self, fineness=0):
6508 hyp = self.OwnHypothesis("AutomaticLength")
6509 hyp.SetFineness( fineness )
6513 # Public class: Mesh_UseExistingElements
6514 # --------------------------------------
6515 ## Defines a Radial Quadrangle 1D2D algorithm
6516 # @ingroup l3_algos_basic
6518 class Mesh_UseExistingElements(Mesh_Algorithm):
6520 def __init__(self, dim, mesh, geom=0):
6522 self.Create(mesh, geom, "Import_1D")
6524 self.Create(mesh, geom, "Import_1D2D")
6527 ## Defines "Source edges" hypothesis, specifying groups of edges to import
6528 # @param groups list of groups of edges
6529 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
6530 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
6531 # @param UseExisting if ==true - searches for the existing hypothesis created with
6532 # the same parameters, else (default) - creates a new one
6533 def SourceEdges(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
6534 if self.algo.GetName() != "Import_1D":
6535 raise ValueError, "algoritm dimension mismatch"
6536 for group in groups:
6537 AssureGeomPublished( self.mesh, group )
6538 hyp = self.Hypothesis("ImportSource1D", [groups, toCopyMesh, toCopyGroups],
6539 UseExisting=UseExisting, CompareMethod=self._compareHyp)
6540 hyp.SetSourceEdges(groups)
6541 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
6544 ## Defines "Source faces" hypothesis, specifying groups of faces to import
6545 # @param groups list of groups of faces
6546 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
6547 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
6548 # @param UseExisting if ==true - searches for the existing hypothesis created with
6549 # the same parameters, else (default) - creates a new one
6550 def SourceFaces(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
6551 if self.algo.GetName() == "Import_1D":
6552 raise ValueError, "algoritm dimension mismatch"
6553 for group in groups:
6554 AssureGeomPublished( self.mesh, group )
6555 hyp = self.Hypothesis("ImportSource2D", [groups, toCopyMesh, toCopyGroups],
6556 UseExisting=UseExisting, CompareMethod=self._compareHyp)
6557 hyp.SetSourceFaces(groups)
6558 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
6561 def _compareHyp(self,hyp,args):
6562 if hasattr( hyp, "GetSourceEdges"):
6563 entries = hyp.GetSourceEdges()
6565 entries = hyp.GetSourceFaces()
6567 toCopyMesh,toCopyGroups = hyp.GetCopySourceMesh()
6568 if len(entries)==len(groups) and toCopyMesh==args[1] and toCopyGroups==args[2]:
6570 study = self.mesh.smeshpyD.GetCurrentStudy()
6573 ior = salome.orb.object_to_string(g)
6574 sobj = study.FindObjectIOR(ior)
6575 if sobj: entries2.append( sobj.GetID() )
6580 return entries == entries2
6583 # Public class: Mesh_Cartesian_3D
6584 # --------------------------------------
6585 ## Defines a Body Fitting 3D algorithm
6586 # @ingroup l3_algos_basic
6588 class Mesh_Cartesian_3D(Mesh_Algorithm):
6590 def __init__(self, mesh, geom=0):
6591 self.Create(mesh, geom, "Cartesian_3D")
6595 ## Defines "Body Fitting parameters" hypothesis
6596 # @param xGridDef is definition of the grid along the X asix.
6597 # It can be in either of two following forms:
6598 # - Explicit coordinates of nodes, e.g. [-1.5, 0.0, 3.1] or range( -100,200,10)
6599 # - Functions f(t) defining grid spacing at each point on grid axis. If there are
6600 # several functions, they must be accompanied by relative coordinates of
6601 # points dividing the whole shape into ranges where the functions apply; points
6602 # coodrinates should vary within (0.0, 1.0) range. Parameter \a t of the spacing
6603 # function f(t) varies from 0.0 to 1.0 witin a shape range.
6605 # - "10.5" - defines a grid with a constant spacing
6606 # - [["1", "1+10*t", "11"] [0.1, 0.6]] - defines different spacing in 3 ranges.
6607 # @param yGridDef defines the grid along the Y asix the same way as \a xGridDef does
6608 # @param zGridDef defines the grid along the Z asix the same way as \a xGridDef does
6609 # @param sizeThreshold (> 1.0) defines a minimal size of a polyhedron so that
6610 # a polyhedron of size less than hexSize/sizeThreshold is not created
6611 # @param UseExisting if ==true - searches for the existing hypothesis created with
6612 # the same parameters, else (default) - creates a new one
6613 def SetGrid(self, xGridDef, yGridDef, zGridDef, sizeThreshold=4.0, UseExisting=False):
6615 self.hyp = self.Hypothesis("CartesianParameters3D",
6616 [xGridDef, yGridDef, zGridDef, sizeThreshold],
6617 UseExisting=UseExisting, CompareMethod=self._compareHyp)
6618 if not self.mesh.IsUsedHypothesis( self.hyp, self.geom ):
6619 self.mesh.AddHypothesis( self.hyp, self.geom )
6621 for axis, gridDef in enumerate( [xGridDef, yGridDef, zGridDef]):
6622 if not gridDef: raise ValueError, "Empty grid definition"
6623 if isinstance( gridDef, str ):
6624 self.hyp.SetGridSpacing( [gridDef], [], axis )
6625 elif isinstance( gridDef[0], str ):
6626 self.hyp.SetGridSpacing( gridDef, [], axis )
6627 elif isinstance( gridDef[0], int ) or \
6628 isinstance( gridDef[0], float ):
6629 self.hyp.SetGrid(gridDef, axis )
6631 self.hyp.SetGridSpacing( gridDef[0], gridDef[1], axis )
6632 self.hyp.SetSizeThreshold( sizeThreshold )
6635 def _compareHyp(self,hyp,args):
6636 # not implemented yet
6639 # Public class: Mesh_UseExisting
6640 # -------------------------------
6641 class Mesh_UseExisting(Mesh_Algorithm):
6643 def __init__(self, dim, mesh, geom=0):
6645 self.Create(mesh, geom, "UseExisting_1D")
6647 self.Create(mesh, geom, "UseExisting_2D")
6650 import salome_notebook
6651 notebook = salome_notebook.notebook
6653 ##Return values of the notebook variables
6654 def ParseParameters(last, nbParams,nbParam, value):
6658 listSize = len(last)
6659 for n in range(0,nbParams):
6661 if counter < listSize:
6662 strResult = strResult + last[counter]
6664 strResult = strResult + ""
6666 if isinstance(value, str):
6667 if notebook.isVariable(value):
6668 result = notebook.get(value)
6669 strResult=strResult+value
6671 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
6673 strResult=strResult+str(value)
6675 if nbParams - 1 != counter:
6676 strResult=strResult+var_separator #":"
6678 return result, strResult
6680 #Wrapper class for StdMeshers_LocalLength hypothesis
6681 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
6683 ## Set Length parameter value
6684 # @param length numerical value or name of variable from notebook
6685 def SetLength(self, length):
6686 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
6687 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6688 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
6690 ## Set Precision parameter value
6691 # @param precision numerical value or name of variable from notebook
6692 def SetPrecision(self, precision):
6693 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
6694 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6695 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
6697 #Registering the new proxy for LocalLength
6698 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
6701 #Wrapper class for StdMeshers_LayerDistribution hypothesis
6702 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
6704 def SetLayerDistribution(self, hypo):
6705 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
6706 hypo.ClearParameters();
6707 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
6709 #Registering the new proxy for LayerDistribution
6710 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
6712 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
6713 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
6715 ## Set Length parameter value
6716 # @param length numerical value or name of variable from notebook
6717 def SetLength(self, length):
6718 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
6719 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
6720 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
6722 #Registering the new proxy for SegmentLengthAroundVertex
6723 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
6726 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
6727 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
6729 ## Set Length parameter value
6730 # @param length numerical value or name of variable from notebook
6731 # @param isStart true is length is Start Length, otherwise false
6732 def SetLength(self, length, isStart):
6736 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
6737 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
6738 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
6740 #Registering the new proxy for Arithmetic1D
6741 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
6743 #Wrapper class for StdMeshers_Deflection1D hypothesis
6744 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
6746 ## Set Deflection parameter value
6747 # @param deflection numerical value or name of variable from notebook
6748 def SetDeflection(self, deflection):
6749 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
6750 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
6751 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
6753 #Registering the new proxy for Deflection1D
6754 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
6756 #Wrapper class for StdMeshers_StartEndLength hypothesis
6757 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
6759 ## Set Length parameter value
6760 # @param length numerical value or name of variable from notebook
6761 # @param isStart true is length is Start Length, otherwise false
6762 def SetLength(self, length, isStart):
6766 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
6767 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
6768 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
6770 #Registering the new proxy for StartEndLength
6771 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
6773 #Wrapper class for StdMeshers_MaxElementArea hypothesis
6774 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
6776 ## Set Max Element Area parameter value
6777 # @param area numerical value or name of variable from notebook
6778 def SetMaxElementArea(self, area):
6779 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
6780 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
6781 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
6783 #Registering the new proxy for MaxElementArea
6784 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
6787 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
6788 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
6790 ## Set Max Element Volume parameter value
6791 # @param volume numerical value or name of variable from notebook
6792 def SetMaxElementVolume(self, volume):
6793 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
6794 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
6795 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
6797 #Registering the new proxy for MaxElementVolume
6798 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
6801 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
6802 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
6804 ## Set Number Of Layers parameter value
6805 # @param nbLayers numerical value or name of variable from notebook
6806 def SetNumberOfLayers(self, nbLayers):
6807 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
6808 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
6809 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
6811 #Registering the new proxy for NumberOfLayers
6812 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
6814 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
6815 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
6817 ## Set Number Of Segments parameter value
6818 # @param nbSeg numerical value or name of variable from notebook
6819 def SetNumberOfSegments(self, nbSeg):
6820 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
6821 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
6822 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6823 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
6825 ## Set Scale Factor parameter value
6826 # @param factor numerical value or name of variable from notebook
6827 def SetScaleFactor(self, factor):
6828 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
6829 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6830 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
6832 #Registering the new proxy for NumberOfSegments
6833 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
6835 if not noNETGENPlugin:
6836 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
6837 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
6839 ## Set Max Size parameter value
6840 # @param maxsize numerical value or name of variable from notebook
6841 def SetMaxSize(self, maxsize):
6842 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6843 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
6844 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6845 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
6847 ## Set Growth Rate parameter value
6848 # @param value numerical value or name of variable from notebook
6849 def SetGrowthRate(self, value):
6850 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6851 value, parameters = ParseParameters(lastParameters,4,2,value)
6852 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6853 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
6855 ## Set Number of Segments per Edge parameter value
6856 # @param value numerical value or name of variable from notebook
6857 def SetNbSegPerEdge(self, value):
6858 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6859 value, parameters = ParseParameters(lastParameters,4,3,value)
6860 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6861 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
6863 ## Set Number of Segments per Radius parameter value
6864 # @param value numerical value or name of variable from notebook
6865 def SetNbSegPerRadius(self, value):
6866 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6867 value, parameters = ParseParameters(lastParameters,4,4,value)
6868 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6869 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
6871 #Registering the new proxy for NETGENPlugin_Hypothesis
6872 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
6875 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
6876 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
6879 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
6880 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
6882 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
6883 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
6885 ## Set Number of Segments parameter value
6886 # @param nbSeg numerical value or name of variable from notebook
6887 def SetNumberOfSegments(self, nbSeg):
6888 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6889 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
6890 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6891 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
6893 ## Set Local Length parameter value
6894 # @param length numerical value or name of variable from notebook
6895 def SetLocalLength(self, length):
6896 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6897 length, parameters = ParseParameters(lastParameters,2,1,length)
6898 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6899 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
6901 ## Set Max Element Area parameter value
6902 # @param area numerical value or name of variable from notebook
6903 def SetMaxElementArea(self, area):
6904 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6905 area, parameters = ParseParameters(lastParameters,2,2,area)
6906 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6907 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
6909 def LengthFromEdges(self):
6910 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6912 value, parameters = ParseParameters(lastParameters,2,2,value)
6913 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6914 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
6916 #Registering the new proxy for NETGEN_SimpleParameters_2D
6917 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
6920 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
6921 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
6922 ## Set Max Element Volume parameter value
6923 # @param volume numerical value or name of variable from notebook
6924 def SetMaxElementVolume(self, volume):
6925 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6926 volume, parameters = ParseParameters(lastParameters,3,3,volume)
6927 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6928 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
6930 def LengthFromFaces(self):
6931 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6933 value, parameters = ParseParameters(lastParameters,3,3,value)
6934 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6935 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
6937 #Registering the new proxy for NETGEN_SimpleParameters_3D
6938 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
6940 pass # if not noNETGENPlugin:
6942 class Pattern(SMESH._objref_SMESH_Pattern):
6944 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
6946 if isinstance(theNodeIndexOnKeyPoint1,str):
6948 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
6950 theNodeIndexOnKeyPoint1 -= 1
6951 theMesh.SetParameters(Parameters)
6952 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
6954 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
6957 if isinstance(theNode000Index,str):
6959 if isinstance(theNode001Index,str):
6961 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
6963 theNode000Index -= 1
6965 theNode001Index -= 1
6966 theMesh.SetParameters(Parameters)
6967 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
6969 #Registering the new proxy for Pattern
6970 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)