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 ## Sets the current study and Geometry component
544 # @ingroup l1_auxiliary
545 def init_smesh(self,theStudy,geompyD):
546 self.SetCurrentStudy(theStudy,geompyD)
548 ## Creates an empty Mesh. This mesh can have an underlying geometry.
549 # @param obj the Geometrical object on which the mesh is built. If not defined,
550 # the mesh will have no underlying geometry.
551 # @param name the name for the new mesh.
552 # @return an instance of Mesh class.
553 # @ingroup l2_construct
554 def Mesh(self, obj=0, name=0):
555 if isinstance(obj,str):
557 return Mesh(self,self.geompyD,obj,name)
559 ## Returns a long value from enumeration
560 # Should be used for SMESH.FunctorType enumeration
561 # @ingroup l1_controls
562 def EnumToLong(self,theItem):
565 ## Returns a string representation of the color.
566 # To be used with filters.
567 # @param c color value (SALOMEDS.Color)
568 # @ingroup l1_controls
569 def ColorToString(self,c):
571 if isinstance(c, SALOMEDS.Color):
572 val = "%s;%s;%s" % (c.R, c.G, c.B)
573 elif isinstance(c, str):
576 raise ValueError, "Color value should be of string or SALOMEDS.Color type"
579 ## Gets PointStruct from vertex
580 # @param theVertex a GEOM object(vertex)
581 # @return SMESH.PointStruct
582 # @ingroup l1_auxiliary
583 def GetPointStruct(self,theVertex):
584 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
585 return PointStruct(x,y,z)
587 ## Gets DirStruct from vector
588 # @param theVector a GEOM object(vector)
589 # @return SMESH.DirStruct
590 # @ingroup l1_auxiliary
591 def GetDirStruct(self,theVector):
592 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
593 if(len(vertices) != 2):
594 print "Error: vector object is incorrect."
596 p1 = self.geompyD.PointCoordinates(vertices[0])
597 p2 = self.geompyD.PointCoordinates(vertices[1])
598 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
599 dirst = DirStruct(pnt)
602 ## Makes DirStruct from a triplet
603 # @param x,y,z vector components
604 # @return SMESH.DirStruct
605 # @ingroup l1_auxiliary
606 def MakeDirStruct(self,x,y,z):
607 pnt = PointStruct(x,y,z)
608 return DirStruct(pnt)
610 ## Get AxisStruct from object
611 # @param theObj a GEOM object (line or plane)
612 # @return SMESH.AxisStruct
613 # @ingroup l1_auxiliary
614 def GetAxisStruct(self,theObj):
615 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
617 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
618 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
619 vertex1 = self.geompyD.PointCoordinates(vertex1)
620 vertex2 = self.geompyD.PointCoordinates(vertex2)
621 vertex3 = self.geompyD.PointCoordinates(vertex3)
622 vertex4 = self.geompyD.PointCoordinates(vertex4)
623 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
624 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
625 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] ]
626 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
628 elif len(edges) == 1:
629 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
630 p1 = self.geompyD.PointCoordinates( vertex1 )
631 p2 = self.geompyD.PointCoordinates( vertex2 )
632 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
636 # From SMESH_Gen interface:
637 # ------------------------
639 ## Sets the given name to the object
640 # @param obj the object to rename
641 # @param name a new object name
642 # @ingroup l1_auxiliary
643 def SetName(self, obj, name):
644 if isinstance( obj, Mesh ):
646 elif isinstance( obj, Mesh_Algorithm ):
647 obj = obj.GetAlgorithm()
648 ior = salome.orb.object_to_string(obj)
649 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
651 ## Sets the current mode
652 # @ingroup l1_auxiliary
653 def SetEmbeddedMode( self,theMode ):
654 #self.SetEmbeddedMode(theMode)
655 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
657 ## Gets the current mode
658 # @ingroup l1_auxiliary
659 def IsEmbeddedMode(self):
660 #return self.IsEmbeddedMode()
661 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
663 ## Sets the current study
664 # @ingroup l1_auxiliary
665 def SetCurrentStudy( self, theStudy, geompyD = None ):
666 #self.SetCurrentStudy(theStudy)
669 geompyD = geompy.geom
672 self.SetGeomEngine(geompyD)
673 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
675 ## Gets the current study
676 # @ingroup l1_auxiliary
677 def GetCurrentStudy(self):
678 #return self.GetCurrentStudy()
679 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
681 ## Creates a Mesh object importing data from the given UNV file
682 # @return an instance of Mesh class
684 def CreateMeshesFromUNV( self,theFileName ):
685 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
686 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
689 ## Creates a Mesh object(s) importing data from the given MED file
690 # @return a list of Mesh class instances
692 def CreateMeshesFromMED( self,theFileName ):
693 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
695 for iMesh in range(len(aSmeshMeshes)) :
696 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
697 aMeshes.append(aMesh)
698 return aMeshes, aStatus
700 ## Creates a Mesh object(s) importing data from the given SAUV file
701 # @return a list of Mesh class instances
703 def CreateMeshesFromSAUV( self,theFileName ):
704 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromSAUV(self,theFileName)
706 for iMesh in range(len(aSmeshMeshes)) :
707 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
708 aMeshes.append(aMesh)
709 return aMeshes, aStatus
711 ## Creates a Mesh object importing data from the given STL file
712 # @return an instance of Mesh class
714 def CreateMeshesFromSTL( self, theFileName ):
715 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
716 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
719 ## Creates Mesh objects importing data from the given CGNS file
720 # @return an instance of Mesh class
722 def CreateMeshesFromCGNS( self, theFileName ):
723 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromCGNS(self,theFileName)
725 for iMesh in range(len(aSmeshMeshes)) :
726 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
727 aMeshes.append(aMesh)
728 return aMeshes, aStatus
730 ## Concatenate the given meshes into one mesh.
731 # @return an instance of Mesh class
732 # @param meshes the meshes to combine into one mesh
733 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
734 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
735 # @param mergeTolerance tolerance for merging nodes
736 # @param allGroups forces creation of groups of all elements
737 def Concatenate( self, meshes, uniteIdenticalGroups,
738 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
739 mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
740 for i,m in enumerate(meshes):
741 if isinstance(m, Mesh):
742 meshes[i] = m.GetMesh()
744 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
745 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
747 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
748 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
749 aSmeshMesh.SetParameters(Parameters)
750 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
753 ## Create a mesh by copying a part of another mesh.
754 # @param meshPart a part of mesh to copy, either a Mesh, a sub-mesh or a group;
755 # to copy nodes or elements not contained in any mesh object,
756 # pass result of Mesh.GetIDSource( list_of_ids, type ) as meshPart
757 # @param meshName a name of the new mesh
758 # @param toCopyGroups to create in the new mesh groups the copied elements belongs to
759 # @param toKeepIDs to preserve IDs of the copied elements or not
760 # @return an instance of Mesh class
761 def CopyMesh( self, meshPart, meshName, toCopyGroups=False, toKeepIDs=False):
762 if (isinstance( meshPart, Mesh )):
763 meshPart = meshPart.GetMesh()
764 mesh = SMESH._objref_SMESH_Gen.CopyMesh( self,meshPart,meshName,toCopyGroups,toKeepIDs )
765 return Mesh(self, self.geompyD, mesh)
767 ## From SMESH_Gen interface
768 # @return the list of integer values
769 # @ingroup l1_auxiliary
770 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
771 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
773 ## From SMESH_Gen interface. Creates a pattern
774 # @return an instance of SMESH_Pattern
776 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
777 # @ingroup l2_modif_patterns
778 def GetPattern(self):
779 return SMESH._objref_SMESH_Gen.GetPattern(self)
781 ## Sets number of segments per diagonal of boundary box of geometry by which
782 # default segment length of appropriate 1D hypotheses is defined.
783 # Default value is 10
784 # @ingroup l1_auxiliary
785 def SetBoundaryBoxSegmentation(self, nbSegments):
786 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
788 # Filtering. Auxiliary functions:
789 # ------------------------------
791 ## Creates an empty criterion
792 # @return SMESH.Filter.Criterion
793 # @ingroup l1_controls
794 def GetEmptyCriterion(self):
795 Type = self.EnumToLong(FT_Undefined)
796 Compare = self.EnumToLong(FT_Undefined)
800 UnaryOp = self.EnumToLong(FT_Undefined)
801 BinaryOp = self.EnumToLong(FT_Undefined)
804 Precision = -1 ##@1e-07
805 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
806 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
808 ## Creates a criterion by the given parameters
809 # \n Criterion structures allow to define complex filters by combining them with logical operations (AND / OR) (see example below)
810 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
811 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
812 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
813 # @param Treshold the threshold value (range of ids as string, shape, numeric)
814 # @param UnaryOp FT_LogicalNOT or FT_Undefined
815 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
816 # FT_Undefined (must be for the last criterion of all criteria)
817 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
818 # FT_LyingOnGeom, FT_CoplanarFaces criteria
819 # @return SMESH.Filter.Criterion
821 # <a href="../tui_filters_page.html#combining_filters">Example of Criteria usage</a>
822 # @ingroup l1_controls
823 def GetCriterion(self,elementType,
825 Compare = FT_EqualTo,
827 UnaryOp=FT_Undefined,
828 BinaryOp=FT_Undefined,
830 if not CritType in SMESH.FunctorType._items:
831 raise TypeError, "CritType should be of SMESH.FunctorType"
832 aCriterion = self.GetEmptyCriterion()
833 aCriterion.TypeOfElement = elementType
834 aCriterion.Type = self.EnumToLong(CritType)
835 aCriterion.Tolerance = Tolerance
839 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
840 aCriterion.Compare = self.EnumToLong(Compare)
841 elif Compare == "=" or Compare == "==":
842 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
844 aCriterion.Compare = self.EnumToLong(FT_LessThan)
846 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
847 elif Compare != FT_Undefined:
848 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
851 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
852 FT_BelongToCylinder, FT_LyingOnGeom]:
853 # Checks the treshold
854 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
855 aCriterion.ThresholdStr = GetName(aTreshold)
856 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
858 print "Error: The treshold should be a shape."
860 if isinstance(UnaryOp,float):
861 aCriterion.Tolerance = UnaryOp
862 UnaryOp = FT_Undefined
864 elif CritType == FT_RangeOfIds:
865 # Checks the treshold
866 if isinstance(aTreshold, str):
867 aCriterion.ThresholdStr = aTreshold
869 print "Error: The treshold should be a string."
871 elif CritType == FT_CoplanarFaces:
872 # Checks the treshold
873 if isinstance(aTreshold, int):
874 aCriterion.ThresholdID = "%s"%aTreshold
875 elif isinstance(aTreshold, str):
878 raise ValueError, "Invalid ID of mesh face: '%s'"%aTreshold
879 aCriterion.ThresholdID = aTreshold
882 "The treshold should be an ID of mesh face and not '%s'"%aTreshold
883 elif CritType == FT_ElemGeomType:
884 # Checks the treshold
886 aCriterion.Threshold = self.EnumToLong(aTreshold)
887 assert( aTreshold in SMESH.GeometryType._items )
889 if isinstance(aTreshold, int):
890 aCriterion.Threshold = aTreshold
892 print "Error: The treshold should be an integer or SMESH.GeometryType."
896 elif CritType == FT_GroupColor:
897 # Checks the treshold
899 aCriterion.ThresholdStr = self.ColorToString(aTreshold)
901 print "Error: The threshold value should be of SALOMEDS.Color type"
904 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_FreeNodes, FT_FreeFaces,
905 FT_LinearOrQuadratic, FT_BadOrientedVolume,
906 FT_BareBorderFace, FT_BareBorderVolume,
907 FT_OverConstrainedFace, FT_OverConstrainedVolume,
908 FT_EqualNodes,FT_EqualEdges,FT_EqualFaces,FT_EqualVolumes ]:
909 # At this point the treshold is unnecessary
910 if aTreshold == FT_LogicalNOT:
911 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
912 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
913 aCriterion.BinaryOp = aTreshold
917 aTreshold = float(aTreshold)
918 aCriterion.Threshold = aTreshold
920 print "Error: The treshold should be a number."
923 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
924 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
926 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
927 aCriterion.BinaryOp = self.EnumToLong(Treshold)
929 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
930 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
932 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
933 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
937 ## Creates a filter with the given parameters
938 # @param elementType the type of elements in the group
939 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
940 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
941 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
942 # @param UnaryOp FT_LogicalNOT or FT_Undefined
943 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
944 # FT_LyingOnGeom, FT_CoplanarFaces and FT_EqualNodes criteria
945 # @return SMESH_Filter
947 # <a href="../tui_filters_page.html#tui_filters">Example of Filters usage</a>
948 # @ingroup l1_controls
949 def GetFilter(self,elementType,
950 CritType=FT_Undefined,
953 UnaryOp=FT_Undefined,
955 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined,Tolerance)
956 aFilterMgr = self.CreateFilterManager()
957 aFilter = aFilterMgr.CreateFilter()
959 aCriteria.append(aCriterion)
960 aFilter.SetCriteria(aCriteria)
961 aFilterMgr.UnRegister()
964 ## Creates a filter from criteria
965 # @param criteria a list of criteria
966 # @return SMESH_Filter
968 # <a href="../tui_filters_page.html#tui_filters">Example of Filters usage</a>
969 # @ingroup l1_controls
970 def GetFilterFromCriteria(self,criteria):
971 aFilterMgr = self.CreateFilterManager()
972 aFilter = aFilterMgr.CreateFilter()
973 aFilter.SetCriteria(criteria)
974 aFilterMgr.UnRegister()
977 ## Creates a numerical functor by its type
978 # @param theCriterion FT_...; functor type
979 # @return SMESH_NumericalFunctor
980 # @ingroup l1_controls
981 def GetFunctor(self,theCriterion):
982 aFilterMgr = self.CreateFilterManager()
983 if theCriterion == FT_AspectRatio:
984 return aFilterMgr.CreateAspectRatio()
985 elif theCriterion == FT_AspectRatio3D:
986 return aFilterMgr.CreateAspectRatio3D()
987 elif theCriterion == FT_Warping:
988 return aFilterMgr.CreateWarping()
989 elif theCriterion == FT_MinimumAngle:
990 return aFilterMgr.CreateMinimumAngle()
991 elif theCriterion == FT_Taper:
992 return aFilterMgr.CreateTaper()
993 elif theCriterion == FT_Skew:
994 return aFilterMgr.CreateSkew()
995 elif theCriterion == FT_Area:
996 return aFilterMgr.CreateArea()
997 elif theCriterion == FT_Volume3D:
998 return aFilterMgr.CreateVolume3D()
999 elif theCriterion == FT_MaxElementLength2D:
1000 return aFilterMgr.CreateMaxElementLength2D()
1001 elif theCriterion == FT_MaxElementLength3D:
1002 return aFilterMgr.CreateMaxElementLength3D()
1003 elif theCriterion == FT_MultiConnection:
1004 return aFilterMgr.CreateMultiConnection()
1005 elif theCriterion == FT_MultiConnection2D:
1006 return aFilterMgr.CreateMultiConnection2D()
1007 elif theCriterion == FT_Length:
1008 return aFilterMgr.CreateLength()
1009 elif theCriterion == FT_Length2D:
1010 return aFilterMgr.CreateLength2D()
1012 print "Error: given parameter is not numerucal functor type."
1014 ## Creates hypothesis
1015 # @param theHType mesh hypothesis type (string)
1016 # @param theLibName mesh plug-in library name
1017 # @return created hypothesis instance
1018 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
1019 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
1021 ## Gets the mesh statistic
1022 # @return dictionary "element type" - "count of elements"
1023 # @ingroup l1_meshinfo
1024 def GetMeshInfo(self, obj):
1025 if isinstance( obj, Mesh ):
1028 if hasattr(obj, "GetMeshInfo"):
1029 values = obj.GetMeshInfo()
1030 for i in range(SMESH.Entity_Last._v):
1031 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
1035 ## Get minimum distance between two objects
1037 # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
1038 # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
1040 # @param src1 first source object
1041 # @param src2 second source object
1042 # @param id1 node/element id from the first source
1043 # @param id2 node/element id from the second (or first) source
1044 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
1045 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
1046 # @return minimum distance value
1047 # @sa GetMinDistance()
1048 # @ingroup l1_measurements
1049 def MinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
1050 result = self.GetMinDistance(src1, src2, id1, id2, isElem1, isElem2)
1054 result = result.value
1057 ## Get measure structure specifying minimum distance data between two objects
1059 # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
1060 # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
1062 # @param src1 first source object
1063 # @param src2 second source object
1064 # @param id1 node/element id from the first source
1065 # @param id2 node/element id from the second (or first) source
1066 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
1067 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
1068 # @return Measure structure or None if input data is invalid
1070 # @ingroup l1_measurements
1071 def GetMinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
1072 if isinstance(src1, Mesh): src1 = src1.mesh
1073 if isinstance(src2, Mesh): src2 = src2.mesh
1074 if src2 is None and id2 != 0: src2 = src1
1075 if not hasattr(src1, "_narrow"): return None
1076 src1 = src1._narrow(SMESH.SMESH_IDSource)
1077 if not src1: return None
1080 e = m.GetMeshEditor()
1082 src1 = e.MakeIDSource([id1], SMESH.FACE)
1084 src1 = e.MakeIDSource([id1], SMESH.NODE)
1086 if hasattr(src2, "_narrow"):
1087 src2 = src2._narrow(SMESH.SMESH_IDSource)
1088 if src2 and id2 != 0:
1090 e = m.GetMeshEditor()
1092 src2 = e.MakeIDSource([id2], SMESH.FACE)
1094 src2 = e.MakeIDSource([id2], SMESH.NODE)
1097 aMeasurements = self.CreateMeasurements()
1098 result = aMeasurements.MinDistance(src1, src2)
1099 aMeasurements.UnRegister()
1102 ## Get bounding box of the specified object(s)
1103 # @param objects single source object or list of source objects
1104 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
1105 # @sa GetBoundingBox()
1106 # @ingroup l1_measurements
1107 def BoundingBox(self, objects):
1108 result = self.GetBoundingBox(objects)
1112 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
1115 ## Get measure structure specifying bounding box data of the specified object(s)
1116 # @param objects single source object or list of source objects
1117 # @return Measure structure
1119 # @ingroup l1_measurements
1120 def GetBoundingBox(self, objects):
1121 if isinstance(objects, tuple):
1122 objects = list(objects)
1123 if not isinstance(objects, list):
1127 if isinstance(o, Mesh):
1128 srclist.append(o.mesh)
1129 elif hasattr(o, "_narrow"):
1130 src = o._narrow(SMESH.SMESH_IDSource)
1131 if src: srclist.append(src)
1134 aMeasurements = self.CreateMeasurements()
1135 result = aMeasurements.BoundingBox(srclist)
1136 aMeasurements.UnRegister()
1140 #Registering the new proxy for SMESH_Gen
1141 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
1144 # Public class: Mesh
1145 # ==================
1147 ## This class allows defining and managing a mesh.
1148 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
1149 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
1150 # new nodes and elements and by changing the existing entities), to get information
1151 # about a mesh and to export a mesh into different formats.
1160 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
1161 # sets the GUI name of this mesh to \a name.
1162 # @param smeshpyD an instance of smeshDC class
1163 # @param geompyD an instance of geompyDC class
1164 # @param obj Shape to be meshed or SMESH_Mesh object
1165 # @param name Study name of the mesh
1166 # @ingroup l2_construct
1167 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
1168 self.smeshpyD=smeshpyD
1169 self.geompyD=geompyD
1173 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
1175 # publish geom of mesh (issue 0021122)
1176 if not self.geom.GetStudyEntry():
1177 studyID = smeshpyD.GetCurrentStudy()._get_StudyId()
1178 if studyID != geompyD.myStudyId:
1179 geompyD.init_geom( smeshpyD.GetCurrentStudy())
1181 geo_name = "%s_%s"%(self.geom.GetShapeType(), id(self.geom)%100)
1182 geompyD.addToStudy( self.geom, geo_name )
1183 self.mesh = self.smeshpyD.CreateMesh(self.geom)
1185 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
1188 self.mesh = self.smeshpyD.CreateEmptyMesh()
1190 self.smeshpyD.SetName(self.mesh, name)
1192 self.smeshpyD.SetName(self.mesh, GetName(obj))
1195 self.geom = self.mesh.GetShapeToMesh()
1197 self.editor = self.mesh.GetMeshEditor()
1199 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
1200 # @param theMesh a SMESH_Mesh object
1201 # @ingroup l2_construct
1202 def SetMesh(self, theMesh):
1204 self.geom = self.mesh.GetShapeToMesh()
1206 ## Returns the mesh, that is an instance of SMESH_Mesh interface
1207 # @return a SMESH_Mesh object
1208 # @ingroup l2_construct
1212 ## Gets the name of the mesh
1213 # @return the name of the mesh as a string
1214 # @ingroup l2_construct
1216 name = GetName(self.GetMesh())
1219 ## Sets a name to the mesh
1220 # @param name a new name of the mesh
1221 # @ingroup l2_construct
1222 def SetName(self, name):
1223 self.smeshpyD.SetName(self.GetMesh(), name)
1225 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
1226 # The subMesh object gives access to the IDs of nodes and elements.
1227 # @param geom a geometrical object (shape)
1228 # @param name a name for the submesh
1229 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
1230 # @ingroup l2_submeshes
1231 def GetSubMesh(self, geom, name):
1232 AssureGeomPublished( self, geom, name )
1233 submesh = self.mesh.GetSubMesh( geom, name )
1236 ## Returns the shape associated to the mesh
1237 # @return a GEOM_Object
1238 # @ingroup l2_construct
1242 ## Associates the given shape to the mesh (entails the recreation of the mesh)
1243 # @param geom the shape to be meshed (GEOM_Object)
1244 # @ingroup l2_construct
1245 def SetShape(self, geom):
1246 self.mesh = self.smeshpyD.CreateMesh(geom)
1248 ## Returns true if the hypotheses are defined well
1249 # @param theSubObject a sub-shape of a mesh shape
1250 # @return True or False
1251 # @ingroup l2_construct
1252 def IsReadyToCompute(self, theSubObject):
1253 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
1255 ## Returns errors of hypotheses definition.
1256 # The list of errors is empty if everything is OK.
1257 # @param theSubObject a sub-shape of a mesh shape
1258 # @return a list of errors
1259 # @ingroup l2_construct
1260 def GetAlgoState(self, theSubObject):
1261 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
1263 ## Returns a geometrical object on which the given element was built.
1264 # The returned geometrical object, if not nil, is either found in the
1265 # study or published by this method with the given name
1266 # @param theElementID the id of the mesh element
1267 # @param theGeomName the user-defined name of the geometrical object
1268 # @return GEOM::GEOM_Object instance
1269 # @ingroup l2_construct
1270 def GetGeometryByMeshElement(self, theElementID, theGeomName):
1271 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
1273 ## Returns the mesh dimension depending on the dimension of the underlying shape
1274 # @return mesh dimension as an integer value [0,3]
1275 # @ingroup l1_auxiliary
1276 def MeshDimension(self):
1277 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
1278 if len( shells ) > 0 :
1280 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
1282 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
1288 ## Creates a segment discretization 1D algorithm.
1289 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
1290 # \n If the optional \a geom parameter is not set, this algorithm is global.
1291 # Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1292 # @param algo the type of the required algorithm. Possible values are:
1294 # - smesh.PYTHON for discretization via a python function,
1295 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
1296 # @param geom If defined is the sub-shape to be meshed
1297 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
1298 # @ingroup l3_algos_basic
1299 def Segment(self, algo=REGULAR, geom=0):
1300 ## if Segment(geom) is called by mistake
1301 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
1302 algo, geom = geom, algo
1303 if not algo: algo = REGULAR
1306 return Mesh_Segment(self, geom)
1307 elif algo == PYTHON:
1308 return Mesh_Segment_Python(self, geom)
1309 elif algo == COMPOSITE:
1310 return Mesh_CompositeSegment(self, geom)
1312 return Mesh_Segment(self, geom)
1314 ## Creates 1D algorithm importing segments conatined in groups of other mesh.
1315 # If the optional \a geom parameter is not set, this algorithm is global.
1316 # Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1317 # @param geom If defined the subshape is to be meshed
1318 # @return an instance of Mesh_UseExistingElements class
1319 # @ingroup l3_algos_basic
1320 def UseExisting1DElements(self, geom=0):
1321 return Mesh_UseExistingElements(1,self, geom)
1323 ## Creates 2D algorithm importing faces conatined in groups of other mesh.
1324 # If the optional \a geom parameter is not set, this algorithm is global.
1325 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1326 # @param geom If defined the sub-shape is to be meshed
1327 # @return an instance of Mesh_UseExistingElements class
1328 # @ingroup l3_algos_basic
1329 def UseExisting2DElements(self, geom=0):
1330 return Mesh_UseExistingElements(2,self, geom)
1332 ## Enables creation of nodes and segments usable by 2D algoritms.
1333 # The added nodes and segments must be bound to edges and vertices by
1334 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
1335 # If the optional \a geom parameter is not set, this algorithm is global.
1336 # \n Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1337 # @param geom the sub-shape to be manually meshed
1338 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
1339 # @ingroup l3_algos_basic
1340 def UseExistingSegments(self, geom=0):
1341 algo = Mesh_UseExisting(1,self,geom)
1342 return algo.GetAlgorithm()
1344 ## Enables creation of nodes and faces usable by 3D algoritms.
1345 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
1346 # and SetMeshElementOnShape()
1347 # If the optional \a geom parameter is not set, this algorithm is global.
1348 # \n Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1349 # @param geom the sub-shape to be manually meshed
1350 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1351 # @ingroup l3_algos_basic
1352 def UseExistingFaces(self, geom=0):
1353 algo = Mesh_UseExisting(2,self,geom)
1354 return algo.GetAlgorithm()
1356 ## Creates a triangle 2D algorithm for faces.
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 algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1360 # @param geom If defined, the sub-shape to be meshed (GEOM_Object)
1361 # @return an instance of Mesh_Triangle algorithm
1362 # @ingroup l3_algos_basic
1363 def Triangle(self, algo=MEFISTO, geom=0):
1364 ## if Triangle(geom) is called by mistake
1365 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1368 return Mesh_Triangle(self, algo, geom)
1370 ## Creates a quadrangle 2D algorithm for faces.
1371 # If the optional \a geom parameter is not set, this algorithm is global.
1372 # \n Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1373 # @param geom If defined, the sub-shape to be meshed (GEOM_Object)
1374 # @param algo values are: smesh.QUADRANGLE || smesh.RADIAL_QUAD
1375 # @return an instance of Mesh_Quadrangle algorithm
1376 # @ingroup l3_algos_basic
1377 def Quadrangle(self, geom=0, algo=QUADRANGLE):
1378 if algo==RADIAL_QUAD:
1379 return Mesh_RadialQuadrangle1D2D(self,geom)
1381 return Mesh_Quadrangle(self, geom)
1383 ## Creates a tetrahedron 3D algorithm for solids.
1384 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1385 # If the optional \a geom parameter is not set, this algorithm is global.
1386 # \n Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1387 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1388 # @param geom If defined, the sub-shape to be meshed (GEOM_Object)
1389 # @return an instance of Mesh_Tetrahedron algorithm
1390 # @ingroup l3_algos_basic
1391 def Tetrahedron(self, algo=NETGEN, geom=0):
1392 ## if Tetrahedron(geom) is called by mistake
1393 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1394 algo, geom = geom, algo
1395 if not algo: algo = NETGEN
1397 return Mesh_Tetrahedron(self, algo, geom)
1399 ## Creates a hexahedron 3D algorithm for solids.
1400 # If the optional \a geom parameter is not set, this algorithm is global.
1401 # \n Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1402 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1403 # @param geom If defined, the sub-shape to be meshed (GEOM_Object)
1404 # @return an instance of Mesh_Hexahedron algorithm
1405 # @ingroup l3_algos_basic
1406 def Hexahedron(self, algo=Hexa, geom=0):
1407 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1408 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1409 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1410 elif geom == 0: algo, geom = Hexa, algo
1411 return Mesh_Hexahedron(self, algo, geom)
1413 ## Deprecated, used only for compatibility!
1414 # @return an instance of Mesh_Netgen algorithm
1415 # @ingroup l3_algos_basic
1416 def Netgen(self, is3D, geom=0):
1417 return Mesh_Netgen(self, is3D, geom)
1419 ## Creates a projection 1D algorithm for edges.
1420 # If the optional \a geom parameter is not set, this algorithm is global.
1421 # Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1422 # @param geom If defined, the sub-shape to be meshed
1423 # @return an instance of Mesh_Projection1D algorithm
1424 # @ingroup l3_algos_proj
1425 def Projection1D(self, geom=0):
1426 return Mesh_Projection1D(self, geom)
1428 ## Creates a projection 1D-2D algorithm for faces.
1429 # If the optional \a geom parameter is not set, this algorithm is global.
1430 # Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1431 # @param geom If defined, the sub-shape to be meshed
1432 # @return an instance of Mesh_Projection2D algorithm
1433 # @ingroup l3_algos_proj
1434 def Projection1D2D(self, geom=0):
1435 return Mesh_Projection2D(self, geom, "Projection_1D2D")
1437 ## Creates a projection 2D algorithm for faces.
1438 # If the optional \a geom parameter is not set, this algorithm is global.
1439 # Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1440 # @param geom If defined, the sub-shape to be meshed
1441 # @return an instance of Mesh_Projection2D algorithm
1442 # @ingroup l3_algos_proj
1443 def Projection2D(self, geom=0):
1444 return Mesh_Projection2D(self, geom, "Projection_2D")
1446 ## Creates a projection 3D algorithm for solids.
1447 # If the optional \a geom parameter is not set, this algorithm is global.
1448 # Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1449 # @param geom If defined, the sub-shape to be meshed
1450 # @return an instance of Mesh_Projection3D algorithm
1451 # @ingroup l3_algos_proj
1452 def Projection3D(self, geom=0):
1453 return Mesh_Projection3D(self, geom)
1455 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1456 # If the optional \a geom parameter is not set, this algorithm is global.
1457 # Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1458 # @param geom If defined, the sub-shape to be meshed
1459 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1460 # @ingroup l3_algos_radialp l3_algos_3dextr
1461 def Prism(self, geom=0):
1465 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1466 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1467 if nbSolids == 0 or nbSolids == nbShells:
1468 return Mesh_Prism3D(self, geom)
1469 return Mesh_RadialPrism3D(self, geom)
1471 ## Creates a "Body Fitted" 3D algorithm for solids, which generates
1472 # 3D structured Cartesian mesh in the internal part of a solid shape
1473 # and polyhedral volumes near the shape boundary.
1474 # If the optional \a geom parameter is not set, this algorithm is global.
1475 # Otherwise, this algorithm defines a submesh based on \a geom sub-shape.
1476 # The algorithm does not support submeshes.
1477 # Generally usage of this algorithm as a local one is useless since
1478 # it does not discretize 1D and 2D sub-shapes in a usual way acceptable
1479 # for other algorithms.
1480 # @param geom If defined, the sub-shape to be meshed
1481 # @return an instance of Mesh_Cartesian_3D algorithm
1482 # @ingroup l3_algos_basic
1483 def BodyFitted(self, geom=0):
1484 return Mesh_Cartesian_3D(self, geom)
1486 ## Evaluates size of prospective mesh on a shape
1487 # @return a list where i-th element is a number of elements of i-th SMESH.EntityType
1488 # To know predicted number of e.g. edges, inquire it this way
1489 # Evaluate()[ EnumToLong( Entity_Edge )]
1490 def Evaluate(self, geom=0):
1491 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1493 geom = self.mesh.GetShapeToMesh()
1496 return self.smeshpyD.Evaluate(self.mesh, geom)
1499 ## Computes the mesh and returns the status of the computation
1500 # @param geom geomtrical shape on which mesh data should be computed
1501 # @param discardModifs if True and the mesh has been edited since
1502 # a last total re-compute and that may prevent successful partial re-compute,
1503 # then the mesh is cleaned before Compute()
1504 # @return True or False
1505 # @ingroup l2_construct
1506 def Compute(self, geom=0, discardModifs=False):
1507 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1509 geom = self.mesh.GetShapeToMesh()
1514 if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693
1516 ok = self.smeshpyD.Compute(self.mesh, geom)
1517 except SALOME.SALOME_Exception, ex:
1518 print "Mesh computation failed, exception caught:"
1519 print " ", ex.details.text
1522 print "Mesh computation failed, exception caught:"
1523 traceback.print_exc()
1527 # Treat compute errors
1528 computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
1529 for err in computeErrors:
1531 if self.mesh.HasShapeToMesh():
1533 mainIOR = salome.orb.object_to_string(geom)
1534 for sname in salome.myStudyManager.GetOpenStudies():
1535 s = salome.myStudyManager.GetStudyByName(sname)
1537 mainSO = s.FindObjectIOR(mainIOR)
1538 if not mainSO: continue
1539 if err.subShapeID == 1:
1540 shapeText = ' on "%s"' % mainSO.GetName()
1541 subIt = s.NewChildIterator(mainSO)
1543 subSO = subIt.Value()
1545 obj = subSO.GetObject()
1546 if not obj: continue
1547 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
1549 ids = go.GetSubShapeIndices()
1550 if len(ids) == 1 and ids[0] == err.subShapeID:
1551 shapeText = ' on "%s"' % subSO.GetName()
1554 shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
1556 shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID)
1558 shapeText = " on subshape #%s" % (err.subShapeID)
1560 shapeText = " on subshape #%s" % (err.subShapeID)
1562 stdErrors = ["OK", #COMPERR_OK
1563 "Invalid input mesh", #COMPERR_BAD_INPUT_MESH
1564 "std::exception", #COMPERR_STD_EXCEPTION
1565 "OCC exception", #COMPERR_OCC_EXCEPTION
1566 "SALOME exception", #COMPERR_SLM_EXCEPTION
1567 "Unknown exception", #COMPERR_EXCEPTION
1568 "Memory allocation problem", #COMPERR_MEMORY_PB
1569 "Algorithm failed", #COMPERR_ALGO_FAILED
1570 "Unexpected geometry"]#COMPERR_BAD_SHAPE
1572 if err.code < len(stdErrors): errText = stdErrors[err.code]
1574 errText = "code %s" % -err.code
1575 if errText: errText += ". "
1576 errText += err.comment
1577 if allReasons != "":allReasons += "\n"
1578 allReasons += '"%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
1582 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1584 if err.isGlobalAlgo:
1592 reason = '%s %sD algorithm is missing' % (glob, dim)
1593 elif err.state == HYP_MISSING:
1594 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1595 % (glob, dim, name, dim))
1596 elif err.state == HYP_NOTCONFORM:
1597 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1598 elif err.state == HYP_BAD_PARAMETER:
1599 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1600 % ( glob, dim, name ))
1601 elif err.state == HYP_BAD_GEOMETRY:
1602 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1603 'geometry' % ( glob, dim, name ))
1605 reason = "For unknown reason."+\
1606 " Revise Mesh.Compute() implementation in smeshDC.py!"
1608 if allReasons != "":allReasons += "\n"
1609 allReasons += reason
1611 if allReasons != "":
1612 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1616 print '"' + GetName(self.mesh) + '"',"has not been computed."
1619 if salome.sg.hasDesktop():
1620 smeshgui = salome.ImportComponentGUI("SMESH")
1621 smeshgui.Init(self.mesh.GetStudyId())
1622 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1623 salome.sg.updateObjBrowser(1)
1627 ## Return submesh objects list in meshing order
1628 # @return list of list of submesh objects
1629 # @ingroup l2_construct
1630 def GetMeshOrder(self):
1631 return self.mesh.GetMeshOrder()
1633 ## Return submesh objects list in meshing order
1634 # @return list of list of submesh objects
1635 # @ingroup l2_construct
1636 def SetMeshOrder(self, submeshes):
1637 return self.mesh.SetMeshOrder(submeshes)
1639 ## Removes all nodes and elements
1640 # @ingroup l2_construct
1643 if salome.sg.hasDesktop():
1644 smeshgui = salome.ImportComponentGUI("SMESH")
1645 smeshgui.Init(self.mesh.GetStudyId())
1646 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1647 salome.sg.updateObjBrowser(1)
1649 ## Removes all nodes and elements of indicated shape
1650 # @ingroup l2_construct
1651 def ClearSubMesh(self, geomId):
1652 self.mesh.ClearSubMesh(geomId)
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 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1660 # @param fineness [0.0,1.0] defines mesh fineness
1661 # @return True or False
1662 # @ingroup l3_algos_basic
1663 def AutomaticTetrahedralization(self, fineness=0):
1664 dim = self.MeshDimension()
1666 self.RemoveGlobalHypotheses()
1667 self.Segment().AutomaticLength(fineness)
1669 self.Triangle().LengthFromEdges()
1672 self.Tetrahedron(NETGEN)
1674 return self.Compute()
1676 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1677 # @param fineness [0.0, 1.0] defines mesh fineness
1678 # @return True or False
1679 # @ingroup l3_algos_basic
1680 def AutomaticHexahedralization(self, fineness=0):
1681 dim = self.MeshDimension()
1682 # assign the hypotheses
1683 self.RemoveGlobalHypotheses()
1684 self.Segment().AutomaticLength(fineness)
1691 return self.Compute()
1693 ## Assigns a hypothesis
1694 # @param hyp a hypothesis to assign
1695 # @param geom a subhape of mesh geometry
1696 # @return SMESH.Hypothesis_Status
1697 # @ingroup l2_hypotheses
1698 def AddHypothesis(self, hyp, geom=0):
1699 if isinstance( hyp, Mesh_Algorithm ):
1700 hyp = hyp.GetAlgorithm()
1705 geom = self.mesh.GetShapeToMesh()
1707 status = self.mesh.AddHypothesis(geom, hyp)
1708 isAlgo = hyp._narrow( SMESH_Algo )
1709 hyp_name = GetName( hyp )
1712 geom_name = GetName( geom )
1713 TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1716 ## Return True if an algorithm of hypothesis is assigned to a given shape
1717 # @param hyp a hypothesis to check
1718 # @param geom a subhape of mesh geometry
1719 # @return True of False
1720 # @ingroup l2_hypotheses
1721 def IsUsedHypothesis(self, hyp, geom):
1722 if not hyp or not geom:
1724 if isinstance( hyp, Mesh_Algorithm ):
1725 hyp = hyp.GetAlgorithm()
1727 hyps = self.GetHypothesisList(geom)
1729 if h.GetId() == hyp.GetId():
1733 ## Unassigns a hypothesis
1734 # @param hyp a hypothesis to unassign
1735 # @param geom a sub-shape of mesh geometry
1736 # @return SMESH.Hypothesis_Status
1737 # @ingroup l2_hypotheses
1738 def RemoveHypothesis(self, hyp, geom=0):
1739 if isinstance( hyp, Mesh_Algorithm ):
1740 hyp = hyp.GetAlgorithm()
1745 status = self.mesh.RemoveHypothesis(geom, hyp)
1748 ## Gets the list of hypotheses added on a geometry
1749 # @param geom a sub-shape of mesh geometry
1750 # @return the sequence of SMESH_Hypothesis
1751 # @ingroup l2_hypotheses
1752 def GetHypothesisList(self, geom):
1753 return self.mesh.GetHypothesisList( geom )
1755 ## Removes all global hypotheses
1756 # @ingroup l2_hypotheses
1757 def RemoveGlobalHypotheses(self):
1758 current_hyps = self.mesh.GetHypothesisList( self.geom )
1759 for hyp in current_hyps:
1760 self.mesh.RemoveHypothesis( self.geom, hyp )
1764 ## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead.
1765 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1766 ## allowing to overwrite the file if it exists or add the exported data to its contents
1767 # @param f the file name
1768 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1769 # @param opt boolean parameter for creating/not creating
1770 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1771 # @param overwrite boolean parameter for overwriting/not overwriting the file
1772 # @ingroup l2_impexp
1773 def ExportToMED(self, f, version, opt=0, overwrite=1):
1774 self.mesh.ExportToMEDX(f, opt, version, overwrite)
1776 ## Exports the mesh in a file in MED format and chooses the \a version of MED format
1777 ## allowing to overwrite the file if it exists or add the exported data to its contents
1778 # @param f is the file name
1779 # @param auto_groups boolean parameter for creating/not creating
1780 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1781 # the typical use is auto_groups=false.
1782 # @param version MED format version(MED_V2_1 or MED_V2_2)
1783 # @param overwrite boolean parameter for overwriting/not overwriting the file
1784 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1785 # @ingroup l2_impexp
1786 def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1, meshPart=None):
1788 if isinstance( meshPart, list ):
1789 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1790 self.mesh.ExportPartToMED( meshPart, f, auto_groups, version, overwrite )
1792 self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
1794 ## Exports the mesh in a file in SAUV format
1795 # @param f is the file name
1796 # @param auto_groups boolean parameter for creating/not creating
1797 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1798 # the typical use is auto_groups=false.
1799 # @ingroup l2_impexp
1800 def ExportSAUV(self, f, auto_groups=0):
1801 self.mesh.ExportSAUV(f, auto_groups)
1803 ## Exports the mesh in a file in DAT format
1804 # @param f the file name
1805 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1806 # @ingroup l2_impexp
1807 def ExportDAT(self, f, meshPart=None):
1809 if isinstance( meshPart, list ):
1810 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1811 self.mesh.ExportPartToDAT( meshPart, f )
1813 self.mesh.ExportDAT(f)
1815 ## Exports the mesh in a file in UNV format
1816 # @param f the file name
1817 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1818 # @ingroup l2_impexp
1819 def ExportUNV(self, f, meshPart=None):
1821 if isinstance( meshPart, list ):
1822 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1823 self.mesh.ExportPartToUNV( meshPart, f )
1825 self.mesh.ExportUNV(f)
1827 ## Export the mesh in a file in STL format
1828 # @param f the file name
1829 # @param ascii defines the file encoding
1830 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1831 # @ingroup l2_impexp
1832 def ExportSTL(self, f, ascii=1, meshPart=None):
1834 if isinstance( meshPart, list ):
1835 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1836 self.mesh.ExportPartToSTL( meshPart, f, ascii )
1838 self.mesh.ExportSTL(f, ascii)
1840 ## Exports the mesh in a file in CGNS format
1841 # @param f is the file name
1842 # @param overwrite boolean parameter for overwriting/not overwriting the file
1843 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1844 # @ingroup l2_impexp
1845 def ExportCGNS(self, f, overwrite=1, meshPart=None):
1846 if isinstance( meshPart, list ):
1847 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1848 if isinstance( meshPart, Mesh ):
1849 meshPart = meshPart.mesh
1851 meshPart = self.mesh
1852 self.mesh.ExportCGNS(meshPart, f, overwrite)
1854 # Operations with groups:
1855 # ----------------------
1857 ## Creates an empty mesh group
1858 # @param elementType the type of elements in the group
1859 # @param name the name of the mesh group
1860 # @return SMESH_Group
1861 # @ingroup l2_grps_create
1862 def CreateEmptyGroup(self, elementType, name):
1863 return self.mesh.CreateGroup(elementType, name)
1865 ## Creates a mesh group based on the geometric object \a grp
1866 # and gives a \a name, \n if this parameter is not defined
1867 # the name is the same as the geometric group name \n
1868 # Note: Works like GroupOnGeom().
1869 # @param grp a geometric group, a vertex, an edge, a face or a solid
1870 # @param name the name of the mesh group
1871 # @return SMESH_GroupOnGeom
1872 # @ingroup l2_grps_create
1873 def Group(self, grp, name=""):
1874 return self.GroupOnGeom(grp, name)
1876 ## Creates a mesh group based on the geometrical object \a grp
1877 # and gives a \a name, \n if this parameter is not defined
1878 # the name is the same as the geometrical group name
1879 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1880 # @param name the name of the mesh group
1881 # @param typ the type of elements in the group. If not set, it is
1882 # automatically detected by the type of the geometry
1883 # @return SMESH_GroupOnGeom
1884 # @ingroup l2_grps_create
1885 def GroupOnGeom(self, grp, name="", typ=None):
1886 AssureGeomPublished( self, grp, name )
1888 name = grp.GetName()
1890 typ = self._groupTypeFromShape( grp )
1891 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1893 ## Pivate method to get a type of group on geometry
1894 def _groupTypeFromShape( self, shape ):
1895 tgeo = str(shape.GetShapeType())
1896 if tgeo == "VERTEX":
1898 elif tgeo == "EDGE":
1900 elif tgeo == "FACE" or tgeo == "SHELL":
1902 elif tgeo == "SOLID" or tgeo == "COMPSOLID":
1904 elif tgeo == "COMPOUND":
1905 sub = self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHAPE"])
1907 raise ValueError,"_groupTypeFromShape(): empty geometric group or compound '%s'" % GetName(shape)
1908 return self._groupTypeFromShape( sub[0] )
1911 "_groupTypeFromShape(): invalid geometry '%s'" % GetName(shape)
1914 ## Creates a mesh group with given \a name based on the \a filter which
1915 ## is a special type of group dynamically updating it's contents during
1916 ## mesh modification
1917 # @param typ the type of elements in the group
1918 # @param name the name of the mesh group
1919 # @param filter the filter defining group contents
1920 # @return SMESH_GroupOnFilter
1921 # @ingroup l2_grps_create
1922 def GroupOnFilter(self, typ, name, filter):
1923 return self.mesh.CreateGroupFromFilter(typ, name, filter)
1925 ## Creates a mesh group by the given ids of elements
1926 # @param groupName the name of the mesh group
1927 # @param elementType the type of elements in the group
1928 # @param elemIDs the list of ids
1929 # @return SMESH_Group
1930 # @ingroup l2_grps_create
1931 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1932 group = self.mesh.CreateGroup(elementType, groupName)
1936 ## Creates a mesh group by the given conditions
1937 # @param groupName the name of the mesh group
1938 # @param elementType the type of elements in the group
1939 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1940 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1941 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1942 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1943 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
1944 # FT_LyingOnGeom, FT_CoplanarFaces criteria
1945 # @return SMESH_Group
1946 # @ingroup l2_grps_create
1950 CritType=FT_Undefined,
1953 UnaryOp=FT_Undefined,
1955 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined,Tolerance)
1956 group = self.MakeGroupByCriterion(groupName, aCriterion)
1959 ## Creates a mesh group by the given criterion
1960 # @param groupName the name of the mesh group
1961 # @param Criterion the instance of Criterion class
1962 # @return SMESH_Group
1963 # @ingroup l2_grps_create
1964 def MakeGroupByCriterion(self, groupName, Criterion):
1965 aFilterMgr = self.smeshpyD.CreateFilterManager()
1966 aFilter = aFilterMgr.CreateFilter()
1968 aCriteria.append(Criterion)
1969 aFilter.SetCriteria(aCriteria)
1970 group = self.MakeGroupByFilter(groupName, aFilter)
1971 aFilterMgr.UnRegister()
1974 ## Creates a mesh group by the given criteria (list of criteria)
1975 # @param groupName the name of the mesh group
1976 # @param theCriteria the list of criteria
1977 # @return SMESH_Group
1978 # @ingroup l2_grps_create
1979 def MakeGroupByCriteria(self, groupName, theCriteria):
1980 aFilterMgr = self.smeshpyD.CreateFilterManager()
1981 aFilter = aFilterMgr.CreateFilter()
1982 aFilter.SetCriteria(theCriteria)
1983 group = self.MakeGroupByFilter(groupName, aFilter)
1984 aFilterMgr.UnRegister()
1987 ## Creates a mesh group by the given filter
1988 # @param groupName the name of the mesh group
1989 # @param theFilter the instance of Filter class
1990 # @return SMESH_Group
1991 # @ingroup l2_grps_create
1992 def MakeGroupByFilter(self, groupName, theFilter):
1993 group = self.CreateEmptyGroup(theFilter.GetElementType(), groupName)
1994 theFilter.SetMesh( self.mesh )
1995 group.AddFrom( theFilter )
1998 ## Passes mesh elements through the given filter and return IDs of fitting elements
1999 # @param theFilter SMESH_Filter
2000 # @return a list of ids
2001 # @ingroup l1_controls
2002 def GetIdsFromFilter(self, theFilter):
2003 theFilter.SetMesh( self.mesh )
2004 return theFilter.GetIDs()
2006 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
2007 # Returns a list of special structures (borders).
2008 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
2009 # @ingroup l1_controls
2010 def GetFreeBorders(self):
2011 aFilterMgr = self.smeshpyD.CreateFilterManager()
2012 aPredicate = aFilterMgr.CreateFreeEdges()
2013 aPredicate.SetMesh(self.mesh)
2014 aBorders = aPredicate.GetBorders()
2015 aFilterMgr.UnRegister()
2019 # @ingroup l2_grps_delete
2020 def RemoveGroup(self, group):
2021 self.mesh.RemoveGroup(group)
2023 ## Removes a group with its contents
2024 # @ingroup l2_grps_delete
2025 def RemoveGroupWithContents(self, group):
2026 self.mesh.RemoveGroupWithContents(group)
2028 ## Gets the list of groups existing in the mesh
2029 # @return a sequence of SMESH_GroupBase
2030 # @ingroup l2_grps_create
2031 def GetGroups(self):
2032 return self.mesh.GetGroups()
2034 ## Gets the number of groups existing in the mesh
2035 # @return the quantity of groups as an integer value
2036 # @ingroup l2_grps_create
2038 return self.mesh.NbGroups()
2040 ## Gets the list of names of groups existing in the mesh
2041 # @return list of strings
2042 # @ingroup l2_grps_create
2043 def GetGroupNames(self):
2044 groups = self.GetGroups()
2046 for group in groups:
2047 names.append(group.GetName())
2050 ## Produces a union of two groups
2051 # A new group is created. All mesh elements that are
2052 # present in the initial groups are added to the new one
2053 # @return an instance of SMESH_Group
2054 # @ingroup l2_grps_operon
2055 def UnionGroups(self, group1, group2, name):
2056 return self.mesh.UnionGroups(group1, group2, name)
2058 ## Produces a union list of groups
2059 # New group is created. All mesh elements that are present in
2060 # initial groups are added to the new one
2061 # @return an instance of SMESH_Group
2062 # @ingroup l2_grps_operon
2063 def UnionListOfGroups(self, groups, name):
2064 return self.mesh.UnionListOfGroups(groups, name)
2066 ## Prodices an intersection of two groups
2067 # A new group is created. All mesh elements that are common
2068 # for the two initial groups are added to the new one.
2069 # @return an instance of SMESH_Group
2070 # @ingroup l2_grps_operon
2071 def IntersectGroups(self, group1, group2, name):
2072 return self.mesh.IntersectGroups(group1, group2, name)
2074 ## Produces an intersection of groups
2075 # New group is created. All mesh elements that are present in all
2076 # initial groups simultaneously are added to the new one
2077 # @return an instance of SMESH_Group
2078 # @ingroup l2_grps_operon
2079 def IntersectListOfGroups(self, groups, name):
2080 return self.mesh.IntersectListOfGroups(groups, name)
2082 ## Produces a cut of two groups
2083 # A new group is created. All mesh elements that are present in
2084 # the main group but are not present in the tool group are added to the new one
2085 # @return an instance of SMESH_Group
2086 # @ingroup l2_grps_operon
2087 def CutGroups(self, main_group, tool_group, name):
2088 return self.mesh.CutGroups(main_group, tool_group, name)
2090 ## Produces a cut of groups
2091 # A new group is created. All mesh elements that are present in main groups
2092 # but do not present in tool groups are added to the new one
2093 # @return an instance of SMESH_Group
2094 # @ingroup l2_grps_operon
2095 def CutListOfGroups(self, main_groups, tool_groups, name):
2096 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
2098 ## Produces a group of elements of specified type using list of existing groups
2099 # A new group is created. System
2100 # 1) extracts all nodes on which groups elements are built
2101 # 2) combines all elements of specified dimension laying on these nodes
2102 # @return an instance of SMESH_Group
2103 # @ingroup l2_grps_operon
2104 def CreateDimGroup(self, groups, elem_type, name):
2105 return self.mesh.CreateDimGroup(groups, elem_type, name)
2108 ## Convert group on geom into standalone group
2109 # @ingroup l2_grps_delete
2110 def ConvertToStandalone(self, group):
2111 return self.mesh.ConvertToStandalone(group)
2113 # Get some info about mesh:
2114 # ------------------------
2116 ## Returns the log of nodes and elements added or removed
2117 # since the previous clear of the log.
2118 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
2119 # @return list of log_block structures:
2124 # @ingroup l1_auxiliary
2125 def GetLog(self, clearAfterGet):
2126 return self.mesh.GetLog(clearAfterGet)
2128 ## Clears the log of nodes and elements added or removed since the previous
2129 # clear. Must be used immediately after GetLog if clearAfterGet is false.
2130 # @ingroup l1_auxiliary
2132 self.mesh.ClearLog()
2134 ## Toggles auto color mode on the object.
2135 # @param theAutoColor the flag which toggles auto color mode.
2136 # @ingroup l1_auxiliary
2137 def SetAutoColor(self, theAutoColor):
2138 self.mesh.SetAutoColor(theAutoColor)
2140 ## Gets flag of object auto color mode.
2141 # @return True or False
2142 # @ingroup l1_auxiliary
2143 def GetAutoColor(self):
2144 return self.mesh.GetAutoColor()
2146 ## Gets the internal ID
2147 # @return integer value, which is the internal Id of the mesh
2148 # @ingroup l1_auxiliary
2150 return self.mesh.GetId()
2153 # @return integer value, which is the study Id of the mesh
2154 # @ingroup l1_auxiliary
2155 def GetStudyId(self):
2156 return self.mesh.GetStudyId()
2158 ## Checks the group names for duplications.
2159 # Consider the maximum group name length stored in MED file.
2160 # @return True or False
2161 # @ingroup l1_auxiliary
2162 def HasDuplicatedGroupNamesMED(self):
2163 return self.mesh.HasDuplicatedGroupNamesMED()
2165 ## Obtains the mesh editor tool
2166 # @return an instance of SMESH_MeshEditor
2167 # @ingroup l1_modifying
2168 def GetMeshEditor(self):
2169 return self.mesh.GetMeshEditor()
2171 ## Wrap a list of IDs of elements or nodes into SMESH_IDSource which
2172 # can be passed as argument to accepting mesh, group or sub-mesh
2173 # @return an instance of SMESH_IDSource
2174 # @ingroup l1_auxiliary
2175 def GetIDSource(self, ids, elemType):
2176 return self.GetMeshEditor().MakeIDSource(ids, elemType)
2179 # @return an instance of SALOME_MED::MESH
2180 # @ingroup l1_auxiliary
2181 def GetMEDMesh(self):
2182 return self.mesh.GetMEDMesh()
2185 # Get informations about mesh contents:
2186 # ------------------------------------
2188 ## Gets the mesh stattistic
2189 # @return dictionary type element - count of elements
2190 # @ingroup l1_meshinfo
2191 def GetMeshInfo(self, obj = None):
2192 if not obj: obj = self.mesh
2193 return self.smeshpyD.GetMeshInfo(obj)
2195 ## Returns the number of nodes in the mesh
2196 # @return an integer value
2197 # @ingroup l1_meshinfo
2199 return self.mesh.NbNodes()
2201 ## Returns the number of elements in the mesh
2202 # @return an integer value
2203 # @ingroup l1_meshinfo
2204 def NbElements(self):
2205 return self.mesh.NbElements()
2207 ## Returns the number of 0d elements in the mesh
2208 # @return an integer value
2209 # @ingroup l1_meshinfo
2210 def Nb0DElements(self):
2211 return self.mesh.Nb0DElements()
2213 ## Returns the number of edges in the mesh
2214 # @return an integer value
2215 # @ingroup l1_meshinfo
2217 return self.mesh.NbEdges()
2219 ## Returns the number of edges with the given order in the mesh
2220 # @param elementOrder the order of elements:
2221 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2222 # @return an integer value
2223 # @ingroup l1_meshinfo
2224 def NbEdgesOfOrder(self, elementOrder):
2225 return self.mesh.NbEdgesOfOrder(elementOrder)
2227 ## Returns the number of faces in the mesh
2228 # @return an integer value
2229 # @ingroup l1_meshinfo
2231 return self.mesh.NbFaces()
2233 ## Returns the number of faces with the given order in the mesh
2234 # @param elementOrder the order of elements:
2235 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2236 # @return an integer value
2237 # @ingroup l1_meshinfo
2238 def NbFacesOfOrder(self, elementOrder):
2239 return self.mesh.NbFacesOfOrder(elementOrder)
2241 ## Returns the number of triangles in the mesh
2242 # @return an integer value
2243 # @ingroup l1_meshinfo
2244 def NbTriangles(self):
2245 return self.mesh.NbTriangles()
2247 ## Returns the number of triangles with the given order in the mesh
2248 # @param elementOrder is the order of elements:
2249 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2250 # @return an integer value
2251 # @ingroup l1_meshinfo
2252 def NbTrianglesOfOrder(self, elementOrder):
2253 return self.mesh.NbTrianglesOfOrder(elementOrder)
2255 ## Returns the number of quadrangles in the mesh
2256 # @return an integer value
2257 # @ingroup l1_meshinfo
2258 def NbQuadrangles(self):
2259 return self.mesh.NbQuadrangles()
2261 ## Returns the number of quadrangles with the given order in the mesh
2262 # @param elementOrder the order of elements:
2263 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2264 # @return an integer value
2265 # @ingroup l1_meshinfo
2266 def NbQuadranglesOfOrder(self, elementOrder):
2267 return self.mesh.NbQuadranglesOfOrder(elementOrder)
2269 ## Returns the number of biquadratic quadrangles in the mesh
2270 # @return an integer value
2271 # @ingroup l1_meshinfo
2272 def NbBiQuadQuadrangles(self):
2273 return self.mesh.NbBiQuadQuadrangles()
2275 ## Returns the number of polygons in the mesh
2276 # @return an integer value
2277 # @ingroup l1_meshinfo
2278 def NbPolygons(self):
2279 return self.mesh.NbPolygons()
2281 ## Returns the number of volumes in the mesh
2282 # @return an integer value
2283 # @ingroup l1_meshinfo
2284 def NbVolumes(self):
2285 return self.mesh.NbVolumes()
2287 ## Returns the number of volumes with the given order in the mesh
2288 # @param elementOrder the order of elements:
2289 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2290 # @return an integer value
2291 # @ingroup l1_meshinfo
2292 def NbVolumesOfOrder(self, elementOrder):
2293 return self.mesh.NbVolumesOfOrder(elementOrder)
2295 ## Returns the number of tetrahedrons in the mesh
2296 # @return an integer value
2297 # @ingroup l1_meshinfo
2299 return self.mesh.NbTetras()
2301 ## Returns the number of tetrahedrons with the given order in the mesh
2302 # @param elementOrder the order of elements:
2303 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2304 # @return an integer value
2305 # @ingroup l1_meshinfo
2306 def NbTetrasOfOrder(self, elementOrder):
2307 return self.mesh.NbTetrasOfOrder(elementOrder)
2309 ## Returns the number of hexahedrons in the mesh
2310 # @return an integer value
2311 # @ingroup l1_meshinfo
2313 return self.mesh.NbHexas()
2315 ## Returns the number of hexahedrons with the given order in the mesh
2316 # @param elementOrder the order of elements:
2317 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2318 # @return an integer value
2319 # @ingroup l1_meshinfo
2320 def NbHexasOfOrder(self, elementOrder):
2321 return self.mesh.NbHexasOfOrder(elementOrder)
2323 ## Returns the number of triquadratic hexahedrons in the mesh
2324 # @return an integer value
2325 # @ingroup l1_meshinfo
2326 def NbTriQuadraticHexas(self):
2327 return self.mesh.NbTriQuadraticHexas()
2329 ## Returns the number of pyramids in the mesh
2330 # @return an integer value
2331 # @ingroup l1_meshinfo
2332 def NbPyramids(self):
2333 return self.mesh.NbPyramids()
2335 ## Returns the number of pyramids with the given order in the mesh
2336 # @param elementOrder the order of elements:
2337 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2338 # @return an integer value
2339 # @ingroup l1_meshinfo
2340 def NbPyramidsOfOrder(self, elementOrder):
2341 return self.mesh.NbPyramidsOfOrder(elementOrder)
2343 ## Returns the number of prisms in the mesh
2344 # @return an integer value
2345 # @ingroup l1_meshinfo
2347 return self.mesh.NbPrisms()
2349 ## Returns the number of prisms with the given order in the mesh
2350 # @param elementOrder the order of elements:
2351 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2352 # @return an integer value
2353 # @ingroup l1_meshinfo
2354 def NbPrismsOfOrder(self, elementOrder):
2355 return self.mesh.NbPrismsOfOrder(elementOrder)
2357 ## Returns the number of hexagonal prisms in the mesh
2358 # @return an integer value
2359 # @ingroup l1_meshinfo
2360 def NbHexagonalPrisms(self):
2361 return self.mesh.NbHexagonalPrisms()
2363 ## Returns the number of polyhedrons in the mesh
2364 # @return an integer value
2365 # @ingroup l1_meshinfo
2366 def NbPolyhedrons(self):
2367 return self.mesh.NbPolyhedrons()
2369 ## Returns the number of submeshes in the mesh
2370 # @return an integer value
2371 # @ingroup l1_meshinfo
2372 def NbSubMesh(self):
2373 return self.mesh.NbSubMesh()
2375 ## Returns the list of mesh elements IDs
2376 # @return the list of integer values
2377 # @ingroup l1_meshinfo
2378 def GetElementsId(self):
2379 return self.mesh.GetElementsId()
2381 ## Returns the list of IDs of mesh elements with the given type
2382 # @param elementType the required type of elements (SMESH.NODE, SMESH.EDGE, SMESH.FACE or SMESH.VOLUME)
2383 # @return list of integer values
2384 # @ingroup l1_meshinfo
2385 def GetElementsByType(self, elementType):
2386 return self.mesh.GetElementsByType(elementType)
2388 ## Returns the list of mesh nodes IDs
2389 # @return the list of integer values
2390 # @ingroup l1_meshinfo
2391 def GetNodesId(self):
2392 return self.mesh.GetNodesId()
2394 # Get the information about mesh elements:
2395 # ------------------------------------
2397 ## Returns the type of mesh element
2398 # @return the value from SMESH::ElementType enumeration
2399 # @ingroup l1_meshinfo
2400 def GetElementType(self, id, iselem):
2401 return self.mesh.GetElementType(id, iselem)
2403 ## Returns the geometric type of mesh element
2404 # @return the value from SMESH::EntityType enumeration
2405 # @ingroup l1_meshinfo
2406 def GetElementGeomType(self, id):
2407 return self.mesh.GetElementGeomType(id)
2409 ## Returns the list of submesh elements IDs
2410 # @param Shape a geom object(sub-shape) IOR
2411 # Shape must be the sub-shape of a ShapeToMesh()
2412 # @return the list of integer values
2413 # @ingroup l1_meshinfo
2414 def GetSubMeshElementsId(self, Shape):
2415 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2416 ShapeID = Shape.GetSubShapeIndices()[0]
2419 return self.mesh.GetSubMeshElementsId(ShapeID)
2421 ## Returns the list of submesh nodes IDs
2422 # @param Shape a geom object(sub-shape) IOR
2423 # Shape must be the sub-shape of a ShapeToMesh()
2424 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
2425 # @return the list of integer values
2426 # @ingroup l1_meshinfo
2427 def GetSubMeshNodesId(self, Shape, all):
2428 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2429 ShapeID = Shape.GetSubShapeIndices()[0]
2432 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2434 ## Returns type of elements on given shape
2435 # @param Shape a geom object(sub-shape) IOR
2436 # Shape must be a sub-shape of a ShapeToMesh()
2437 # @return element type
2438 # @ingroup l1_meshinfo
2439 def GetSubMeshElementType(self, Shape):
2440 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2441 ShapeID = Shape.GetSubShapeIndices()[0]
2444 return self.mesh.GetSubMeshElementType(ShapeID)
2446 ## Gets the mesh description
2447 # @return string value
2448 # @ingroup l1_meshinfo
2450 return self.mesh.Dump()
2453 # Get the information about nodes and elements of a mesh by its IDs:
2454 # -----------------------------------------------------------
2456 ## Gets XYZ coordinates of a node
2457 # \n If there is no nodes for the given ID - returns an empty list
2458 # @return a list of double precision values
2459 # @ingroup l1_meshinfo
2460 def GetNodeXYZ(self, id):
2461 return self.mesh.GetNodeXYZ(id)
2463 ## Returns list of IDs of inverse elements for the given node
2464 # \n If there is no node for the given ID - returns an empty list
2465 # @return a list of integer values
2466 # @ingroup l1_meshinfo
2467 def GetNodeInverseElements(self, id):
2468 return self.mesh.GetNodeInverseElements(id)
2470 ## @brief Returns the position of a node on the shape
2471 # @return SMESH::NodePosition
2472 # @ingroup l1_meshinfo
2473 def GetNodePosition(self,NodeID):
2474 return self.mesh.GetNodePosition(NodeID)
2476 ## If the given element is a node, returns the ID of shape
2477 # \n If there is no node for the given ID - returns -1
2478 # @return an integer value
2479 # @ingroup l1_meshinfo
2480 def GetShapeID(self, id):
2481 return self.mesh.GetShapeID(id)
2483 ## Returns the ID of the result shape after
2484 # FindShape() from SMESH_MeshEditor for the given element
2485 # \n If there is no element for the given ID - returns -1
2486 # @return an integer value
2487 # @ingroup l1_meshinfo
2488 def GetShapeIDForElem(self,id):
2489 return self.mesh.GetShapeIDForElem(id)
2491 ## Returns the number of nodes for the given element
2492 # \n If there is no element for the given ID - returns -1
2493 # @return an integer value
2494 # @ingroup l1_meshinfo
2495 def GetElemNbNodes(self, id):
2496 return self.mesh.GetElemNbNodes(id)
2498 ## Returns the node ID the given index for the given element
2499 # \n If there is no element for the given ID - returns -1
2500 # \n If there is no node for the given index - returns -2
2501 # @return an integer value
2502 # @ingroup l1_meshinfo
2503 def GetElemNode(self, id, index):
2504 return self.mesh.GetElemNode(id, index)
2506 ## Returns the IDs of nodes of the given element
2507 # @return a list of integer values
2508 # @ingroup l1_meshinfo
2509 def GetElemNodes(self, id):
2510 return self.mesh.GetElemNodes(id)
2512 ## Returns true if the given node is the medium node in the given quadratic element
2513 # @ingroup l1_meshinfo
2514 def IsMediumNode(self, elementID, nodeID):
2515 return self.mesh.IsMediumNode(elementID, nodeID)
2517 ## Returns true if the given node is the medium node in one of quadratic elements
2518 # @ingroup l1_meshinfo
2519 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2520 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2522 ## Returns the number of edges for the given element
2523 # @ingroup l1_meshinfo
2524 def ElemNbEdges(self, id):
2525 return self.mesh.ElemNbEdges(id)
2527 ## Returns the number of faces for the given element
2528 # @ingroup l1_meshinfo
2529 def ElemNbFaces(self, id):
2530 return self.mesh.ElemNbFaces(id)
2532 ## Returns nodes of given face (counted from zero) for given volumic element.
2533 # @ingroup l1_meshinfo
2534 def GetElemFaceNodes(self,elemId, faceIndex):
2535 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2537 ## Returns an element based on all given nodes.
2538 # @ingroup l1_meshinfo
2539 def FindElementByNodes(self,nodes):
2540 return self.mesh.FindElementByNodes(nodes)
2542 ## Returns true if the given element is a polygon
2543 # @ingroup l1_meshinfo
2544 def IsPoly(self, id):
2545 return self.mesh.IsPoly(id)
2547 ## Returns true if the given element is quadratic
2548 # @ingroup l1_meshinfo
2549 def IsQuadratic(self, id):
2550 return self.mesh.IsQuadratic(id)
2552 ## Returns XYZ coordinates of the barycenter of the given element
2553 # \n If there is no element for the given ID - returns an empty list
2554 # @return a list of three double values
2555 # @ingroup l1_meshinfo
2556 def BaryCenter(self, id):
2557 return self.mesh.BaryCenter(id)
2560 # Get mesh measurements information:
2561 # ------------------------------------
2563 ## Get minimum distance between two nodes, elements or distance to the origin
2564 # @param id1 first node/element id
2565 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2566 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2567 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2568 # @return minimum distance value
2569 # @sa GetMinDistance()
2570 def MinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2571 aMeasure = self.GetMinDistance(id1, id2, isElem1, isElem2)
2572 return aMeasure.value
2574 ## Get measure structure specifying minimum distance data between two objects
2575 # @param id1 first node/element id
2576 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2577 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2578 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2579 # @return Measure structure
2581 def GetMinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2583 id1 = self.editor.MakeIDSource([id1], SMESH.FACE)
2585 id1 = self.editor.MakeIDSource([id1], SMESH.NODE)
2588 id2 = self.editor.MakeIDSource([id2], SMESH.FACE)
2590 id2 = self.editor.MakeIDSource([id2], SMESH.NODE)
2595 aMeasurements = self.smeshpyD.CreateMeasurements()
2596 aMeasure = aMeasurements.MinDistance(id1, id2)
2597 aMeasurements.UnRegister()
2600 ## Get bounding box of the specified object(s)
2601 # @param objects single source object or list of source objects or list of nodes/elements IDs
2602 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2603 # @c False specifies that @a objects are nodes
2604 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
2605 # @sa GetBoundingBox()
2606 def BoundingBox(self, objects=None, isElem=False):
2607 result = self.GetBoundingBox(objects, isElem)
2611 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
2614 ## Get measure structure specifying bounding box data of the specified object(s)
2615 # @param IDs single source object or list of source objects or list of nodes/elements IDs
2616 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2617 # @c False specifies that @a objects are nodes
2618 # @return Measure structure
2620 def GetBoundingBox(self, IDs=None, isElem=False):
2623 elif isinstance(IDs, tuple):
2625 if not isinstance(IDs, list):
2627 if len(IDs) > 0 and isinstance(IDs[0], int):
2631 if isinstance(o, Mesh):
2632 srclist.append(o.mesh)
2633 elif hasattr(o, "_narrow"):
2634 src = o._narrow(SMESH.SMESH_IDSource)
2635 if src: srclist.append(src)
2637 elif isinstance(o, list):
2639 srclist.append(self.editor.MakeIDSource(o, SMESH.FACE))
2641 srclist.append(self.editor.MakeIDSource(o, SMESH.NODE))
2644 aMeasurements = self.smeshpyD.CreateMeasurements()
2645 aMeasure = aMeasurements.BoundingBox(srclist)
2646 aMeasurements.UnRegister()
2649 # Mesh edition (SMESH_MeshEditor functionality):
2650 # ---------------------------------------------
2652 ## Removes the elements from the mesh by ids
2653 # @param IDsOfElements is a list of ids of elements to remove
2654 # @return True or False
2655 # @ingroup l2_modif_del
2656 def RemoveElements(self, IDsOfElements):
2657 return self.editor.RemoveElements(IDsOfElements)
2659 ## Removes nodes from mesh by ids
2660 # @param IDsOfNodes is a list of ids of nodes to remove
2661 # @return True or False
2662 # @ingroup l2_modif_del
2663 def RemoveNodes(self, IDsOfNodes):
2664 return self.editor.RemoveNodes(IDsOfNodes)
2666 ## Removes all orphan (free) nodes from mesh
2667 # @return number of the removed nodes
2668 # @ingroup l2_modif_del
2669 def RemoveOrphanNodes(self):
2670 return self.editor.RemoveOrphanNodes()
2672 ## Add a node to the mesh by coordinates
2673 # @return Id of the new node
2674 # @ingroup l2_modif_add
2675 def AddNode(self, x, y, z):
2676 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2677 self.mesh.SetParameters(Parameters)
2678 return self.editor.AddNode( x, y, z)
2680 ## Creates a 0D element on a node with given number.
2681 # @param IDOfNode the ID of node for creation of the element.
2682 # @return the Id of the new 0D element
2683 # @ingroup l2_modif_add
2684 def Add0DElement(self, IDOfNode):
2685 return self.editor.Add0DElement(IDOfNode)
2687 ## Creates a linear or quadratic edge (this is determined
2688 # by the number of given nodes).
2689 # @param IDsOfNodes the list of node IDs for creation of the element.
2690 # The order of nodes in this list should correspond to the description
2691 # of MED. \n This description is located by the following link:
2692 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2693 # @return the Id of the new edge
2694 # @ingroup l2_modif_add
2695 def AddEdge(self, IDsOfNodes):
2696 return self.editor.AddEdge(IDsOfNodes)
2698 ## Creates a linear or quadratic face (this is determined
2699 # by the number of given nodes).
2700 # @param IDsOfNodes the list of node IDs for creation of the element.
2701 # The order of nodes in this list should correspond to the description
2702 # of MED. \n This description is located by the following link:
2703 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2704 # @return the Id of the new face
2705 # @ingroup l2_modif_add
2706 def AddFace(self, IDsOfNodes):
2707 return self.editor.AddFace(IDsOfNodes)
2709 ## Adds a polygonal face to the mesh by the list of node IDs
2710 # @param IdsOfNodes the list of node IDs for creation of the element.
2711 # @return the Id of the new face
2712 # @ingroup l2_modif_add
2713 def AddPolygonalFace(self, IdsOfNodes):
2714 return self.editor.AddPolygonalFace(IdsOfNodes)
2716 ## Creates both simple and quadratic volume (this is determined
2717 # by the number of given nodes).
2718 # @param IDsOfNodes the list of node IDs for creation of the element.
2719 # The order of nodes in this list should correspond to the description
2720 # of MED. \n This description is located by the following link:
2721 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2722 # @return the Id of the new volumic element
2723 # @ingroup l2_modif_add
2724 def AddVolume(self, IDsOfNodes):
2725 return self.editor.AddVolume(IDsOfNodes)
2727 ## Creates a volume of many faces, giving nodes for each face.
2728 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2729 # @param Quantities the list of integer values, Quantities[i]
2730 # gives the quantity of nodes in face number i.
2731 # @return the Id of the new volumic element
2732 # @ingroup l2_modif_add
2733 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2734 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2736 ## Creates a volume of many faces, giving the IDs of the existing faces.
2737 # @param IdsOfFaces the list of face IDs for volume creation.
2739 # Note: The created volume will refer only to the nodes
2740 # of the given faces, not to the faces themselves.
2741 # @return the Id of the new volumic element
2742 # @ingroup l2_modif_add
2743 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2744 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2747 ## @brief Binds a node to a vertex
2748 # @param NodeID a node ID
2749 # @param Vertex a vertex or vertex ID
2750 # @return True if succeed else raises an exception
2751 # @ingroup l2_modif_add
2752 def SetNodeOnVertex(self, NodeID, Vertex):
2753 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2754 VertexID = Vertex.GetSubShapeIndices()[0]
2758 self.editor.SetNodeOnVertex(NodeID, VertexID)
2759 except SALOME.SALOME_Exception, inst:
2760 raise ValueError, inst.details.text
2764 ## @brief Stores the node position on an edge
2765 # @param NodeID a node ID
2766 # @param Edge an edge or edge ID
2767 # @param paramOnEdge a parameter on the edge where the node is located
2768 # @return True if succeed else raises an exception
2769 # @ingroup l2_modif_add
2770 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2771 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2772 EdgeID = Edge.GetSubShapeIndices()[0]
2776 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2777 except SALOME.SALOME_Exception, inst:
2778 raise ValueError, inst.details.text
2781 ## @brief Stores node position on a face
2782 # @param NodeID a node ID
2783 # @param Face a face or face ID
2784 # @param u U parameter on the face where the node is located
2785 # @param v V parameter on the face where the node is located
2786 # @return True if succeed else raises an exception
2787 # @ingroup l2_modif_add
2788 def SetNodeOnFace(self, NodeID, Face, u, v):
2789 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2790 FaceID = Face.GetSubShapeIndices()[0]
2794 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2795 except SALOME.SALOME_Exception, inst:
2796 raise ValueError, inst.details.text
2799 ## @brief Binds a node to a solid
2800 # @param NodeID a node ID
2801 # @param Solid a solid or solid ID
2802 # @return True if succeed else raises an exception
2803 # @ingroup l2_modif_add
2804 def SetNodeInVolume(self, NodeID, Solid):
2805 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2806 SolidID = Solid.GetSubShapeIndices()[0]
2810 self.editor.SetNodeInVolume(NodeID, SolidID)
2811 except SALOME.SALOME_Exception, inst:
2812 raise ValueError, inst.details.text
2815 ## @brief Bind an element to a shape
2816 # @param ElementID an element ID
2817 # @param Shape a shape or shape ID
2818 # @return True if succeed else raises an exception
2819 # @ingroup l2_modif_add
2820 def SetMeshElementOnShape(self, ElementID, Shape):
2821 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2822 ShapeID = Shape.GetSubShapeIndices()[0]
2826 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2827 except SALOME.SALOME_Exception, inst:
2828 raise ValueError, inst.details.text
2832 ## Moves the node with the given id
2833 # @param NodeID the id of the node
2834 # @param x a new X coordinate
2835 # @param y a new Y coordinate
2836 # @param z a new Z coordinate
2837 # @return True if succeed else False
2838 # @ingroup l2_modif_movenode
2839 def MoveNode(self, NodeID, x, y, z):
2840 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2841 self.mesh.SetParameters(Parameters)
2842 return self.editor.MoveNode(NodeID, x, y, z)
2844 ## Finds the node closest to a point and moves it to a point location
2845 # @param x the X coordinate of a point
2846 # @param y the Y coordinate of a point
2847 # @param z the Z coordinate of a point
2848 # @param NodeID if specified (>0), the node with this ID is moved,
2849 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2850 # @return the ID of a node
2851 # @ingroup l2_modif_throughp
2852 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2853 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2854 self.mesh.SetParameters(Parameters)
2855 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2857 ## Finds the node closest to a point
2858 # @param x the X coordinate of a point
2859 # @param y the Y coordinate of a point
2860 # @param z the Z coordinate of a point
2861 # @return the ID of a node
2862 # @ingroup l2_modif_throughp
2863 def FindNodeClosestTo(self, x, y, z):
2864 #preview = self.mesh.GetMeshEditPreviewer()
2865 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2866 return self.editor.FindNodeClosestTo(x, y, z)
2868 ## Finds the elements where a point lays IN or ON
2869 # @param x the X coordinate of a point
2870 # @param y the Y coordinate of a point
2871 # @param z the Z coordinate of a point
2872 # @param elementType type of elements to find (SMESH.ALL type
2873 # means elements of any type excluding nodes and 0D elements)
2874 # @param meshPart a part of mesh (group, sub-mesh) to search within
2875 # @return list of IDs of found elements
2876 # @ingroup l2_modif_throughp
2877 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL, meshPart=None):
2879 return self.editor.FindAmongElementsByPoint( meshPart, x, y, z, elementType );
2881 return self.editor.FindElementsByPoint(x, y, z, elementType)
2883 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2884 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2886 def GetPointState(self, x, y, z):
2887 return self.editor.GetPointState(x, y, z)
2889 ## Finds the node closest to a point and moves it to a point location
2890 # @param x the X coordinate of a point
2891 # @param y the Y coordinate of a point
2892 # @param z the Z coordinate of a point
2893 # @return the ID of a moved node
2894 # @ingroup l2_modif_throughp
2895 def MeshToPassThroughAPoint(self, x, y, z):
2896 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2898 ## Replaces two neighbour triangles sharing Node1-Node2 link
2899 # with the triangles built on the same 4 nodes but having other common link.
2900 # @param NodeID1 the ID of the first node
2901 # @param NodeID2 the ID of the second node
2902 # @return false if proper faces were not found
2903 # @ingroup l2_modif_invdiag
2904 def InverseDiag(self, NodeID1, NodeID2):
2905 return self.editor.InverseDiag(NodeID1, NodeID2)
2907 ## Replaces two neighbour triangles sharing Node1-Node2 link
2908 # with a quadrangle built on the same 4 nodes.
2909 # @param NodeID1 the ID of the first node
2910 # @param NodeID2 the ID of the second node
2911 # @return false if proper faces were not found
2912 # @ingroup l2_modif_unitetri
2913 def DeleteDiag(self, NodeID1, NodeID2):
2914 return self.editor.DeleteDiag(NodeID1, NodeID2)
2916 ## Reorients elements by ids
2917 # @param IDsOfElements if undefined reorients all mesh elements
2918 # @return True if succeed else False
2919 # @ingroup l2_modif_changori
2920 def Reorient(self, IDsOfElements=None):
2921 if IDsOfElements == None:
2922 IDsOfElements = self.GetElementsId()
2923 return self.editor.Reorient(IDsOfElements)
2925 ## Reorients all elements of the object
2926 # @param theObject mesh, submesh or group
2927 # @return True if succeed else False
2928 # @ingroup l2_modif_changori
2929 def ReorientObject(self, theObject):
2930 if ( isinstance( theObject, Mesh )):
2931 theObject = theObject.GetMesh()
2932 return self.editor.ReorientObject(theObject)
2934 ## Fuses the neighbouring triangles into quadrangles.
2935 # @param IDsOfElements The triangles to be fused,
2936 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2937 # @param MaxAngle is the maximum angle between element normals at which the fusion
2938 # is still performed; theMaxAngle is mesured in radians.
2939 # Also it could be a name of variable which defines angle in degrees.
2940 # @return TRUE in case of success, FALSE otherwise.
2941 # @ingroup l2_modif_unitetri
2942 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2944 if isinstance(MaxAngle,str):
2946 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2948 MaxAngle = DegreesToRadians(MaxAngle)
2949 if IDsOfElements == []:
2950 IDsOfElements = self.GetElementsId()
2951 self.mesh.SetParameters(Parameters)
2953 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2954 Functor = theCriterion
2956 Functor = self.smeshpyD.GetFunctor(theCriterion)
2957 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2959 ## Fuses the neighbouring triangles of the object into quadrangles
2960 # @param theObject is mesh, submesh or group
2961 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2962 # @param MaxAngle a max angle between element normals at which the fusion
2963 # is still performed; theMaxAngle is mesured in radians.
2964 # @return TRUE in case of success, FALSE otherwise.
2965 # @ingroup l2_modif_unitetri
2966 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2967 if ( isinstance( theObject, Mesh )):
2968 theObject = theObject.GetMesh()
2969 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2971 ## Splits quadrangles into triangles.
2972 # @param IDsOfElements the faces to be splitted.
2973 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2974 # @return TRUE in case of success, FALSE otherwise.
2975 # @ingroup l2_modif_cutquadr
2976 def QuadToTri (self, IDsOfElements, theCriterion):
2977 if IDsOfElements == []:
2978 IDsOfElements = self.GetElementsId()
2979 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2981 ## Splits quadrangles into triangles.
2982 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
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 QuadToTriObject (self, theObject, theCriterion):
2987 if ( isinstance( theObject, Mesh )):
2988 theObject = theObject.GetMesh()
2989 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2991 ## Splits quadrangles into triangles.
2992 # @param IDsOfElements the faces to be splitted
2993 # @param Diag13 is used to choose a diagonal for splitting.
2994 # @return TRUE in case of success, FALSE otherwise.
2995 # @ingroup l2_modif_cutquadr
2996 def SplitQuad (self, IDsOfElements, Diag13):
2997 if IDsOfElements == []:
2998 IDsOfElements = self.GetElementsId()
2999 return self.editor.SplitQuad(IDsOfElements, Diag13)
3001 ## Splits quadrangles into triangles.
3002 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
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 SplitQuadObject (self, theObject, Diag13):
3007 if ( isinstance( theObject, Mesh )):
3008 theObject = theObject.GetMesh()
3009 return self.editor.SplitQuadObject(theObject, Diag13)
3011 ## Finds a better splitting of the given quadrangle.
3012 # @param IDOfQuad the ID of the quadrangle to be splitted.
3013 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
3014 # @return 1 if 1-3 diagonal is better, 2 if 2-4
3015 # diagonal is better, 0 if error occurs.
3016 # @ingroup l2_modif_cutquadr
3017 def BestSplit (self, IDOfQuad, theCriterion):
3018 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
3020 ## Splits volumic elements into tetrahedrons
3021 # @param elemIDs either list of elements or mesh or group or submesh
3022 # @param method flags passing splitting method: Hex_5Tet, Hex_6Tet, Hex_24Tet
3023 # Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc
3024 # @ingroup l2_modif_cutquadr
3025 def SplitVolumesIntoTetra(self, elemIDs, method=Hex_5Tet ):
3026 if isinstance( elemIDs, Mesh ):
3027 elemIDs = elemIDs.GetMesh()
3028 if ( isinstance( elemIDs, list )):
3029 elemIDs = self.editor.MakeIDSource(elemIDs, SMESH.VOLUME)
3030 self.editor.SplitVolumesIntoTetra(elemIDs, method)
3032 ## Splits quadrangle faces near triangular facets of volumes
3034 # @ingroup l1_auxiliary
3035 def SplitQuadsNearTriangularFacets(self):
3036 faces_array = self.GetElementsByType(SMESH.FACE)
3037 for face_id in faces_array:
3038 if self.GetElemNbNodes(face_id) == 4: # quadrangle
3039 quad_nodes = self.mesh.GetElemNodes(face_id)
3040 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
3041 isVolumeFound = False
3042 for node1_elem in node1_elems:
3043 if not isVolumeFound:
3044 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
3045 nb_nodes = self.GetElemNbNodes(node1_elem)
3046 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
3047 volume_elem = node1_elem
3048 volume_nodes = self.mesh.GetElemNodes(volume_elem)
3049 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
3050 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
3051 isVolumeFound = True
3052 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
3053 self.SplitQuad([face_id], False) # diagonal 2-4
3054 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
3055 isVolumeFound = True
3056 self.SplitQuad([face_id], True) # diagonal 1-3
3057 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
3058 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
3059 isVolumeFound = True
3060 self.SplitQuad([face_id], True) # diagonal 1-3
3062 ## @brief Splits hexahedrons into tetrahedrons.
3064 # This operation uses pattern mapping functionality for splitting.
3065 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
3066 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
3067 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
3068 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
3069 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
3070 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
3071 # @return TRUE in case of success, FALSE otherwise.
3072 # @ingroup l1_auxiliary
3073 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
3074 # Pattern: 5.---------.6
3079 # (0,0,1) 4.---------.7 * |
3086 # (0,0,0) 0.---------.3
3087 pattern_tetra = "!!! Nb of points: \n 8 \n\
3097 !!! Indices of points of 6 tetras: \n\
3105 pattern = self.smeshpyD.GetPattern()
3106 isDone = pattern.LoadFromFile(pattern_tetra)
3108 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
3111 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
3112 isDone = pattern.MakeMesh(self.mesh, False, False)
3113 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
3115 # split quafrangle faces near triangular facets of volumes
3116 self.SplitQuadsNearTriangularFacets()
3120 ## @brief Split hexahedrons into prisms.
3122 # Uses the pattern mapping functionality for splitting.
3123 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
3124 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
3125 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
3126 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
3127 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
3128 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
3129 # @return TRUE in case of success, FALSE otherwise.
3130 # @ingroup l1_auxiliary
3131 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
3132 # Pattern: 5.---------.6
3137 # (0,0,1) 4.---------.7 |
3144 # (0,0,0) 0.---------.3
3145 pattern_prism = "!!! Nb of points: \n 8 \n\
3155 !!! Indices of points of 2 prisms: \n\
3159 pattern = self.smeshpyD.GetPattern()
3160 isDone = pattern.LoadFromFile(pattern_prism)
3162 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
3165 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
3166 isDone = pattern.MakeMesh(self.mesh, False, False)
3167 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
3169 # Splits quafrangle faces near triangular facets of volumes
3170 self.SplitQuadsNearTriangularFacets()
3174 ## Smoothes elements
3175 # @param IDsOfElements the list if ids of elements to smooth
3176 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3177 # Note that nodes built on edges and boundary nodes are always fixed.
3178 # @param MaxNbOfIterations the maximum number of iterations
3179 # @param MaxAspectRatio varies in range [1.0, inf]
3180 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3181 # @return TRUE in case of success, FALSE otherwise.
3182 # @ingroup l2_modif_smooth
3183 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
3184 MaxNbOfIterations, MaxAspectRatio, Method):
3185 if IDsOfElements == []:
3186 IDsOfElements = self.GetElementsId()
3187 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
3188 self.mesh.SetParameters(Parameters)
3189 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
3190 MaxNbOfIterations, MaxAspectRatio, Method)
3192 ## Smoothes elements which belong to the given object
3193 # @param theObject the object to smooth
3194 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3195 # Note that nodes built on edges and boundary nodes are always fixed.
3196 # @param MaxNbOfIterations the maximum number of iterations
3197 # @param MaxAspectRatio varies in range [1.0, inf]
3198 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3199 # @return TRUE in case of success, FALSE otherwise.
3200 # @ingroup l2_modif_smooth
3201 def SmoothObject(self, theObject, IDsOfFixedNodes,
3202 MaxNbOfIterations, MaxAspectRatio, Method):
3203 if ( isinstance( theObject, Mesh )):
3204 theObject = theObject.GetMesh()
3205 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
3206 MaxNbOfIterations, MaxAspectRatio, Method)
3208 ## Parametrically smoothes the given elements
3209 # @param IDsOfElements the list if ids of elements to smooth
3210 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3211 # Note that nodes built on edges and boundary nodes are always fixed.
3212 # @param MaxNbOfIterations the maximum number of iterations
3213 # @param MaxAspectRatio varies in range [1.0, inf]
3214 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3215 # @return TRUE in case of success, FALSE otherwise.
3216 # @ingroup l2_modif_smooth
3217 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
3218 MaxNbOfIterations, MaxAspectRatio, Method):
3219 if IDsOfElements == []:
3220 IDsOfElements = self.GetElementsId()
3221 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
3222 self.mesh.SetParameters(Parameters)
3223 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
3224 MaxNbOfIterations, MaxAspectRatio, Method)
3226 ## Parametrically smoothes the elements which belong to the given object
3227 # @param theObject the object to smooth
3228 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3229 # Note that nodes built on edges and boundary nodes are always fixed.
3230 # @param MaxNbOfIterations the maximum number of iterations
3231 # @param MaxAspectRatio varies in range [1.0, inf]
3232 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3233 # @return TRUE in case of success, FALSE otherwise.
3234 # @ingroup l2_modif_smooth
3235 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
3236 MaxNbOfIterations, MaxAspectRatio, Method):
3237 if ( isinstance( theObject, Mesh )):
3238 theObject = theObject.GetMesh()
3239 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
3240 MaxNbOfIterations, MaxAspectRatio, Method)
3242 ## Converts the mesh to quadratic, deletes old elements, replacing
3243 # them with quadratic with the same id.
3244 # @param theForce3d new node creation method:
3245 # 0 - the medium node lies at the geometrical entity from which the mesh element is built
3246 # 1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element
3247 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
3248 # @ingroup l2_modif_tofromqu
3249 def ConvertToQuadratic(self, theForce3d, theSubMesh=None):
3251 self.editor.ConvertToQuadraticObject(theForce3d,theSubMesh)
3253 self.editor.ConvertToQuadratic(theForce3d)
3255 ## Converts the mesh from quadratic to ordinary,
3256 # deletes old quadratic elements, \n replacing
3257 # them with ordinary mesh elements with the same id.
3258 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
3259 # @ingroup l2_modif_tofromqu
3260 def ConvertFromQuadratic(self, theSubMesh=None):
3262 self.editor.ConvertFromQuadraticObject(theSubMesh)
3264 return self.editor.ConvertFromQuadratic()
3266 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
3267 # @return TRUE if operation has been completed successfully, FALSE otherwise
3268 # @ingroup l2_modif_edit
3269 def Make2DMeshFrom3D(self):
3270 return self.editor. Make2DMeshFrom3D()
3272 ## Creates missing boundary elements
3273 # @param elements - elements whose boundary is to be checked:
3274 # mesh, group, sub-mesh or list of elements
3275 # if elements is mesh, it must be the mesh whose MakeBoundaryMesh() is called
3276 # @param dimension - defines type of boundary elements to create:
3277 # SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D
3278 # SMESH.BND_1DFROM3D creates mesh edges on all borders of free facets of 3D cells
3279 # @param groupName - a name of group to store created boundary elements in,
3280 # "" means not to create the group
3281 # @param meshName - a name of new mesh to store created boundary elements in,
3282 # "" means not to create the new mesh
3283 # @param toCopyElements - if true, the checked elements will be copied into
3284 # the new mesh else only boundary elements will be copied into the new mesh
3285 # @param toCopyExistingBondary - if true, not only new but also pre-existing
3286 # boundary elements will be copied into the new mesh
3287 # @return tuple (mesh, group) where bondary elements were added to
3288 # @ingroup l2_modif_edit
3289 def MakeBoundaryMesh(self, elements, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3290 toCopyElements=False, toCopyExistingBondary=False):
3291 if isinstance( elements, Mesh ):
3292 elements = elements.GetMesh()
3293 if ( isinstance( elements, list )):
3294 elemType = SMESH.ALL
3295 if elements: elemType = self.GetElementType( elements[0], iselem=True)
3296 elements = self.editor.MakeIDSource(elements, elemType)
3297 mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName,
3298 toCopyElements,toCopyExistingBondary)
3299 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3303 # @brief Creates missing boundary elements around either the whole mesh or
3304 # groups of 2D elements
3305 # @param dimension - defines type of boundary elements to create
3306 # @param groupName - a name of group to store all boundary elements in,
3307 # "" means not to create the group
3308 # @param meshName - a name of a new mesh, which is a copy of the initial
3309 # mesh + created boundary elements; "" means not to create the new mesh
3310 # @param toCopyAll - if true, the whole initial mesh will be copied into
3311 # the new mesh else only boundary elements will be copied into the new mesh
3312 # @param groups - groups of 2D elements to make boundary around
3313 # @retval tuple( long, mesh, groups )
3314 # long - number of added boundary elements
3315 # mesh - the mesh where elements were added to
3316 # group - the group of boundary elements or None
3318 def MakeBoundaryElements(self, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3319 toCopyAll=False, groups=[]):
3320 nb, mesh, group = self.editor.MakeBoundaryElements(dimension,groupName,meshName,
3322 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3323 return nb, mesh, group
3325 ## Renumber mesh nodes
3326 # @ingroup l2_modif_renumber
3327 def RenumberNodes(self):
3328 self.editor.RenumberNodes()
3330 ## Renumber mesh elements
3331 # @ingroup l2_modif_renumber
3332 def RenumberElements(self):
3333 self.editor.RenumberElements()
3335 ## Generates new elements by rotation of the elements around the axis
3336 # @param IDsOfElements the list of ids of elements to sweep
3337 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3338 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
3339 # @param NbOfSteps the number of steps
3340 # @param Tolerance tolerance
3341 # @param MakeGroups forces the generation of new groups from existing ones
3342 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3343 # of all steps, else - size of each step
3344 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3345 # @ingroup l2_modif_extrurev
3346 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
3347 MakeGroups=False, TotalAngle=False):
3349 if isinstance(AngleInRadians,str):
3351 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3353 AngleInRadians = DegreesToRadians(AngleInRadians)
3354 if IDsOfElements == []:
3355 IDsOfElements = self.GetElementsId()
3356 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3357 Axis = self.smeshpyD.GetAxisStruct(Axis)
3358 Axis,AxisParameters = ParseAxisStruct(Axis)
3359 if TotalAngle and NbOfSteps:
3360 AngleInRadians /= NbOfSteps
3361 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3362 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3363 self.mesh.SetParameters(Parameters)
3365 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
3366 AngleInRadians, NbOfSteps, Tolerance)
3367 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
3370 ## Generates new elements by rotation of the elements of object around the axis
3371 # @param theObject object which elements should be sweeped.
3372 # It can be a mesh, a sub mesh or a group.
3373 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3374 # @param AngleInRadians the angle of Rotation
3375 # @param NbOfSteps number of steps
3376 # @param Tolerance tolerance
3377 # @param MakeGroups forces the generation of new groups from existing ones
3378 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3379 # of all steps, else - size of each step
3380 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3381 # @ingroup l2_modif_extrurev
3382 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3383 MakeGroups=False, TotalAngle=False):
3385 if isinstance(AngleInRadians,str):
3387 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3389 AngleInRadians = DegreesToRadians(AngleInRadians)
3390 if ( isinstance( theObject, Mesh )):
3391 theObject = theObject.GetMesh()
3392 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3393 Axis = self.smeshpyD.GetAxisStruct(Axis)
3394 Axis,AxisParameters = ParseAxisStruct(Axis)
3395 if TotalAngle and NbOfSteps:
3396 AngleInRadians /= NbOfSteps
3397 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3398 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3399 self.mesh.SetParameters(Parameters)
3401 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
3402 NbOfSteps, Tolerance)
3403 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3406 ## Generates new elements by rotation of the elements of object around the axis
3407 # @param theObject object which elements should be sweeped.
3408 # It can be a mesh, a sub mesh or a group.
3409 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3410 # @param AngleInRadians the angle of Rotation
3411 # @param NbOfSteps number of steps
3412 # @param Tolerance tolerance
3413 # @param MakeGroups forces the generation of new groups from existing ones
3414 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3415 # of all steps, else - size of each step
3416 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3417 # @ingroup l2_modif_extrurev
3418 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3419 MakeGroups=False, TotalAngle=False):
3421 if isinstance(AngleInRadians,str):
3423 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3425 AngleInRadians = DegreesToRadians(AngleInRadians)
3426 if ( isinstance( theObject, Mesh )):
3427 theObject = theObject.GetMesh()
3428 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3429 Axis = self.smeshpyD.GetAxisStruct(Axis)
3430 Axis,AxisParameters = ParseAxisStruct(Axis)
3431 if TotalAngle and NbOfSteps:
3432 AngleInRadians /= NbOfSteps
3433 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3434 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3435 self.mesh.SetParameters(Parameters)
3437 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
3438 NbOfSteps, Tolerance)
3439 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3442 ## Generates new elements by rotation of the elements of object around the axis
3443 # @param theObject object which elements should be sweeped.
3444 # It can be a mesh, a sub mesh or a group.
3445 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3446 # @param AngleInRadians the angle of Rotation
3447 # @param NbOfSteps number of steps
3448 # @param Tolerance tolerance
3449 # @param MakeGroups forces the generation of new groups from existing ones
3450 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3451 # of all steps, else - size of each step
3452 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3453 # @ingroup l2_modif_extrurev
3454 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3455 MakeGroups=False, TotalAngle=False):
3457 if isinstance(AngleInRadians,str):
3459 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3461 AngleInRadians = DegreesToRadians(AngleInRadians)
3462 if ( isinstance( theObject, Mesh )):
3463 theObject = theObject.GetMesh()
3464 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3465 Axis = self.smeshpyD.GetAxisStruct(Axis)
3466 Axis,AxisParameters = ParseAxisStruct(Axis)
3467 if TotalAngle and NbOfSteps:
3468 AngleInRadians /= NbOfSteps
3469 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3470 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3471 self.mesh.SetParameters(Parameters)
3473 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
3474 NbOfSteps, Tolerance)
3475 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3478 ## Generates new elements by extrusion of the elements with given ids
3479 # @param IDsOfElements the list of elements ids for extrusion
3480 # @param StepVector vector or DirStruct, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3481 # @param NbOfSteps the number of steps
3482 # @param MakeGroups forces the generation of new groups from existing ones
3483 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3484 # @ingroup l2_modif_extrurev
3485 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
3486 if IDsOfElements == []:
3487 IDsOfElements = self.GetElementsId()
3488 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3489 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3490 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3491 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3492 Parameters = StepVectorParameters + var_separator + Parameters
3493 self.mesh.SetParameters(Parameters)
3495 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
3496 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
3499 ## Generates new elements by extrusion of the elements with given ids
3500 # @param IDsOfElements is ids of elements
3501 # @param StepVector vector, defining the direction and value of extrusion
3502 # @param NbOfSteps the number of steps
3503 # @param ExtrFlags sets flags for extrusion
3504 # @param SewTolerance uses for comparing locations of nodes if flag
3505 # EXTRUSION_FLAG_SEW is set
3506 # @param MakeGroups forces the generation of new groups from existing ones
3507 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3508 # @ingroup l2_modif_extrurev
3509 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
3510 ExtrFlags, SewTolerance, MakeGroups=False):
3511 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3512 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3514 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
3515 ExtrFlags, SewTolerance)
3516 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
3517 ExtrFlags, SewTolerance)
3520 ## Generates new elements by extrusion of the elements which belong to the object
3521 # @param theObject the object which elements should be processed.
3522 # It can be a mesh, a sub mesh or a group.
3523 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3524 # @param NbOfSteps the number of steps
3525 # @param MakeGroups forces the generation of new groups from existing ones
3526 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3527 # @ingroup l2_modif_extrurev
3528 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3529 if ( isinstance( theObject, Mesh )):
3530 theObject = theObject.GetMesh()
3531 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3532 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3533 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3534 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3535 Parameters = StepVectorParameters + var_separator + Parameters
3536 self.mesh.SetParameters(Parameters)
3538 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3539 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
3542 ## Generates new elements by extrusion of the elements which belong to the object
3543 # @param theObject object which elements should be processed.
3544 # It can be a mesh, a sub mesh or a group.
3545 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3546 # @param NbOfSteps the number of steps
3547 # @param MakeGroups to generate new groups from existing ones
3548 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3549 # @ingroup l2_modif_extrurev
3550 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3551 if ( isinstance( theObject, Mesh )):
3552 theObject = theObject.GetMesh()
3553 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3554 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3555 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3556 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3557 Parameters = StepVectorParameters + var_separator + Parameters
3558 self.mesh.SetParameters(Parameters)
3560 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3561 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3564 ## Generates new elements by extrusion of the elements which belong to the object
3565 # @param theObject object which elements should be processed.
3566 # It can be a mesh, a sub mesh or a group.
3567 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3568 # @param NbOfSteps the number of steps
3569 # @param MakeGroups forces the generation of new groups from existing ones
3570 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3571 # @ingroup l2_modif_extrurev
3572 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3573 if ( isinstance( theObject, Mesh )):
3574 theObject = theObject.GetMesh()
3575 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3576 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3577 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3578 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3579 Parameters = StepVectorParameters + var_separator + Parameters
3580 self.mesh.SetParameters(Parameters)
3582 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3583 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3588 ## Generates new elements by extrusion of the given elements
3589 # The path of extrusion must be a meshed edge.
3590 # @param Base mesh or group, or submesh, or list of ids of elements for extrusion
3591 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3592 # @param NodeStart the start node from Path. Defines the direction of extrusion
3593 # @param HasAngles allows the shape to be rotated around the path
3594 # to get the resulting mesh in a helical fashion
3595 # @param Angles list of angles in radians
3596 # @param LinearVariation forces the computation of rotation angles as linear
3597 # variation of the given Angles along path steps
3598 # @param HasRefPoint allows using the reference point
3599 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3600 # The User can specify any point as the Reference Point.
3601 # @param MakeGroups forces the generation of new groups from existing ones
3602 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3603 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3604 # only SMESH::Extrusion_Error otherwise
3605 # @ingroup l2_modif_extrurev
3606 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3607 HasAngles, Angles, LinearVariation,
3608 HasRefPoint, RefPoint, MakeGroups, ElemType):
3609 Angles,AnglesParameters = ParseAngles(Angles)
3610 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3611 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3612 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3614 Parameters = AnglesParameters + var_separator + RefPointParameters
3615 self.mesh.SetParameters(Parameters)
3617 if (isinstance(Path, Mesh)): Path = Path.GetMesh()
3619 if isinstance(Base, list):
3621 if Base == []: IDsOfElements = self.GetElementsId()
3622 else: IDsOfElements = Base
3623 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3624 HasAngles, Angles, LinearVariation,
3625 HasRefPoint, RefPoint, MakeGroups, ElemType)
3627 if isinstance(Base, Mesh): Base = Base.GetMesh()
3628 if isinstance(Base, SMESH._objref_SMESH_Mesh) or isinstance(Base, SMESH._objref_SMESH_Group) or isinstance(Base, SMESH._objref_SMESH_subMesh):
3629 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3630 HasAngles, Angles, LinearVariation,
3631 HasRefPoint, RefPoint, MakeGroups, ElemType)
3633 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3636 ## Generates new elements by extrusion of the given elements
3637 # The path of extrusion must be a meshed edge.
3638 # @param IDsOfElements ids of elements
3639 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3640 # @param PathShape shape(edge) defines the sub-mesh for the path
3641 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3642 # @param HasAngles allows the shape to be rotated around the path
3643 # to get the resulting mesh in a helical fashion
3644 # @param Angles list of angles in radians
3645 # @param HasRefPoint allows using the reference point
3646 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3647 # The User can specify any point as the Reference Point.
3648 # @param MakeGroups forces the generation of new groups from existing ones
3649 # @param LinearVariation forces the computation of rotation angles as linear
3650 # variation of the given Angles along path steps
3651 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3652 # only SMESH::Extrusion_Error otherwise
3653 # @ingroup l2_modif_extrurev
3654 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3655 HasAngles, Angles, HasRefPoint, RefPoint,
3656 MakeGroups=False, LinearVariation=False):
3657 Angles,AnglesParameters = ParseAngles(Angles)
3658 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3659 if IDsOfElements == []:
3660 IDsOfElements = self.GetElementsId()
3661 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3662 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3664 if ( isinstance( PathMesh, Mesh )):
3665 PathMesh = PathMesh.GetMesh()
3666 if HasAngles and Angles and LinearVariation:
3667 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3669 Parameters = AnglesParameters + var_separator + RefPointParameters
3670 self.mesh.SetParameters(Parameters)
3672 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3673 PathShape, NodeStart, HasAngles,
3674 Angles, HasRefPoint, RefPoint)
3675 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3676 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3678 ## Generates new elements by extrusion of the elements which belong to the object
3679 # The path of extrusion must be a meshed edge.
3680 # @param theObject the object which elements should be processed.
3681 # It can be a mesh, a sub mesh or a group.
3682 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3683 # @param PathShape shape(edge) defines the sub-mesh for the path
3684 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3685 # @param HasAngles allows the shape to be rotated around the path
3686 # to get the resulting mesh in a helical fashion
3687 # @param Angles list of angles
3688 # @param HasRefPoint allows using the reference point
3689 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3690 # The User can specify any point as the Reference Point.
3691 # @param MakeGroups forces the generation of new groups from existing ones
3692 # @param LinearVariation forces the computation of rotation angles as linear
3693 # variation of the given Angles along path steps
3694 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3695 # only SMESH::Extrusion_Error otherwise
3696 # @ingroup l2_modif_extrurev
3697 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3698 HasAngles, Angles, HasRefPoint, RefPoint,
3699 MakeGroups=False, LinearVariation=False):
3700 Angles,AnglesParameters = ParseAngles(Angles)
3701 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3702 if ( isinstance( theObject, Mesh )):
3703 theObject = theObject.GetMesh()
3704 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3705 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3706 if ( isinstance( PathMesh, Mesh )):
3707 PathMesh = PathMesh.GetMesh()
3708 if HasAngles and Angles and LinearVariation:
3709 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3711 Parameters = AnglesParameters + var_separator + RefPointParameters
3712 self.mesh.SetParameters(Parameters)
3714 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3715 PathShape, NodeStart, HasAngles,
3716 Angles, HasRefPoint, RefPoint)
3717 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3718 NodeStart, HasAngles, Angles, HasRefPoint,
3721 ## Generates new elements by extrusion of the elements which belong to the object
3722 # The path of extrusion must be a meshed edge.
3723 # @param theObject the object which elements should be processed.
3724 # It can be a mesh, a sub mesh or a group.
3725 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3726 # @param PathShape shape(edge) defines the sub-mesh for the path
3727 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3728 # @param HasAngles allows the shape to be rotated around the path
3729 # to get the resulting mesh in a helical fashion
3730 # @param Angles list of angles
3731 # @param HasRefPoint allows using the reference point
3732 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3733 # The User can specify any point as the Reference Point.
3734 # @param MakeGroups forces the generation of new groups from existing ones
3735 # @param LinearVariation forces the computation of rotation angles as linear
3736 # variation of the given Angles along path steps
3737 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3738 # only SMESH::Extrusion_Error otherwise
3739 # @ingroup l2_modif_extrurev
3740 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3741 HasAngles, Angles, HasRefPoint, RefPoint,
3742 MakeGroups=False, LinearVariation=False):
3743 Angles,AnglesParameters = ParseAngles(Angles)
3744 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3745 if ( isinstance( theObject, Mesh )):
3746 theObject = theObject.GetMesh()
3747 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3748 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3749 if ( isinstance( PathMesh, Mesh )):
3750 PathMesh = PathMesh.GetMesh()
3751 if HasAngles and Angles and LinearVariation:
3752 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3754 Parameters = AnglesParameters + var_separator + RefPointParameters
3755 self.mesh.SetParameters(Parameters)
3757 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3758 PathShape, NodeStart, HasAngles,
3759 Angles, HasRefPoint, RefPoint)
3760 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3761 NodeStart, HasAngles, Angles, HasRefPoint,
3764 ## Generates new elements by extrusion of the elements which belong to the object
3765 # The path of extrusion must be a meshed edge.
3766 # @param theObject the object which elements should be processed.
3767 # It can be a mesh, a sub mesh or a group.
3768 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3769 # @param PathShape shape(edge) defines the sub-mesh for the path
3770 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3771 # @param HasAngles allows the shape to be rotated around the path
3772 # to get the resulting mesh in a helical fashion
3773 # @param Angles list of angles
3774 # @param HasRefPoint allows using the reference point
3775 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3776 # The User can specify any point as the Reference Point.
3777 # @param MakeGroups forces the generation of new groups from existing ones
3778 # @param LinearVariation forces the computation of rotation angles as linear
3779 # variation of the given Angles along path steps
3780 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3781 # only SMESH::Extrusion_Error otherwise
3782 # @ingroup l2_modif_extrurev
3783 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3784 HasAngles, Angles, HasRefPoint, RefPoint,
3785 MakeGroups=False, LinearVariation=False):
3786 Angles,AnglesParameters = ParseAngles(Angles)
3787 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3788 if ( isinstance( theObject, Mesh )):
3789 theObject = theObject.GetMesh()
3790 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3791 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3792 if ( isinstance( PathMesh, Mesh )):
3793 PathMesh = PathMesh.GetMesh()
3794 if HasAngles and Angles and LinearVariation:
3795 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3797 Parameters = AnglesParameters + var_separator + RefPointParameters
3798 self.mesh.SetParameters(Parameters)
3800 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3801 PathShape, NodeStart, HasAngles,
3802 Angles, HasRefPoint, RefPoint)
3803 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3804 NodeStart, HasAngles, Angles, HasRefPoint,
3807 ## Creates a symmetrical copy of mesh elements
3808 # @param IDsOfElements list of elements ids
3809 # @param Mirror is AxisStruct or geom object(point, line, plane)
3810 # @param theMirrorType is POINT, AXIS or PLANE
3811 # If the Mirror is a geom object this parameter is unnecessary
3812 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3813 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3814 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3815 # @ingroup l2_modif_trsf
3816 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3817 if IDsOfElements == []:
3818 IDsOfElements = self.GetElementsId()
3819 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3820 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3821 Mirror,Parameters = ParseAxisStruct(Mirror)
3822 self.mesh.SetParameters(Parameters)
3823 if Copy and MakeGroups:
3824 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3825 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3828 ## Creates a new mesh by a symmetrical copy of mesh elements
3829 # @param IDsOfElements the list of elements ids
3830 # @param Mirror is AxisStruct or geom object (point, line, plane)
3831 # @param theMirrorType is POINT, AXIS or PLANE
3832 # If the Mirror is a geom object this parameter is unnecessary
3833 # @param MakeGroups to generate new groups from existing ones
3834 # @param NewMeshName a name of the new mesh to create
3835 # @return instance of Mesh class
3836 # @ingroup l2_modif_trsf
3837 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3838 if IDsOfElements == []:
3839 IDsOfElements = self.GetElementsId()
3840 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3841 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3842 Mirror,Parameters = ParseAxisStruct(Mirror)
3843 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3844 MakeGroups, NewMeshName)
3845 mesh.SetParameters(Parameters)
3846 return Mesh(self.smeshpyD,self.geompyD,mesh)
3848 ## Creates a symmetrical copy of the object
3849 # @param theObject mesh, submesh or group
3850 # @param Mirror AxisStruct or geom object (point, line, plane)
3851 # @param theMirrorType is POINT, AXIS or PLANE
3852 # If the Mirror is a geom object this parameter is unnecessary
3853 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3854 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3855 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3856 # @ingroup l2_modif_trsf
3857 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3858 if ( isinstance( theObject, Mesh )):
3859 theObject = theObject.GetMesh()
3860 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3861 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3862 Mirror,Parameters = ParseAxisStruct(Mirror)
3863 self.mesh.SetParameters(Parameters)
3864 if Copy and MakeGroups:
3865 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3866 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3869 ## Creates a new mesh by a symmetrical copy of the object
3870 # @param theObject mesh, submesh or group
3871 # @param Mirror AxisStruct or geom object (point, line, plane)
3872 # @param theMirrorType POINT, AXIS or PLANE
3873 # If the Mirror is a geom object this parameter is unnecessary
3874 # @param MakeGroups forces the generation of new groups from existing ones
3875 # @param NewMeshName the name of the new mesh to create
3876 # @return instance of Mesh class
3877 # @ingroup l2_modif_trsf
3878 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3879 if ( isinstance( theObject, Mesh )):
3880 theObject = theObject.GetMesh()
3881 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3882 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3883 Mirror,Parameters = ParseAxisStruct(Mirror)
3884 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3885 MakeGroups, NewMeshName)
3886 mesh.SetParameters(Parameters)
3887 return Mesh( self.smeshpyD,self.geompyD,mesh )
3889 ## Translates the elements
3890 # @param IDsOfElements list of elements ids
3891 # @param Vector the direction of translation (DirStruct or vector)
3892 # @param Copy allows copying the translated elements
3893 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3894 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3895 # @ingroup l2_modif_trsf
3896 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3897 if IDsOfElements == []:
3898 IDsOfElements = self.GetElementsId()
3899 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3900 Vector = self.smeshpyD.GetDirStruct(Vector)
3901 Vector,Parameters = ParseDirStruct(Vector)
3902 self.mesh.SetParameters(Parameters)
3903 if Copy and MakeGroups:
3904 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3905 self.editor.Translate(IDsOfElements, Vector, Copy)
3908 ## Creates a new mesh of translated elements
3909 # @param IDsOfElements list of elements ids
3910 # @param Vector the direction of translation (DirStruct or vector)
3911 # @param MakeGroups forces the generation of new groups from existing ones
3912 # @param NewMeshName the name of the newly created mesh
3913 # @return instance of Mesh class
3914 # @ingroup l2_modif_trsf
3915 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3916 if IDsOfElements == []:
3917 IDsOfElements = self.GetElementsId()
3918 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3919 Vector = self.smeshpyD.GetDirStruct(Vector)
3920 Vector,Parameters = ParseDirStruct(Vector)
3921 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3922 mesh.SetParameters(Parameters)
3923 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3925 ## Translates the object
3926 # @param theObject the object to translate (mesh, submesh, or group)
3927 # @param Vector direction of translation (DirStruct or geom vector)
3928 # @param Copy allows copying the translated elements
3929 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3930 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3931 # @ingroup l2_modif_trsf
3932 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3933 if ( isinstance( theObject, Mesh )):
3934 theObject = theObject.GetMesh()
3935 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3936 Vector = self.smeshpyD.GetDirStruct(Vector)
3937 Vector,Parameters = ParseDirStruct(Vector)
3938 self.mesh.SetParameters(Parameters)
3939 if Copy and MakeGroups:
3940 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3941 self.editor.TranslateObject(theObject, Vector, Copy)
3944 ## Creates a new mesh from the translated object
3945 # @param theObject the object to translate (mesh, submesh, or group)
3946 # @param Vector the direction of translation (DirStruct or geom vector)
3947 # @param MakeGroups forces the generation of new groups from existing ones
3948 # @param NewMeshName the name of the newly created mesh
3949 # @return instance of Mesh class
3950 # @ingroup l2_modif_trsf
3951 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3952 if (isinstance(theObject, Mesh)):
3953 theObject = theObject.GetMesh()
3954 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3955 Vector = self.smeshpyD.GetDirStruct(Vector)
3956 Vector,Parameters = ParseDirStruct(Vector)
3957 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3958 mesh.SetParameters(Parameters)
3959 return Mesh( self.smeshpyD, self.geompyD, mesh )
3963 ## Scales the object
3964 # @param theObject - the object to translate (mesh, submesh, or group)
3965 # @param thePoint - base point for scale
3966 # @param theScaleFact - list of 1-3 scale factors for axises
3967 # @param Copy - allows copying the translated elements
3968 # @param MakeGroups - forces the generation of new groups from existing
3970 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3971 # empty list otherwise
3972 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3973 if ( isinstance( theObject, Mesh )):
3974 theObject = theObject.GetMesh()
3975 if ( isinstance( theObject, list )):
3976 theObject = self.GetIDSource(theObject, SMESH.ALL)
3978 thePoint, Parameters = ParsePointStruct(thePoint)
3979 self.mesh.SetParameters(Parameters)
3981 if Copy and MakeGroups:
3982 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3983 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3986 ## Creates a new mesh from the translated object
3987 # @param theObject - the object to translate (mesh, submesh, or group)
3988 # @param thePoint - base point for scale
3989 # @param theScaleFact - list of 1-3 scale factors for axises
3990 # @param MakeGroups - forces the generation of new groups from existing ones
3991 # @param NewMeshName - the name of the newly created mesh
3992 # @return instance of Mesh class
3993 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3994 if (isinstance(theObject, Mesh)):
3995 theObject = theObject.GetMesh()
3996 if ( isinstance( theObject, list )):
3997 theObject = self.GetIDSource(theObject,SMESH.ALL)
3999 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
4000 MakeGroups, NewMeshName)
4001 #mesh.SetParameters(Parameters)
4002 return Mesh( self.smeshpyD, self.geompyD, mesh )
4006 ## Rotates the elements
4007 # @param IDsOfElements list of elements ids
4008 # @param Axis the axis of rotation (AxisStruct or geom line)
4009 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
4010 # @param Copy allows copying the rotated elements
4011 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
4012 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
4013 # @ingroup l2_modif_trsf
4014 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
4016 if isinstance(AngleInRadians,str):
4018 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
4020 AngleInRadians = DegreesToRadians(AngleInRadians)
4021 if IDsOfElements == []:
4022 IDsOfElements = self.GetElementsId()
4023 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
4024 Axis = self.smeshpyD.GetAxisStruct(Axis)
4025 Axis,AxisParameters = ParseAxisStruct(Axis)
4026 Parameters = AxisParameters + var_separator + Parameters
4027 self.mesh.SetParameters(Parameters)
4028 if Copy and MakeGroups:
4029 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
4030 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
4033 ## Creates a new mesh of rotated elements
4034 # @param IDsOfElements list of element ids
4035 # @param Axis the axis of rotation (AxisStruct or geom line)
4036 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
4037 # @param MakeGroups forces the generation of new groups from existing ones
4038 # @param NewMeshName the name of the newly created mesh
4039 # @return instance of Mesh class
4040 # @ingroup l2_modif_trsf
4041 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
4043 if isinstance(AngleInRadians,str):
4045 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
4047 AngleInRadians = DegreesToRadians(AngleInRadians)
4048 if IDsOfElements == []:
4049 IDsOfElements = self.GetElementsId()
4050 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
4051 Axis = self.smeshpyD.GetAxisStruct(Axis)
4052 Axis,AxisParameters = ParseAxisStruct(Axis)
4053 Parameters = AxisParameters + var_separator + Parameters
4054 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
4055 MakeGroups, NewMeshName)
4056 mesh.SetParameters(Parameters)
4057 return Mesh( self.smeshpyD, self.geompyD, mesh )
4059 ## Rotates the object
4060 # @param theObject the object to rotate( mesh, submesh, or group)
4061 # @param Axis the axis of rotation (AxisStruct or geom line)
4062 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
4063 # @param Copy allows copying the rotated elements
4064 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
4065 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
4066 # @ingroup l2_modif_trsf
4067 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
4069 if isinstance(AngleInRadians,str):
4071 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
4073 AngleInRadians = DegreesToRadians(AngleInRadians)
4074 if (isinstance(theObject, Mesh)):
4075 theObject = theObject.GetMesh()
4076 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
4077 Axis = self.smeshpyD.GetAxisStruct(Axis)
4078 Axis,AxisParameters = ParseAxisStruct(Axis)
4079 Parameters = AxisParameters + ":" + Parameters
4080 self.mesh.SetParameters(Parameters)
4081 if Copy and MakeGroups:
4082 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
4083 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
4086 ## Creates a new mesh from the rotated object
4087 # @param theObject the object to rotate (mesh, submesh, or group)
4088 # @param Axis the axis of rotation (AxisStruct or geom line)
4089 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
4090 # @param MakeGroups forces the generation of new groups from existing ones
4091 # @param NewMeshName the name of the newly created mesh
4092 # @return instance of Mesh class
4093 # @ingroup l2_modif_trsf
4094 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
4096 if isinstance(AngleInRadians,str):
4098 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
4100 AngleInRadians = DegreesToRadians(AngleInRadians)
4101 if (isinstance( theObject, Mesh )):
4102 theObject = theObject.GetMesh()
4103 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
4104 Axis = self.smeshpyD.GetAxisStruct(Axis)
4105 Axis,AxisParameters = ParseAxisStruct(Axis)
4106 Parameters = AxisParameters + ":" + Parameters
4107 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
4108 MakeGroups, NewMeshName)
4109 mesh.SetParameters(Parameters)
4110 return Mesh( self.smeshpyD, self.geompyD, mesh )
4112 ## Finds groups of ajacent nodes within Tolerance.
4113 # @param Tolerance the value of tolerance
4114 # @return the list of groups of nodes
4115 # @ingroup l2_modif_trsf
4116 def FindCoincidentNodes (self, Tolerance):
4117 return self.editor.FindCoincidentNodes(Tolerance)
4119 ## Finds groups of ajacent nodes within Tolerance.
4120 # @param Tolerance the value of tolerance
4121 # @param SubMeshOrGroup SubMesh or Group
4122 # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
4123 # @return the list of groups of nodes
4124 # @ingroup l2_modif_trsf
4125 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
4126 if (isinstance( SubMeshOrGroup, Mesh )):
4127 SubMeshOrGroup = SubMeshOrGroup.GetMesh()
4128 if not isinstance( exceptNodes, list):
4129 exceptNodes = [ exceptNodes ]
4130 if exceptNodes and isinstance( exceptNodes[0], int):
4131 exceptNodes = [ self.GetIDSource( exceptNodes, SMESH.NODE)]
4132 return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes)
4135 # @param GroupsOfNodes the list of groups of nodes
4136 # @ingroup l2_modif_trsf
4137 def MergeNodes (self, GroupsOfNodes):
4138 self.editor.MergeNodes(GroupsOfNodes)
4140 ## Finds the elements built on the same nodes.
4141 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
4142 # @return a list of groups of equal elements
4143 # @ingroup l2_modif_trsf
4144 def FindEqualElements (self, MeshOrSubMeshOrGroup):
4145 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
4146 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
4147 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
4149 ## Merges elements in each given group.
4150 # @param GroupsOfElementsID groups of elements for merging
4151 # @ingroup l2_modif_trsf
4152 def MergeElements(self, GroupsOfElementsID):
4153 self.editor.MergeElements(GroupsOfElementsID)
4155 ## Leaves one element and removes all other elements built on the same nodes.
4156 # @ingroup l2_modif_trsf
4157 def MergeEqualElements(self):
4158 self.editor.MergeEqualElements()
4160 ## Sews free borders
4161 # @return SMESH::Sew_Error
4162 # @ingroup l2_modif_trsf
4163 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
4164 FirstNodeID2, SecondNodeID2, LastNodeID2,
4165 CreatePolygons, CreatePolyedrs):
4166 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
4167 FirstNodeID2, SecondNodeID2, LastNodeID2,
4168 CreatePolygons, CreatePolyedrs)
4170 ## Sews conform free borders
4171 # @return SMESH::Sew_Error
4172 # @ingroup l2_modif_trsf
4173 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
4174 FirstNodeID2, SecondNodeID2):
4175 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
4176 FirstNodeID2, SecondNodeID2)
4178 ## Sews border to side
4179 # @return SMESH::Sew_Error
4180 # @ingroup l2_modif_trsf
4181 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
4182 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
4183 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
4184 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
4186 ## Sews two sides of a mesh. The nodes belonging to Side1 are
4187 # merged with the nodes of elements of Side2.
4188 # The number of elements in theSide1 and in theSide2 must be
4189 # equal and they should have similar nodal connectivity.
4190 # The nodes to merge should belong to side borders and
4191 # the first node should be linked to the second.
4192 # @return SMESH::Sew_Error
4193 # @ingroup l2_modif_trsf
4194 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
4195 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
4196 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
4197 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
4198 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
4199 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
4201 ## Sets new nodes for the given element.
4202 # @param ide the element id
4203 # @param newIDs nodes ids
4204 # @return If the number of nodes does not correspond to the type of element - returns false
4205 # @ingroup l2_modif_edit
4206 def ChangeElemNodes(self, ide, newIDs):
4207 return self.editor.ChangeElemNodes(ide, newIDs)
4209 ## If during the last operation of MeshEditor some nodes were
4210 # created, this method returns the list of their IDs, \n
4211 # if new nodes were not created - returns empty list
4212 # @return the list of integer values (can be empty)
4213 # @ingroup l1_auxiliary
4214 def GetLastCreatedNodes(self):
4215 return self.editor.GetLastCreatedNodes()
4217 ## If during the last operation of MeshEditor some elements were
4218 # created this method returns the list of their IDs, \n
4219 # if new elements were not created - returns empty list
4220 # @return the list of integer values (can be empty)
4221 # @ingroup l1_auxiliary
4222 def GetLastCreatedElems(self):
4223 return self.editor.GetLastCreatedElems()
4225 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4226 # @param theNodes identifiers of nodes to be doubled
4227 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
4228 # nodes. If list of element identifiers is empty then nodes are doubled but
4229 # they not assigned to elements
4230 # @return TRUE if operation has been completed successfully, FALSE otherwise
4231 # @ingroup l2_modif_edit
4232 def DoubleNodes(self, theNodes, theModifiedElems):
4233 return self.editor.DoubleNodes(theNodes, theModifiedElems)
4235 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4236 # This method provided for convenience works as DoubleNodes() described above.
4237 # @param theNodeId identifiers of node to be doubled
4238 # @param theModifiedElems identifiers of elements to be updated
4239 # @return TRUE if operation has been completed successfully, FALSE otherwise
4240 # @ingroup l2_modif_edit
4241 def DoubleNode(self, theNodeId, theModifiedElems):
4242 return self.editor.DoubleNode(theNodeId, theModifiedElems)
4244 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4245 # This method provided for convenience works as DoubleNodes() described above.
4246 # @param theNodes group of nodes to be doubled
4247 # @param theModifiedElems group of elements to be updated.
4248 # @param theMakeGroup forces the generation of a group containing new nodes.
4249 # @return TRUE or a created group if operation has been completed successfully,
4250 # FALSE or None otherwise
4251 # @ingroup l2_modif_edit
4252 def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
4254 return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
4255 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
4257 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4258 # This method provided for convenience works as DoubleNodes() described above.
4259 # @param theNodes list of groups of nodes to be doubled
4260 # @param theModifiedElems list of groups of elements to be updated.
4261 # @param theMakeGroup forces the generation of a group containing new nodes.
4262 # @return TRUE if operation has been completed successfully, FALSE otherwise
4263 # @ingroup l2_modif_edit
4264 def DoubleNodeGroups(self, theNodes, theModifiedElems, theMakeGroup=False):
4266 return self.editor.DoubleNodeGroupsNew(theNodes, theModifiedElems)
4267 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
4269 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4270 # @param theElems - the list of elements (edges or faces) to be replicated
4271 # The nodes for duplication could be found from these elements
4272 # @param theNodesNot - list of nodes to NOT replicate
4273 # @param theAffectedElems - the list of elements (cells and edges) to which the
4274 # replicated nodes should be associated to.
4275 # @return TRUE if operation has been completed successfully, FALSE otherwise
4276 # @ingroup l2_modif_edit
4277 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
4278 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
4280 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4281 # @param theElems - the list of elements (edges or faces) to be replicated
4282 # The nodes for duplication could be found from these elements
4283 # @param theNodesNot - list of nodes to NOT replicate
4284 # @param theShape - shape to detect affected elements (element which geometric center
4285 # located on or inside shape).
4286 # The replicated nodes should be associated to affected elements.
4287 # @return TRUE if operation has been completed successfully, FALSE otherwise
4288 # @ingroup l2_modif_edit
4289 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
4290 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
4292 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4293 # This method provided for convenience works as DoubleNodes() described above.
4294 # @param theElems - group of of elements (edges or faces) to be replicated
4295 # @param theNodesNot - group of nodes not to replicated
4296 # @param theAffectedElems - group of elements to which the replicated nodes
4297 # should be associated to.
4298 # @param theMakeGroup forces the generation of a group containing new elements.
4299 # @return TRUE or a created group if operation has been completed successfully,
4300 # FALSE or None otherwise
4301 # @ingroup l2_modif_edit
4302 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4304 return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
4305 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
4307 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4308 # This method provided for convenience works as DoubleNodes() described above.
4309 # @param theElems - group of of elements (edges or faces) to be replicated
4310 # @param theNodesNot - group of nodes not to replicated
4311 # @param theShape - shape to detect affected elements (element which geometric center
4312 # located on or inside shape).
4313 # The replicated nodes should be associated to affected elements.
4314 # @ingroup l2_modif_edit
4315 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
4316 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
4318 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4319 # This method provided for convenience works as DoubleNodes() described above.
4320 # @param theElems - list of groups of elements (edges or faces) to be replicated
4321 # @param theNodesNot - list of groups of nodes not to replicated
4322 # @param theAffectedElems - group of elements to which the replicated nodes
4323 # should be associated to.
4324 # @param theMakeGroup forces the generation of a group containing new elements.
4325 # @return TRUE or a created group if operation has been completed successfully,
4326 # FALSE or None otherwise
4327 # @ingroup l2_modif_edit
4328 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4330 return self.editor.DoubleNodeElemGroupsNew(theElems, theNodesNot, theAffectedElems)
4331 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
4333 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4334 # This method provided for convenience works as DoubleNodes() described above.
4335 # @param theElems - list of groups of elements (edges or faces) to be replicated
4336 # @param theNodesNot - list of groups of nodes not to replicated
4337 # @param theShape - shape to detect affected elements (element which geometric center
4338 # located on or inside shape).
4339 # The replicated nodes should be associated to affected elements.
4340 # @return TRUE if operation has been completed successfully, FALSE otherwise
4341 # @ingroup l2_modif_edit
4342 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
4343 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
4345 ## Double nodes on shared faces between groups of volumes and create flat elements on demand.
4346 # The list of groups must describe a partition of the mesh volumes.
4347 # The nodes of the internal faces at the boundaries of the groups are doubled.
4348 # In option, the internal faces are replaced by flat elements.
4349 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4350 # @param theDomains - list of groups of volumes
4351 # @param createJointElems - if TRUE, create the elements
4352 # @return TRUE if operation has been completed successfully, FALSE otherwise
4353 def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems ):
4354 return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems )
4356 ## Double nodes on some external faces and create flat elements.
4357 # Flat elements are mainly used by some types of mechanic calculations.
4359 # Each group of the list must be constituted of faces.
4360 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4361 # @param theGroupsOfFaces - list of groups of faces
4362 # @return TRUE if operation has been completed successfully, FALSE otherwise
4363 def CreateFlatElementsOnFacesGroups(self, theGroupsOfFaces ):
4364 return self.editor.CreateFlatElementsOnFacesGroups( theGroupsOfFaces )
4366 def _valueFromFunctor(self, funcType, elemId):
4367 fn = self.smeshpyD.GetFunctor(funcType)
4368 fn.SetMesh(self.mesh)
4369 if fn.GetElementType() == self.GetElementType(elemId, True):
4370 val = fn.GetValue(elemId)
4375 ## Get length of 1D element.
4376 # @param elemId mesh element ID
4377 # @return element's length value
4378 # @ingroup l1_measurements
4379 def GetLength(self, elemId):
4380 return self._valueFromFunctor(SMESH.FT_Length, elemId)
4382 ## Get area of 2D element.
4383 # @param elemId mesh element ID
4384 # @return element's area value
4385 # @ingroup l1_measurements
4386 def GetArea(self, elemId):
4387 return self._valueFromFunctor(SMESH.FT_Area, elemId)
4389 ## Get volume of 3D element.
4390 # @param elemId mesh element ID
4391 # @return element's volume value
4392 # @ingroup l1_measurements
4393 def GetVolume(self, elemId):
4394 return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
4396 ## Get maximum element length.
4397 # @param elemId mesh element ID
4398 # @return element's maximum length value
4399 # @ingroup l1_measurements
4400 def GetMaxElementLength(self, elemId):
4401 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4402 ftype = SMESH.FT_MaxElementLength3D
4404 ftype = SMESH.FT_MaxElementLength2D
4405 return self._valueFromFunctor(ftype, elemId)
4407 ## Get aspect ratio of 2D or 3D element.
4408 # @param elemId mesh element ID
4409 # @return element's aspect ratio value
4410 # @ingroup l1_measurements
4411 def GetAspectRatio(self, elemId):
4412 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4413 ftype = SMESH.FT_AspectRatio3D
4415 ftype = SMESH.FT_AspectRatio
4416 return self._valueFromFunctor(ftype, elemId)
4418 ## Get warping angle of 2D element.
4419 # @param elemId mesh element ID
4420 # @return element's warping angle value
4421 # @ingroup l1_measurements
4422 def GetWarping(self, elemId):
4423 return self._valueFromFunctor(SMESH.FT_Warping, elemId)
4425 ## Get minimum angle of 2D element.
4426 # @param elemId mesh element ID
4427 # @return element's minimum angle value
4428 # @ingroup l1_measurements
4429 def GetMinimumAngle(self, elemId):
4430 return self._valueFromFunctor(SMESH.FT_MinimumAngle, elemId)
4432 ## Get taper of 2D element.
4433 # @param elemId mesh element ID
4434 # @return element's taper value
4435 # @ingroup l1_measurements
4436 def GetTaper(self, elemId):
4437 return self._valueFromFunctor(SMESH.FT_Taper, elemId)
4439 ## Get skew of 2D element.
4440 # @param elemId mesh element ID
4441 # @return element's skew value
4442 # @ingroup l1_measurements
4443 def GetSkew(self, elemId):
4444 return self._valueFromFunctor(SMESH.FT_Skew, elemId)
4446 ## The mother class to define algorithm, it is not recommended to use it directly.
4449 # @ingroup l2_algorithms
4450 class Mesh_Algorithm:
4451 # @class Mesh_Algorithm
4452 # @brief Class Mesh_Algorithm
4454 #def __init__(self,smesh):
4462 ## Finds a hypothesis in the study by its type name and parameters.
4463 # Finds only the hypotheses created in smeshpyD engine.
4464 # @return SMESH.SMESH_Hypothesis
4465 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
4466 study = smeshpyD.GetCurrentStudy()
4467 #to do: find component by smeshpyD object, not by its data type
4468 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4469 if scomp is not None:
4470 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
4471 # Check if the root label of the hypotheses exists
4472 if res and hypRoot is not None:
4473 iter = study.NewChildIterator(hypRoot)
4474 # Check all published hypotheses
4476 hypo_so_i = iter.Value()
4477 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
4478 if attr is not None:
4479 anIOR = attr.Value()
4480 hypo_o_i = salome.orb.string_to_object(anIOR)
4481 if hypo_o_i is not None:
4482 # Check if this is a hypothesis
4483 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
4484 if hypo_i is not None:
4485 # Check if the hypothesis belongs to current engine
4486 if smeshpyD.GetObjectId(hypo_i) > 0:
4487 # Check if this is the required hypothesis
4488 if hypo_i.GetName() == hypname:
4490 if CompareMethod(hypo_i, args):
4504 ## Finds the algorithm in the study by its type name.
4505 # Finds only the algorithms, which have been created in smeshpyD engine.
4506 # @return SMESH.SMESH_Algo
4507 def FindAlgorithm (self, algoname, smeshpyD):
4508 study = smeshpyD.GetCurrentStudy()
4509 #to do: find component by smeshpyD object, not by its data type
4510 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4511 if scomp is not None:
4512 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
4513 # Check if the root label of the algorithms exists
4514 if res and hypRoot is not None:
4515 iter = study.NewChildIterator(hypRoot)
4516 # Check all published algorithms
4518 algo_so_i = iter.Value()
4519 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
4520 if attr is not None:
4521 anIOR = attr.Value()
4522 algo_o_i = salome.orb.string_to_object(anIOR)
4523 if algo_o_i is not None:
4524 # Check if this is an algorithm
4525 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
4526 if algo_i is not None:
4527 # Checks if the algorithm belongs to the current engine
4528 if smeshpyD.GetObjectId(algo_i) > 0:
4529 # Check if this is the required algorithm
4530 if algo_i.GetName() == algoname:
4543 ## If the algorithm is global, returns 0; \n
4544 # else returns the submesh associated to this algorithm.
4545 def GetSubMesh(self):
4548 ## Returns the wrapped mesher.
4549 def GetAlgorithm(self):
4552 ## Gets the list of hypothesis that can be used with this algorithm
4553 def GetCompatibleHypothesis(self):
4556 mylist = self.algo.GetCompatibleHypothesis()
4559 ## Gets the name of the algorithm
4563 ## Sets the name to the algorithm
4564 def SetName(self, name):
4565 self.mesh.smeshpyD.SetName(self.algo, name)
4567 ## Gets the id of the algorithm
4569 return self.algo.GetId()
4572 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
4574 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
4575 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
4577 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
4579 self.Assign(algo, mesh, geom)
4583 def Assign(self, algo, mesh, geom):
4585 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
4589 self.geom = mesh.geom
4592 AssureGeomPublished( mesh, geom )
4594 name = GetName(geom)
4598 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
4600 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
4601 TreatHypoStatus( status, algo.GetName(), name, True )
4604 def CompareHyp (self, hyp, args):
4605 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
4608 def CompareEqualHyp (self, hyp, args):
4612 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
4613 UseExisting=0, CompareMethod=""):
4616 if CompareMethod == "": CompareMethod = self.CompareHyp
4617 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
4620 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
4625 if isinstance( arg, geompyDC.GEOM._objref_GEOM_Object ):
4626 argStr = arg.GetStudyEntry()
4627 if not argStr: argStr = "GEOM_Obj_%s", arg.GetEntry()
4628 if len( argStr ) > 10:
4629 argStr = argStr[:7]+"..."
4630 if argStr[0] == '[': argStr += ']'
4636 self.mesh.smeshpyD.SetName(hypo, hyp + a)
4640 geomName = GetName(self.geom)
4641 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
4642 TreatHypoStatus( status, GetName(hypo), geomName, 0 )
4645 ## Returns entry of the shape to mesh in the study
4646 def MainShapeEntry(self):
4648 if not self.mesh or not self.mesh.GetMesh(): return entry
4649 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
4650 study = self.mesh.smeshpyD.GetCurrentStudy()
4651 ior = salome.orb.object_to_string( self.mesh.GetShape() )
4652 sobj = study.FindObjectIOR(ior)
4653 if sobj: entry = sobj.GetID()
4654 if not entry: return ""
4657 ## Defines "ViscousLayers" hypothesis to give parameters of layers of prisms to build
4658 # near mesh boundary. This hypothesis can be used by several 3D algorithms:
4659 # NETGEN 3D, GHS3D, Hexahedron(i,j,k)
4660 # @param thickness total thickness of layers of prisms
4661 # @param numberOfLayers number of layers of prisms
4662 # @param stretchFactor factor (>1.0) of growth of layer thickness towards inside of mesh
4663 # @param ignoreFaces list of geometrical faces (or their ids) not to generate layers on
4664 # @ingroup l3_hypos_additi
4665 def ViscousLayers(self, thickness, numberOfLayers, stretchFactor, ignoreFaces=[]):
4666 if not isinstance(self.algo, SMESH._objref_SMESH_3D_Algo):
4667 raise TypeError, "ViscousLayers are supported by 3D algorithms only"
4668 if not "ViscousLayers" in self.GetCompatibleHypothesis():
4669 raise TypeError, "ViscousLayers are not supported by %s"%self.algo.GetName()
4670 if ignoreFaces and isinstance( ignoreFaces[0], geompyDC.GEOM._objref_GEOM_Object ):
4671 ignoreFaces = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, f) for f in ignoreFaces ]
4672 hyp = self.Hypothesis("ViscousLayers",
4673 [thickness, numberOfLayers, stretchFactor, ignoreFaces])
4674 hyp.SetTotalThickness(thickness)
4675 hyp.SetNumberLayers(numberOfLayers)
4676 hyp.SetStretchFactor(stretchFactor)
4677 hyp.SetIgnoreFaces(ignoreFaces)
4680 ## Transform a list of ether edges or tuples (edge 1st_vertex_of_edge)
4681 # into a list acceptable to SetReversedEdges() of some 1D hypotheses
4682 # @ingroup l3_hypos_1dhyps
4683 def ReversedEdgeIndices(self, reverseList):
4685 geompy = self.mesh.geompyD
4686 for i in reverseList:
4687 if isinstance( i, int ):
4688 s = geompy.SubShapes(self.mesh.geom, [i])[0]
4689 if s.GetShapeType() != geompyDC.GEOM.EDGE:
4690 raise TypeError, "Not EDGE index given"
4692 elif isinstance( i, geompyDC.GEOM._objref_GEOM_Object ):
4693 if i.GetShapeType() != geompyDC.GEOM.EDGE:
4694 raise TypeError, "Not an EDGE given"
4695 resList.append( geompy.GetSubShapeID(self.mesh.geom, i ))
4699 if not isinstance( e, geompyDC.GEOM._objref_GEOM_Object ) or \
4700 not isinstance( v, geompyDC.GEOM._objref_GEOM_Object ):
4701 raise TypeError, "A list item must be a tuple (edge 1st_vertex_of_edge)"
4702 if v.GetShapeType() == geompyDC.GEOM.EDGE and \
4703 e.GetShapeType() == geompyDC.GEOM.VERTEX:
4705 if e.GetShapeType() != geompyDC.GEOM.EDGE or \
4706 v.GetShapeType() != geompyDC.GEOM.VERTEX:
4707 raise TypeError, "A list item must be a tuple (edge 1st_vertex_of_edge)"
4708 vFirst = FirstVertexOnCurve( e )
4709 tol = geompy.Tolerance( vFirst )[-1]
4710 if geompy.MinDistance( v, vFirst ) > 1.5*tol:
4711 resList.append( geompy.GetSubShapeID(self.mesh.geom, e ))
4713 raise TypeError, "Item must be either an edge or tuple (edge 1st_vertex_of_edge)"
4716 # Public class: Mesh_Segment
4717 # --------------------------
4719 ## Class to define a segment 1D algorithm for discretization
4722 # @ingroup l3_algos_basic
4723 class Mesh_Segment(Mesh_Algorithm):
4725 ## Private constructor.
4726 def __init__(self, mesh, geom=0):
4727 Mesh_Algorithm.__init__(self)
4728 self.Create(mesh, geom, "Regular_1D")
4730 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
4731 # @param l for the length of segments that cut an edge
4732 # @param UseExisting if ==true - searches for an existing hypothesis created with
4733 # the same parameters, else (default) - creates a new one
4734 # @param p precision, used for calculation of the number of segments.
4735 # The precision should be a positive, meaningful value within the range [0,1].
4736 # In general, the number of segments is calculated with the formula:
4737 # nb = ceil((edge_length / l) - p)
4738 # Function ceil rounds its argument to the higher integer.
4739 # So, p=0 means rounding of (edge_length / l) to the higher integer,
4740 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
4741 # p=1 means rounding of (edge_length / l) to the lower integer.
4742 # Default value is 1e-07.
4743 # @return an instance of StdMeshers_LocalLength hypothesis
4744 # @ingroup l3_hypos_1dhyps
4745 def LocalLength(self, l, UseExisting=0, p=1e-07):
4746 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
4747 CompareMethod=self.CompareLocalLength)
4753 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
4754 def CompareLocalLength(self, hyp, args):
4755 if IsEqual(hyp.GetLength(), args[0]):
4756 return IsEqual(hyp.GetPrecision(), args[1])
4759 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
4760 # @param length is optional maximal allowed length of segment, if it is omitted
4761 # the preestimated length is used that depends on geometry size
4762 # @param UseExisting if ==true - searches for an existing hypothesis created with
4763 # the same parameters, else (default) - create a new one
4764 # @return an instance of StdMeshers_MaxLength hypothesis
4765 # @ingroup l3_hypos_1dhyps
4766 def MaxSize(self, length=0.0, UseExisting=0):
4767 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
4770 hyp.SetLength(length)
4772 # set preestimated length
4773 gen = self.mesh.smeshpyD
4774 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
4775 self.mesh.GetMesh(), self.mesh.GetShape(),
4777 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
4779 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
4782 hyp.SetUsePreestimatedLength( length == 0.0 )
4785 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
4786 # @param n for the number of segments that cut an edge
4787 # @param s for the scale factor (optional)
4788 # @param reversedEdges is a list of edges to mesh using reversed orientation.
4789 # A list item can also be a tuple (edge 1st_vertex_of_edge)
4790 # @param UseExisting if ==true - searches for an existing hypothesis created with
4791 # the same parameters, else (default) - create a new one
4792 # @return an instance of StdMeshers_NumberOfSegments hypothesis
4793 # @ingroup l3_hypos_1dhyps
4794 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4795 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4796 reversedEdges, UseExisting = [], reversedEdges
4797 entry = self.MainShapeEntry()
4798 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
4800 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdgeInd, entry],
4801 UseExisting=UseExisting,
4802 CompareMethod=self.CompareNumberOfSegments)
4804 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdgeInd, entry],
4805 UseExisting=UseExisting,
4806 CompareMethod=self.CompareNumberOfSegments)
4807 hyp.SetDistrType( 1 )
4808 hyp.SetScaleFactor(s)
4809 hyp.SetNumberOfSegments(n)
4810 hyp.SetReversedEdges( reversedEdgeInd )
4811 hyp.SetObjectEntry( entry )
4815 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4816 def CompareNumberOfSegments(self, hyp, args):
4817 if hyp.GetNumberOfSegments() == args[0]:
4819 if hyp.GetReversedEdges() == args[1]:
4820 if not args[1] or hyp.GetObjectEntry() == args[2]:
4823 if hyp.GetReversedEdges() == args[2]:
4824 if not args[2] or hyp.GetObjectEntry() == args[3]:
4825 if hyp.GetDistrType() == 1:
4826 if IsEqual(hyp.GetScaleFactor(), args[1]):
4830 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4831 # @param start defines the length of the first segment
4832 # @param end defines the length of the last segment
4833 # @param reversedEdges is a list of edges to mesh using reversed orientation.
4834 # A list item can also be a tuple (edge 1st_vertex_of_edge)
4835 # @param UseExisting if ==true - searches for an existing hypothesis created with
4836 # the same parameters, else (default) - creates a new one
4837 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4838 # @ingroup l3_hypos_1dhyps
4839 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4840 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4841 reversedEdges, UseExisting = [], reversedEdges
4842 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
4843 entry = self.MainShapeEntry()
4844 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdgeInd, entry],
4845 UseExisting=UseExisting,
4846 CompareMethod=self.CompareArithmetic1D)
4847 hyp.SetStartLength(start)
4848 hyp.SetEndLength(end)
4849 hyp.SetReversedEdges( reversedEdgeInd )
4850 hyp.SetObjectEntry( entry )
4854 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4855 def CompareArithmetic1D(self, hyp, args):
4856 if IsEqual(hyp.GetLength(1), args[0]):
4857 if IsEqual(hyp.GetLength(0), args[1]):
4858 if hyp.GetReversedEdges() == args[2]:
4859 if not args[2] or hyp.GetObjectEntry() == args[3]:
4864 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4865 # on curve from 0 to 1 (additionally it is neecessary to check
4866 # orientation of edges and create list of reversed edges if it is
4867 # needed) and sets numbers of segments between given points (default
4868 # values are equals 1
4869 # @param points defines the list of parameters on curve
4870 # @param nbSegs defines the list of numbers of segments
4871 # @param reversedEdges is a list of edges to mesh using reversed orientation.
4872 # A list item can also be a tuple (edge 1st_vertex_of_edge)
4873 # @param UseExisting if ==true - searches for an existing hypothesis created with
4874 # the same parameters, else (default) - creates a new one
4875 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4876 # @ingroup l3_hypos_1dhyps
4877 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4878 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4879 reversedEdges, UseExisting = [], reversedEdges
4880 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
4881 entry = self.MainShapeEntry()
4882 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdgeInd, entry],
4883 UseExisting=UseExisting,
4884 CompareMethod=self.CompareFixedPoints1D)
4885 hyp.SetPoints(points)
4886 hyp.SetNbSegments(nbSegs)
4887 hyp.SetReversedEdges(reversedEdgeInd)
4888 hyp.SetObjectEntry(entry)
4892 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4893 ## as the given arguments
4894 def CompareFixedPoints1D(self, hyp, args):
4895 if hyp.GetPoints() == args[0]:
4896 if hyp.GetNbSegments() == args[1]:
4897 if hyp.GetReversedEdges() == args[2]:
4898 if not args[2] or hyp.GetObjectEntry() == args[3]:
4904 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4905 # @param start defines the length of the first segment
4906 # @param end defines the length of the last segment
4907 # @param reversedEdges is a list of edges to mesh using reversed orientation.
4908 # A list item can also be a tuple (edge 1st_vertex_of_edge)
4909 # @param UseExisting if ==true - searches for an existing hypothesis created with
4910 # the same parameters, else (default) - creates a new one
4911 # @return an instance of StdMeshers_StartEndLength hypothesis
4912 # @ingroup l3_hypos_1dhyps
4913 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4914 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4915 reversedEdges, UseExisting = [], reversedEdges
4916 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
4917 entry = self.MainShapeEntry()
4918 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdgeInd, entry],
4919 UseExisting=UseExisting,
4920 CompareMethod=self.CompareStartEndLength)
4921 hyp.SetStartLength(start)
4922 hyp.SetEndLength(end)
4923 hyp.SetReversedEdges( reversedEdgeInd )
4924 hyp.SetObjectEntry( entry )
4927 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4928 def CompareStartEndLength(self, hyp, args):
4929 if IsEqual(hyp.GetLength(1), args[0]):
4930 if IsEqual(hyp.GetLength(0), args[1]):
4931 if hyp.GetReversedEdges() == args[2]:
4932 if not args[2] or hyp.GetObjectEntry() == args[3]:
4936 ## Defines "Deflection1D" hypothesis
4937 # @param d for the deflection
4938 # @param UseExisting if ==true - searches for an existing hypothesis created with
4939 # the same parameters, else (default) - create a new one
4940 # @ingroup l3_hypos_1dhyps
4941 def Deflection1D(self, d, UseExisting=0):
4942 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4943 CompareMethod=self.CompareDeflection1D)
4944 hyp.SetDeflection(d)
4947 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4948 def CompareDeflection1D(self, hyp, args):
4949 return IsEqual(hyp.GetDeflection(), args[0])
4951 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4952 # the opposite side in case of quadrangular faces
4953 # @ingroup l3_hypos_additi
4954 def Propagation(self):
4955 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4957 ## Defines "AutomaticLength" hypothesis
4958 # @param fineness for the fineness [0-1]
4959 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4960 # same parameters, else (default) - create a new one
4961 # @ingroup l3_hypos_1dhyps
4962 def AutomaticLength(self, fineness=0, UseExisting=0):
4963 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4964 CompareMethod=self.CompareAutomaticLength)
4965 hyp.SetFineness( fineness )
4968 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4969 def CompareAutomaticLength(self, hyp, args):
4970 return IsEqual(hyp.GetFineness(), args[0])
4972 ## Defines "SegmentLengthAroundVertex" hypothesis
4973 # @param length for the segment length
4974 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4975 # Any other integer value means that the hypothesis will be set on the
4976 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4977 # @param UseExisting if ==true - searches for an existing hypothesis created with
4978 # the same parameters, else (default) - creates a new one
4979 # @ingroup l3_algos_segmarv
4980 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4982 store_geom = self.geom
4983 if type(vertex) is types.IntType:
4984 if vertex == 0 or vertex == 1:
4985 vertex = self.mesh.geompyD.ExtractShapes(self.geom, geompyDC.ShapeType["VERTEX"],True)[vertex]
4993 if self.geom is None:
4994 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4995 AssureGeomPublished( self.mesh, self.geom )
4996 name = GetName(self.geom)
4998 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
5000 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
5002 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
5003 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
5005 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
5006 CompareMethod=self.CompareLengthNearVertex)
5007 self.geom = store_geom
5008 hyp.SetLength( length )
5011 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
5012 # @ingroup l3_algos_segmarv
5013 def CompareLengthNearVertex(self, hyp, args):
5014 return IsEqual(hyp.GetLength(), args[0])
5016 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
5017 # If the 2D mesher sees that all boundary edges are quadratic,
5018 # it generates quadratic faces, else it generates linear faces using
5019 # medium nodes as if they are vertices.
5020 # The 3D mesher generates quadratic volumes only if all boundary faces
5021 # are quadratic, else it fails.
5023 # @ingroup l3_hypos_additi
5024 def QuadraticMesh(self):
5025 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
5028 # Public class: Mesh_CompositeSegment
5029 # --------------------------
5031 ## Defines a segment 1D algorithm for discretization
5033 # @ingroup l3_algos_basic
5034 class Mesh_CompositeSegment(Mesh_Segment):
5036 ## Private constructor.
5037 def __init__(self, mesh, geom=0):
5038 self.Create(mesh, geom, "CompositeSegment_1D")
5041 # Public class: Mesh_Segment_Python
5042 # ---------------------------------
5044 ## Defines a segment 1D algorithm for discretization with python function
5046 # @ingroup l3_algos_basic
5047 class Mesh_Segment_Python(Mesh_Segment):
5049 ## Private constructor.
5050 def __init__(self, mesh, geom=0):
5051 import Python1dPlugin
5052 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
5054 ## Defines "PythonSplit1D" hypothesis
5055 # @param n for the number of segments that cut an edge
5056 # @param func for the python function that calculates the length of all segments
5057 # @param UseExisting if ==true - searches for the existing hypothesis created with
5058 # the same parameters, else (default) - creates a new one
5059 # @ingroup l3_hypos_1dhyps
5060 def PythonSplit1D(self, n, func, UseExisting=0):
5061 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
5062 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
5063 hyp.SetNumberOfSegments(n)
5064 hyp.SetPythonLog10RatioFunction(func)
5067 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
5068 def ComparePythonSplit1D(self, hyp, args):
5069 #if hyp.GetNumberOfSegments() == args[0]:
5070 # if hyp.GetPythonLog10RatioFunction() == args[1]:
5074 # Public class: Mesh_Triangle
5075 # ---------------------------
5077 ## Defines a triangle 2D algorithm
5079 # @ingroup l3_algos_basic
5080 class Mesh_Triangle(Mesh_Algorithm):
5089 ## Private constructor.
5090 def __init__(self, mesh, algoType, geom=0):
5091 Mesh_Algorithm.__init__(self)
5093 if algoType == MEFISTO:
5094 self.Create(mesh, geom, "MEFISTO_2D")
5096 elif algoType == BLSURF:
5098 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
5099 #self.SetPhysicalMesh() - PAL19680
5100 elif algoType == NETGEN:
5102 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
5104 elif algoType == NETGEN_2D:
5106 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
5109 self.algoType = algoType
5111 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
5112 # @param area for the maximum area of each triangle
5113 # @param UseExisting if ==true - searches for an existing hypothesis created with the
5114 # same parameters, else (default) - creates a new one
5116 # Only for algoType == MEFISTO || NETGEN_2D
5117 # @ingroup l3_hypos_2dhyps
5118 def MaxElementArea(self, area, UseExisting=0):
5119 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
5120 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
5121 CompareMethod=self.CompareMaxElementArea)
5122 elif self.algoType == NETGEN:
5123 hyp = self.Parameters(SIMPLE)
5124 hyp.SetMaxElementArea(area)
5127 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
5128 def CompareMaxElementArea(self, hyp, args):
5129 return IsEqual(hyp.GetMaxElementArea(), args[0])
5131 ## Defines "LengthFromEdges" hypothesis to build triangles
5132 # based on the length of the edges taken from the wire
5134 # Only for algoType == MEFISTO || NETGEN_2D
5135 # @ingroup l3_hypos_2dhyps
5136 def LengthFromEdges(self):
5137 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
5138 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
5140 elif self.algoType == NETGEN:
5141 hyp = self.Parameters(SIMPLE)
5142 hyp.LengthFromEdges()
5145 ## Sets a way to define size of mesh elements to generate.
5146 # @param thePhysicalMesh is: DefaultSize, BLSURF_Custom or SizeMap.
5147 # @ingroup l3_hypos_blsurf
5148 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
5149 if self.Parameters():
5150 # Parameter of BLSURF algo
5151 self.params.SetPhysicalMesh(thePhysicalMesh)
5153 ## Sets size of mesh elements to generate.
5154 # @ingroup l3_hypos_blsurf
5155 def SetPhySize(self, theVal):
5156 if self.Parameters():
5157 # Parameter of BLSURF algo
5158 self.params.SetPhySize(theVal)
5160 ## Sets lower boundary of mesh element size (PhySize).
5161 # @ingroup l3_hypos_blsurf
5162 def SetPhyMin(self, theVal=-1):
5163 if self.Parameters():
5164 # Parameter of BLSURF algo
5165 self.params.SetPhyMin(theVal)
5167 ## Sets upper boundary of mesh element size (PhySize).
5168 # @ingroup l3_hypos_blsurf
5169 def SetPhyMax(self, theVal=-1):
5170 if self.Parameters():
5171 # Parameter of BLSURF algo
5172 self.params.SetPhyMax(theVal)
5174 ## Sets a way to define maximum angular deflection of mesh from CAD model.
5175 # @param theGeometricMesh is: 0 (None) or 1 (Custom)
5176 # @ingroup l3_hypos_blsurf
5177 def SetGeometricMesh(self, theGeometricMesh=0):
5178 if self.Parameters():
5179 # Parameter of BLSURF algo
5180 if self.params.GetPhysicalMesh() == 0: theGeometricMesh = 1
5181 self.params.SetGeometricMesh(theGeometricMesh)
5183 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
5184 # @ingroup l3_hypos_blsurf
5185 def SetAngleMeshS(self, theVal=_angleMeshS):
5186 if self.Parameters():
5187 # Parameter of BLSURF algo
5188 if self.params.GetGeometricMesh() == 0: theVal = self._angleMeshS
5189 self.params.SetAngleMeshS(theVal)
5191 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
5192 # @ingroup l3_hypos_blsurf
5193 def SetAngleMeshC(self, theVal=_angleMeshS):
5194 if self.Parameters():
5195 # Parameter of BLSURF algo
5196 if self.params.GetGeometricMesh() == 0: theVal = self._angleMeshS
5197 self.params.SetAngleMeshC(theVal)
5199 ## Sets lower boundary of mesh element size computed to respect angular deflection.
5200 # @ingroup l3_hypos_blsurf
5201 def SetGeoMin(self, theVal=-1):
5202 if self.Parameters():
5203 # Parameter of BLSURF algo
5204 self.params.SetGeoMin(theVal)
5206 ## Sets upper boundary of mesh element size computed to respect angular deflection.
5207 # @ingroup l3_hypos_blsurf
5208 def SetGeoMax(self, theVal=-1):
5209 if self.Parameters():
5210 # Parameter of BLSURF algo
5211 self.params.SetGeoMax(theVal)
5213 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
5214 # @ingroup l3_hypos_blsurf
5215 def SetGradation(self, theVal=_gradation):
5216 if self.Parameters():
5217 # Parameter of BLSURF algo
5218 if self.params.GetGeometricMesh() == 0: theVal = self._gradation
5219 self.params.SetGradation(theVal)
5221 ## Sets topology usage way.
5222 # @param way defines how mesh conformity is assured <ul>
5223 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
5224 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li>
5225 # <li>PreCAD - by pre-processing with PreCAD a CAD model</li></ul>
5226 # @ingroup l3_hypos_blsurf
5227 def SetTopology(self, way):
5228 if self.Parameters():
5229 # Parameter of BLSURF algo
5230 self.params.SetTopology(way)
5232 ## To respect geometrical edges or not.
5233 # @ingroup l3_hypos_blsurf
5234 def SetDecimesh(self, toIgnoreEdges=False):
5235 if self.Parameters():
5236 # Parameter of BLSURF algo
5237 self.params.SetDecimesh(toIgnoreEdges)
5239 ## Sets verbosity level in the range 0 to 100.
5240 # @ingroup l3_hypos_blsurf
5241 def SetVerbosity(self, level):
5242 if self.Parameters():
5243 # Parameter of BLSURF algo
5244 self.params.SetVerbosity(level)
5246 ## To optimize merges edges.
5247 # @ingroup l3_hypos_blsurf
5248 def SetPreCADMergeEdges(self, toMergeEdges=False):
5249 if self.Parameters():
5250 # Parameter of BLSURF algo
5251 self.params.SetPreCADMergeEdges(toMergeEdges)
5253 ## To remove nano edges.
5254 # @ingroup l3_hypos_blsurf
5255 def SetPreCADRemoveNanoEdges(self, toRemoveNanoEdges=False):
5256 if self.Parameters():
5257 # Parameter of BLSURF algo
5258 self.params.SetPreCADRemoveNanoEdges(toRemoveNanoEdges)
5260 ## To compute topology from scratch
5261 # @ingroup l3_hypos_blsurf
5262 def SetPreCADDiscardInput(self, toDiscardInput=False):
5263 if self.Parameters():
5264 # Parameter of BLSURF algo
5265 self.params.SetPreCADDiscardInput(toDiscardInput)
5267 ## Sets the length below which an edge is considered as nano
5268 # for the topology processing.
5269 # @ingroup l3_hypos_blsurf
5270 def SetPreCADEpsNano(self, epsNano):
5271 if self.Parameters():
5272 # Parameter of BLSURF algo
5273 self.params.SetPreCADEpsNano(epsNano)
5275 ## Sets advanced option value.
5276 # @ingroup l3_hypos_blsurf
5277 def SetOptionValue(self, optionName, level):
5278 if self.Parameters():
5279 # Parameter of BLSURF algo
5280 self.params.SetOptionValue(optionName,level)
5282 ## Sets advanced PreCAD option value.
5283 # Keyword arguments:
5284 # optionName: name of the option
5285 # optionValue: value of the option
5286 # @ingroup l3_hypos_blsurf
5287 def SetPreCADOptionValue(self, optionName, optionValue):
5288 if self.Parameters():
5289 # Parameter of BLSURF algo
5290 self.params.SetPreCADOptionValue(optionName,optionValue)
5292 ## Sets GMF file for export at computation
5293 # @ingroup l3_hypos_blsurf
5294 def SetGMFFile(self, fileName):
5295 if self.Parameters():
5296 # Parameter of BLSURF algo
5297 self.params.SetGMFFile(fileName)
5299 ## Enforced vertices (BLSURF)
5301 ## To get all the enforced vertices
5302 # @ingroup l3_hypos_blsurf
5303 def GetAllEnforcedVertices(self):
5304 if self.Parameters():
5305 # Parameter of BLSURF algo
5306 return self.params.GetAllEnforcedVertices()
5308 ## To get all the enforced vertices sorted by face (or group, compound)
5309 # @ingroup l3_hypos_blsurf
5310 def GetAllEnforcedVerticesByFace(self):
5311 if self.Parameters():
5312 # Parameter of BLSURF algo
5313 return self.params.GetAllEnforcedVerticesByFace()
5315 ## To get all the enforced vertices sorted by coords of input vertices
5316 # @ingroup l3_hypos_blsurf
5317 def GetAllEnforcedVerticesByCoords(self):
5318 if self.Parameters():
5319 # Parameter of BLSURF algo
5320 return self.params.GetAllEnforcedVerticesByCoords()
5322 ## To get all the coords of input vertices sorted by face (or group, compound)
5323 # @ingroup l3_hypos_blsurf
5324 def GetAllCoordsByFace(self):
5325 if self.Parameters():
5326 # Parameter of BLSURF algo
5327 return self.params.GetAllCoordsByFace()
5329 ## To get all the enforced vertices on a face (or group, compound)
5330 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
5331 # @ingroup l3_hypos_blsurf
5332 def GetEnforcedVertices(self, theFace):
5333 if self.Parameters():
5334 # Parameter of BLSURF algo
5335 AssureGeomPublished( self.mesh, theFace )
5336 return self.params.GetEnforcedVertices(theFace)
5338 ## To clear all the enforced vertices
5339 # @ingroup l3_hypos_blsurf
5340 def ClearAllEnforcedVertices(self):
5341 if self.Parameters():
5342 # Parameter of BLSURF algo
5343 return self.params.ClearAllEnforcedVertices()
5345 ## 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.
5346 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
5347 # @param x : x coordinate
5348 # @param y : y coordinate
5349 # @param z : z coordinate
5350 # @param vertexName : name of the enforced vertex
5351 # @param groupName : name of the group
5352 # @ingroup l3_hypos_blsurf
5353 def SetEnforcedVertex(self, theFace, x, y, z, vertexName = "", groupName = ""):
5354 if self.Parameters():
5355 # Parameter of BLSURF algo
5356 AssureGeomPublished( self.mesh, theFace )
5357 if vertexName == "":
5359 return self.params.SetEnforcedVertex(theFace, x, y, z)
5361 return self.params.SetEnforcedVertexWithGroup(theFace, x, y, z, groupName)
5364 return self.params.SetEnforcedVertexNamed(theFace, x, y, z, vertexName)
5366 return self.params.SetEnforcedVertexNamedWithGroup(theFace, x, y, z, vertexName, groupName)
5368 ## To set an enforced vertex on a face (or group, compound) given a GEOM vertex, group or compound.
5369 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
5370 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
5371 # @param groupName : name of the group
5372 # @ingroup l3_hypos_blsurf
5373 def SetEnforcedVertexGeom(self, theFace, theVertex, groupName = ""):
5374 if self.Parameters():
5375 # Parameter of BLSURF algo
5376 AssureGeomPublished( self.mesh, theFace )
5377 AssureGeomPublished( self.mesh, theVertex )
5379 return self.params.SetEnforcedVertexGeom(theFace, theVertex)
5381 return self.params.SetEnforcedVertexGeomWithGroup(theFace, theVertex,groupName)
5383 ## To remove an enforced vertex on a given GEOM face (or group, compound) given the coordinates.
5384 # @param theFace : GEOM face (or group, compound) on which to remove the enforced vertex
5385 # @param x : x coordinate
5386 # @param y : y coordinate
5387 # @param z : z coordinate
5388 # @ingroup l3_hypos_blsurf
5389 def UnsetEnforcedVertex(self, theFace, x, y, z):
5390 if self.Parameters():
5391 # Parameter of BLSURF algo
5392 AssureGeomPublished( self.mesh, theFace )
5393 return self.params.UnsetEnforcedVertex(theFace, x, y, z)
5395 ## To remove an enforced vertex on a given GEOM face (or group, compound) given a GEOM vertex, group or compound.
5396 # @param theFace : GEOM face (or group, compound) on which to remove the enforced vertex
5397 # @param theVertex : GEOM vertex (or group, compound) to remove.
5398 # @ingroup l3_hypos_blsurf
5399 def UnsetEnforcedVertexGeom(self, theFace, theVertex):
5400 if self.Parameters():
5401 # Parameter of BLSURF algo
5402 AssureGeomPublished( self.mesh, theFace )
5403 AssureGeomPublished( self.mesh, theVertex )
5404 return self.params.UnsetEnforcedVertexGeom(theFace, theVertex)
5406 ## To remove all enforced vertices on a given face.
5407 # @param theFace : face (or group/compound of faces) on which to remove all enforced vertices
5408 # @ingroup l3_hypos_blsurf
5409 def UnsetEnforcedVertices(self, theFace):
5410 if self.Parameters():
5411 # Parameter of BLSURF algo
5412 AssureGeomPublished( self.mesh, theFace )
5413 return self.params.UnsetEnforcedVertices(theFace)
5415 ## Attractors (BLSURF)
5417 ## 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 ]
5418 # @param theFace : face on which the attractor will be defined
5419 # @param theAttractor : geometrical object from which the mesh size "h" decreases exponentially
5420 # @param theStartSize : mesh size on theAttractor
5421 # @param theEndSize : maximum size that will be reached on theFace
5422 # @param theInfluenceDistance : influence of the attractor ( the size grow slower on theFace if it's high)
5423 # @param theConstantSizeDistance : distance until which the mesh size will be kept constant on theFace
5424 # @ingroup l3_hypos_blsurf
5425 def SetAttractorGeom(self, theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance):
5426 if self.Parameters():
5427 # Parameter of BLSURF algo
5428 AssureGeomPublished( self.mesh, theFace )
5429 AssureGeomPublished( self.mesh, theAttractor )
5430 self.params.SetAttractorGeom(theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance)
5432 ## Unsets an attractor on the chosen face.
5433 # @param theFace : face on which the attractor has to be removed
5434 # @ingroup l3_hypos_blsurf
5435 def UnsetAttractorGeom(self, theFace):
5436 if self.Parameters():
5437 # Parameter of BLSURF algo
5438 AssureGeomPublished( self.mesh, theFace )
5439 self.params.SetAttractorGeom(theFace)
5441 ## Size maps (BLSURF)
5443 ## To set a size map on a face, edge or vertex (or group, compound) given Python function.
5444 # If theObject is a face, the function can be: def f(u,v): return u+v
5445 # If theObject is an edge, the function can be: def f(t): return t/2
5446 # If theObject is a vertex, the function can be: def f(): return 10
5447 # @param theObject : GEOM face, edge or vertex (or group, compound) on which to define a size map
5448 # @param theSizeMap : Size map defined as a string
5449 # @ingroup l3_hypos_blsurf
5450 def SetSizeMap(self, theObject, theSizeMap):
5451 if self.Parameters():
5452 # Parameter of BLSURF algo
5453 AssureGeomPublished( self.mesh, theObject )
5454 return self.params.SetSizeMap(theObject, theSizeMap)
5456 ## To remove a size map defined on a face, edge or vertex (or group, compound)
5457 # @param theObject : GEOM face, edge or vertex (or group, compound) on which to define a size map
5458 # @ingroup l3_hypos_blsurf
5459 def UnsetSizeMap(self, theObject):
5460 if self.Parameters():
5461 # Parameter of BLSURF algo
5462 AssureGeomPublished( self.mesh, theObject )
5463 return self.params.UnsetSizeMap(theObject)
5465 ## To remove all the size maps
5466 # @ingroup l3_hypos_blsurf
5467 def ClearSizeMaps(self):
5468 if self.Parameters():
5469 # Parameter of BLSURF algo
5470 return self.params.ClearSizeMaps()
5473 ## Sets QuadAllowed flag.
5474 # Only for algoType == NETGEN(NETGEN_1D2D) || NETGEN_2D || BLSURF
5475 # @ingroup l3_hypos_netgen l3_hypos_blsurf
5476 def SetQuadAllowed(self, toAllow=True):
5477 if self.algoType == NETGEN_2D:
5480 hasSimpleHyps = False
5481 simpleHyps = ["QuadranglePreference","LengthFromEdges","MaxElementArea"]
5482 for hyp in self.mesh.GetHypothesisList( self.geom ):
5483 if hyp.GetName() in simpleHyps:
5484 hasSimpleHyps = True
5485 if hyp.GetName() == "QuadranglePreference":
5486 if not toAllow: # remove QuadranglePreference
5487 self.mesh.RemoveHypothesis( self.geom, hyp )
5493 if toAllow: # add QuadranglePreference
5494 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
5499 if self.Parameters():
5500 self.params.SetQuadAllowed(toAllow)
5503 ## Defines hypothesis having several parameters
5505 # @ingroup l3_hypos_netgen
5506 def Parameters(self, which=SOLE):
5508 if self.algoType == NETGEN:
5510 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
5511 "libNETGENEngine.so", UseExisting=0)
5513 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
5514 "libNETGENEngine.so", UseExisting=0)
5515 elif self.algoType == MEFISTO:
5516 print "Mefisto algo support no multi-parameter hypothesis"
5517 elif self.algoType == NETGEN_2D:
5518 self.params = self.Hypothesis("NETGEN_Parameters_2D_ONLY", [],
5519 "libNETGENEngine.so", UseExisting=0)
5520 elif self.algoType == BLSURF:
5521 self.params = self.Hypothesis("BLSURF_Parameters", [],
5522 "libBLSURFEngine.so", UseExisting=0)
5524 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
5529 # Only for algoType == NETGEN
5530 # @ingroup l3_hypos_netgen
5531 def SetMaxSize(self, theSize):
5532 if self.Parameters():
5533 self.params.SetMaxSize(theSize)
5535 ## Sets SecondOrder flag
5537 # Only for algoType == NETGEN
5538 # @ingroup l3_hypos_netgen
5539 def SetSecondOrder(self, theVal):
5540 if self.Parameters():
5541 self.params.SetSecondOrder(theVal)
5543 ## Sets Optimize flag
5545 # Only for algoType == NETGEN
5546 # @ingroup l3_hypos_netgen
5547 def SetOptimize(self, theVal):
5548 if self.Parameters():
5549 self.params.SetOptimize(theVal)
5552 # @param theFineness is:
5553 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5555 # Only for algoType == NETGEN
5556 # @ingroup l3_hypos_netgen
5557 def SetFineness(self, theFineness):
5558 if self.Parameters():
5559 self.params.SetFineness(theFineness)
5563 # Only for algoType == NETGEN
5564 # @ingroup l3_hypos_netgen
5565 def SetGrowthRate(self, theRate):
5566 if self.Parameters():
5567 self.params.SetGrowthRate(theRate)
5569 ## Sets NbSegPerEdge
5571 # Only for algoType == NETGEN
5572 # @ingroup l3_hypos_netgen
5573 def SetNbSegPerEdge(self, theVal):
5574 if self.Parameters():
5575 self.params.SetNbSegPerEdge(theVal)
5577 ## Sets NbSegPerRadius
5579 # Only for algoType == NETGEN
5580 # @ingroup l3_hypos_netgen
5581 def SetNbSegPerRadius(self, theVal):
5582 if self.Parameters():
5583 self.params.SetNbSegPerRadius(theVal)
5585 ## Sets number of segments overriding value set by SetLocalLength()
5587 # Only for algoType == NETGEN
5588 # @ingroup l3_hypos_netgen
5589 def SetNumberOfSegments(self, theVal):
5590 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5592 ## Sets number of segments overriding value set by SetNumberOfSegments()
5594 # Only for algoType == NETGEN
5595 # @ingroup l3_hypos_netgen
5596 def SetLocalLength(self, theVal):
5597 self.Parameters(SIMPLE).SetLocalLength(theVal)
5602 # Public class: Mesh_Quadrangle
5603 # -----------------------------
5605 ## Defines a quadrangle 2D algorithm
5607 # @ingroup l3_algos_basic
5608 class Mesh_Quadrangle(Mesh_Algorithm):
5612 ## Private constructor.
5613 def __init__(self, mesh, geom=0):
5614 Mesh_Algorithm.__init__(self)
5615 self.Create(mesh, geom, "Quadrangle_2D")
5618 ## Defines "QuadrangleParameters" hypothesis
5619 # @param quadType defines the algorithm of transition between differently descretized
5620 # sides of a geometrical face:
5621 # - QUAD_STANDARD - both triangles and quadrangles are possible in the transition
5622 # area along the finer meshed sides.
5623 # - QUAD_TRIANGLE_PREF - only triangles are built in the transition area along the
5624 # finer meshed sides.
5625 # - QUAD_QUADRANGLE_PREF - only quadrangles are built in the transition area along
5626 # the finer meshed sides, iff the total quantity of segments on
5627 # all four sides of the face is even (divisible by 2).
5628 # - QUAD_QUADRANGLE_PREF_REVERSED - same as QUAD_QUADRANGLE_PREF but the transition
5629 # area is located along the coarser meshed sides.
5630 # - QUAD_REDUCED - only quadrangles are built and the transition between the sides
5631 # is made gradually, layer by layer. This type has a limitation on
5632 # the number of segments: one pair of opposite sides must have the
5633 # same number of segments, the other pair must have an even difference
5634 # between the numbers of segments on the sides.
5635 # @param triangleVertex: vertex of a trilateral geometrical face, around which triangles
5636 # will be created while other elements will be quadrangles.
5637 # Vertex can be either a GEOM_Object or a vertex ID within the
5639 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5640 # the same parameters, else (default) - creates a new one
5641 # @ingroup l3_hypos_quad
5642 def QuadrangleParameters(self, quadType=StdMeshers.QUAD_STANDARD, triangleVertex=0, UseExisting=0):
5643 vertexID = triangleVertex
5644 if isinstance( triangleVertex, geompyDC.GEOM._objref_GEOM_Object ):
5645 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, triangleVertex )
5647 compFun = lambda hyp,args: \
5648 hyp.GetQuadType() == args[0] and \
5649 ( hyp.GetTriaVertex()==args[1] or ( hyp.GetTriaVertex()<1 and args[1]<1))
5650 self.params = self.Hypothesis("QuadrangleParams", [quadType,vertexID],
5651 UseExisting = UseExisting, CompareMethod=compFun)
5653 if self.params.GetQuadType() != quadType:
5654 self.params.SetQuadType(quadType)
5656 self.params.SetTriaVertex( vertexID )
5659 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5660 # quadrangles are built in the transition area along the finer meshed sides,
5661 # iff the total quantity of segments on all four sides of the face is even.
5662 # @param reversed if True, transition area is located along the coarser meshed sides.
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 QuadranglePreference(self, reversed=False, UseExisting=0):
5668 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF_REVERSED,UseExisting=UseExisting)
5669 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF,UseExisting=UseExisting)
5671 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5672 # triangles are built in the transition area along the finer meshed sides.
5673 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5674 # the same parameters, else (default) - creates a new one
5675 # @ingroup l3_hypos_quad
5676 def TrianglePreference(self, UseExisting=0):
5677 return self.QuadrangleParameters(QUAD_TRIANGLE_PREF,UseExisting=UseExisting)
5679 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5680 # quadrangles are built and the transition between the sides is made gradually,
5681 # layer by layer. This type has a limitation on the number of segments: one pair
5682 # of opposite sides must have the same number of segments, the other pair must
5683 # have an even difference between the numbers of segments on the sides.
5684 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5685 # the same parameters, else (default) - creates a new one
5686 # @ingroup l3_hypos_quad
5687 def Reduced(self, UseExisting=0):
5688 return self.QuadrangleParameters(QUAD_REDUCED,UseExisting=UseExisting)
5690 ## Defines "QuadrangleParams" hypothesis with QUAD_STANDARD type of quadrangulation
5691 # @param vertex: vertex of a trilateral geometrical face, around which triangles
5692 # will be created while other elements will be quadrangles.
5693 # Vertex can be either a GEOM_Object or a vertex ID within the
5695 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5696 # the same parameters, else (default) - creates a new one
5697 # @ingroup l3_hypos_quad
5698 def TriangleVertex(self, vertex, UseExisting=0):
5699 return self.QuadrangleParameters(QUAD_STANDARD,vertex,UseExisting)
5702 # Public class: Mesh_Tetrahedron
5703 # ------------------------------
5705 ## Defines a tetrahedron 3D algorithm
5707 # @ingroup l3_algos_basic
5708 class Mesh_Tetrahedron(Mesh_Algorithm):
5713 ## Private constructor.
5714 def __init__(self, mesh, algoType, geom=0):
5715 Mesh_Algorithm.__init__(self)
5717 if algoType == NETGEN:
5719 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
5722 elif algoType == FULL_NETGEN:
5724 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5727 elif algoType == GHS3D:
5729 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
5732 elif algoType == GHS3DPRL:
5733 CheckPlugin(GHS3DPRL)
5734 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
5737 self.algoType = algoType
5739 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
5740 # @param vol for the maximum volume of each tetrahedron
5741 # @param UseExisting if ==true - searches for the existing hypothesis created with
5742 # the same parameters, else (default) - creates a new one
5743 # @ingroup l3_hypos_maxvol
5744 def MaxElementVolume(self, vol, UseExisting=0):
5745 if self.algoType == NETGEN:
5746 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
5747 CompareMethod=self.CompareMaxElementVolume)
5748 hyp.SetMaxElementVolume(vol)
5750 elif self.algoType == FULL_NETGEN:
5751 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
5754 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
5755 def CompareMaxElementVolume(self, hyp, args):
5756 return IsEqual(hyp.GetMaxElementVolume(), args[0])
5758 ## Defines hypothesis having several parameters
5760 # @ingroup l3_hypos_netgen
5761 def Parameters(self, which=SOLE):
5764 if self.algoType == FULL_NETGEN:
5766 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
5767 "libNETGENEngine.so", UseExisting=0)
5769 self.params = self.Hypothesis("NETGEN_Parameters", [],
5770 "libNETGENEngine.so", UseExisting=0)
5772 elif self.algoType == NETGEN:
5773 self.params = self.Hypothesis("NETGEN_Parameters_3D", [],
5774 "libNETGENEngine.so", UseExisting=0)
5776 elif self.algoType == GHS3D:
5777 self.params = self.Hypothesis("GHS3D_Parameters", [],
5778 "libGHS3DEngine.so", UseExisting=0)
5780 elif self.algoType == GHS3DPRL:
5781 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
5782 "libGHS3DPRLEngine.so", UseExisting=0)
5784 print "Warning: %s supports no multi-parameter hypothesis"%self.algo.GetName()
5789 # Parameter of FULL_NETGEN and NETGEN
5790 # @ingroup l3_hypos_netgen
5791 def SetMaxSize(self, theSize):
5792 self.Parameters().SetMaxSize(theSize)
5794 ## Sets SecondOrder flag
5795 # Parameter of FULL_NETGEN
5796 # @ingroup l3_hypos_netgen
5797 def SetSecondOrder(self, theVal):
5798 self.Parameters().SetSecondOrder(theVal)
5800 ## Sets Optimize flag
5801 # Parameter of FULL_NETGEN and NETGEN
5802 # @ingroup l3_hypos_netgen
5803 def SetOptimize(self, theVal):
5804 self.Parameters().SetOptimize(theVal)
5807 # @param theFineness is:
5808 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5809 # Parameter of FULL_NETGEN
5810 # @ingroup l3_hypos_netgen
5811 def SetFineness(self, theFineness):
5812 self.Parameters().SetFineness(theFineness)
5815 # Parameter of FULL_NETGEN
5816 # @ingroup l3_hypos_netgen
5817 def SetGrowthRate(self, theRate):
5818 self.Parameters().SetGrowthRate(theRate)
5820 ## Sets NbSegPerEdge
5821 # Parameter of FULL_NETGEN
5822 # @ingroup l3_hypos_netgen
5823 def SetNbSegPerEdge(self, theVal):
5824 self.Parameters().SetNbSegPerEdge(theVal)
5826 ## Sets NbSegPerRadius
5827 # Parameter of FULL_NETGEN
5828 # @ingroup l3_hypos_netgen
5829 def SetNbSegPerRadius(self, theVal):
5830 self.Parameters().SetNbSegPerRadius(theVal)
5832 ## Sets number of segments overriding value set by SetLocalLength()
5833 # Only for algoType == NETGEN_FULL
5834 # @ingroup l3_hypos_netgen
5835 def SetNumberOfSegments(self, theVal):
5836 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5838 ## Sets number of segments overriding value set by SetNumberOfSegments()
5839 # Only for algoType == NETGEN_FULL
5840 # @ingroup l3_hypos_netgen
5841 def SetLocalLength(self, theVal):
5842 self.Parameters(SIMPLE).SetLocalLength(theVal)
5844 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
5845 # Overrides value set by LengthFromEdges()
5846 # Only for algoType == NETGEN_FULL
5847 # @ingroup l3_hypos_netgen
5848 def MaxElementArea(self, area):
5849 self.Parameters(SIMPLE).SetMaxElementArea(area)
5851 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
5852 # Overrides value set by MaxElementArea()
5853 # Only for algoType == NETGEN_FULL
5854 # @ingroup l3_hypos_netgen
5855 def LengthFromEdges(self):
5856 self.Parameters(SIMPLE).LengthFromEdges()
5858 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
5859 # Overrides value set by MaxElementVolume()
5860 # Only for algoType == NETGEN_FULL
5861 # @ingroup l3_hypos_netgen
5862 def LengthFromFaces(self):
5863 self.Parameters(SIMPLE).LengthFromFaces()
5865 ## To mesh "holes" in a solid or not. Default is to mesh.
5866 # @ingroup l3_hypos_ghs3dh
5867 def SetToMeshHoles(self, toMesh):
5868 # Parameter of GHS3D
5869 if self.Parameters():
5870 self.params.SetToMeshHoles(toMesh)
5872 ## Set Optimization level:
5873 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
5874 # Strong_Optimization.
5875 # Default is Standard_Optimization
5876 # @ingroup l3_hypos_ghs3dh
5877 def SetOptimizationLevel(self, level):
5878 # Parameter of GHS3D
5879 if self.Parameters():
5880 self.params.SetOptimizationLevel(level)
5882 ## Maximal size of memory to be used by the algorithm (in Megabytes).
5883 # @ingroup l3_hypos_ghs3dh
5884 def SetMaximumMemory(self, MB):
5885 # Advanced parameter of GHS3D
5886 if self.Parameters():
5887 self.params.SetMaximumMemory(MB)
5889 ## Initial size of memory to be used by the algorithm (in Megabytes) in
5890 # automatic memory adjustment mode.
5891 # @ingroup l3_hypos_ghs3dh
5892 def SetInitialMemory(self, MB):
5893 # Advanced parameter of GHS3D
5894 if self.Parameters():
5895 self.params.SetInitialMemory(MB)
5897 ## Path to working directory.
5898 # @ingroup l3_hypos_ghs3dh
5899 def SetWorkingDirectory(self, path):
5900 # Advanced parameter of GHS3D
5901 if self.Parameters():
5902 self.params.SetWorkingDirectory(path)
5904 ## To keep working files or remove them. Log file remains in case of errors anyway.
5905 # @ingroup l3_hypos_ghs3dh
5906 def SetKeepFiles(self, toKeep):
5907 # Advanced parameter of GHS3D and GHS3DPRL
5908 if self.Parameters():
5909 self.params.SetKeepFiles(toKeep)
5911 ## To set verbose level [0-10]. <ul>
5912 #<li> 0 - no standard output,
5913 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
5914 # indicates when the final mesh is being saved. In addition the software
5915 # gives indication regarding the CPU time.
5916 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
5917 # histogram of the skin mesh, quality statistics histogram together with
5918 # the characteristics of the final mesh.</ul>
5919 # @ingroup l3_hypos_ghs3dh
5920 def SetVerboseLevel(self, level):
5921 # Advanced parameter of GHS3D
5922 if self.Parameters():
5923 self.params.SetVerboseLevel(level)
5925 ## To create new nodes.
5926 # @ingroup l3_hypos_ghs3dh
5927 def SetToCreateNewNodes(self, toCreate):
5928 # Advanced parameter of GHS3D
5929 if self.Parameters():
5930 self.params.SetToCreateNewNodes(toCreate)
5932 ## To use boundary recovery version which tries to create mesh on a very poor
5933 # quality surface mesh.
5934 # @ingroup l3_hypos_ghs3dh
5935 def SetToUseBoundaryRecoveryVersion(self, toUse):
5936 # Advanced parameter of GHS3D
5937 if self.Parameters():
5938 self.params.SetToUseBoundaryRecoveryVersion(toUse)
5940 ## Applies finite-element correction by replacing overconstrained elements where
5941 # it is possible. The process is cutting first the overconstrained edges and
5942 # second the overconstrained facets. This insure that no edges have two boundary
5943 # vertices and that no facets have three boundary vertices.
5944 # @ingroup l3_hypos_ghs3dh
5945 def SetFEMCorrection(self, toUseFem):
5946 # Advanced parameter of GHS3D
5947 if self.Parameters():
5948 self.params.SetFEMCorrection(toUseFem)
5950 ## To removes initial central point.
5951 # @ingroup l3_hypos_ghs3dh
5952 def SetToRemoveCentralPoint(self, toRemove):
5953 # Advanced parameter of GHS3D
5954 if self.Parameters():
5955 self.params.SetToRemoveCentralPoint(toRemove)
5957 ## To set an enforced vertex.
5958 # @param x : x coordinate
5959 # @param y : y coordinate
5960 # @param z : z coordinate
5961 # @param size : size of 1D element around enforced vertex
5962 # @param vertexName : name of the enforced vertex
5963 # @param groupName : name of the group
5964 # @ingroup l3_hypos_ghs3dh
5965 def SetEnforcedVertex(self, x, y, z, size, vertexName = "", groupName = ""):
5966 # Advanced parameter of GHS3D
5967 if self.Parameters():
5968 if vertexName == "":
5970 return self.params.SetEnforcedVertex(x, y, z, size)
5972 return self.params.SetEnforcedVertexWithGroup(x, y, z, size, groupName)
5975 return self.params.SetEnforcedVertexNamed(x, y, z, size, vertexName)
5977 return self.params.SetEnforcedVertexNamedWithGroup(x, y, z, size, vertexName, groupName)
5979 ## To set an enforced vertex given a GEOM vertex, group or compound.
5980 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
5981 # @param size : size of 1D element around enforced vertex
5982 # @param groupName : name of the group
5983 # @ingroup l3_hypos_ghs3dh
5984 def SetEnforcedVertexGeom(self, theVertex, size, groupName = ""):
5985 AssureGeomPublished( self.mesh, theVertex )
5986 # Advanced parameter of GHS3D
5987 if self.Parameters():
5989 return self.params.SetEnforcedVertexGeom(theVertex, size)
5991 return self.params.SetEnforcedVertexGeomWithGroup(theVertex, size, groupName)
5993 ## To remove an enforced vertex.
5994 # @param x : x coordinate
5995 # @param y : y coordinate
5996 # @param z : z coordinate
5997 # @ingroup l3_hypos_ghs3dh
5998 def RemoveEnforcedVertex(self, x, y, z):
5999 # Advanced parameter of GHS3D
6000 if self.Parameters():
6001 return self.params.RemoveEnforcedVertex(x, y, z)
6003 ## To remove an enforced vertex given a GEOM vertex, group or compound.
6004 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
6005 # @ingroup l3_hypos_ghs3dh
6006 def RemoveEnforcedVertexGeom(self, theVertex):
6007 AssureGeomPublished( self.mesh, theVertex )
6008 # Advanced parameter of GHS3D
6009 if self.Parameters():
6010 return self.params.RemoveEnforcedVertexGeom(theVertex)
6012 ## To set an enforced mesh with given size and add the enforced elements in the group "groupName".
6013 # @param theSource : source mesh which provides constraint elements/nodes
6014 # @param elementType : SMESH.ElementType (NODE, EDGE or FACE)
6015 # @param size : size of elements around enforced elements. Unused if -1.
6016 # @param groupName : group in which enforced elements will be added. Unused if "".
6017 # @ingroup l3_hypos_ghs3dh
6018 def SetEnforcedMesh(self, theSource, elementType, size = -1, groupName = ""):
6019 # Advanced parameter of GHS3D
6020 if self.Parameters():
6023 return self.params.SetEnforcedMesh(theSource, elementType)
6025 return self.params.SetEnforcedMeshWithGroup(theSource, elementType, groupName)
6028 return self.params.SetEnforcedMeshSize(theSource, elementType, size)
6030 return self.params.SetEnforcedMeshSizeWithGroup(theSource, elementType, size, groupName)
6032 ## Sets command line option as text.
6033 # @ingroup l3_hypos_ghs3dh
6034 def SetTextOption(self, option):
6035 # Advanced parameter of GHS3D
6036 if self.Parameters():
6037 self.params.SetTextOption(option)
6039 ## Sets MED files name and path.
6040 def SetMEDName(self, value):
6041 if self.Parameters():
6042 self.params.SetMEDName(value)
6044 ## Sets the number of partition of the initial mesh
6045 def SetNbPart(self, value):
6046 if self.Parameters():
6047 self.params.SetNbPart(value)
6049 ## When big mesh, start tepal in background
6050 def SetBackground(self, value):
6051 if self.Parameters():
6052 self.params.SetBackground(value)
6054 # Public class: Mesh_Hexahedron
6055 # ------------------------------
6057 ## Defines a hexahedron 3D algorithm
6059 # @ingroup l3_algos_basic
6060 class Mesh_Hexahedron(Mesh_Algorithm):
6065 ## Private constructor.
6066 def __init__(self, mesh, algoType=Hexa, geom=0):
6067 Mesh_Algorithm.__init__(self)
6069 self.algoType = algoType
6071 if algoType == Hexa:
6072 self.Create(mesh, geom, "Hexa_3D")
6075 elif algoType == Hexotic:
6076 CheckPlugin(Hexotic)
6077 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
6080 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
6081 # @ingroup l3_hypos_hexotic
6082 def MinMaxQuad(self, min=3, max=8, quad=True):
6083 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
6085 self.params.SetHexesMinLevel(min)
6086 self.params.SetHexesMaxLevel(max)
6087 self.params.SetHexoticQuadrangles(quad)
6090 # Deprecated, only for compatibility!
6091 # Public class: Mesh_Netgen
6092 # ------------------------------
6094 ## Defines a NETGEN-based 2D or 3D algorithm
6095 # that needs no discrete boundary (i.e. independent)
6097 # This class is deprecated, only for compatibility!
6100 # @ingroup l3_algos_basic
6101 class Mesh_Netgen(Mesh_Algorithm):
6105 ## Private constructor.
6106 def __init__(self, mesh, is3D, geom=0):
6107 Mesh_Algorithm.__init__(self)
6113 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
6117 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
6120 ## Defines the hypothesis containing parameters of the algorithm
6121 def Parameters(self):
6123 hyp = self.Hypothesis("NETGEN_Parameters", [],
6124 "libNETGENEngine.so", UseExisting=0)
6126 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
6127 "libNETGENEngine.so", UseExisting=0)
6130 # Public class: Mesh_Projection1D
6131 # ------------------------------
6133 ## Defines a projection 1D algorithm
6134 # @ingroup l3_algos_proj
6136 class Mesh_Projection1D(Mesh_Algorithm):
6138 ## Private constructor.
6139 def __init__(self, mesh, geom=0):
6140 Mesh_Algorithm.__init__(self)
6141 self.Create(mesh, geom, "Projection_1D")
6143 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
6144 # a mesh pattern is taken, and, optionally, the association of vertices
6145 # between the source edge and a target edge (to which a hypothesis is assigned)
6146 # @param edge from which nodes distribution is taken
6147 # @param mesh from which nodes distribution is taken (optional)
6148 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
6149 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
6150 # to associate with \a srcV (optional)
6151 # @param UseExisting if ==true - searches for the existing hypothesis created with
6152 # the same parameters, else (default) - creates a new one
6153 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
6154 AssureGeomPublished( self.mesh, edge )
6155 AssureGeomPublished( self.mesh, srcV )
6156 AssureGeomPublished( self.mesh, tgtV )
6157 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
6159 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
6160 hyp.SetSourceEdge( edge )
6161 if not mesh is None and isinstance(mesh, Mesh):
6162 mesh = mesh.GetMesh()
6163 hyp.SetSourceMesh( mesh )
6164 hyp.SetVertexAssociation( srcV, tgtV )
6167 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
6168 #def CompareSourceEdge(self, hyp, args):
6169 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
6173 # Public class: Mesh_Projection2D
6174 # ------------------------------
6176 ## Defines a projection 2D algorithm
6177 # @ingroup l3_algos_proj
6179 class Mesh_Projection2D(Mesh_Algorithm):
6181 ## Private constructor.
6182 def __init__(self, mesh, geom=0, algoName="Projection_2D"):
6183 Mesh_Algorithm.__init__(self)
6184 self.Create(mesh, geom, algoName)
6186 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
6187 # a mesh pattern is taken, and, optionally, the association of vertices
6188 # between the source face and the target face (to which a hypothesis is assigned)
6189 # @param face from which the mesh pattern is taken
6190 # @param mesh from which the mesh pattern is taken (optional)
6191 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
6192 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
6193 # to associate with \a srcV1 (optional)
6194 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
6195 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
6196 # to associate with \a srcV2 (optional)
6197 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
6198 # the same parameters, else (default) - forces the creation a new one
6200 # Note: all association vertices must belong to one edge of a face
6201 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
6202 srcV2=None, tgtV2=None, UseExisting=0):
6203 for geom in [ face, srcV1, tgtV1, srcV2, tgtV2 ]:
6204 AssureGeomPublished( self.mesh, geom )
6205 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
6207 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
6208 hyp.SetSourceFace( face )
6209 if isinstance(mesh, Mesh):
6210 mesh = mesh.GetMesh()
6211 hyp.SetSourceMesh( mesh )
6212 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
6215 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
6216 #def CompareSourceFace(self, hyp, args):
6217 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
6220 # Public class: Mesh_Projection3D
6221 # ------------------------------
6223 ## Defines a projection 3D algorithm
6224 # @ingroup l3_algos_proj
6226 class Mesh_Projection3D(Mesh_Algorithm):
6228 ## Private constructor.
6229 def __init__(self, mesh, geom=0):
6230 Mesh_Algorithm.__init__(self)
6231 self.Create(mesh, geom, "Projection_3D")
6233 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
6234 # the mesh pattern is taken, and, optionally, the association of vertices
6235 # between the source and the target solid (to which a hipothesis is assigned)
6236 # @param solid from where the mesh pattern is taken
6237 # @param mesh from where the mesh pattern is taken (optional)
6238 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
6239 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
6240 # to associate with \a srcV1 (optional)
6241 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
6242 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
6243 # to associate with \a srcV2 (optional)
6244 # @param UseExisting - if ==true - searches for the existing hypothesis created with
6245 # the same parameters, else (default) - creates a new one
6247 # Note: association vertices must belong to one edge of a solid
6248 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
6249 srcV2=0, tgtV2=0, UseExisting=0):
6250 for geom in [ solid, srcV1, tgtV1, srcV2, tgtV2 ]:
6251 AssureGeomPublished( self.mesh, geom )
6252 hyp = self.Hypothesis("ProjectionSource3D",
6253 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
6255 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
6256 hyp.SetSource3DShape( solid )
6257 if not mesh is None and isinstance(mesh, Mesh):
6258 mesh = mesh.GetMesh()
6259 hyp.SetSourceMesh( mesh )
6260 if srcV1 and srcV2 and tgtV1 and tgtV2:
6261 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
6262 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
6265 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
6266 #def CompareSourceShape3D(self, hyp, args):
6267 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
6271 # Public class: Mesh_Prism
6272 # ------------------------
6274 ## Defines a 3D extrusion algorithm
6275 # @ingroup l3_algos_3dextr
6277 class Mesh_Prism3D(Mesh_Algorithm):
6279 ## Private constructor.
6280 def __init__(self, mesh, geom=0):
6281 Mesh_Algorithm.__init__(self)
6282 self.Create(mesh, geom, "Prism_3D")
6284 # Public class: Mesh_RadialPrism
6285 # -------------------------------
6287 ## Defines a Radial Prism 3D algorithm
6288 # @ingroup l3_algos_radialp
6290 class Mesh_RadialPrism3D(Mesh_Algorithm):
6292 ## Private constructor.
6293 def __init__(self, mesh, geom=0):
6294 Mesh_Algorithm.__init__(self)
6295 self.Create(mesh, geom, "RadialPrism_3D")
6297 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
6298 self.nbLayers = None
6300 ## Return 3D hypothesis holding the 1D one
6301 def Get3DHypothesis(self):
6302 return self.distribHyp
6304 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
6305 # hypothesis. Returns the created hypothesis
6306 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
6307 #print "OwnHypothesis",hypType
6308 if not self.nbLayers is None:
6309 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
6310 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
6311 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
6312 self.mesh.smeshpyD.SetCurrentStudy( None )
6313 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
6314 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
6315 self.distribHyp.SetLayerDistribution( hyp )
6318 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
6319 # prisms to build between the inner and outer shells
6320 # @param n number of layers
6321 # @param UseExisting if ==true - searches for the existing hypothesis created with
6322 # the same parameters, else (default) - creates a new one
6323 def NumberOfLayers(self, n, UseExisting=0):
6324 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
6325 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
6326 CompareMethod=self.CompareNumberOfLayers)
6327 self.nbLayers.SetNumberOfLayers( n )
6328 return self.nbLayers
6330 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
6331 def CompareNumberOfLayers(self, hyp, args):
6332 return IsEqual(hyp.GetNumberOfLayers(), args[0])
6334 ## Defines "LocalLength" hypothesis, specifying the segment length
6335 # to build between the inner and the outer shells
6336 # @param l the length of segments
6337 # @param p the precision of rounding
6338 def LocalLength(self, l, p=1e-07):
6339 hyp = self.OwnHypothesis("LocalLength", [l,p])
6344 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
6345 # prisms to build between the inner and the outer shells.
6346 # @param n the number of layers
6347 # @param s the scale factor (optional)
6348 def NumberOfSegments(self, n, s=[]):
6350 hyp = self.OwnHypothesis("NumberOfSegments", [n])
6352 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
6353 hyp.SetDistrType( 1 )
6354 hyp.SetScaleFactor(s)
6355 hyp.SetNumberOfSegments(n)
6358 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
6359 # to build between the inner and the outer shells with a length that changes in arithmetic progression
6360 # @param start the length of the first segment
6361 # @param end the length of the last segment
6362 def Arithmetic1D(self, start, end ):
6363 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
6364 hyp.SetLength(start, 1)
6365 hyp.SetLength(end , 0)
6368 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
6369 # to build between the inner and the outer shells as geometric length increasing
6370 # @param start for the length of the first segment
6371 # @param end for the length of the last segment
6372 def StartEndLength(self, start, end):
6373 hyp = self.OwnHypothesis("StartEndLength", [start, end])
6374 hyp.SetLength(start, 1)
6375 hyp.SetLength(end , 0)
6378 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
6379 # to build between the inner and outer shells
6380 # @param fineness defines the quality of the mesh within the range [0-1]
6381 def AutomaticLength(self, fineness=0):
6382 hyp = self.OwnHypothesis("AutomaticLength")
6383 hyp.SetFineness( fineness )
6386 # Public class: Mesh_RadialQuadrangle1D2D
6387 # -------------------------------
6389 ## Defines a Radial Quadrangle 1D2D algorithm
6390 # @ingroup l2_algos_radialq
6392 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
6394 ## Private constructor.
6395 def __init__(self, mesh, geom=0):
6396 Mesh_Algorithm.__init__(self)
6397 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
6399 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
6400 self.nbLayers = None
6402 ## Return 2D hypothesis holding the 1D one
6403 def Get2DHypothesis(self):
6404 return self.distribHyp
6406 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
6407 # hypothesis. Returns the created hypothesis
6408 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
6409 #print "OwnHypothesis",hypType
6411 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
6412 if self.distribHyp is None:
6413 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
6415 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
6416 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
6417 self.mesh.smeshpyD.SetCurrentStudy( None )
6418 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
6419 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
6420 self.distribHyp.SetLayerDistribution( hyp )
6423 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
6424 # @param n number of layers
6425 # @param UseExisting if ==true - searches for the existing hypothesis created with
6426 # the same parameters, else (default) - creates a new one
6427 def NumberOfLayers(self, n, UseExisting=0):
6429 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
6430 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
6431 CompareMethod=self.CompareNumberOfLayers)
6432 self.nbLayers.SetNumberOfLayers( n )
6433 return self.nbLayers
6435 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
6436 def CompareNumberOfLayers(self, hyp, args):
6437 return IsEqual(hyp.GetNumberOfLayers(), args[0])
6439 ## Defines "LocalLength" hypothesis, specifying the segment length
6440 # @param l the length of segments
6441 # @param p the precision of rounding
6442 def LocalLength(self, l, p=1e-07):
6443 hyp = self.OwnHypothesis("LocalLength", [l,p])
6448 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
6449 # @param n the number of layers
6450 # @param s the scale factor (optional)
6451 def NumberOfSegments(self, n, s=[]):
6453 hyp = self.OwnHypothesis("NumberOfSegments", [n])
6455 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
6456 hyp.SetDistrType( 1 )
6457 hyp.SetScaleFactor(s)
6458 hyp.SetNumberOfSegments(n)
6461 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
6462 # with a length that changes in arithmetic progression
6463 # @param start the length of the first segment
6464 # @param end the length of the last segment
6465 def Arithmetic1D(self, start, end ):
6466 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
6467 hyp.SetLength(start, 1)
6468 hyp.SetLength(end , 0)
6471 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
6472 # as geometric length increasing
6473 # @param start for the length of the first segment
6474 # @param end for the length of the last segment
6475 def StartEndLength(self, start, end):
6476 hyp = self.OwnHypothesis("StartEndLength", [start, end])
6477 hyp.SetLength(start, 1)
6478 hyp.SetLength(end , 0)
6481 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
6482 # @param fineness defines the quality of the mesh within the range [0-1]
6483 def AutomaticLength(self, fineness=0):
6484 hyp = self.OwnHypothesis("AutomaticLength")
6485 hyp.SetFineness( fineness )
6489 # Public class: Mesh_UseExistingElements
6490 # --------------------------------------
6491 ## Defines a Radial Quadrangle 1D2D algorithm
6492 # @ingroup l3_algos_basic
6494 class Mesh_UseExistingElements(Mesh_Algorithm):
6496 def __init__(self, dim, mesh, geom=0):
6498 self.Create(mesh, geom, "Import_1D")
6500 self.Create(mesh, geom, "Import_1D2D")
6503 ## Defines "Source edges" hypothesis, specifying groups of edges to import
6504 # @param groups list of groups of edges
6505 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
6506 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
6507 # @param UseExisting if ==true - searches for the existing hypothesis created with
6508 # the same parameters, else (default) - creates a new one
6509 def SourceEdges(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
6510 if self.algo.GetName() != "Import_1D":
6511 raise ValueError, "algoritm dimension mismatch"
6512 for group in groups:
6513 AssureGeomPublished( self.mesh, group )
6514 hyp = self.Hypothesis("ImportSource1D", [groups, toCopyMesh, toCopyGroups],
6515 UseExisting=UseExisting, CompareMethod=self._compareHyp)
6516 hyp.SetSourceEdges(groups)
6517 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
6520 ## Defines "Source faces" hypothesis, specifying groups of faces to import
6521 # @param groups list of groups of faces
6522 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
6523 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
6524 # @param UseExisting if ==true - searches for the existing hypothesis created with
6525 # the same parameters, else (default) - creates a new one
6526 def SourceFaces(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
6527 if self.algo.GetName() == "Import_1D":
6528 raise ValueError, "algoritm dimension mismatch"
6529 for group in groups:
6530 AssureGeomPublished( self.mesh, group )
6531 hyp = self.Hypothesis("ImportSource2D", [groups, toCopyMesh, toCopyGroups],
6532 UseExisting=UseExisting, CompareMethod=self._compareHyp)
6533 hyp.SetSourceFaces(groups)
6534 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
6537 def _compareHyp(self,hyp,args):
6538 if hasattr( hyp, "GetSourceEdges"):
6539 entries = hyp.GetSourceEdges()
6541 entries = hyp.GetSourceFaces()
6543 toCopyMesh,toCopyGroups = hyp.GetCopySourceMesh()
6544 if len(entries)==len(groups) and toCopyMesh==args[1] and toCopyGroups==args[2]:
6546 study = self.mesh.smeshpyD.GetCurrentStudy()
6549 ior = salome.orb.object_to_string(g)
6550 sobj = study.FindObjectIOR(ior)
6551 if sobj: entries2.append( sobj.GetID() )
6556 return entries == entries2
6559 # Public class: Mesh_Cartesian_3D
6560 # --------------------------------------
6561 ## Defines a Body Fitting 3D algorithm
6562 # @ingroup l3_algos_basic
6564 class Mesh_Cartesian_3D(Mesh_Algorithm):
6566 def __init__(self, mesh, geom=0):
6567 self.Create(mesh, geom, "Cartesian_3D")
6571 ## Defines "Body Fitting parameters" hypothesis
6572 # @param xGridDef is definition of the grid along the X asix.
6573 # It can be in either of two following forms:
6574 # - Explicit coordinates of nodes, e.g. [-1.5, 0.0, 3.1] or range( -100,200,10)
6575 # - Functions f(t) defining grid spacing at each point on grid axis. If there are
6576 # several functions, they must be accompanied by relative coordinates of
6577 # points dividing the whole shape into ranges where the functions apply; points
6578 # coodrinates should vary within (0.0, 1.0) range. Parameter \a t of the spacing
6579 # function f(t) varies from 0.0 to 1.0 witin a shape range.
6581 # - "10.5" - defines a grid with a constant spacing
6582 # - [["1", "1+10*t", "11"] [0.1, 0.6]] - defines different spacing in 3 ranges.
6583 # @param yGridDef defines the grid along the Y asix the same way as \a xGridDef does
6584 # @param zGridDef defines the grid along the Z asix the same way as \a xGridDef does
6585 # @param sizeThreshold (> 1.0) defines a minimal size of a polyhedron so that
6586 # a polyhedron of size less than hexSize/sizeThreshold is not created
6587 # @param UseExisting if ==true - searches for the existing hypothesis created with
6588 # the same parameters, else (default) - creates a new one
6589 def SetGrid(self, xGridDef, yGridDef, zGridDef, sizeThreshold=4.0, UseExisting=False):
6591 self.hyp = self.Hypothesis("CartesianParameters3D",
6592 [xGridDef, yGridDef, zGridDef, sizeThreshold],
6593 UseExisting=UseExisting, CompareMethod=self._compareHyp)
6594 if not self.mesh.IsUsedHypothesis( self.hyp, self.geom ):
6595 self.mesh.AddHypothesis( self.hyp, self.geom )
6597 for axis, gridDef in enumerate( [xGridDef, yGridDef, zGridDef]):
6598 if not gridDef: raise ValueError, "Empty grid definition"
6599 if isinstance( gridDef, str ):
6600 self.hyp.SetGridSpacing( [gridDef], [], axis )
6601 elif isinstance( gridDef[0], str ):
6602 self.hyp.SetGridSpacing( gridDef, [], axis )
6603 elif isinstance( gridDef[0], int ) or \
6604 isinstance( gridDef[0], float ):
6605 self.hyp.SetGrid(gridDef, axis )
6607 self.hyp.SetGridSpacing( gridDef[0], gridDef[1], axis )
6608 self.hyp.SetSizeThreshold( sizeThreshold )
6611 def _compareHyp(self,hyp,args):
6612 # not implemented yet
6615 # Public class: Mesh_UseExisting
6616 # -------------------------------
6617 class Mesh_UseExisting(Mesh_Algorithm):
6619 def __init__(self, dim, mesh, geom=0):
6621 self.Create(mesh, geom, "UseExisting_1D")
6623 self.Create(mesh, geom, "UseExisting_2D")
6626 import salome_notebook
6627 notebook = salome_notebook.notebook
6629 ##Return values of the notebook variables
6630 def ParseParameters(last, nbParams,nbParam, value):
6634 listSize = len(last)
6635 for n in range(0,nbParams):
6637 if counter < listSize:
6638 strResult = strResult + last[counter]
6640 strResult = strResult + ""
6642 if isinstance(value, str):
6643 if notebook.isVariable(value):
6644 result = notebook.get(value)
6645 strResult=strResult+value
6647 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
6649 strResult=strResult+str(value)
6651 if nbParams - 1 != counter:
6652 strResult=strResult+var_separator #":"
6654 return result, strResult
6656 #Wrapper class for StdMeshers_LocalLength hypothesis
6657 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
6659 ## Set Length parameter value
6660 # @param length numerical value or name of variable from notebook
6661 def SetLength(self, length):
6662 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
6663 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6664 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
6666 ## Set Precision parameter value
6667 # @param precision numerical value or name of variable from notebook
6668 def SetPrecision(self, precision):
6669 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
6670 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6671 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
6673 #Registering the new proxy for LocalLength
6674 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
6677 #Wrapper class for StdMeshers_LayerDistribution hypothesis
6678 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
6680 def SetLayerDistribution(self, hypo):
6681 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
6682 hypo.ClearParameters();
6683 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
6685 #Registering the new proxy for LayerDistribution
6686 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
6688 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
6689 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
6691 ## Set Length parameter value
6692 # @param length numerical value or name of variable from notebook
6693 def SetLength(self, length):
6694 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
6695 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
6696 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
6698 #Registering the new proxy for SegmentLengthAroundVertex
6699 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
6702 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
6703 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
6705 ## Set Length parameter value
6706 # @param length numerical value or name of variable from notebook
6707 # @param isStart true is length is Start Length, otherwise false
6708 def SetLength(self, length, isStart):
6712 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
6713 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
6714 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
6716 #Registering the new proxy for Arithmetic1D
6717 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
6719 #Wrapper class for StdMeshers_Deflection1D hypothesis
6720 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
6722 ## Set Deflection parameter value
6723 # @param deflection numerical value or name of variable from notebook
6724 def SetDeflection(self, deflection):
6725 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
6726 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
6727 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
6729 #Registering the new proxy for Deflection1D
6730 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
6732 #Wrapper class for StdMeshers_StartEndLength hypothesis
6733 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
6735 ## Set Length parameter value
6736 # @param length numerical value or name of variable from notebook
6737 # @param isStart true is length is Start Length, otherwise false
6738 def SetLength(self, length, isStart):
6742 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
6743 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
6744 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
6746 #Registering the new proxy for StartEndLength
6747 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
6749 #Wrapper class for StdMeshers_MaxElementArea hypothesis
6750 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
6752 ## Set Max Element Area parameter value
6753 # @param area numerical value or name of variable from notebook
6754 def SetMaxElementArea(self, area):
6755 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
6756 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
6757 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
6759 #Registering the new proxy for MaxElementArea
6760 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
6763 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
6764 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
6766 ## Set Max Element Volume parameter value
6767 # @param volume numerical value or name of variable from notebook
6768 def SetMaxElementVolume(self, volume):
6769 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
6770 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
6771 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
6773 #Registering the new proxy for MaxElementVolume
6774 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
6777 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
6778 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
6780 ## Set Number Of Layers parameter value
6781 # @param nbLayers numerical value or name of variable from notebook
6782 def SetNumberOfLayers(self, nbLayers):
6783 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
6784 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
6785 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
6787 #Registering the new proxy for NumberOfLayers
6788 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
6790 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
6791 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
6793 ## Set Number Of Segments parameter value
6794 # @param nbSeg numerical value or name of variable from notebook
6795 def SetNumberOfSegments(self, nbSeg):
6796 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
6797 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
6798 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6799 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
6801 ## Set Scale Factor parameter value
6802 # @param factor numerical value or name of variable from notebook
6803 def SetScaleFactor(self, factor):
6804 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
6805 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6806 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
6808 #Registering the new proxy for NumberOfSegments
6809 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
6811 if not noNETGENPlugin:
6812 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
6813 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
6815 ## Set Max Size parameter value
6816 # @param maxsize numerical value or name of variable from notebook
6817 def SetMaxSize(self, maxsize):
6818 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6819 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
6820 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6821 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
6823 ## Set Growth Rate parameter value
6824 # @param value numerical value or name of variable from notebook
6825 def SetGrowthRate(self, value):
6826 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6827 value, parameters = ParseParameters(lastParameters,4,2,value)
6828 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6829 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
6831 ## Set Number of Segments per Edge parameter value
6832 # @param value numerical value or name of variable from notebook
6833 def SetNbSegPerEdge(self, value):
6834 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6835 value, parameters = ParseParameters(lastParameters,4,3,value)
6836 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6837 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
6839 ## Set Number of Segments per Radius parameter value
6840 # @param value numerical value or name of variable from notebook
6841 def SetNbSegPerRadius(self, value):
6842 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6843 value, parameters = ParseParameters(lastParameters,4,4,value)
6844 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6845 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
6847 #Registering the new proxy for NETGENPlugin_Hypothesis
6848 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
6851 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
6852 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
6855 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
6856 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
6858 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
6859 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
6861 ## Set Number of Segments parameter value
6862 # @param nbSeg numerical value or name of variable from notebook
6863 def SetNumberOfSegments(self, nbSeg):
6864 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6865 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
6866 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6867 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
6869 ## Set Local Length parameter value
6870 # @param length numerical value or name of variable from notebook
6871 def SetLocalLength(self, length):
6872 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6873 length, parameters = ParseParameters(lastParameters,2,1,length)
6874 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6875 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
6877 ## Set Max Element Area parameter value
6878 # @param area numerical value or name of variable from notebook
6879 def SetMaxElementArea(self, area):
6880 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6881 area, parameters = ParseParameters(lastParameters,2,2,area)
6882 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6883 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
6885 def LengthFromEdges(self):
6886 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6888 value, parameters = ParseParameters(lastParameters,2,2,value)
6889 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6890 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
6892 #Registering the new proxy for NETGEN_SimpleParameters_2D
6893 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
6896 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
6897 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
6898 ## Set Max Element Volume parameter value
6899 # @param volume numerical value or name of variable from notebook
6900 def SetMaxElementVolume(self, volume):
6901 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6902 volume, parameters = ParseParameters(lastParameters,3,3,volume)
6903 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6904 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
6906 def LengthFromFaces(self):
6907 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6909 value, parameters = ParseParameters(lastParameters,3,3,value)
6910 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6911 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
6913 #Registering the new proxy for NETGEN_SimpleParameters_3D
6914 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
6916 pass # if not noNETGENPlugin:
6918 class Pattern(SMESH._objref_SMESH_Pattern):
6920 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
6922 if isinstance(theNodeIndexOnKeyPoint1,str):
6924 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
6926 theNodeIndexOnKeyPoint1 -= 1
6927 theMesh.SetParameters(Parameters)
6928 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
6930 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
6933 if isinstance(theNode000Index,str):
6935 if isinstance(theNode001Index,str):
6937 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
6939 theNode000Index -= 1
6941 theNode001Index -= 1
6942 theMesh.SetParameters(Parameters)
6943 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
6945 #Registering the new proxy for Pattern
6946 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)