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 subshape, 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_BadOrientedVolume, FT_FreeNodes,
905 FT_FreeFaces, FT_LinearOrQuadratic,
906 FT_BareBorderFace, FT_BareBorderVolume,
907 FT_OverConstrainedFace, FT_OverConstrainedVolume]:
908 # At this point the treshold is unnecessary
909 if aTreshold == FT_LogicalNOT:
910 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
911 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
912 aCriterion.BinaryOp = aTreshold
916 aTreshold = float(aTreshold)
917 aCriterion.Threshold = aTreshold
919 print "Error: The treshold should be a number."
922 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
923 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
925 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
926 aCriterion.BinaryOp = self.EnumToLong(Treshold)
928 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
929 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
931 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
932 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
936 ## Creates a filter with the given parameters
937 # @param elementType the type of elements in the group
938 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
939 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
940 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
941 # @param UnaryOp FT_LogicalNOT or FT_Undefined
942 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
943 # FT_LyingOnGeom, FT_CoplanarFaces criteria
944 # @return SMESH_Filter
946 # <a href="../tui_filters_page.html#tui_filters">Example of Filters usage</a>
947 # @ingroup l1_controls
948 def GetFilter(self,elementType,
949 CritType=FT_Undefined,
952 UnaryOp=FT_Undefined,
954 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined,Tolerance)
955 aFilterMgr = self.CreateFilterManager()
956 aFilter = aFilterMgr.CreateFilter()
958 aCriteria.append(aCriterion)
959 aFilter.SetCriteria(aCriteria)
960 aFilterMgr.UnRegister()
963 ## Creates a filter from criteria
964 # @param criteria a list of criteria
965 # @return SMESH_Filter
967 # <a href="../tui_filters_page.html#tui_filters">Example of Filters usage</a>
968 # @ingroup l1_controls
969 def GetFilterFromCriteria(self,criteria):
970 aFilterMgr = self.CreateFilterManager()
971 aFilter = aFilterMgr.CreateFilter()
972 aFilter.SetCriteria(criteria)
973 aFilterMgr.UnRegister()
976 ## Creates a numerical functor by its type
977 # @param theCriterion FT_...; functor type
978 # @return SMESH_NumericalFunctor
979 # @ingroup l1_controls
980 def GetFunctor(self,theCriterion):
981 aFilterMgr = self.CreateFilterManager()
982 if theCriterion == FT_AspectRatio:
983 return aFilterMgr.CreateAspectRatio()
984 elif theCriterion == FT_AspectRatio3D:
985 return aFilterMgr.CreateAspectRatio3D()
986 elif theCriterion == FT_Warping:
987 return aFilterMgr.CreateWarping()
988 elif theCriterion == FT_MinimumAngle:
989 return aFilterMgr.CreateMinimumAngle()
990 elif theCriterion == FT_Taper:
991 return aFilterMgr.CreateTaper()
992 elif theCriterion == FT_Skew:
993 return aFilterMgr.CreateSkew()
994 elif theCriterion == FT_Area:
995 return aFilterMgr.CreateArea()
996 elif theCriterion == FT_Volume3D:
997 return aFilterMgr.CreateVolume3D()
998 elif theCriterion == FT_MaxElementLength2D:
999 return aFilterMgr.CreateMaxElementLength2D()
1000 elif theCriterion == FT_MaxElementLength3D:
1001 return aFilterMgr.CreateMaxElementLength3D()
1002 elif theCriterion == FT_MultiConnection:
1003 return aFilterMgr.CreateMultiConnection()
1004 elif theCriterion == FT_MultiConnection2D:
1005 return aFilterMgr.CreateMultiConnection2D()
1006 elif theCriterion == FT_Length:
1007 return aFilterMgr.CreateLength()
1008 elif theCriterion == FT_Length2D:
1009 return aFilterMgr.CreateLength2D()
1011 print "Error: given parameter is not numerucal functor type."
1013 ## Creates hypothesis
1014 # @param theHType mesh hypothesis type (string)
1015 # @param theLibName mesh plug-in library name
1016 # @return created hypothesis instance
1017 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
1018 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
1020 ## Gets the mesh statistic
1021 # @return dictionary "element type" - "count of elements"
1022 # @ingroup l1_meshinfo
1023 def GetMeshInfo(self, obj):
1024 if isinstance( obj, Mesh ):
1027 if hasattr(obj, "GetMeshInfo"):
1028 values = obj.GetMeshInfo()
1029 for i in range(SMESH.Entity_Last._v):
1030 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
1034 ## Get minimum distance between two objects
1036 # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
1037 # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
1039 # @param src1 first source object
1040 # @param src2 second source object
1041 # @param id1 node/element id from the first source
1042 # @param id2 node/element id from the second (or first) source
1043 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
1044 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
1045 # @return minimum distance value
1046 # @sa GetMinDistance()
1047 # @ingroup l1_measurements
1048 def MinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
1049 result = self.GetMinDistance(src1, src2, id1, id2, isElem1, isElem2)
1053 result = result.value
1056 ## Get measure structure specifying minimum distance data between two objects
1058 # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
1059 # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
1061 # @param src1 first source object
1062 # @param src2 second source object
1063 # @param id1 node/element id from the first source
1064 # @param id2 node/element id from the second (or first) source
1065 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
1066 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
1067 # @return Measure structure or None if input data is invalid
1069 # @ingroup l1_measurements
1070 def GetMinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
1071 if isinstance(src1, Mesh): src1 = src1.mesh
1072 if isinstance(src2, Mesh): src2 = src2.mesh
1073 if src2 is None and id2 != 0: src2 = src1
1074 if not hasattr(src1, "_narrow"): return None
1075 src1 = src1._narrow(SMESH.SMESH_IDSource)
1076 if not src1: return None
1079 e = m.GetMeshEditor()
1081 src1 = e.MakeIDSource([id1], SMESH.FACE)
1083 src1 = e.MakeIDSource([id1], SMESH.NODE)
1085 if hasattr(src2, "_narrow"):
1086 src2 = src2._narrow(SMESH.SMESH_IDSource)
1087 if src2 and id2 != 0:
1089 e = m.GetMeshEditor()
1091 src2 = e.MakeIDSource([id2], SMESH.FACE)
1093 src2 = e.MakeIDSource([id2], SMESH.NODE)
1096 aMeasurements = self.CreateMeasurements()
1097 result = aMeasurements.MinDistance(src1, src2)
1098 aMeasurements.UnRegister()
1101 ## Get bounding box of the specified object(s)
1102 # @param objects single source object or list of source objects
1103 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
1104 # @sa GetBoundingBox()
1105 # @ingroup l1_measurements
1106 def BoundingBox(self, objects):
1107 result = self.GetBoundingBox(objects)
1111 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
1114 ## Get measure structure specifying bounding box data of the specified object(s)
1115 # @param objects single source object or list of source objects
1116 # @return Measure structure
1118 # @ingroup l1_measurements
1119 def GetBoundingBox(self, objects):
1120 if isinstance(objects, tuple):
1121 objects = list(objects)
1122 if not isinstance(objects, list):
1126 if isinstance(o, Mesh):
1127 srclist.append(o.mesh)
1128 elif hasattr(o, "_narrow"):
1129 src = o._narrow(SMESH.SMESH_IDSource)
1130 if src: srclist.append(src)
1133 aMeasurements = self.CreateMeasurements()
1134 result = aMeasurements.BoundingBox(srclist)
1135 aMeasurements.UnRegister()
1139 #Registering the new proxy for SMESH_Gen
1140 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
1143 # Public class: Mesh
1144 # ==================
1146 ## This class allows defining and managing a mesh.
1147 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
1148 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
1149 # new nodes and elements and by changing the existing entities), to get information
1150 # about a mesh and to export a mesh into different formats.
1159 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
1160 # sets the GUI name of this mesh to \a name.
1161 # @param smeshpyD an instance of smeshDC class
1162 # @param geompyD an instance of geompyDC class
1163 # @param obj Shape to be meshed or SMESH_Mesh object
1164 # @param name Study name of the mesh
1165 # @ingroup l2_construct
1166 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
1167 self.smeshpyD=smeshpyD
1168 self.geompyD=geompyD
1172 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
1174 # publish geom of mesh (issue 0021122)
1175 if not self.geom.GetStudyEntry():
1176 studyID = smeshpyD.GetCurrentStudy()._get_StudyId()
1177 if studyID != geompyD.myStudyId:
1178 geompyD.init_geom( smeshpyD.GetCurrentStudy())
1180 geo_name = "%s_%s"%(self.geom.GetShapeType(), id(self.geom)%100)
1181 geompyD.addToStudy( self.geom, geo_name )
1182 self.mesh = self.smeshpyD.CreateMesh(self.geom)
1184 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
1187 self.mesh = self.smeshpyD.CreateEmptyMesh()
1189 self.smeshpyD.SetName(self.mesh, name)
1191 self.smeshpyD.SetName(self.mesh, GetName(obj))
1194 self.geom = self.mesh.GetShapeToMesh()
1196 self.editor = self.mesh.GetMeshEditor()
1198 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
1199 # @param theMesh a SMESH_Mesh object
1200 # @ingroup l2_construct
1201 def SetMesh(self, theMesh):
1203 self.geom = self.mesh.GetShapeToMesh()
1205 ## Returns the mesh, that is an instance of SMESH_Mesh interface
1206 # @return a SMESH_Mesh object
1207 # @ingroup l2_construct
1211 ## Gets the name of the mesh
1212 # @return the name of the mesh as a string
1213 # @ingroup l2_construct
1215 name = GetName(self.GetMesh())
1218 ## Sets a name to the mesh
1219 # @param name a new name of the mesh
1220 # @ingroup l2_construct
1221 def SetName(self, name):
1222 self.smeshpyD.SetName(self.GetMesh(), name)
1224 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
1225 # The subMesh object gives access to the IDs of nodes and elements.
1226 # @param geom a geometrical object (shape)
1227 # @param name a name for the submesh
1228 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
1229 # @ingroup l2_submeshes
1230 def GetSubMesh(self, geom, name):
1231 AssureGeomPublished( self, geom, name )
1232 submesh = self.mesh.GetSubMesh( geom, name )
1235 ## Returns the shape associated to the mesh
1236 # @return a GEOM_Object
1237 # @ingroup l2_construct
1241 ## Associates the given shape to the mesh (entails the recreation of the mesh)
1242 # @param geom the shape to be meshed (GEOM_Object)
1243 # @ingroup l2_construct
1244 def SetShape(self, geom):
1245 self.mesh = self.smeshpyD.CreateMesh(geom)
1247 ## Returns true if the hypotheses are defined well
1248 # @param theSubObject a subshape of a mesh shape
1249 # @return True or False
1250 # @ingroup l2_construct
1251 def IsReadyToCompute(self, theSubObject):
1252 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
1254 ## Returns errors of hypotheses definition.
1255 # The list of errors is empty if everything is OK.
1256 # @param theSubObject a subshape of a mesh shape
1257 # @return a list of errors
1258 # @ingroup l2_construct
1259 def GetAlgoState(self, theSubObject):
1260 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
1262 ## Returns a geometrical object on which the given element was built.
1263 # The returned geometrical object, if not nil, is either found in the
1264 # study or published by this method with the given name
1265 # @param theElementID the id of the mesh element
1266 # @param theGeomName the user-defined name of the geometrical object
1267 # @return GEOM::GEOM_Object instance
1268 # @ingroup l2_construct
1269 def GetGeometryByMeshElement(self, theElementID, theGeomName):
1270 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
1272 ## Returns the mesh dimension depending on the dimension of the underlying shape
1273 # @return mesh dimension as an integer value [0,3]
1274 # @ingroup l1_auxiliary
1275 def MeshDimension(self):
1276 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
1277 if len( shells ) > 0 :
1279 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
1281 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
1287 ## Creates a segment discretization 1D algorithm.
1288 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
1289 # \n If the optional \a geom parameter is not set, this algorithm is global.
1290 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1291 # @param algo the type of the required algorithm. Possible values are:
1293 # - smesh.PYTHON for discretization via a python function,
1294 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
1295 # @param geom If defined is the subshape to be meshed
1296 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
1297 # @ingroup l3_algos_basic
1298 def Segment(self, algo=REGULAR, geom=0):
1299 ## if Segment(geom) is called by mistake
1300 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
1301 algo, geom = geom, algo
1302 if not algo: algo = REGULAR
1305 return Mesh_Segment(self, geom)
1306 elif algo == PYTHON:
1307 return Mesh_Segment_Python(self, geom)
1308 elif algo == COMPOSITE:
1309 return Mesh_CompositeSegment(self, geom)
1311 return Mesh_Segment(self, geom)
1313 ## Creates 1D algorithm importing segments conatined in groups of other mesh.
1314 # If the optional \a geom parameter is not set, this algorithm is global.
1315 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1316 # @param geom If defined the subshape is to be meshed
1317 # @return an instance of Mesh_UseExistingElements class
1318 # @ingroup l3_algos_basic
1319 def UseExisting1DElements(self, geom=0):
1320 return Mesh_UseExistingElements(1,self, geom)
1322 ## Creates 2D algorithm importing faces conatined in groups of other mesh.
1323 # If the optional \a geom parameter is not set, this algorithm is global.
1324 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1325 # @param geom If defined the subshape is to be meshed
1326 # @return an instance of Mesh_UseExistingElements class
1327 # @ingroup l3_algos_basic
1328 def UseExisting2DElements(self, geom=0):
1329 return Mesh_UseExistingElements(2,self, geom)
1331 ## Enables creation of nodes and segments usable by 2D algoritms.
1332 # The added nodes and segments must be bound to edges and vertices by
1333 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
1334 # If the optional \a geom parameter is not set, this algorithm is global.
1335 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1336 # @param geom the subshape to be manually meshed
1337 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
1338 # @ingroup l3_algos_basic
1339 def UseExistingSegments(self, geom=0):
1340 algo = Mesh_UseExisting(1,self,geom)
1341 return algo.GetAlgorithm()
1343 ## Enables creation of nodes and faces usable by 3D algoritms.
1344 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
1345 # and SetMeshElementOnShape()
1346 # If the optional \a geom parameter is not set, this algorithm is global.
1347 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1348 # @param geom the subshape to be manually meshed
1349 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1350 # @ingroup l3_algos_basic
1351 def UseExistingFaces(self, geom=0):
1352 algo = Mesh_UseExisting(2,self,geom)
1353 return algo.GetAlgorithm()
1355 ## Creates a triangle 2D algorithm for faces.
1356 # If the optional \a geom parameter is not set, this algorithm is global.
1357 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1358 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1359 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1360 # @return an instance of Mesh_Triangle algorithm
1361 # @ingroup l3_algos_basic
1362 def Triangle(self, algo=MEFISTO, geom=0):
1363 ## if Triangle(geom) is called by mistake
1364 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1367 return Mesh_Triangle(self, algo, geom)
1369 ## Creates a quadrangle 2D algorithm for faces.
1370 # If the optional \a geom parameter is not set, this algorithm is global.
1371 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1372 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1373 # @param algo values are: smesh.QUADRANGLE || smesh.RADIAL_QUAD
1374 # @return an instance of Mesh_Quadrangle algorithm
1375 # @ingroup l3_algos_basic
1376 def Quadrangle(self, geom=0, algo=QUADRANGLE):
1377 if algo==RADIAL_QUAD:
1378 return Mesh_RadialQuadrangle1D2D(self,geom)
1380 return Mesh_Quadrangle(self, geom)
1382 ## Creates a tetrahedron 3D algorithm for solids.
1383 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1384 # If the optional \a geom parameter is not set, this algorithm is global.
1385 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1386 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1387 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1388 # @return an instance of Mesh_Tetrahedron algorithm
1389 # @ingroup l3_algos_basic
1390 def Tetrahedron(self, algo=NETGEN, geom=0):
1391 ## if Tetrahedron(geom) is called by mistake
1392 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1393 algo, geom = geom, algo
1394 if not algo: algo = NETGEN
1396 return Mesh_Tetrahedron(self, algo, geom)
1398 ## Creates a hexahedron 3D algorithm for solids.
1399 # If the optional \a geom parameter is not set, this algorithm is global.
1400 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1401 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1402 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1403 # @return an instance of Mesh_Hexahedron algorithm
1404 # @ingroup l3_algos_basic
1405 def Hexahedron(self, algo=Hexa, geom=0):
1406 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1407 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1408 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1409 elif geom == 0: algo, geom = Hexa, algo
1410 return Mesh_Hexahedron(self, algo, geom)
1412 ## Deprecated, used only for compatibility!
1413 # @return an instance of Mesh_Netgen algorithm
1414 # @ingroup l3_algos_basic
1415 def Netgen(self, is3D, geom=0):
1416 return Mesh_Netgen(self, is3D, geom)
1418 ## Creates a projection 1D algorithm for edges.
1419 # If the optional \a geom parameter is not set, this algorithm is global.
1420 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1421 # @param geom If defined, the subshape to be meshed
1422 # @return an instance of Mesh_Projection1D algorithm
1423 # @ingroup l3_algos_proj
1424 def Projection1D(self, geom=0):
1425 return Mesh_Projection1D(self, geom)
1427 ## Creates a projection 1D-2D algorithm for faces.
1428 # If the optional \a geom parameter is not set, this algorithm is global.
1429 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1430 # @param geom If defined, the subshape to be meshed
1431 # @return an instance of Mesh_Projection2D algorithm
1432 # @ingroup l3_algos_proj
1433 def Projection1D2D(self, geom=0):
1434 return Mesh_Projection2D(self, geom, "Projection_1D2D")
1436 ## Creates a projection 2D algorithm for faces.
1437 # If the optional \a geom parameter is not set, this algorithm is global.
1438 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1439 # @param geom If defined, the subshape to be meshed
1440 # @return an instance of Mesh_Projection2D algorithm
1441 # @ingroup l3_algos_proj
1442 def Projection2D(self, geom=0):
1443 return Mesh_Projection2D(self, geom, "Projection_2D")
1445 ## Creates a projection 3D algorithm for solids.
1446 # If the optional \a geom parameter is not set, this algorithm is global.
1447 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1448 # @param geom If defined, the subshape to be meshed
1449 # @return an instance of Mesh_Projection3D algorithm
1450 # @ingroup l3_algos_proj
1451 def Projection3D(self, geom=0):
1452 return Mesh_Projection3D(self, geom)
1454 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1455 # If the optional \a geom parameter is not set, this algorithm is global.
1456 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1457 # @param geom If defined, the subshape to be meshed
1458 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1459 # @ingroup l3_algos_radialp l3_algos_3dextr
1460 def Prism(self, geom=0):
1464 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1465 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1466 if nbSolids == 0 or nbSolids == nbShells:
1467 return Mesh_Prism3D(self, geom)
1468 return Mesh_RadialPrism3D(self, geom)
1470 ## Creates a "Body Fitted" 3D algorithm for solids, which generates
1471 # 3D structured Cartesian mesh in the internal part of a solid shape
1472 # and polyhedral volumes near the shape boundary.
1473 # If the optional \a geom parameter is not set, this algorithm is global.
1474 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1475 # The algorithm does not support submeshes.
1476 # Generally usage of this algorithm as a local one is useless since
1477 # it does not discretize 1D and 2D subshapes in a usual way acceptable
1478 # for other algorithms.
1479 # @param geom If defined, the subshape to be meshed
1480 # @return an instance of Mesh_Cartesian_3D algorithm
1481 # @ingroup l3_algos_basic
1482 def BodyFitted(self, geom=0):
1483 return Mesh_Cartesian_3D(self, geom)
1485 ## Evaluates size of prospective mesh on a shape
1486 # @return a list where i-th element is a number of elements of i-th SMESH.EntityType
1487 # To know predicted number of e.g. edges, inquire it this way
1488 # Evaluate()[ EnumToLong( Entity_Edge )]
1489 def Evaluate(self, geom=0):
1490 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1492 geom = self.mesh.GetShapeToMesh()
1495 return self.smeshpyD.Evaluate(self.mesh, geom)
1498 ## Computes the mesh and returns the status of the computation
1499 # @param geom geomtrical shape on which mesh data should be computed
1500 # @param discardModifs if True and the mesh has been edited since
1501 # a last total re-compute and that may prevent successful partial re-compute,
1502 # then the mesh is cleaned before Compute()
1503 # @return True or False
1504 # @ingroup l2_construct
1505 def Compute(self, geom=0, discardModifs=False):
1506 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1508 geom = self.mesh.GetShapeToMesh()
1513 if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693
1515 ok = self.smeshpyD.Compute(self.mesh, geom)
1516 except SALOME.SALOME_Exception, ex:
1517 print "Mesh computation failed, exception caught:"
1518 print " ", ex.details.text
1521 print "Mesh computation failed, exception caught:"
1522 traceback.print_exc()
1526 # Treat compute errors
1527 computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
1528 for err in computeErrors:
1530 if self.mesh.HasShapeToMesh():
1532 mainIOR = salome.orb.object_to_string(geom)
1533 for sname in salome.myStudyManager.GetOpenStudies():
1534 s = salome.myStudyManager.GetStudyByName(sname)
1536 mainSO = s.FindObjectIOR(mainIOR)
1537 if not mainSO: continue
1538 if err.subShapeID == 1:
1539 shapeText = ' on "%s"' % mainSO.GetName()
1540 subIt = s.NewChildIterator(mainSO)
1542 subSO = subIt.Value()
1544 obj = subSO.GetObject()
1545 if not obj: continue
1546 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
1548 ids = go.GetSubShapeIndices()
1549 if len(ids) == 1 and ids[0] == err.subShapeID:
1550 shapeText = ' on "%s"' % subSO.GetName()
1553 shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
1555 shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID)
1557 shapeText = " on subshape #%s" % (err.subShapeID)
1559 shapeText = " on subshape #%s" % (err.subShapeID)
1561 stdErrors = ["OK", #COMPERR_OK
1562 "Invalid input mesh", #COMPERR_BAD_INPUT_MESH
1563 "std::exception", #COMPERR_STD_EXCEPTION
1564 "OCC exception", #COMPERR_OCC_EXCEPTION
1565 "SALOME exception", #COMPERR_SLM_EXCEPTION
1566 "Unknown exception", #COMPERR_EXCEPTION
1567 "Memory allocation problem", #COMPERR_MEMORY_PB
1568 "Algorithm failed", #COMPERR_ALGO_FAILED
1569 "Unexpected geometry"]#COMPERR_BAD_SHAPE
1571 if err.code < len(stdErrors): errText = stdErrors[err.code]
1573 errText = "code %s" % -err.code
1574 if errText: errText += ". "
1575 errText += err.comment
1576 if allReasons != "":allReasons += "\n"
1577 allReasons += '"%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
1581 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1583 if err.isGlobalAlgo:
1591 reason = '%s %sD algorithm is missing' % (glob, dim)
1592 elif err.state == HYP_MISSING:
1593 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1594 % (glob, dim, name, dim))
1595 elif err.state == HYP_NOTCONFORM:
1596 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1597 elif err.state == HYP_BAD_PARAMETER:
1598 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1599 % ( glob, dim, name ))
1600 elif err.state == HYP_BAD_GEOMETRY:
1601 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1602 'geometry' % ( glob, dim, name ))
1604 reason = "For unknown reason."+\
1605 " Revise Mesh.Compute() implementation in smeshDC.py!"
1607 if allReasons != "":allReasons += "\n"
1608 allReasons += reason
1610 if allReasons != "":
1611 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1615 print '"' + GetName(self.mesh) + '"',"has not been computed."
1618 if salome.sg.hasDesktop():
1619 smeshgui = salome.ImportComponentGUI("SMESH")
1620 smeshgui.Init(self.mesh.GetStudyId())
1621 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1622 salome.sg.updateObjBrowser(1)
1626 ## Return submesh objects list in meshing order
1627 # @return list of list of submesh objects
1628 # @ingroup l2_construct
1629 def GetMeshOrder(self):
1630 return self.mesh.GetMeshOrder()
1632 ## Return submesh objects list in meshing order
1633 # @return list of list of submesh objects
1634 # @ingroup l2_construct
1635 def SetMeshOrder(self, submeshes):
1636 return self.mesh.SetMeshOrder(submeshes)
1638 ## Removes all nodes and elements
1639 # @ingroup l2_construct
1642 if salome.sg.hasDesktop():
1643 smeshgui = salome.ImportComponentGUI("SMESH")
1644 smeshgui.Init(self.mesh.GetStudyId())
1645 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1646 salome.sg.updateObjBrowser(1)
1648 ## Removes all nodes and elements of indicated shape
1649 # @ingroup l2_construct
1650 def ClearSubMesh(self, geomId):
1651 self.mesh.ClearSubMesh(geomId)
1652 if salome.sg.hasDesktop():
1653 smeshgui = salome.ImportComponentGUI("SMESH")
1654 smeshgui.Init(self.mesh.GetStudyId())
1655 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1656 salome.sg.updateObjBrowser(1)
1658 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1659 # @param fineness [0.0,1.0] defines mesh fineness
1660 # @return True or False
1661 # @ingroup l3_algos_basic
1662 def AutomaticTetrahedralization(self, fineness=0):
1663 dim = self.MeshDimension()
1665 self.RemoveGlobalHypotheses()
1666 self.Segment().AutomaticLength(fineness)
1668 self.Triangle().LengthFromEdges()
1671 self.Tetrahedron(NETGEN)
1673 return self.Compute()
1675 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1676 # @param fineness [0.0, 1.0] defines mesh fineness
1677 # @return True or False
1678 # @ingroup l3_algos_basic
1679 def AutomaticHexahedralization(self, fineness=0):
1680 dim = self.MeshDimension()
1681 # assign the hypotheses
1682 self.RemoveGlobalHypotheses()
1683 self.Segment().AutomaticLength(fineness)
1690 return self.Compute()
1692 ## Assigns a hypothesis
1693 # @param hyp a hypothesis to assign
1694 # @param geom a subhape of mesh geometry
1695 # @return SMESH.Hypothesis_Status
1696 # @ingroup l2_hypotheses
1697 def AddHypothesis(self, hyp, geom=0):
1698 if isinstance( hyp, Mesh_Algorithm ):
1699 hyp = hyp.GetAlgorithm()
1704 geom = self.mesh.GetShapeToMesh()
1706 status = self.mesh.AddHypothesis(geom, hyp)
1707 isAlgo = hyp._narrow( SMESH_Algo )
1708 hyp_name = GetName( hyp )
1711 geom_name = GetName( geom )
1712 TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1715 ## Unassigns a hypothesis
1716 # @param hyp a hypothesis to unassign
1717 # @param geom a subshape of mesh geometry
1718 # @return SMESH.Hypothesis_Status
1719 # @ingroup l2_hypotheses
1720 def RemoveHypothesis(self, hyp, geom=0):
1721 if isinstance( hyp, Mesh_Algorithm ):
1722 hyp = hyp.GetAlgorithm()
1727 status = self.mesh.RemoveHypothesis(geom, hyp)
1730 ## Gets the list of hypotheses added on a geometry
1731 # @param geom a subshape of mesh geometry
1732 # @return the sequence of SMESH_Hypothesis
1733 # @ingroup l2_hypotheses
1734 def GetHypothesisList(self, geom):
1735 return self.mesh.GetHypothesisList( geom )
1737 ## Removes all global hypotheses
1738 # @ingroup l2_hypotheses
1739 def RemoveGlobalHypotheses(self):
1740 current_hyps = self.mesh.GetHypothesisList( self.geom )
1741 for hyp in current_hyps:
1742 self.mesh.RemoveHypothesis( self.geom, hyp )
1746 ## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead.
1747 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1748 ## allowing to overwrite the file if it exists or add the exported data to its contents
1749 # @param f the file name
1750 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1751 # @param opt boolean parameter for creating/not creating
1752 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1753 # @param overwrite boolean parameter for overwriting/not overwriting the file
1754 # @ingroup l2_impexp
1755 def ExportToMED(self, f, version, opt=0, overwrite=1):
1756 self.mesh.ExportToMEDX(f, opt, version, overwrite)
1758 ## Exports the mesh in a file in MED format and chooses the \a version of MED format
1759 ## allowing to overwrite the file if it exists or add the exported data to its contents
1760 # @param f is the file name
1761 # @param auto_groups boolean parameter for creating/not creating
1762 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1763 # the typical use is auto_groups=false.
1764 # @param version MED format version(MED_V2_1 or MED_V2_2)
1765 # @param overwrite boolean parameter for overwriting/not overwriting the file
1766 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1767 # @ingroup l2_impexp
1768 def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1, meshPart=None):
1770 if isinstance( meshPart, list ):
1771 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1772 self.mesh.ExportPartToMED( meshPart, f, auto_groups, version, overwrite )
1774 self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
1776 ## Exports the mesh in a file in SAUV format
1777 # @param f is the file name
1778 # @param auto_groups boolean parameter for creating/not creating
1779 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1780 # the typical use is auto_groups=false.
1781 # @ingroup l2_impexp
1782 def ExportSAUV(self, f, auto_groups=0):
1783 self.mesh.ExportSAUV(f, auto_groups)
1785 ## Exports the mesh in a file in DAT format
1786 # @param f the file name
1787 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1788 # @ingroup l2_impexp
1789 def ExportDAT(self, f, meshPart=None):
1791 if isinstance( meshPart, list ):
1792 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1793 self.mesh.ExportPartToDAT( meshPart, f )
1795 self.mesh.ExportDAT(f)
1797 ## Exports the mesh in a file in UNV format
1798 # @param f the file name
1799 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1800 # @ingroup l2_impexp
1801 def ExportUNV(self, f, meshPart=None):
1803 if isinstance( meshPart, list ):
1804 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1805 self.mesh.ExportPartToUNV( meshPart, f )
1807 self.mesh.ExportUNV(f)
1809 ## Export the mesh in a file in STL format
1810 # @param f the file name
1811 # @param ascii defines the file encoding
1812 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1813 # @ingroup l2_impexp
1814 def ExportSTL(self, f, ascii=1, meshPart=None):
1816 if isinstance( meshPart, list ):
1817 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1818 self.mesh.ExportPartToSTL( meshPart, f, ascii )
1820 self.mesh.ExportSTL(f, ascii)
1822 ## Exports the mesh in a file in CGNS format
1823 # @param f is the file name
1824 # @param overwrite boolean parameter for overwriting/not overwriting the file
1825 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1826 # @ingroup l2_impexp
1827 def ExportCGNS(self, f, overwrite=1, meshPart=None):
1828 if isinstance( meshPart, list ):
1829 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1830 if isinstance( meshPart, Mesh ):
1831 meshPart = meshPart.mesh
1833 meshPart = self.mesh
1834 self.mesh.ExportCGNS(meshPart, f, overwrite)
1836 # Operations with groups:
1837 # ----------------------
1839 ## Creates an empty mesh group
1840 # @param elementType the type of elements in the group
1841 # @param name the name of the mesh group
1842 # @return SMESH_Group
1843 # @ingroup l2_grps_create
1844 def CreateEmptyGroup(self, elementType, name):
1845 return self.mesh.CreateGroup(elementType, name)
1847 ## Creates a mesh group based on the geometric object \a grp
1848 # and gives a \a name, \n if this parameter is not defined
1849 # the name is the same as the geometric group name \n
1850 # Note: Works like GroupOnGeom().
1851 # @param grp a geometric group, a vertex, an edge, a face or a solid
1852 # @param name the name of the mesh group
1853 # @return SMESH_GroupOnGeom
1854 # @ingroup l2_grps_create
1855 def Group(self, grp, name=""):
1856 return self.GroupOnGeom(grp, name)
1858 ## Creates a mesh group based on the geometrical object \a grp
1859 # and gives a \a name, \n if this parameter is not defined
1860 # the name is the same as the geometrical group name
1861 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1862 # @param name the name of the mesh group
1863 # @param typ the type of elements in the group. If not set, it is
1864 # automatically detected by the type of the geometry
1865 # @return SMESH_GroupOnGeom
1866 # @ingroup l2_grps_create
1867 def GroupOnGeom(self, grp, name="", typ=None):
1868 AssureGeomPublished( self, grp, name )
1870 name = grp.GetName()
1872 typ = self._groupTypeFromShape( grp )
1873 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1875 ## Pivate method to get a type of group on geometry
1876 def _groupTypeFromShape( self, shape ):
1877 tgeo = str(shape.GetShapeType())
1878 if tgeo == "VERTEX":
1880 elif tgeo == "EDGE":
1882 elif tgeo == "FACE" or tgeo == "SHELL":
1884 elif tgeo == "SOLID" or tgeo == "COMPSOLID":
1886 elif tgeo == "COMPOUND":
1887 sub = self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHAPE"])
1889 raise ValueError,"_groupTypeFromShape(): empty geometric group or compound '%s'" % GetName(shape)
1890 return self._groupTypeFromShape( sub[0] )
1893 "_groupTypeFromShape(): invalid geometry '%s'" % GetName(shape)
1896 ## Creates a mesh group with given \a name based on the \a filter which
1897 ## is a special type of group dynamically updating it's contents during
1898 ## mesh modification
1899 # @param typ the type of elements in the group
1900 # @param name the name of the mesh group
1901 # @param filter the filter defining group contents
1902 # @return SMESH_GroupOnFilter
1903 # @ingroup l2_grps_create
1904 def GroupOnFilter(self, typ, name, filter):
1905 return self.mesh.CreateGroupFromFilter(typ, name, filter)
1907 ## Creates a mesh group by the given ids of elements
1908 # @param groupName the name of the mesh group
1909 # @param elementType the type of elements in the group
1910 # @param elemIDs the list of ids
1911 # @return SMESH_Group
1912 # @ingroup l2_grps_create
1913 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1914 group = self.mesh.CreateGroup(elementType, groupName)
1918 ## Creates a mesh group by the given conditions
1919 # @param groupName the name of the mesh group
1920 # @param elementType the type of elements in the group
1921 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1922 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1923 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1924 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1925 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
1926 # FT_LyingOnGeom, FT_CoplanarFaces criteria
1927 # @return SMESH_Group
1928 # @ingroup l2_grps_create
1932 CritType=FT_Undefined,
1935 UnaryOp=FT_Undefined,
1937 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined,Tolerance)
1938 group = self.MakeGroupByCriterion(groupName, aCriterion)
1941 ## Creates a mesh group by the given criterion
1942 # @param groupName the name of the mesh group
1943 # @param Criterion the instance of Criterion class
1944 # @return SMESH_Group
1945 # @ingroup l2_grps_create
1946 def MakeGroupByCriterion(self, groupName, Criterion):
1947 aFilterMgr = self.smeshpyD.CreateFilterManager()
1948 aFilter = aFilterMgr.CreateFilter()
1950 aCriteria.append(Criterion)
1951 aFilter.SetCriteria(aCriteria)
1952 group = self.MakeGroupByFilter(groupName, aFilter)
1953 aFilterMgr.UnRegister()
1956 ## Creates a mesh group by the given criteria (list of criteria)
1957 # @param groupName the name of the mesh group
1958 # @param theCriteria the list of criteria
1959 # @return SMESH_Group
1960 # @ingroup l2_grps_create
1961 def MakeGroupByCriteria(self, groupName, theCriteria):
1962 aFilterMgr = self.smeshpyD.CreateFilterManager()
1963 aFilter = aFilterMgr.CreateFilter()
1964 aFilter.SetCriteria(theCriteria)
1965 group = self.MakeGroupByFilter(groupName, aFilter)
1966 aFilterMgr.UnRegister()
1969 ## Creates a mesh group by the given filter
1970 # @param groupName the name of the mesh group
1971 # @param theFilter the instance of Filter class
1972 # @return SMESH_Group
1973 # @ingroup l2_grps_create
1974 def MakeGroupByFilter(self, groupName, theFilter):
1975 group = self.CreateEmptyGroup(theFilter.GetElementType(), groupName)
1976 theFilter.SetMesh( self.mesh )
1977 group.AddFrom( theFilter )
1980 ## Passes mesh elements through the given filter and return IDs of fitting elements
1981 # @param theFilter SMESH_Filter
1982 # @return a list of ids
1983 # @ingroup l1_controls
1984 def GetIdsFromFilter(self, theFilter):
1985 theFilter.SetMesh( self.mesh )
1986 return theFilter.GetIDs()
1988 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1989 # Returns a list of special structures (borders).
1990 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1991 # @ingroup l1_controls
1992 def GetFreeBorders(self):
1993 aFilterMgr = self.smeshpyD.CreateFilterManager()
1994 aPredicate = aFilterMgr.CreateFreeEdges()
1995 aPredicate.SetMesh(self.mesh)
1996 aBorders = aPredicate.GetBorders()
1997 aFilterMgr.UnRegister()
2001 # @ingroup l2_grps_delete
2002 def RemoveGroup(self, group):
2003 self.mesh.RemoveGroup(group)
2005 ## Removes a group with its contents
2006 # @ingroup l2_grps_delete
2007 def RemoveGroupWithContents(self, group):
2008 self.mesh.RemoveGroupWithContents(group)
2010 ## Gets the list of groups existing in the mesh
2011 # @return a sequence of SMESH_GroupBase
2012 # @ingroup l2_grps_create
2013 def GetGroups(self):
2014 return self.mesh.GetGroups()
2016 ## Gets the number of groups existing in the mesh
2017 # @return the quantity of groups as an integer value
2018 # @ingroup l2_grps_create
2020 return self.mesh.NbGroups()
2022 ## Gets the list of names of groups existing in the mesh
2023 # @return list of strings
2024 # @ingroup l2_grps_create
2025 def GetGroupNames(self):
2026 groups = self.GetGroups()
2028 for group in groups:
2029 names.append(group.GetName())
2032 ## Produces a union of two groups
2033 # A new group is created. All mesh elements that are
2034 # present in the initial groups are added to the new one
2035 # @return an instance of SMESH_Group
2036 # @ingroup l2_grps_operon
2037 def UnionGroups(self, group1, group2, name):
2038 return self.mesh.UnionGroups(group1, group2, name)
2040 ## Produces a union list of groups
2041 # New group is created. All mesh elements that are present in
2042 # initial groups are added to the new one
2043 # @return an instance of SMESH_Group
2044 # @ingroup l2_grps_operon
2045 def UnionListOfGroups(self, groups, name):
2046 return self.mesh.UnionListOfGroups(groups, name)
2048 ## Prodices an intersection of two groups
2049 # A new group is created. All mesh elements that are common
2050 # for the two initial groups are added to the new one.
2051 # @return an instance of SMESH_Group
2052 # @ingroup l2_grps_operon
2053 def IntersectGroups(self, group1, group2, name):
2054 return self.mesh.IntersectGroups(group1, group2, name)
2056 ## Produces an intersection of groups
2057 # New group is created. All mesh elements that are present in all
2058 # initial groups simultaneously are added to the new one
2059 # @return an instance of SMESH_Group
2060 # @ingroup l2_grps_operon
2061 def IntersectListOfGroups(self, groups, name):
2062 return self.mesh.IntersectListOfGroups(groups, name)
2064 ## Produces a cut of two groups
2065 # A new group is created. All mesh elements that are present in
2066 # the main group but are not present in the tool group are added to the new one
2067 # @return an instance of SMESH_Group
2068 # @ingroup l2_grps_operon
2069 def CutGroups(self, main_group, tool_group, name):
2070 return self.mesh.CutGroups(main_group, tool_group, name)
2072 ## Produces a cut of groups
2073 # A new group is created. All mesh elements that are present in main groups
2074 # but do not present in tool groups are added to the new one
2075 # @return an instance of SMESH_Group
2076 # @ingroup l2_grps_operon
2077 def CutListOfGroups(self, main_groups, tool_groups, name):
2078 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
2080 ## Produces a group of elements of specified type using list of existing groups
2081 # A new group is created. System
2082 # 1) extracts all nodes on which groups elements are built
2083 # 2) combines all elements of specified dimension laying on these nodes
2084 # @return an instance of SMESH_Group
2085 # @ingroup l2_grps_operon
2086 def CreateDimGroup(self, groups, elem_type, name):
2087 return self.mesh.CreateDimGroup(groups, elem_type, name)
2090 ## Convert group on geom into standalone group
2091 # @ingroup l2_grps_delete
2092 def ConvertToStandalone(self, group):
2093 return self.mesh.ConvertToStandalone(group)
2095 # Get some info about mesh:
2096 # ------------------------
2098 ## Returns the log of nodes and elements added or removed
2099 # since the previous clear of the log.
2100 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
2101 # @return list of log_block structures:
2106 # @ingroup l1_auxiliary
2107 def GetLog(self, clearAfterGet):
2108 return self.mesh.GetLog(clearAfterGet)
2110 ## Clears the log of nodes and elements added or removed since the previous
2111 # clear. Must be used immediately after GetLog if clearAfterGet is false.
2112 # @ingroup l1_auxiliary
2114 self.mesh.ClearLog()
2116 ## Toggles auto color mode on the object.
2117 # @param theAutoColor the flag which toggles auto color mode.
2118 # @ingroup l1_auxiliary
2119 def SetAutoColor(self, theAutoColor):
2120 self.mesh.SetAutoColor(theAutoColor)
2122 ## Gets flag of object auto color mode.
2123 # @return True or False
2124 # @ingroup l1_auxiliary
2125 def GetAutoColor(self):
2126 return self.mesh.GetAutoColor()
2128 ## Gets the internal ID
2129 # @return integer value, which is the internal Id of the mesh
2130 # @ingroup l1_auxiliary
2132 return self.mesh.GetId()
2135 # @return integer value, which is the study Id of the mesh
2136 # @ingroup l1_auxiliary
2137 def GetStudyId(self):
2138 return self.mesh.GetStudyId()
2140 ## Checks the group names for duplications.
2141 # Consider the maximum group name length stored in MED file.
2142 # @return True or False
2143 # @ingroup l1_auxiliary
2144 def HasDuplicatedGroupNamesMED(self):
2145 return self.mesh.HasDuplicatedGroupNamesMED()
2147 ## Obtains the mesh editor tool
2148 # @return an instance of SMESH_MeshEditor
2149 # @ingroup l1_modifying
2150 def GetMeshEditor(self):
2151 return self.mesh.GetMeshEditor()
2153 ## Wrap a list of IDs of elements or nodes into SMESH_IDSource which
2154 # can be passed as argument to accepting mesh, group or sub-mesh
2155 # @return an instance of SMESH_IDSource
2156 # @ingroup l1_auxiliary
2157 def GetIDSource(self, ids, elemType):
2158 return self.GetMeshEditor().MakeIDSource(ids, elemType)
2161 # @return an instance of SALOME_MED::MESH
2162 # @ingroup l1_auxiliary
2163 def GetMEDMesh(self):
2164 return self.mesh.GetMEDMesh()
2167 # Get informations about mesh contents:
2168 # ------------------------------------
2170 ## Gets the mesh stattistic
2171 # @return dictionary type element - count of elements
2172 # @ingroup l1_meshinfo
2173 def GetMeshInfo(self, obj = None):
2174 if not obj: obj = self.mesh
2175 return self.smeshpyD.GetMeshInfo(obj)
2177 ## Returns the number of nodes in the mesh
2178 # @return an integer value
2179 # @ingroup l1_meshinfo
2181 return self.mesh.NbNodes()
2183 ## Returns the number of elements in the mesh
2184 # @return an integer value
2185 # @ingroup l1_meshinfo
2186 def NbElements(self):
2187 return self.mesh.NbElements()
2189 ## Returns the number of 0d elements in the mesh
2190 # @return an integer value
2191 # @ingroup l1_meshinfo
2192 def Nb0DElements(self):
2193 return self.mesh.Nb0DElements()
2195 ## Returns the number of edges in the mesh
2196 # @return an integer value
2197 # @ingroup l1_meshinfo
2199 return self.mesh.NbEdges()
2201 ## Returns the number of edges with the given order in the mesh
2202 # @param elementOrder the order of elements:
2203 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2204 # @return an integer value
2205 # @ingroup l1_meshinfo
2206 def NbEdgesOfOrder(self, elementOrder):
2207 return self.mesh.NbEdgesOfOrder(elementOrder)
2209 ## Returns the number of faces in the mesh
2210 # @return an integer value
2211 # @ingroup l1_meshinfo
2213 return self.mesh.NbFaces()
2215 ## Returns the number of faces with the given order in the mesh
2216 # @param elementOrder the order of elements:
2217 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2218 # @return an integer value
2219 # @ingroup l1_meshinfo
2220 def NbFacesOfOrder(self, elementOrder):
2221 return self.mesh.NbFacesOfOrder(elementOrder)
2223 ## Returns the number of triangles in the mesh
2224 # @return an integer value
2225 # @ingroup l1_meshinfo
2226 def NbTriangles(self):
2227 return self.mesh.NbTriangles()
2229 ## Returns the number of triangles with the given order in the mesh
2230 # @param elementOrder is the order of elements:
2231 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2232 # @return an integer value
2233 # @ingroup l1_meshinfo
2234 def NbTrianglesOfOrder(self, elementOrder):
2235 return self.mesh.NbTrianglesOfOrder(elementOrder)
2237 ## Returns the number of quadrangles in the mesh
2238 # @return an integer value
2239 # @ingroup l1_meshinfo
2240 def NbQuadrangles(self):
2241 return self.mesh.NbQuadrangles()
2243 ## Returns the number of quadrangles with the given order in the mesh
2244 # @param elementOrder the order of elements:
2245 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2246 # @return an integer value
2247 # @ingroup l1_meshinfo
2248 def NbQuadranglesOfOrder(self, elementOrder):
2249 return self.mesh.NbQuadranglesOfOrder(elementOrder)
2251 ## Returns the number of polygons in the mesh
2252 # @return an integer value
2253 # @ingroup l1_meshinfo
2254 def NbPolygons(self):
2255 return self.mesh.NbPolygons()
2257 ## Returns the number of volumes in the mesh
2258 # @return an integer value
2259 # @ingroup l1_meshinfo
2260 def NbVolumes(self):
2261 return self.mesh.NbVolumes()
2263 ## Returns the number of volumes with the given order in the mesh
2264 # @param elementOrder the order of elements:
2265 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2266 # @return an integer value
2267 # @ingroup l1_meshinfo
2268 def NbVolumesOfOrder(self, elementOrder):
2269 return self.mesh.NbVolumesOfOrder(elementOrder)
2271 ## Returns the number of tetrahedrons in the mesh
2272 # @return an integer value
2273 # @ingroup l1_meshinfo
2275 return self.mesh.NbTetras()
2277 ## Returns the number of tetrahedrons with the given order in the mesh
2278 # @param elementOrder the order of elements:
2279 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2280 # @return an integer value
2281 # @ingroup l1_meshinfo
2282 def NbTetrasOfOrder(self, elementOrder):
2283 return self.mesh.NbTetrasOfOrder(elementOrder)
2285 ## Returns the number of hexahedrons in the mesh
2286 # @return an integer value
2287 # @ingroup l1_meshinfo
2289 return self.mesh.NbHexas()
2291 ## Returns the number of hexahedrons with the given order in the mesh
2292 # @param elementOrder the order of elements:
2293 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2294 # @return an integer value
2295 # @ingroup l1_meshinfo
2296 def NbHexasOfOrder(self, elementOrder):
2297 return self.mesh.NbHexasOfOrder(elementOrder)
2299 ## Returns the number of pyramids in the mesh
2300 # @return an integer value
2301 # @ingroup l1_meshinfo
2302 def NbPyramids(self):
2303 return self.mesh.NbPyramids()
2305 ## Returns the number of pyramids with the given order in the mesh
2306 # @param elementOrder the order of elements:
2307 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2308 # @return an integer value
2309 # @ingroup l1_meshinfo
2310 def NbPyramidsOfOrder(self, elementOrder):
2311 return self.mesh.NbPyramidsOfOrder(elementOrder)
2313 ## Returns the number of prisms in the mesh
2314 # @return an integer value
2315 # @ingroup l1_meshinfo
2317 return self.mesh.NbPrisms()
2319 ## Returns the number of prisms with the given order in the mesh
2320 # @param elementOrder the order of elements:
2321 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2322 # @return an integer value
2323 # @ingroup l1_meshinfo
2324 def NbPrismsOfOrder(self, elementOrder):
2325 return self.mesh.NbPrismsOfOrder(elementOrder)
2327 ## Returns the number of polyhedrons in the mesh
2328 # @return an integer value
2329 # @ingroup l1_meshinfo
2330 def NbPolyhedrons(self):
2331 return self.mesh.NbPolyhedrons()
2333 ## Returns the number of submeshes in the mesh
2334 # @return an integer value
2335 # @ingroup l1_meshinfo
2336 def NbSubMesh(self):
2337 return self.mesh.NbSubMesh()
2339 ## Returns the list of mesh elements IDs
2340 # @return the list of integer values
2341 # @ingroup l1_meshinfo
2342 def GetElementsId(self):
2343 return self.mesh.GetElementsId()
2345 ## Returns the list of IDs of mesh elements with the given type
2346 # @param elementType the required type of elements (SMESH.NODE, SMESH.EDGE, SMESH.FACE or SMESH.VOLUME)
2347 # @return list of integer values
2348 # @ingroup l1_meshinfo
2349 def GetElementsByType(self, elementType):
2350 return self.mesh.GetElementsByType(elementType)
2352 ## Returns the list of mesh nodes IDs
2353 # @return the list of integer values
2354 # @ingroup l1_meshinfo
2355 def GetNodesId(self):
2356 return self.mesh.GetNodesId()
2358 # Get the information about mesh elements:
2359 # ------------------------------------
2361 ## Returns the type of mesh element
2362 # @return the value from SMESH::ElementType enumeration
2363 # @ingroup l1_meshinfo
2364 def GetElementType(self, id, iselem):
2365 return self.mesh.GetElementType(id, iselem)
2367 ## Returns the geometric type of mesh element
2368 # @return the value from SMESH::EntityType enumeration
2369 # @ingroup l1_meshinfo
2370 def GetElementGeomType(self, id):
2371 return self.mesh.GetElementGeomType(id)
2373 ## Returns the list of submesh elements IDs
2374 # @param Shape a geom object(subshape) IOR
2375 # Shape must be the subshape of a ShapeToMesh()
2376 # @return the list of integer values
2377 # @ingroup l1_meshinfo
2378 def GetSubMeshElementsId(self, Shape):
2379 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2380 ShapeID = Shape.GetSubShapeIndices()[0]
2383 return self.mesh.GetSubMeshElementsId(ShapeID)
2385 ## Returns the list of submesh nodes IDs
2386 # @param Shape a geom object(subshape) IOR
2387 # Shape must be the subshape of a ShapeToMesh()
2388 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
2389 # @return the list of integer values
2390 # @ingroup l1_meshinfo
2391 def GetSubMeshNodesId(self, Shape, all):
2392 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2393 ShapeID = Shape.GetSubShapeIndices()[0]
2396 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2398 ## Returns type of elements on given shape
2399 # @param Shape a geom object(subshape) IOR
2400 # Shape must be a subshape of a ShapeToMesh()
2401 # @return element type
2402 # @ingroup l1_meshinfo
2403 def GetSubMeshElementType(self, Shape):
2404 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2405 ShapeID = Shape.GetSubShapeIndices()[0]
2408 return self.mesh.GetSubMeshElementType(ShapeID)
2410 ## Gets the mesh description
2411 # @return string value
2412 # @ingroup l1_meshinfo
2414 return self.mesh.Dump()
2417 # Get the information about nodes and elements of a mesh by its IDs:
2418 # -----------------------------------------------------------
2420 ## Gets XYZ coordinates of a node
2421 # \n If there is no nodes for the given ID - returns an empty list
2422 # @return a list of double precision values
2423 # @ingroup l1_meshinfo
2424 def GetNodeXYZ(self, id):
2425 return self.mesh.GetNodeXYZ(id)
2427 ## Returns list of IDs of inverse elements for the given node
2428 # \n If there is no node for the given ID - returns an empty list
2429 # @return a list of integer values
2430 # @ingroup l1_meshinfo
2431 def GetNodeInverseElements(self, id):
2432 return self.mesh.GetNodeInverseElements(id)
2434 ## @brief Returns the position of a node on the shape
2435 # @return SMESH::NodePosition
2436 # @ingroup l1_meshinfo
2437 def GetNodePosition(self,NodeID):
2438 return self.mesh.GetNodePosition(NodeID)
2440 ## If the given element is a node, returns the ID of shape
2441 # \n If there is no node for the given ID - returns -1
2442 # @return an integer value
2443 # @ingroup l1_meshinfo
2444 def GetShapeID(self, id):
2445 return self.mesh.GetShapeID(id)
2447 ## Returns the ID of the result shape after
2448 # FindShape() from SMESH_MeshEditor for the given element
2449 # \n If there is no element for the given ID - returns -1
2450 # @return an integer value
2451 # @ingroup l1_meshinfo
2452 def GetShapeIDForElem(self,id):
2453 return self.mesh.GetShapeIDForElem(id)
2455 ## Returns the number of nodes for the given element
2456 # \n If there is no element for the given ID - returns -1
2457 # @return an integer value
2458 # @ingroup l1_meshinfo
2459 def GetElemNbNodes(self, id):
2460 return self.mesh.GetElemNbNodes(id)
2462 ## Returns the node ID the given index for the given element
2463 # \n If there is no element for the given ID - returns -1
2464 # \n If there is no node for the given index - returns -2
2465 # @return an integer value
2466 # @ingroup l1_meshinfo
2467 def GetElemNode(self, id, index):
2468 return self.mesh.GetElemNode(id, index)
2470 ## Returns the IDs of nodes of the given element
2471 # @return a list of integer values
2472 # @ingroup l1_meshinfo
2473 def GetElemNodes(self, id):
2474 return self.mesh.GetElemNodes(id)
2476 ## Returns true if the given node is the medium node in the given quadratic element
2477 # @ingroup l1_meshinfo
2478 def IsMediumNode(self, elementID, nodeID):
2479 return self.mesh.IsMediumNode(elementID, nodeID)
2481 ## Returns true if the given node is the medium node in one of quadratic elements
2482 # @ingroup l1_meshinfo
2483 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2484 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2486 ## Returns the number of edges for the given element
2487 # @ingroup l1_meshinfo
2488 def ElemNbEdges(self, id):
2489 return self.mesh.ElemNbEdges(id)
2491 ## Returns the number of faces for the given element
2492 # @ingroup l1_meshinfo
2493 def ElemNbFaces(self, id):
2494 return self.mesh.ElemNbFaces(id)
2496 ## Returns nodes of given face (counted from zero) for given volumic element.
2497 # @ingroup l1_meshinfo
2498 def GetElemFaceNodes(self,elemId, faceIndex):
2499 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2501 ## Returns an element based on all given nodes.
2502 # @ingroup l1_meshinfo
2503 def FindElementByNodes(self,nodes):
2504 return self.mesh.FindElementByNodes(nodes)
2506 ## Returns true if the given element is a polygon
2507 # @ingroup l1_meshinfo
2508 def IsPoly(self, id):
2509 return self.mesh.IsPoly(id)
2511 ## Returns true if the given element is quadratic
2512 # @ingroup l1_meshinfo
2513 def IsQuadratic(self, id):
2514 return self.mesh.IsQuadratic(id)
2516 ## Returns XYZ coordinates of the barycenter of the given element
2517 # \n If there is no element for the given ID - returns an empty list
2518 # @return a list of three double values
2519 # @ingroup l1_meshinfo
2520 def BaryCenter(self, id):
2521 return self.mesh.BaryCenter(id)
2524 # Get mesh measurements information:
2525 # ------------------------------------
2527 ## Get minimum distance between two nodes, elements or distance to the origin
2528 # @param id1 first node/element id
2529 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2530 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2531 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2532 # @return minimum distance value
2533 # @sa GetMinDistance()
2534 def MinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2535 aMeasure = self.GetMinDistance(id1, id2, isElem1, isElem2)
2536 return aMeasure.value
2538 ## Get measure structure specifying minimum distance data between two objects
2539 # @param id1 first node/element id
2540 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2541 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2542 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2543 # @return Measure structure
2545 def GetMinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2547 id1 = self.editor.MakeIDSource([id1], SMESH.FACE)
2549 id1 = self.editor.MakeIDSource([id1], SMESH.NODE)
2552 id2 = self.editor.MakeIDSource([id2], SMESH.FACE)
2554 id2 = self.editor.MakeIDSource([id2], SMESH.NODE)
2559 aMeasurements = self.smeshpyD.CreateMeasurements()
2560 aMeasure = aMeasurements.MinDistance(id1, id2)
2561 aMeasurements.UnRegister()
2564 ## Get bounding box of the specified object(s)
2565 # @param objects single source object or list of source objects or list of nodes/elements IDs
2566 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2567 # @c False specifies that @a objects are nodes
2568 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
2569 # @sa GetBoundingBox()
2570 def BoundingBox(self, objects=None, isElem=False):
2571 result = self.GetBoundingBox(objects, isElem)
2575 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
2578 ## Get measure structure specifying bounding box data of the specified object(s)
2579 # @param IDs single source object or list of source objects or list of nodes/elements IDs
2580 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2581 # @c False specifies that @a objects are nodes
2582 # @return Measure structure
2584 def GetBoundingBox(self, IDs=None, isElem=False):
2587 elif isinstance(IDs, tuple):
2589 if not isinstance(IDs, list):
2591 if len(IDs) > 0 and isinstance(IDs[0], int):
2595 if isinstance(o, Mesh):
2596 srclist.append(o.mesh)
2597 elif hasattr(o, "_narrow"):
2598 src = o._narrow(SMESH.SMESH_IDSource)
2599 if src: srclist.append(src)
2601 elif isinstance(o, list):
2603 srclist.append(self.editor.MakeIDSource(o, SMESH.FACE))
2605 srclist.append(self.editor.MakeIDSource(o, SMESH.NODE))
2608 aMeasurements = self.smeshpyD.CreateMeasurements()
2609 aMeasure = aMeasurements.BoundingBox(srclist)
2610 aMeasurements.UnRegister()
2613 # Mesh edition (SMESH_MeshEditor functionality):
2614 # ---------------------------------------------
2616 ## Removes the elements from the mesh by ids
2617 # @param IDsOfElements is a list of ids of elements to remove
2618 # @return True or False
2619 # @ingroup l2_modif_del
2620 def RemoveElements(self, IDsOfElements):
2621 return self.editor.RemoveElements(IDsOfElements)
2623 ## Removes nodes from mesh by ids
2624 # @param IDsOfNodes is a list of ids of nodes to remove
2625 # @return True or False
2626 # @ingroup l2_modif_del
2627 def RemoveNodes(self, IDsOfNodes):
2628 return self.editor.RemoveNodes(IDsOfNodes)
2630 ## Removes all orphan (free) nodes from mesh
2631 # @return number of the removed nodes
2632 # @ingroup l2_modif_del
2633 def RemoveOrphanNodes(self):
2634 return self.editor.RemoveOrphanNodes()
2636 ## Add a node to the mesh by coordinates
2637 # @return Id of the new node
2638 # @ingroup l2_modif_add
2639 def AddNode(self, x, y, z):
2640 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2641 self.mesh.SetParameters(Parameters)
2642 return self.editor.AddNode( x, y, z)
2644 ## Creates a 0D element on a node with given number.
2645 # @param IDOfNode the ID of node for creation of the element.
2646 # @return the Id of the new 0D element
2647 # @ingroup l2_modif_add
2648 def Add0DElement(self, IDOfNode):
2649 return self.editor.Add0DElement(IDOfNode)
2651 ## Creates a linear or quadratic edge (this is determined
2652 # by the number of given nodes).
2653 # @param IDsOfNodes the list of node IDs for creation of the element.
2654 # The order of nodes in this list should correspond to the description
2655 # of MED. \n This description is located by the following link:
2656 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2657 # @return the Id of the new edge
2658 # @ingroup l2_modif_add
2659 def AddEdge(self, IDsOfNodes):
2660 return self.editor.AddEdge(IDsOfNodes)
2662 ## Creates a linear or quadratic face (this is determined
2663 # by the number of given nodes).
2664 # @param IDsOfNodes the list of node IDs for creation of the element.
2665 # The order of nodes in this list should correspond to the description
2666 # of MED. \n This description is located by the following link:
2667 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2668 # @return the Id of the new face
2669 # @ingroup l2_modif_add
2670 def AddFace(self, IDsOfNodes):
2671 return self.editor.AddFace(IDsOfNodes)
2673 ## Adds a polygonal face to the mesh by the list of node IDs
2674 # @param IdsOfNodes the list of node IDs for creation of the element.
2675 # @return the Id of the new face
2676 # @ingroup l2_modif_add
2677 def AddPolygonalFace(self, IdsOfNodes):
2678 return self.editor.AddPolygonalFace(IdsOfNodes)
2680 ## Creates both simple and quadratic volume (this is determined
2681 # by the number of given nodes).
2682 # @param IDsOfNodes the list of node IDs for creation of the element.
2683 # The order of nodes in this list should correspond to the description
2684 # of MED. \n This description is located by the following link:
2685 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2686 # @return the Id of the new volumic element
2687 # @ingroup l2_modif_add
2688 def AddVolume(self, IDsOfNodes):
2689 return self.editor.AddVolume(IDsOfNodes)
2691 ## Creates a volume of many faces, giving nodes for each face.
2692 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2693 # @param Quantities the list of integer values, Quantities[i]
2694 # gives the quantity of nodes in face number i.
2695 # @return the Id of the new volumic element
2696 # @ingroup l2_modif_add
2697 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2698 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2700 ## Creates a volume of many faces, giving the IDs of the existing faces.
2701 # @param IdsOfFaces the list of face IDs for volume creation.
2703 # Note: The created volume will refer only to the nodes
2704 # of the given faces, not to the faces themselves.
2705 # @return the Id of the new volumic element
2706 # @ingroup l2_modif_add
2707 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2708 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2711 ## @brief Binds a node to a vertex
2712 # @param NodeID a node ID
2713 # @param Vertex a vertex or vertex ID
2714 # @return True if succeed else raises an exception
2715 # @ingroup l2_modif_add
2716 def SetNodeOnVertex(self, NodeID, Vertex):
2717 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2718 VertexID = Vertex.GetSubShapeIndices()[0]
2722 self.editor.SetNodeOnVertex(NodeID, VertexID)
2723 except SALOME.SALOME_Exception, inst:
2724 raise ValueError, inst.details.text
2728 ## @brief Stores the node position on an edge
2729 # @param NodeID a node ID
2730 # @param Edge an edge or edge ID
2731 # @param paramOnEdge a parameter on the edge where the node is located
2732 # @return True if succeed else raises an exception
2733 # @ingroup l2_modif_add
2734 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2735 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2736 EdgeID = Edge.GetSubShapeIndices()[0]
2740 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2741 except SALOME.SALOME_Exception, inst:
2742 raise ValueError, inst.details.text
2745 ## @brief Stores node position on a face
2746 # @param NodeID a node ID
2747 # @param Face a face or face ID
2748 # @param u U parameter on the face where the node is located
2749 # @param v V parameter on the face where the node is located
2750 # @return True if succeed else raises an exception
2751 # @ingroup l2_modif_add
2752 def SetNodeOnFace(self, NodeID, Face, u, v):
2753 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2754 FaceID = Face.GetSubShapeIndices()[0]
2758 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2759 except SALOME.SALOME_Exception, inst:
2760 raise ValueError, inst.details.text
2763 ## @brief Binds a node to a solid
2764 # @param NodeID a node ID
2765 # @param Solid a solid or solid ID
2766 # @return True if succeed else raises an exception
2767 # @ingroup l2_modif_add
2768 def SetNodeInVolume(self, NodeID, Solid):
2769 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2770 SolidID = Solid.GetSubShapeIndices()[0]
2774 self.editor.SetNodeInVolume(NodeID, SolidID)
2775 except SALOME.SALOME_Exception, inst:
2776 raise ValueError, inst.details.text
2779 ## @brief Bind an element to a shape
2780 # @param ElementID an element ID
2781 # @param Shape a shape or shape ID
2782 # @return True if succeed else raises an exception
2783 # @ingroup l2_modif_add
2784 def SetMeshElementOnShape(self, ElementID, Shape):
2785 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2786 ShapeID = Shape.GetSubShapeIndices()[0]
2790 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2791 except SALOME.SALOME_Exception, inst:
2792 raise ValueError, inst.details.text
2796 ## Moves the node with the given id
2797 # @param NodeID the id of the node
2798 # @param x a new X coordinate
2799 # @param y a new Y coordinate
2800 # @param z a new Z coordinate
2801 # @return True if succeed else False
2802 # @ingroup l2_modif_movenode
2803 def MoveNode(self, NodeID, x, y, z):
2804 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2805 self.mesh.SetParameters(Parameters)
2806 return self.editor.MoveNode(NodeID, x, y, z)
2808 ## Finds the node closest to a point and moves it to a point location
2809 # @param x the X coordinate of a point
2810 # @param y the Y coordinate of a point
2811 # @param z the Z coordinate of a point
2812 # @param NodeID if specified (>0), the node with this ID is moved,
2813 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2814 # @return the ID of a node
2815 # @ingroup l2_modif_throughp
2816 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2817 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2818 self.mesh.SetParameters(Parameters)
2819 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2821 ## Finds the node closest to a point
2822 # @param x the X coordinate of a point
2823 # @param y the Y coordinate of a point
2824 # @param z the Z coordinate of a point
2825 # @return the ID of a node
2826 # @ingroup l2_modif_throughp
2827 def FindNodeClosestTo(self, x, y, z):
2828 #preview = self.mesh.GetMeshEditPreviewer()
2829 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2830 return self.editor.FindNodeClosestTo(x, y, z)
2832 ## Finds the elements where a point lays IN or ON
2833 # @param x the X coordinate of a point
2834 # @param y the Y coordinate of a point
2835 # @param z the Z coordinate of a point
2836 # @param elementType type of elements to find (SMESH.ALL type
2837 # means elements of any type excluding nodes and 0D elements)
2838 # @param meshPart a part of mesh (group, sub-mesh) to search within
2839 # @return list of IDs of found elements
2840 # @ingroup l2_modif_throughp
2841 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL, meshPart=None):
2843 return self.editor.FindAmongElementsByPoint( meshPart, x, y, z, elementType );
2845 return self.editor.FindElementsByPoint(x, y, z, elementType)
2847 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2848 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2850 def GetPointState(self, x, y, z):
2851 return self.editor.GetPointState(x, y, z)
2853 ## Finds the node closest to a point and moves it to a point location
2854 # @param x the X coordinate of a point
2855 # @param y the Y coordinate of a point
2856 # @param z the Z coordinate of a point
2857 # @return the ID of a moved node
2858 # @ingroup l2_modif_throughp
2859 def MeshToPassThroughAPoint(self, x, y, z):
2860 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2862 ## Replaces two neighbour triangles sharing Node1-Node2 link
2863 # with the triangles built on the same 4 nodes but having other common link.
2864 # @param NodeID1 the ID of the first node
2865 # @param NodeID2 the ID of the second node
2866 # @return false if proper faces were not found
2867 # @ingroup l2_modif_invdiag
2868 def InverseDiag(self, NodeID1, NodeID2):
2869 return self.editor.InverseDiag(NodeID1, NodeID2)
2871 ## Replaces two neighbour triangles sharing Node1-Node2 link
2872 # with a quadrangle built on the same 4 nodes.
2873 # @param NodeID1 the ID of the first node
2874 # @param NodeID2 the ID of the second node
2875 # @return false if proper faces were not found
2876 # @ingroup l2_modif_unitetri
2877 def DeleteDiag(self, NodeID1, NodeID2):
2878 return self.editor.DeleteDiag(NodeID1, NodeID2)
2880 ## Reorients elements by ids
2881 # @param IDsOfElements if undefined reorients all mesh elements
2882 # @return True if succeed else False
2883 # @ingroup l2_modif_changori
2884 def Reorient(self, IDsOfElements=None):
2885 if IDsOfElements == None:
2886 IDsOfElements = self.GetElementsId()
2887 return self.editor.Reorient(IDsOfElements)
2889 ## Reorients all elements of the object
2890 # @param theObject mesh, submesh or group
2891 # @return True if succeed else False
2892 # @ingroup l2_modif_changori
2893 def ReorientObject(self, theObject):
2894 if ( isinstance( theObject, Mesh )):
2895 theObject = theObject.GetMesh()
2896 return self.editor.ReorientObject(theObject)
2898 ## Fuses the neighbouring triangles into quadrangles.
2899 # @param IDsOfElements The triangles to be fused,
2900 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2901 # @param MaxAngle is the maximum angle between element normals at which the fusion
2902 # is still performed; theMaxAngle is mesured in radians.
2903 # Also it could be a name of variable which defines angle in degrees.
2904 # @return TRUE in case of success, FALSE otherwise.
2905 # @ingroup l2_modif_unitetri
2906 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2908 if isinstance(MaxAngle,str):
2910 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2912 MaxAngle = DegreesToRadians(MaxAngle)
2913 if IDsOfElements == []:
2914 IDsOfElements = self.GetElementsId()
2915 self.mesh.SetParameters(Parameters)
2917 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2918 Functor = theCriterion
2920 Functor = self.smeshpyD.GetFunctor(theCriterion)
2921 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2923 ## Fuses the neighbouring triangles of the object into quadrangles
2924 # @param theObject is mesh, submesh or group
2925 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2926 # @param MaxAngle a max angle between element normals at which the fusion
2927 # is still performed; theMaxAngle is mesured in radians.
2928 # @return TRUE in case of success, FALSE otherwise.
2929 # @ingroup l2_modif_unitetri
2930 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2931 if ( isinstance( theObject, Mesh )):
2932 theObject = theObject.GetMesh()
2933 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2935 ## Splits quadrangles into triangles.
2936 # @param IDsOfElements the faces to be splitted.
2937 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2938 # @return TRUE in case of success, FALSE otherwise.
2939 # @ingroup l2_modif_cutquadr
2940 def QuadToTri (self, IDsOfElements, theCriterion):
2941 if IDsOfElements == []:
2942 IDsOfElements = self.GetElementsId()
2943 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2945 ## Splits quadrangles into triangles.
2946 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2947 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2948 # @return TRUE in case of success, FALSE otherwise.
2949 # @ingroup l2_modif_cutquadr
2950 def QuadToTriObject (self, theObject, theCriterion):
2951 if ( isinstance( theObject, Mesh )):
2952 theObject = theObject.GetMesh()
2953 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2955 ## Splits quadrangles into triangles.
2956 # @param IDsOfElements the faces to be splitted
2957 # @param Diag13 is used to choose a diagonal for splitting.
2958 # @return TRUE in case of success, FALSE otherwise.
2959 # @ingroup l2_modif_cutquadr
2960 def SplitQuad (self, IDsOfElements, Diag13):
2961 if IDsOfElements == []:
2962 IDsOfElements = self.GetElementsId()
2963 return self.editor.SplitQuad(IDsOfElements, Diag13)
2965 ## Splits quadrangles into triangles.
2966 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2967 # @param Diag13 is used to choose a diagonal for splitting.
2968 # @return TRUE in case of success, FALSE otherwise.
2969 # @ingroup l2_modif_cutquadr
2970 def SplitQuadObject (self, theObject, Diag13):
2971 if ( isinstance( theObject, Mesh )):
2972 theObject = theObject.GetMesh()
2973 return self.editor.SplitQuadObject(theObject, Diag13)
2975 ## Finds a better splitting of the given quadrangle.
2976 # @param IDOfQuad the ID of the quadrangle to be splitted.
2977 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2978 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2979 # diagonal is better, 0 if error occurs.
2980 # @ingroup l2_modif_cutquadr
2981 def BestSplit (self, IDOfQuad, theCriterion):
2982 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2984 ## Splits volumic elements into tetrahedrons
2985 # @param elemIDs either list of elements or mesh or group or submesh
2986 # @param method flags passing splitting method: Hex_5Tet, Hex_6Tet, Hex_24Tet
2987 # Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc
2988 # @ingroup l2_modif_cutquadr
2989 def SplitVolumesIntoTetra(self, elemIDs, method=Hex_5Tet ):
2990 if isinstance( elemIDs, Mesh ):
2991 elemIDs = elemIDs.GetMesh()
2992 if ( isinstance( elemIDs, list )):
2993 elemIDs = self.editor.MakeIDSource(elemIDs, SMESH.VOLUME)
2994 self.editor.SplitVolumesIntoTetra(elemIDs, method)
2996 ## Splits quadrangle faces near triangular facets of volumes
2998 # @ingroup l1_auxiliary
2999 def SplitQuadsNearTriangularFacets(self):
3000 faces_array = self.GetElementsByType(SMESH.FACE)
3001 for face_id in faces_array:
3002 if self.GetElemNbNodes(face_id) == 4: # quadrangle
3003 quad_nodes = self.mesh.GetElemNodes(face_id)
3004 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
3005 isVolumeFound = False
3006 for node1_elem in node1_elems:
3007 if not isVolumeFound:
3008 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
3009 nb_nodes = self.GetElemNbNodes(node1_elem)
3010 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
3011 volume_elem = node1_elem
3012 volume_nodes = self.mesh.GetElemNodes(volume_elem)
3013 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
3014 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
3015 isVolumeFound = True
3016 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
3017 self.SplitQuad([face_id], False) # diagonal 2-4
3018 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
3019 isVolumeFound = True
3020 self.SplitQuad([face_id], True) # diagonal 1-3
3021 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
3022 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
3023 isVolumeFound = True
3024 self.SplitQuad([face_id], True) # diagonal 1-3
3026 ## @brief Splits hexahedrons into tetrahedrons.
3028 # This operation uses pattern mapping functionality for splitting.
3029 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
3030 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
3031 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
3032 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
3033 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
3034 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
3035 # @return TRUE in case of success, FALSE otherwise.
3036 # @ingroup l1_auxiliary
3037 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
3038 # Pattern: 5.---------.6
3043 # (0,0,1) 4.---------.7 * |
3050 # (0,0,0) 0.---------.3
3051 pattern_tetra = "!!! Nb of points: \n 8 \n\
3061 !!! Indices of points of 6 tetras: \n\
3069 pattern = self.smeshpyD.GetPattern()
3070 isDone = pattern.LoadFromFile(pattern_tetra)
3072 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
3075 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
3076 isDone = pattern.MakeMesh(self.mesh, False, False)
3077 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
3079 # split quafrangle faces near triangular facets of volumes
3080 self.SplitQuadsNearTriangularFacets()
3084 ## @brief Split hexahedrons into prisms.
3086 # Uses the pattern mapping functionality for splitting.
3087 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
3088 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
3089 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
3090 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
3091 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
3092 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
3093 # @return TRUE in case of success, FALSE otherwise.
3094 # @ingroup l1_auxiliary
3095 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
3096 # Pattern: 5.---------.6
3101 # (0,0,1) 4.---------.7 |
3108 # (0,0,0) 0.---------.3
3109 pattern_prism = "!!! Nb of points: \n 8 \n\
3119 !!! Indices of points of 2 prisms: \n\
3123 pattern = self.smeshpyD.GetPattern()
3124 isDone = pattern.LoadFromFile(pattern_prism)
3126 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
3129 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
3130 isDone = pattern.MakeMesh(self.mesh, False, False)
3131 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
3133 # Splits quafrangle faces near triangular facets of volumes
3134 self.SplitQuadsNearTriangularFacets()
3138 ## Smoothes elements
3139 # @param IDsOfElements the list if ids of elements to smooth
3140 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3141 # Note that nodes built on edges and boundary nodes are always fixed.
3142 # @param MaxNbOfIterations the maximum number of iterations
3143 # @param MaxAspectRatio varies in range [1.0, inf]
3144 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3145 # @return TRUE in case of success, FALSE otherwise.
3146 # @ingroup l2_modif_smooth
3147 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
3148 MaxNbOfIterations, MaxAspectRatio, Method):
3149 if IDsOfElements == []:
3150 IDsOfElements = self.GetElementsId()
3151 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
3152 self.mesh.SetParameters(Parameters)
3153 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
3154 MaxNbOfIterations, MaxAspectRatio, Method)
3156 ## Smoothes elements which belong to the given object
3157 # @param theObject the object to smooth
3158 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3159 # Note that nodes built on edges and boundary nodes are always fixed.
3160 # @param MaxNbOfIterations the maximum number of iterations
3161 # @param MaxAspectRatio varies in range [1.0, inf]
3162 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3163 # @return TRUE in case of success, FALSE otherwise.
3164 # @ingroup l2_modif_smooth
3165 def SmoothObject(self, theObject, IDsOfFixedNodes,
3166 MaxNbOfIterations, MaxAspectRatio, Method):
3167 if ( isinstance( theObject, Mesh )):
3168 theObject = theObject.GetMesh()
3169 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
3170 MaxNbOfIterations, MaxAspectRatio, Method)
3172 ## Parametrically smoothes the given elements
3173 # @param IDsOfElements the list if ids of elements to smooth
3174 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3175 # Note that nodes built on edges and boundary nodes are always fixed.
3176 # @param MaxNbOfIterations the maximum number of iterations
3177 # @param MaxAspectRatio varies in range [1.0, inf]
3178 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3179 # @return TRUE in case of success, FALSE otherwise.
3180 # @ingroup l2_modif_smooth
3181 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
3182 MaxNbOfIterations, MaxAspectRatio, Method):
3183 if IDsOfElements == []:
3184 IDsOfElements = self.GetElementsId()
3185 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
3186 self.mesh.SetParameters(Parameters)
3187 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
3188 MaxNbOfIterations, MaxAspectRatio, Method)
3190 ## Parametrically smoothes the elements which belong to the given object
3191 # @param theObject the object to smooth
3192 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3193 # Note that nodes built on edges and boundary nodes are always fixed.
3194 # @param MaxNbOfIterations the maximum number of iterations
3195 # @param MaxAspectRatio varies in range [1.0, inf]
3196 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3197 # @return TRUE in case of success, FALSE otherwise.
3198 # @ingroup l2_modif_smooth
3199 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
3200 MaxNbOfIterations, MaxAspectRatio, Method):
3201 if ( isinstance( theObject, Mesh )):
3202 theObject = theObject.GetMesh()
3203 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
3204 MaxNbOfIterations, MaxAspectRatio, Method)
3206 ## Converts the mesh to quadratic, deletes old elements, replacing
3207 # them with quadratic with the same id.
3208 # @param theForce3d new node creation method:
3209 # 0 - the medium node lies at the geometrical entity from which the mesh element is built
3210 # 1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element
3211 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
3212 # @ingroup l2_modif_tofromqu
3213 def ConvertToQuadratic(self, theForce3d, theSubMesh=None):
3215 self.editor.ConvertToQuadraticObject(theForce3d,theSubMesh)
3217 self.editor.ConvertToQuadratic(theForce3d)
3219 ## Converts the mesh from quadratic to ordinary,
3220 # deletes old quadratic elements, \n replacing
3221 # them with ordinary mesh elements with the same id.
3222 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
3223 # @ingroup l2_modif_tofromqu
3224 def ConvertFromQuadratic(self, theSubMesh=None):
3226 self.editor.ConvertFromQuadraticObject(theSubMesh)
3228 return self.editor.ConvertFromQuadratic()
3230 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
3231 # @return TRUE if operation has been completed successfully, FALSE otherwise
3232 # @ingroup l2_modif_edit
3233 def Make2DMeshFrom3D(self):
3234 return self.editor. Make2DMeshFrom3D()
3236 ## Creates missing boundary elements
3237 # @param elements - elements whose boundary is to be checked:
3238 # mesh, group, sub-mesh or list of elements
3239 # if elements is mesh, it must be the mesh whose MakeBoundaryMesh() is called
3240 # @param dimension - defines type of boundary elements to create:
3241 # SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D
3242 # SMESH.BND_1DFROM3D creates mesh edges on all borders of free facets of 3D cells
3243 # @param groupName - a name of group to store created boundary elements in,
3244 # "" means not to create the group
3245 # @param meshName - a name of new mesh to store created boundary elements in,
3246 # "" means not to create the new mesh
3247 # @param toCopyElements - if true, the checked elements will be copied into
3248 # the new mesh else only boundary elements will be copied into the new mesh
3249 # @param toCopyExistingBondary - if true, not only new but also pre-existing
3250 # boundary elements will be copied into the new mesh
3251 # @return tuple (mesh, group) where bondary elements were added to
3252 # @ingroup l2_modif_edit
3253 def MakeBoundaryMesh(self, elements, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3254 toCopyElements=False, toCopyExistingBondary=False):
3255 if isinstance( elements, Mesh ):
3256 elements = elements.GetMesh()
3257 if ( isinstance( elements, list )):
3258 elemType = SMESH.ALL
3259 if elements: elemType = self.GetElementType( elements[0], iselem=True)
3260 elements = self.editor.MakeIDSource(elements, elemType)
3261 mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName,
3262 toCopyElements,toCopyExistingBondary)
3263 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3267 # @brief Creates missing boundary elements around either the whole mesh or
3268 # groups of 2D elements
3269 # @param dimension - defines type of boundary elements to create
3270 # @param groupName - a name of group to store all boundary elements in,
3271 # "" means not to create the group
3272 # @param meshName - a name of a new mesh, which is a copy of the initial
3273 # mesh + created boundary elements; "" means not to create the new mesh
3274 # @param toCopyAll - if true, the whole initial mesh will be copied into
3275 # the new mesh else only boundary elements will be copied into the new mesh
3276 # @param groups - groups of 2D elements to make boundary around
3277 # @retval tuple( long, mesh, groups )
3278 # long - number of added boundary elements
3279 # mesh - the mesh where elements were added to
3280 # group - the group of boundary elements or None
3282 def MakeBoundaryElements(self, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3283 toCopyAll=False, groups=[]):
3284 nb, mesh, group = self.editor.MakeBoundaryElements(dimension,groupName,meshName,
3286 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3287 return nb, mesh, group
3289 ## Renumber mesh nodes
3290 # @ingroup l2_modif_renumber
3291 def RenumberNodes(self):
3292 self.editor.RenumberNodes()
3294 ## Renumber mesh elements
3295 # @ingroup l2_modif_renumber
3296 def RenumberElements(self):
3297 self.editor.RenumberElements()
3299 ## Generates new elements by rotation of the elements around the axis
3300 # @param IDsOfElements the list of ids of elements to sweep
3301 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3302 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
3303 # @param NbOfSteps the number of steps
3304 # @param Tolerance tolerance
3305 # @param MakeGroups forces the generation of new groups from existing ones
3306 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3307 # of all steps, else - size of each step
3308 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3309 # @ingroup l2_modif_extrurev
3310 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
3311 MakeGroups=False, TotalAngle=False):
3313 if isinstance(AngleInRadians,str):
3315 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3317 AngleInRadians = DegreesToRadians(AngleInRadians)
3318 if IDsOfElements == []:
3319 IDsOfElements = self.GetElementsId()
3320 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3321 Axis = self.smeshpyD.GetAxisStruct(Axis)
3322 Axis,AxisParameters = ParseAxisStruct(Axis)
3323 if TotalAngle and NbOfSteps:
3324 AngleInRadians /= NbOfSteps
3325 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3326 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3327 self.mesh.SetParameters(Parameters)
3329 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
3330 AngleInRadians, NbOfSteps, Tolerance)
3331 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
3334 ## Generates new elements by rotation of the elements of object around the axis
3335 # @param theObject object which elements should be sweeped.
3336 # It can be a mesh, a sub mesh or a group.
3337 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3338 # @param AngleInRadians the angle of Rotation
3339 # @param NbOfSteps 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 RotationSweepObject(self, theObject, 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 ( isinstance( theObject, Mesh )):
3355 theObject = theObject.GetMesh()
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.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
3366 NbOfSteps, Tolerance)
3367 self.editor.RotationSweepObject(theObject, 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 RotationSweepObject1D(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.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
3402 NbOfSteps, Tolerance)
3403 self.editor.RotationSweepObject1D(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 RotationSweepObject2D(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.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
3438 NbOfSteps, Tolerance)
3439 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3442 ## Generates new elements by extrusion of the elements with given ids
3443 # @param IDsOfElements the list of elements ids for extrusion
3444 # @param StepVector vector or DirStruct, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3445 # @param NbOfSteps the number of steps
3446 # @param MakeGroups forces the generation of new groups from existing ones
3447 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3448 # @ingroup l2_modif_extrurev
3449 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
3450 if IDsOfElements == []:
3451 IDsOfElements = self.GetElementsId()
3452 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3453 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3454 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3455 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3456 Parameters = StepVectorParameters + var_separator + Parameters
3457 self.mesh.SetParameters(Parameters)
3459 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
3460 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
3463 ## Generates new elements by extrusion of the elements with given ids
3464 # @param IDsOfElements is ids of elements
3465 # @param StepVector vector, defining the direction and value of extrusion
3466 # @param NbOfSteps the number of steps
3467 # @param ExtrFlags sets flags for extrusion
3468 # @param SewTolerance uses for comparing locations of nodes if flag
3469 # EXTRUSION_FLAG_SEW is set
3470 # @param MakeGroups forces the generation of new groups from existing ones
3471 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3472 # @ingroup l2_modif_extrurev
3473 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
3474 ExtrFlags, SewTolerance, MakeGroups=False):
3475 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3476 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3478 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
3479 ExtrFlags, SewTolerance)
3480 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
3481 ExtrFlags, SewTolerance)
3484 ## Generates new elements by extrusion of the elements which belong to the object
3485 # @param theObject the object which elements should be processed.
3486 # It can be a mesh, a sub mesh or a group.
3487 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3488 # @param NbOfSteps the number of steps
3489 # @param MakeGroups forces the generation of new groups from existing ones
3490 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3491 # @ingroup l2_modif_extrurev
3492 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3493 if ( isinstance( theObject, Mesh )):
3494 theObject = theObject.GetMesh()
3495 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3496 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3497 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3498 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3499 Parameters = StepVectorParameters + var_separator + Parameters
3500 self.mesh.SetParameters(Parameters)
3502 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3503 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
3506 ## Generates new elements by extrusion of the elements which belong to the object
3507 # @param theObject object which elements should be processed.
3508 # It can be a mesh, a sub mesh or a group.
3509 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3510 # @param NbOfSteps the number of steps
3511 # @param MakeGroups to generate new groups from existing ones
3512 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3513 # @ingroup l2_modif_extrurev
3514 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3515 if ( isinstance( theObject, Mesh )):
3516 theObject = theObject.GetMesh()
3517 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3518 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3519 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3520 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3521 Parameters = StepVectorParameters + var_separator + Parameters
3522 self.mesh.SetParameters(Parameters)
3524 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3525 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3528 ## Generates new elements by extrusion of the elements which belong to the object
3529 # @param theObject object which elements should be processed.
3530 # It can be a mesh, a sub mesh or a group.
3531 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3532 # @param NbOfSteps the number of steps
3533 # @param MakeGroups forces the generation of new groups from existing ones
3534 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3535 # @ingroup l2_modif_extrurev
3536 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3537 if ( isinstance( theObject, Mesh )):
3538 theObject = theObject.GetMesh()
3539 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3540 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3541 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3542 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3543 Parameters = StepVectorParameters + var_separator + Parameters
3544 self.mesh.SetParameters(Parameters)
3546 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3547 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3552 ## Generates new elements by extrusion of the given elements
3553 # The path of extrusion must be a meshed edge.
3554 # @param Base mesh or group, or submesh, or list of ids of elements for extrusion
3555 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3556 # @param NodeStart the start node from Path. Defines the direction of extrusion
3557 # @param HasAngles allows the shape to be rotated around the path
3558 # to get the resulting mesh in a helical fashion
3559 # @param Angles list of angles in radians
3560 # @param LinearVariation forces the computation of rotation angles as linear
3561 # variation of the given Angles along path steps
3562 # @param HasRefPoint allows using the reference point
3563 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3564 # The User can specify any point as the Reference Point.
3565 # @param MakeGroups forces the generation of new groups from existing ones
3566 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3567 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3568 # only SMESH::Extrusion_Error otherwise
3569 # @ingroup l2_modif_extrurev
3570 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3571 HasAngles, Angles, LinearVariation,
3572 HasRefPoint, RefPoint, MakeGroups, ElemType):
3573 Angles,AnglesParameters = ParseAngles(Angles)
3574 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3575 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3576 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3578 Parameters = AnglesParameters + var_separator + RefPointParameters
3579 self.mesh.SetParameters(Parameters)
3581 if (isinstance(Path, Mesh)): Path = Path.GetMesh()
3583 if isinstance(Base, list):
3585 if Base == []: IDsOfElements = self.GetElementsId()
3586 else: IDsOfElements = Base
3587 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3588 HasAngles, Angles, LinearVariation,
3589 HasRefPoint, RefPoint, MakeGroups, ElemType)
3591 if isinstance(Base, Mesh): Base = Base.GetMesh()
3592 if isinstance(Base, SMESH._objref_SMESH_Mesh) or isinstance(Base, SMESH._objref_SMESH_Group) or isinstance(Base, SMESH._objref_SMESH_subMesh):
3593 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3594 HasAngles, Angles, LinearVariation,
3595 HasRefPoint, RefPoint, MakeGroups, ElemType)
3597 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3600 ## Generates new elements by extrusion of the given elements
3601 # The path of extrusion must be a meshed edge.
3602 # @param IDsOfElements ids of elements
3603 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3604 # @param PathShape shape(edge) defines the sub-mesh for the path
3605 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3606 # @param HasAngles allows the shape to be rotated around the path
3607 # to get the resulting mesh in a helical fashion
3608 # @param Angles list of angles in radians
3609 # @param HasRefPoint allows using the reference point
3610 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3611 # The User can specify any point as the Reference Point.
3612 # @param MakeGroups forces the generation of new groups from existing ones
3613 # @param LinearVariation forces the computation of rotation angles as linear
3614 # variation of the given Angles along path steps
3615 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3616 # only SMESH::Extrusion_Error otherwise
3617 # @ingroup l2_modif_extrurev
3618 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3619 HasAngles, Angles, HasRefPoint, RefPoint,
3620 MakeGroups=False, LinearVariation=False):
3621 Angles,AnglesParameters = ParseAngles(Angles)
3622 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3623 if IDsOfElements == []:
3624 IDsOfElements = self.GetElementsId()
3625 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3626 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3628 if ( isinstance( PathMesh, Mesh )):
3629 PathMesh = PathMesh.GetMesh()
3630 if HasAngles and Angles and LinearVariation:
3631 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3633 Parameters = AnglesParameters + var_separator + RefPointParameters
3634 self.mesh.SetParameters(Parameters)
3636 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3637 PathShape, NodeStart, HasAngles,
3638 Angles, HasRefPoint, RefPoint)
3639 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3640 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3642 ## Generates new elements by extrusion of the elements which belong to the object
3643 # The path of extrusion must be a meshed edge.
3644 # @param theObject the object which elements should be processed.
3645 # It can be a mesh, a sub mesh or a group.
3646 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3647 # @param PathShape shape(edge) defines the sub-mesh for the path
3648 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3649 # @param HasAngles allows the shape to be rotated around the path
3650 # to get the resulting mesh in a helical fashion
3651 # @param Angles list of angles
3652 # @param HasRefPoint allows using the reference point
3653 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3654 # The User can specify any point as the Reference Point.
3655 # @param MakeGroups forces the generation of new groups from existing ones
3656 # @param LinearVariation forces the computation of rotation angles as linear
3657 # variation of the given Angles along path steps
3658 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3659 # only SMESH::Extrusion_Error otherwise
3660 # @ingroup l2_modif_extrurev
3661 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3662 HasAngles, Angles, HasRefPoint, RefPoint,
3663 MakeGroups=False, LinearVariation=False):
3664 Angles,AnglesParameters = ParseAngles(Angles)
3665 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3666 if ( isinstance( theObject, Mesh )):
3667 theObject = theObject.GetMesh()
3668 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3669 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3670 if ( isinstance( PathMesh, Mesh )):
3671 PathMesh = PathMesh.GetMesh()
3672 if HasAngles and Angles and LinearVariation:
3673 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3675 Parameters = AnglesParameters + var_separator + RefPointParameters
3676 self.mesh.SetParameters(Parameters)
3678 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3679 PathShape, NodeStart, HasAngles,
3680 Angles, HasRefPoint, RefPoint)
3681 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3682 NodeStart, HasAngles, Angles, HasRefPoint,
3685 ## Generates new elements by extrusion of the elements which belong to the object
3686 # The path of extrusion must be a meshed edge.
3687 # @param theObject the object which elements should be processed.
3688 # It can be a mesh, a sub mesh or a group.
3689 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3690 # @param PathShape shape(edge) defines the sub-mesh for the path
3691 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3692 # @param HasAngles allows the shape to be rotated around the path
3693 # to get the resulting mesh in a helical fashion
3694 # @param Angles list of angles
3695 # @param HasRefPoint allows using the reference point
3696 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3697 # The User can specify any point as the Reference Point.
3698 # @param MakeGroups forces the generation of new groups from existing ones
3699 # @param LinearVariation forces the computation of rotation angles as linear
3700 # variation of the given Angles along path steps
3701 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3702 # only SMESH::Extrusion_Error otherwise
3703 # @ingroup l2_modif_extrurev
3704 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3705 HasAngles, Angles, HasRefPoint, RefPoint,
3706 MakeGroups=False, LinearVariation=False):
3707 Angles,AnglesParameters = ParseAngles(Angles)
3708 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3709 if ( isinstance( theObject, Mesh )):
3710 theObject = theObject.GetMesh()
3711 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3712 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3713 if ( isinstance( PathMesh, Mesh )):
3714 PathMesh = PathMesh.GetMesh()
3715 if HasAngles and Angles and LinearVariation:
3716 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3718 Parameters = AnglesParameters + var_separator + RefPointParameters
3719 self.mesh.SetParameters(Parameters)
3721 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3722 PathShape, NodeStart, HasAngles,
3723 Angles, HasRefPoint, RefPoint)
3724 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3725 NodeStart, HasAngles, Angles, HasRefPoint,
3728 ## Generates new elements by extrusion of the elements which belong to the object
3729 # The path of extrusion must be a meshed edge.
3730 # @param theObject the object which elements should be processed.
3731 # It can be a mesh, a sub mesh or a group.
3732 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3733 # @param PathShape shape(edge) defines the sub-mesh for the path
3734 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3735 # @param HasAngles allows the shape to be rotated around the path
3736 # to get the resulting mesh in a helical fashion
3737 # @param Angles list of angles
3738 # @param HasRefPoint allows using the reference point
3739 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3740 # The User can specify any point as the Reference Point.
3741 # @param MakeGroups forces the generation of new groups from existing ones
3742 # @param LinearVariation forces the computation of rotation angles as linear
3743 # variation of the given Angles along path steps
3744 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3745 # only SMESH::Extrusion_Error otherwise
3746 # @ingroup l2_modif_extrurev
3747 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3748 HasAngles, Angles, HasRefPoint, RefPoint,
3749 MakeGroups=False, LinearVariation=False):
3750 Angles,AnglesParameters = ParseAngles(Angles)
3751 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3752 if ( isinstance( theObject, Mesh )):
3753 theObject = theObject.GetMesh()
3754 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3755 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3756 if ( isinstance( PathMesh, Mesh )):
3757 PathMesh = PathMesh.GetMesh()
3758 if HasAngles and Angles and LinearVariation:
3759 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3761 Parameters = AnglesParameters + var_separator + RefPointParameters
3762 self.mesh.SetParameters(Parameters)
3764 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3765 PathShape, NodeStart, HasAngles,
3766 Angles, HasRefPoint, RefPoint)
3767 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3768 NodeStart, HasAngles, Angles, HasRefPoint,
3771 ## Creates a symmetrical copy of mesh elements
3772 # @param IDsOfElements list of elements ids
3773 # @param Mirror is AxisStruct or geom object(point, line, plane)
3774 # @param theMirrorType is POINT, AXIS or PLANE
3775 # If the Mirror is a geom object this parameter is unnecessary
3776 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3777 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3778 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3779 # @ingroup l2_modif_trsf
3780 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3781 if IDsOfElements == []:
3782 IDsOfElements = self.GetElementsId()
3783 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3784 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3785 Mirror,Parameters = ParseAxisStruct(Mirror)
3786 self.mesh.SetParameters(Parameters)
3787 if Copy and MakeGroups:
3788 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3789 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3792 ## Creates a new mesh by a symmetrical copy of mesh elements
3793 # @param IDsOfElements the list of elements ids
3794 # @param Mirror is AxisStruct or geom object (point, line, plane)
3795 # @param theMirrorType is POINT, AXIS or PLANE
3796 # If the Mirror is a geom object this parameter is unnecessary
3797 # @param MakeGroups to generate new groups from existing ones
3798 # @param NewMeshName a name of the new mesh to create
3799 # @return instance of Mesh class
3800 # @ingroup l2_modif_trsf
3801 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3802 if IDsOfElements == []:
3803 IDsOfElements = self.GetElementsId()
3804 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3805 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3806 Mirror,Parameters = ParseAxisStruct(Mirror)
3807 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3808 MakeGroups, NewMeshName)
3809 mesh.SetParameters(Parameters)
3810 return Mesh(self.smeshpyD,self.geompyD,mesh)
3812 ## Creates a symmetrical copy of the object
3813 # @param theObject mesh, submesh or group
3814 # @param Mirror AxisStruct or geom object (point, line, plane)
3815 # @param theMirrorType is POINT, AXIS or PLANE
3816 # If the Mirror is a geom object this parameter is unnecessary
3817 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3818 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3819 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3820 # @ingroup l2_modif_trsf
3821 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3822 if ( isinstance( theObject, Mesh )):
3823 theObject = theObject.GetMesh()
3824 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3825 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3826 Mirror,Parameters = ParseAxisStruct(Mirror)
3827 self.mesh.SetParameters(Parameters)
3828 if Copy and MakeGroups:
3829 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3830 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3833 ## Creates a new mesh by a symmetrical copy of the object
3834 # @param theObject mesh, submesh or group
3835 # @param Mirror AxisStruct or geom object (point, line, plane)
3836 # @param theMirrorType POINT, AXIS or PLANE
3837 # If the Mirror is a geom object this parameter is unnecessary
3838 # @param MakeGroups forces the generation of new groups from existing ones
3839 # @param NewMeshName the name of the new mesh to create
3840 # @return instance of Mesh class
3841 # @ingroup l2_modif_trsf
3842 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3843 if ( isinstance( theObject, Mesh )):
3844 theObject = theObject.GetMesh()
3845 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3846 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3847 Mirror,Parameters = ParseAxisStruct(Mirror)
3848 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3849 MakeGroups, NewMeshName)
3850 mesh.SetParameters(Parameters)
3851 return Mesh( self.smeshpyD,self.geompyD,mesh )
3853 ## Translates the elements
3854 # @param IDsOfElements list of elements ids
3855 # @param Vector the direction of translation (DirStruct or vector)
3856 # @param Copy allows copying the translated elements
3857 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3858 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3859 # @ingroup l2_modif_trsf
3860 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3861 if IDsOfElements == []:
3862 IDsOfElements = self.GetElementsId()
3863 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3864 Vector = self.smeshpyD.GetDirStruct(Vector)
3865 Vector,Parameters = ParseDirStruct(Vector)
3866 self.mesh.SetParameters(Parameters)
3867 if Copy and MakeGroups:
3868 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3869 self.editor.Translate(IDsOfElements, Vector, Copy)
3872 ## Creates a new mesh of translated elements
3873 # @param IDsOfElements list of elements ids
3874 # @param Vector the direction of translation (DirStruct or vector)
3875 # @param MakeGroups forces the generation of new groups from existing ones
3876 # @param NewMeshName the name of the newly created mesh
3877 # @return instance of Mesh class
3878 # @ingroup l2_modif_trsf
3879 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3880 if IDsOfElements == []:
3881 IDsOfElements = self.GetElementsId()
3882 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3883 Vector = self.smeshpyD.GetDirStruct(Vector)
3884 Vector,Parameters = ParseDirStruct(Vector)
3885 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3886 mesh.SetParameters(Parameters)
3887 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3889 ## Translates the object
3890 # @param theObject the object to translate (mesh, submesh, or group)
3891 # @param Vector direction of translation (DirStruct or geom 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 TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3897 if ( isinstance( theObject, Mesh )):
3898 theObject = theObject.GetMesh()
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.TranslateObjectMakeGroups(theObject, Vector)
3905 self.editor.TranslateObject(theObject, Vector, Copy)
3908 ## Creates a new mesh from the translated object
3909 # @param theObject the object to translate (mesh, submesh, or group)
3910 # @param Vector the direction of translation (DirStruct or geom 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 TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3916 if (isinstance(theObject, Mesh)):
3917 theObject = theObject.GetMesh()
3918 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3919 Vector = self.smeshpyD.GetDirStruct(Vector)
3920 Vector,Parameters = ParseDirStruct(Vector)
3921 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3922 mesh.SetParameters(Parameters)
3923 return Mesh( self.smeshpyD, self.geompyD, mesh )
3927 ## Scales the object
3928 # @param theObject - the object to translate (mesh, submesh, or group)
3929 # @param thePoint - base point for scale
3930 # @param theScaleFact - list of 1-3 scale factors for axises
3931 # @param Copy - allows copying the translated elements
3932 # @param MakeGroups - forces the generation of new groups from existing
3934 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3935 # empty list otherwise
3936 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3937 if ( isinstance( theObject, Mesh )):
3938 theObject = theObject.GetMesh()
3939 if ( isinstance( theObject, list )):
3940 theObject = self.GetIDSource(theObject, SMESH.ALL)
3942 thePoint, Parameters = ParsePointStruct(thePoint)
3943 self.mesh.SetParameters(Parameters)
3945 if Copy and MakeGroups:
3946 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3947 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3950 ## Creates a new mesh from the translated object
3951 # @param theObject - the object to translate (mesh, submesh, or group)
3952 # @param thePoint - base point for scale
3953 # @param theScaleFact - list of 1-3 scale factors for axises
3954 # @param MakeGroups - forces the generation of new groups from existing ones
3955 # @param NewMeshName - the name of the newly created mesh
3956 # @return instance of Mesh class
3957 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3958 if (isinstance(theObject, Mesh)):
3959 theObject = theObject.GetMesh()
3960 if ( isinstance( theObject, list )):
3961 theObject = self.GetIDSource(theObject,SMESH.ALL)
3963 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3964 MakeGroups, NewMeshName)
3965 #mesh.SetParameters(Parameters)
3966 return Mesh( self.smeshpyD, self.geompyD, mesh )
3970 ## Rotates the elements
3971 # @param IDsOfElements list of elements ids
3972 # @param Axis the axis of rotation (AxisStruct or geom line)
3973 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3974 # @param Copy allows copying the rotated elements
3975 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3976 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3977 # @ingroup l2_modif_trsf
3978 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3980 if isinstance(AngleInRadians,str):
3982 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3984 AngleInRadians = DegreesToRadians(AngleInRadians)
3985 if IDsOfElements == []:
3986 IDsOfElements = self.GetElementsId()
3987 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3988 Axis = self.smeshpyD.GetAxisStruct(Axis)
3989 Axis,AxisParameters = ParseAxisStruct(Axis)
3990 Parameters = AxisParameters + var_separator + Parameters
3991 self.mesh.SetParameters(Parameters)
3992 if Copy and MakeGroups:
3993 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3994 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3997 ## Creates a new mesh of rotated elements
3998 # @param IDsOfElements list of element ids
3999 # @param Axis the axis of rotation (AxisStruct or geom line)
4000 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
4001 # @param MakeGroups forces the generation of new groups from existing ones
4002 # @param NewMeshName the name of the newly created mesh
4003 # @return instance of Mesh class
4004 # @ingroup l2_modif_trsf
4005 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
4007 if isinstance(AngleInRadians,str):
4009 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
4011 AngleInRadians = DegreesToRadians(AngleInRadians)
4012 if IDsOfElements == []:
4013 IDsOfElements = self.GetElementsId()
4014 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
4015 Axis = self.smeshpyD.GetAxisStruct(Axis)
4016 Axis,AxisParameters = ParseAxisStruct(Axis)
4017 Parameters = AxisParameters + var_separator + Parameters
4018 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
4019 MakeGroups, NewMeshName)
4020 mesh.SetParameters(Parameters)
4021 return Mesh( self.smeshpyD, self.geompyD, mesh )
4023 ## Rotates the object
4024 # @param theObject the object to rotate( mesh, submesh, or group)
4025 # @param Axis the axis of rotation (AxisStruct or geom line)
4026 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
4027 # @param Copy allows copying the rotated elements
4028 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
4029 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
4030 # @ingroup l2_modif_trsf
4031 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
4033 if isinstance(AngleInRadians,str):
4035 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
4037 AngleInRadians = DegreesToRadians(AngleInRadians)
4038 if (isinstance(theObject, Mesh)):
4039 theObject = theObject.GetMesh()
4040 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
4041 Axis = self.smeshpyD.GetAxisStruct(Axis)
4042 Axis,AxisParameters = ParseAxisStruct(Axis)
4043 Parameters = AxisParameters + ":" + Parameters
4044 self.mesh.SetParameters(Parameters)
4045 if Copy and MakeGroups:
4046 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
4047 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
4050 ## Creates a new mesh from the rotated object
4051 # @param theObject the object to rotate (mesh, submesh, or group)
4052 # @param Axis the axis of rotation (AxisStruct or geom line)
4053 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
4054 # @param MakeGroups forces the generation of new groups from existing ones
4055 # @param NewMeshName the name of the newly created mesh
4056 # @return instance of Mesh class
4057 # @ingroup l2_modif_trsf
4058 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
4060 if isinstance(AngleInRadians,str):
4062 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
4064 AngleInRadians = DegreesToRadians(AngleInRadians)
4065 if (isinstance( theObject, Mesh )):
4066 theObject = theObject.GetMesh()
4067 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
4068 Axis = self.smeshpyD.GetAxisStruct(Axis)
4069 Axis,AxisParameters = ParseAxisStruct(Axis)
4070 Parameters = AxisParameters + ":" + Parameters
4071 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
4072 MakeGroups, NewMeshName)
4073 mesh.SetParameters(Parameters)
4074 return Mesh( self.smeshpyD, self.geompyD, mesh )
4076 ## Finds groups of ajacent nodes within Tolerance.
4077 # @param Tolerance the value of tolerance
4078 # @return the list of groups of nodes
4079 # @ingroup l2_modif_trsf
4080 def FindCoincidentNodes (self, Tolerance):
4081 return self.editor.FindCoincidentNodes(Tolerance)
4083 ## Finds groups of ajacent nodes within Tolerance.
4084 # @param Tolerance the value of tolerance
4085 # @param SubMeshOrGroup SubMesh or Group
4086 # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
4087 # @return the list of groups of nodes
4088 # @ingroup l2_modif_trsf
4089 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
4090 if (isinstance( SubMeshOrGroup, Mesh )):
4091 SubMeshOrGroup = SubMeshOrGroup.GetMesh()
4092 if not isinstance( exceptNodes, list):
4093 exceptNodes = [ exceptNodes ]
4094 if exceptNodes and isinstance( exceptNodes[0], int):
4095 exceptNodes = [ self.GetIDSource( exceptNodes, SMESH.NODE)]
4096 return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes)
4099 # @param GroupsOfNodes the list of groups of nodes
4100 # @ingroup l2_modif_trsf
4101 def MergeNodes (self, GroupsOfNodes):
4102 self.editor.MergeNodes(GroupsOfNodes)
4104 ## Finds the elements built on the same nodes.
4105 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
4106 # @return a list of groups of equal elements
4107 # @ingroup l2_modif_trsf
4108 def FindEqualElements (self, MeshOrSubMeshOrGroup):
4109 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
4110 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
4111 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
4113 ## Merges elements in each given group.
4114 # @param GroupsOfElementsID groups of elements for merging
4115 # @ingroup l2_modif_trsf
4116 def MergeElements(self, GroupsOfElementsID):
4117 self.editor.MergeElements(GroupsOfElementsID)
4119 ## Leaves one element and removes all other elements built on the same nodes.
4120 # @ingroup l2_modif_trsf
4121 def MergeEqualElements(self):
4122 self.editor.MergeEqualElements()
4124 ## Sews free borders
4125 # @return SMESH::Sew_Error
4126 # @ingroup l2_modif_trsf
4127 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
4128 FirstNodeID2, SecondNodeID2, LastNodeID2,
4129 CreatePolygons, CreatePolyedrs):
4130 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
4131 FirstNodeID2, SecondNodeID2, LastNodeID2,
4132 CreatePolygons, CreatePolyedrs)
4134 ## Sews conform free borders
4135 # @return SMESH::Sew_Error
4136 # @ingroup l2_modif_trsf
4137 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
4138 FirstNodeID2, SecondNodeID2):
4139 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
4140 FirstNodeID2, SecondNodeID2)
4142 ## Sews border to side
4143 # @return SMESH::Sew_Error
4144 # @ingroup l2_modif_trsf
4145 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
4146 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
4147 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
4148 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
4150 ## Sews two sides of a mesh. The nodes belonging to Side1 are
4151 # merged with the nodes of elements of Side2.
4152 # The number of elements in theSide1 and in theSide2 must be
4153 # equal and they should have similar nodal connectivity.
4154 # The nodes to merge should belong to side borders and
4155 # the first node should be linked to the second.
4156 # @return SMESH::Sew_Error
4157 # @ingroup l2_modif_trsf
4158 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
4159 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
4160 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
4161 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
4162 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
4163 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
4165 ## Sets new nodes for the given element.
4166 # @param ide the element id
4167 # @param newIDs nodes ids
4168 # @return If the number of nodes does not correspond to the type of element - returns false
4169 # @ingroup l2_modif_edit
4170 def ChangeElemNodes(self, ide, newIDs):
4171 return self.editor.ChangeElemNodes(ide, newIDs)
4173 ## If during the last operation of MeshEditor some nodes were
4174 # created, this method returns the list of their IDs, \n
4175 # if new nodes were not created - returns empty list
4176 # @return the list of integer values (can be empty)
4177 # @ingroup l1_auxiliary
4178 def GetLastCreatedNodes(self):
4179 return self.editor.GetLastCreatedNodes()
4181 ## If during the last operation of MeshEditor some elements were
4182 # created this method returns the list of their IDs, \n
4183 # if new elements were not created - returns empty list
4184 # @return the list of integer values (can be empty)
4185 # @ingroup l1_auxiliary
4186 def GetLastCreatedElems(self):
4187 return self.editor.GetLastCreatedElems()
4189 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4190 # @param theNodes identifiers of nodes to be doubled
4191 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
4192 # nodes. If list of element identifiers is empty then nodes are doubled but
4193 # they not assigned to elements
4194 # @return TRUE if operation has been completed successfully, FALSE otherwise
4195 # @ingroup l2_modif_edit
4196 def DoubleNodes(self, theNodes, theModifiedElems):
4197 return self.editor.DoubleNodes(theNodes, theModifiedElems)
4199 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4200 # This method provided for convenience works as DoubleNodes() described above.
4201 # @param theNodeId identifiers of node to be doubled
4202 # @param theModifiedElems identifiers of elements to be updated
4203 # @return TRUE if operation has been completed successfully, FALSE otherwise
4204 # @ingroup l2_modif_edit
4205 def DoubleNode(self, theNodeId, theModifiedElems):
4206 return self.editor.DoubleNode(theNodeId, theModifiedElems)
4208 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4209 # This method provided for convenience works as DoubleNodes() described above.
4210 # @param theNodes group of nodes to be doubled
4211 # @param theModifiedElems group of elements to be updated.
4212 # @param theMakeGroup forces the generation of a group containing new nodes.
4213 # @return TRUE or a created group if operation has been completed successfully,
4214 # FALSE or None otherwise
4215 # @ingroup l2_modif_edit
4216 def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
4218 return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
4219 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
4221 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4222 # This method provided for convenience works as DoubleNodes() described above.
4223 # @param theNodes list of groups of nodes to be doubled
4224 # @param theModifiedElems list of groups of elements to be updated.
4225 # @param theMakeGroup forces the generation of a group containing new nodes.
4226 # @return TRUE if operation has been completed successfully, FALSE otherwise
4227 # @ingroup l2_modif_edit
4228 def DoubleNodeGroups(self, theNodes, theModifiedElems, theMakeGroup=False):
4230 return self.editor.DoubleNodeGroupsNew(theNodes, theModifiedElems)
4231 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
4233 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4234 # @param theElems - the list of elements (edges or faces) to be replicated
4235 # The nodes for duplication could be found from these elements
4236 # @param theNodesNot - list of nodes to NOT replicate
4237 # @param theAffectedElems - the list of elements (cells and edges) to which the
4238 # replicated nodes should be associated to.
4239 # @return TRUE if operation has been completed successfully, FALSE otherwise
4240 # @ingroup l2_modif_edit
4241 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
4242 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
4244 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4245 # @param theElems - the list of elements (edges or faces) to be replicated
4246 # The nodes for duplication could be found from these elements
4247 # @param theNodesNot - list of nodes to NOT replicate
4248 # @param theShape - shape to detect affected elements (element which geometric center
4249 # located on or inside shape).
4250 # The replicated nodes should be associated to affected elements.
4251 # @return TRUE if operation has been completed successfully, FALSE otherwise
4252 # @ingroup l2_modif_edit
4253 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
4254 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
4256 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4257 # This method provided for convenience works as DoubleNodes() described above.
4258 # @param theElems - group of of elements (edges or faces) to be replicated
4259 # @param theNodesNot - group of nodes not to replicated
4260 # @param theAffectedElems - group of elements to which the replicated nodes
4261 # should be associated to.
4262 # @param theMakeGroup forces the generation of a group containing new elements.
4263 # @return TRUE or a created group if operation has been completed successfully,
4264 # FALSE or None otherwise
4265 # @ingroup l2_modif_edit
4266 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4268 return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
4269 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
4271 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4272 # This method provided for convenience works as DoubleNodes() described above.
4273 # @param theElems - group of of elements (edges or faces) to be replicated
4274 # @param theNodesNot - group of nodes not to replicated
4275 # @param theShape - shape to detect affected elements (element which geometric center
4276 # located on or inside shape).
4277 # The replicated nodes should be associated to affected elements.
4278 # @ingroup l2_modif_edit
4279 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
4280 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
4282 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4283 # This method provided for convenience works as DoubleNodes() described above.
4284 # @param theElems - list of groups of elements (edges or faces) to be replicated
4285 # @param theNodesNot - list of groups of nodes not to replicated
4286 # @param theAffectedElems - group of elements to which the replicated nodes
4287 # should be associated to.
4288 # @param theMakeGroup forces the generation of a group containing new elements.
4289 # @return TRUE or a created group if operation has been completed successfully,
4290 # FALSE or None otherwise
4291 # @ingroup l2_modif_edit
4292 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4294 return self.editor.DoubleNodeElemGroupsNew(theElems, theNodesNot, theAffectedElems)
4295 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
4297 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4298 # This method provided for convenience works as DoubleNodes() described above.
4299 # @param theElems - list of groups of elements (edges or faces) to be replicated
4300 # @param theNodesNot - list of groups of nodes not to replicated
4301 # @param theShape - shape to detect affected elements (element which geometric center
4302 # located on or inside shape).
4303 # The replicated nodes should be associated to affected elements.
4304 # @return TRUE if operation has been completed successfully, FALSE otherwise
4305 # @ingroup l2_modif_edit
4306 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
4307 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
4309 ## Double nodes on shared faces between groups of volumes and create flat elements on demand.
4310 # The list of groups must describe a partition of the mesh volumes.
4311 # The nodes of the internal faces at the boundaries of the groups are doubled.
4312 # In option, the internal faces are replaced by flat elements.
4313 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4314 # @param theDomains - list of groups of volumes
4315 # @param createJointElems - if TRUE, create the elements
4316 # @return TRUE if operation has been completed successfully, FALSE otherwise
4317 def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems ):
4318 return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems )
4320 ## Double nodes on some external faces and create flat elements.
4321 # Flat elements are mainly used by some types of mechanic calculations.
4323 # Each group of the list must be constituted of faces.
4324 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4325 # @param theGroupsOfFaces - list of groups of faces
4326 # @return TRUE if operation has been completed successfully, FALSE otherwise
4327 def CreateFlatElementsOnFacesGroups(self, theGroupsOfFaces ):
4328 return self.editor.CreateFlatElementsOnFacesGroups( theGroupsOfFaces )
4330 def _valueFromFunctor(self, funcType, elemId):
4331 fn = self.smeshpyD.GetFunctor(funcType)
4332 fn.SetMesh(self.mesh)
4333 if fn.GetElementType() == self.GetElementType(elemId, True):
4334 val = fn.GetValue(elemId)
4339 ## Get length of 1D element.
4340 # @param elemId mesh element ID
4341 # @return element's length value
4342 # @ingroup l1_measurements
4343 def GetLength(self, elemId):
4344 return self._valueFromFunctor(SMESH.FT_Length, elemId)
4346 ## Get area of 2D element.
4347 # @param elemId mesh element ID
4348 # @return element's area value
4349 # @ingroup l1_measurements
4350 def GetArea(self, elemId):
4351 return self._valueFromFunctor(SMESH.FT_Area, elemId)
4353 ## Get volume of 3D element.
4354 # @param elemId mesh element ID
4355 # @return element's volume value
4356 # @ingroup l1_measurements
4357 def GetVolume(self, elemId):
4358 return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
4360 ## Get maximum element length.
4361 # @param elemId mesh element ID
4362 # @return element's maximum length value
4363 # @ingroup l1_measurements
4364 def GetMaxElementLength(self, elemId):
4365 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4366 ftype = SMESH.FT_MaxElementLength3D
4368 ftype = SMESH.FT_MaxElementLength2D
4369 return self._valueFromFunctor(ftype, elemId)
4371 ## Get aspect ratio of 2D or 3D element.
4372 # @param elemId mesh element ID
4373 # @return element's aspect ratio value
4374 # @ingroup l1_measurements
4375 def GetAspectRatio(self, elemId):
4376 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4377 ftype = SMESH.FT_AspectRatio3D
4379 ftype = SMESH.FT_AspectRatio
4380 return self._valueFromFunctor(ftype, elemId)
4382 ## Get warping angle of 2D element.
4383 # @param elemId mesh element ID
4384 # @return element's warping angle value
4385 # @ingroup l1_measurements
4386 def GetWarping(self, elemId):
4387 return self._valueFromFunctor(SMESH.FT_Warping, elemId)
4389 ## Get minimum angle of 2D element.
4390 # @param elemId mesh element ID
4391 # @return element's minimum angle value
4392 # @ingroup l1_measurements
4393 def GetMinimumAngle(self, elemId):
4394 return self._valueFromFunctor(SMESH.FT_MinimumAngle, elemId)
4396 ## Get taper of 2D element.
4397 # @param elemId mesh element ID
4398 # @return element's taper value
4399 # @ingroup l1_measurements
4400 def GetTaper(self, elemId):
4401 return self._valueFromFunctor(SMESH.FT_Taper, elemId)
4403 ## Get skew of 2D element.
4404 # @param elemId mesh element ID
4405 # @return element's skew value
4406 # @ingroup l1_measurements
4407 def GetSkew(self, elemId):
4408 return self._valueFromFunctor(SMESH.FT_Skew, elemId)
4410 ## The mother class to define algorithm, it is not recommended to use it directly.
4413 # @ingroup l2_algorithms
4414 class Mesh_Algorithm:
4415 # @class Mesh_Algorithm
4416 # @brief Class Mesh_Algorithm
4418 #def __init__(self,smesh):
4426 ## Finds a hypothesis in the study by its type name and parameters.
4427 # Finds only the hypotheses created in smeshpyD engine.
4428 # @return SMESH.SMESH_Hypothesis
4429 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
4430 study = smeshpyD.GetCurrentStudy()
4431 #to do: find component by smeshpyD object, not by its data type
4432 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4433 if scomp is not None:
4434 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
4435 # Check if the root label of the hypotheses exists
4436 if res and hypRoot is not None:
4437 iter = study.NewChildIterator(hypRoot)
4438 # Check all published hypotheses
4440 hypo_so_i = iter.Value()
4441 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
4442 if attr is not None:
4443 anIOR = attr.Value()
4444 hypo_o_i = salome.orb.string_to_object(anIOR)
4445 if hypo_o_i is not None:
4446 # Check if this is a hypothesis
4447 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
4448 if hypo_i is not None:
4449 # Check if the hypothesis belongs to current engine
4450 if smeshpyD.GetObjectId(hypo_i) > 0:
4451 # Check if this is the required hypothesis
4452 if hypo_i.GetName() == hypname:
4454 if CompareMethod(hypo_i, args):
4468 ## Finds the algorithm in the study by its type name.
4469 # Finds only the algorithms, which have been created in smeshpyD engine.
4470 # @return SMESH.SMESH_Algo
4471 def FindAlgorithm (self, algoname, smeshpyD):
4472 study = smeshpyD.GetCurrentStudy()
4473 #to do: find component by smeshpyD object, not by its data type
4474 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4475 if scomp is not None:
4476 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
4477 # Check if the root label of the algorithms exists
4478 if res and hypRoot is not None:
4479 iter = study.NewChildIterator(hypRoot)
4480 # Check all published algorithms
4482 algo_so_i = iter.Value()
4483 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
4484 if attr is not None:
4485 anIOR = attr.Value()
4486 algo_o_i = salome.orb.string_to_object(anIOR)
4487 if algo_o_i is not None:
4488 # Check if this is an algorithm
4489 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
4490 if algo_i is not None:
4491 # Checks if the algorithm belongs to the current engine
4492 if smeshpyD.GetObjectId(algo_i) > 0:
4493 # Check if this is the required algorithm
4494 if algo_i.GetName() == algoname:
4507 ## If the algorithm is global, returns 0; \n
4508 # else returns the submesh associated to this algorithm.
4509 def GetSubMesh(self):
4512 ## Returns the wrapped mesher.
4513 def GetAlgorithm(self):
4516 ## Gets the list of hypothesis that can be used with this algorithm
4517 def GetCompatibleHypothesis(self):
4520 mylist = self.algo.GetCompatibleHypothesis()
4523 ## Gets the name of the algorithm
4527 ## Sets the name to the algorithm
4528 def SetName(self, name):
4529 self.mesh.smeshpyD.SetName(self.algo, name)
4531 ## Gets the id of the algorithm
4533 return self.algo.GetId()
4536 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
4538 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
4539 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
4541 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
4543 self.Assign(algo, mesh, geom)
4547 def Assign(self, algo, mesh, geom):
4549 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
4553 self.geom = mesh.geom
4556 AssureGeomPublished( mesh, geom )
4558 name = GetName(geom)
4562 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
4564 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
4565 TreatHypoStatus( status, algo.GetName(), name, True )
4568 def CompareHyp (self, hyp, args):
4569 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
4572 def CompareEqualHyp (self, hyp, args):
4576 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
4577 UseExisting=0, CompareMethod=""):
4580 if CompareMethod == "": CompareMethod = self.CompareHyp
4581 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
4584 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
4589 if isinstance( arg, geompyDC.GEOM._objref_GEOM_Object ):
4590 argStr = arg.GetStudyEntry()
4591 if not argStr: argStr = "GEOM_Obj_%s", arg.GetEntry()
4595 self.mesh.smeshpyD.SetName(hypo, hyp + a)
4599 geomName = GetName(self.geom)
4600 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
4601 TreatHypoStatus( status, GetName(hypo), geomName, 0 )
4604 ## Returns entry of the shape to mesh in the study
4605 def MainShapeEntry(self):
4607 if not self.mesh or not self.mesh.GetMesh(): return entry
4608 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
4609 study = self.mesh.smeshpyD.GetCurrentStudy()
4610 ior = salome.orb.object_to_string( self.mesh.GetShape() )
4611 sobj = study.FindObjectIOR(ior)
4612 if sobj: entry = sobj.GetID()
4613 if not entry: return ""
4616 ## Defines "ViscousLayers" hypothesis to give parameters of layers of prisms to build
4617 # near mesh boundary. This hypothesis can be used by several 3D algorithms:
4618 # NETGEN 3D, GHS3D, Hexahedron(i,j,k)
4619 # @param thickness total thickness of layers of prisms
4620 # @param numberOfLayers number of layers of prisms
4621 # @param stretchFactor factor (>1.0) of growth of layer thickness towards inside of mesh
4622 # @param ignoreFaces list of geometrical faces (or their ids) not to generate layers on
4623 # @ingroup l3_hypos_additi
4624 def ViscousLayers(self, thickness, numberOfLayers, stretchFactor, ignoreFaces=[]):
4625 if not isinstance(self.algo, SMESH._objref_SMESH_3D_Algo):
4626 raise TypeError, "ViscousLayers are supported by 3D algorithms only"
4627 if not "ViscousLayers" in self.GetCompatibleHypothesis():
4628 raise TypeError, "ViscousLayers are not supported by %s"%self.algo.GetName()
4629 if ignoreFaces and isinstance( ignoreFaces[0], geompyDC.GEOM._objref_GEOM_Object ):
4630 ignoreFaces = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, f) for f in ignoreFaces ]
4631 hyp = self.Hypothesis("ViscousLayers",
4632 [thickness, numberOfLayers, stretchFactor, ignoreFaces])
4633 hyp.SetTotalThickness(thickness)
4634 hyp.SetNumberLayers(numberOfLayers)
4635 hyp.SetStretchFactor(stretchFactor)
4636 hyp.SetIgnoreFaces(ignoreFaces)
4639 ## Transform a list of ether edges or tuples (edge 1st_vertex_of_edge)
4640 # into a list acceptable to SetReversedEdges() of some 1D hypotheses
4641 # @ingroupl3_hypos_1dhyps
4642 def ReversedEdgeIndices(self, reverseList):
4644 geompy = self.mesh.geompyD
4645 for i in reverseList:
4646 if isinstance( i, int ):
4647 s = geompy.SubShapes(self.mesh.geom, [i])[0]
4648 if s.GetShapeType() != geompyDC.GEOM.EDGE:
4649 raise TypeError, "Not EDGE index given"
4651 elif isinstance( i, geompyDC.GEOM._objref_GEOM_Object ):
4652 if i.GetShapeType() != geompyDC.GEOM.EDGE:
4653 raise TypeError, "Not an EDGE given"
4654 resList.append( geompy.GetSubShapeID(self.mesh.geom, i ))
4658 if not isinstance( e, geompyDC.GEOM._objref_GEOM_Object ) or \
4659 not isinstance( v, geompyDC.GEOM._objref_GEOM_Object ):
4660 raise TypeError, "A list item must be a tuple (edge 1st_vertex_of_edge)"
4661 if v.GetShapeType() == geompyDC.GEOM.EDGE and \
4662 e.GetShapeType() == geompyDC.GEOM.VERTEX:
4664 if e.GetShapeType() != geompyDC.GEOM.EDGE or \
4665 v.GetShapeType() != geompyDC.GEOM.VERTEX:
4666 raise TypeError, "A list item must be a tuple (edge 1st_vertex_of_edge)"
4667 vFirst = FirstVertexOnCurve( e )
4668 tol = geompy.Tolerance( vFirst )[-1]
4669 if geompy.MinDistance( v, vFirst ) > 1.5*tol:
4670 resList.append( geompy.GetSubShapeID(self.mesh.geom, e ))
4672 raise TypeError, "Item must be either an edge or tuple (edge 1st_vertex_of_edge)"
4675 # Public class: Mesh_Segment
4676 # --------------------------
4678 ## Class to define a segment 1D algorithm for discretization
4681 # @ingroup l3_algos_basic
4682 class Mesh_Segment(Mesh_Algorithm):
4684 ## Private constructor.
4685 def __init__(self, mesh, geom=0):
4686 Mesh_Algorithm.__init__(self)
4687 self.Create(mesh, geom, "Regular_1D")
4689 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
4690 # @param l for the length of segments that cut an edge
4691 # @param UseExisting if ==true - searches for an existing hypothesis created with
4692 # the same parameters, else (default) - creates a new one
4693 # @param p precision, used for calculation of the number of segments.
4694 # The precision should be a positive, meaningful value within the range [0,1].
4695 # In general, the number of segments is calculated with the formula:
4696 # nb = ceil((edge_length / l) - p)
4697 # Function ceil rounds its argument to the higher integer.
4698 # So, p=0 means rounding of (edge_length / l) to the higher integer,
4699 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
4700 # p=1 means rounding of (edge_length / l) to the lower integer.
4701 # Default value is 1e-07.
4702 # @return an instance of StdMeshers_LocalLength hypothesis
4703 # @ingroup l3_hypos_1dhyps
4704 def LocalLength(self, l, UseExisting=0, p=1e-07):
4705 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
4706 CompareMethod=self.CompareLocalLength)
4712 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
4713 def CompareLocalLength(self, hyp, args):
4714 if IsEqual(hyp.GetLength(), args[0]):
4715 return IsEqual(hyp.GetPrecision(), args[1])
4718 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
4719 # @param length is optional maximal allowed length of segment, if it is omitted
4720 # the preestimated length is used that depends on geometry size
4721 # @param UseExisting if ==true - searches for an existing hypothesis created with
4722 # the same parameters, else (default) - create a new one
4723 # @return an instance of StdMeshers_MaxLength hypothesis
4724 # @ingroup l3_hypos_1dhyps
4725 def MaxSize(self, length=0.0, UseExisting=0):
4726 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
4729 hyp.SetLength(length)
4731 # set preestimated length
4732 gen = self.mesh.smeshpyD
4733 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
4734 self.mesh.GetMesh(), self.mesh.GetShape(),
4736 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
4738 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
4741 hyp.SetUsePreestimatedLength( length == 0.0 )
4744 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
4745 # @param n for the number of segments that cut an edge
4746 # @param s for the scale factor (optional)
4747 # @param reversedEdges is a list of edges to mesh using reversed orientation.
4748 # A list item can also be a tuple (edge 1st_vertex_of_edge)
4749 # @param UseExisting if ==true - searches for an existing hypothesis created with
4750 # the same parameters, else (default) - create a new one
4751 # @return an instance of StdMeshers_NumberOfSegments hypothesis
4752 # @ingroup l3_hypos_1dhyps
4753 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4754 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4755 reversedEdges, UseExisting = [], reversedEdges
4756 entry = self.MainShapeEntry()
4757 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
4759 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdgeInd, entry],
4760 UseExisting=UseExisting,
4761 CompareMethod=self.CompareNumberOfSegments)
4763 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdgeInd, entry],
4764 UseExisting=UseExisting,
4765 CompareMethod=self.CompareNumberOfSegments)
4766 hyp.SetDistrType( 1 )
4767 hyp.SetScaleFactor(s)
4768 hyp.SetNumberOfSegments(n)
4769 hyp.SetReversedEdges( reversedEdgeInd )
4770 hyp.SetObjectEntry( entry )
4774 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4775 def CompareNumberOfSegments(self, hyp, args):
4776 if hyp.GetNumberOfSegments() == args[0]:
4778 if hyp.GetReversedEdges() == args[1]:
4779 if not args[1] or hyp.GetObjectEntry() == args[2]:
4782 if hyp.GetReversedEdges() == args[2]:
4783 if not args[2] or hyp.GetObjectEntry() == args[3]:
4784 if hyp.GetDistrType() == 1:
4785 if IsEqual(hyp.GetScaleFactor(), args[1]):
4789 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4790 # @param start defines the length of the first segment
4791 # @param end defines the length of the last segment
4792 # @param reversedEdges is a list of edges to mesh using reversed orientation.
4793 # A list item can also be a tuple (edge 1st_vertex_of_edge)
4794 # @param UseExisting if ==true - searches for an existing hypothesis created with
4795 # the same parameters, else (default) - creates a new one
4796 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4797 # @ingroup l3_hypos_1dhyps
4798 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4799 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4800 reversedEdges, UseExisting = [], reversedEdges
4801 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
4802 entry = self.MainShapeEntry()
4803 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdgeInd, entry],
4804 UseExisting=UseExisting,
4805 CompareMethod=self.CompareArithmetic1D)
4806 hyp.SetStartLength(start)
4807 hyp.SetEndLength(end)
4808 hyp.SetReversedEdges( reversedEdgeInd )
4809 hyp.SetObjectEntry( entry )
4813 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4814 def CompareArithmetic1D(self, hyp, args):
4815 if IsEqual(hyp.GetLength(1), args[0]):
4816 if IsEqual(hyp.GetLength(0), args[1]):
4817 if hyp.GetReversedEdges() == args[2]:
4818 if not args[2] or hyp.GetObjectEntry() == args[3]:
4823 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4824 # on curve from 0 to 1 (additionally it is neecessary to check
4825 # orientation of edges and create list of reversed edges if it is
4826 # needed) and sets numbers of segments between given points (default
4827 # values are equals 1
4828 # @param points defines the list of parameters on curve
4829 # @param nbSegs defines the list of numbers of segments
4830 # @param reversedEdges is a list of edges to mesh using reversed orientation.
4831 # A list item can also be a tuple (edge 1st_vertex_of_edge)
4832 # @param UseExisting if ==true - searches for an existing hypothesis created with
4833 # the same parameters, else (default) - creates a new one
4834 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4835 # @ingroup l3_hypos_1dhyps
4836 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4837 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4838 reversedEdges, UseExisting = [], reversedEdges
4839 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
4840 entry = self.MainShapeEntry()
4841 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdgeInd, entry],
4842 UseExisting=UseExisting,
4843 CompareMethod=self.CompareFixedPoints1D)
4844 hyp.SetPoints(points)
4845 hyp.SetNbSegments(nbSegs)
4846 hyp.SetReversedEdges(reversedEdgeInd)
4847 hyp.SetObjectEntry(entry)
4851 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4852 ## as the given arguments
4853 def CompareFixedPoints1D(self, hyp, args):
4854 if hyp.GetPoints() == args[0]:
4855 if hyp.GetNbSegments() == args[1]:
4856 if hyp.GetReversedEdges() == args[2]:
4857 if not args[2] or hyp.GetObjectEntry() == args[3]:
4863 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4864 # @param start defines the length of the first segment
4865 # @param end defines the length of the last segment
4866 # @param reversedEdges is a list of edges to mesh using reversed orientation.
4867 # A list item can also be a tuple (edge 1st_vertex_of_edge)
4868 # @param UseExisting if ==true - searches for an existing hypothesis created with
4869 # the same parameters, else (default) - creates a new one
4870 # @return an instance of StdMeshers_StartEndLength hypothesis
4871 # @ingroup l3_hypos_1dhyps
4872 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4873 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4874 reversedEdges, UseExisting = [], reversedEdges
4875 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
4876 entry = self.MainShapeEntry()
4877 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdgeInd, entry],
4878 UseExisting=UseExisting,
4879 CompareMethod=self.CompareStartEndLength)
4880 hyp.SetStartLength(start)
4881 hyp.SetEndLength(end)
4882 hyp.SetReversedEdges( reversedEdgeInd )
4883 hyp.SetObjectEntry( entry )
4886 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4887 def CompareStartEndLength(self, hyp, args):
4888 if IsEqual(hyp.GetLength(1), args[0]):
4889 if IsEqual(hyp.GetLength(0), args[1]):
4890 if hyp.GetReversedEdges() == args[2]:
4891 if not args[2] or hyp.GetObjectEntry() == args[3]:
4895 ## Defines "Deflection1D" hypothesis
4896 # @param d for the deflection
4897 # @param UseExisting if ==true - searches for an existing hypothesis created with
4898 # the same parameters, else (default) - create a new one
4899 # @ingroup l3_hypos_1dhyps
4900 def Deflection1D(self, d, UseExisting=0):
4901 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4902 CompareMethod=self.CompareDeflection1D)
4903 hyp.SetDeflection(d)
4906 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4907 def CompareDeflection1D(self, hyp, args):
4908 return IsEqual(hyp.GetDeflection(), args[0])
4910 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4911 # the opposite side in case of quadrangular faces
4912 # @ingroup l3_hypos_additi
4913 def Propagation(self):
4914 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4916 ## Defines "AutomaticLength" hypothesis
4917 # @param fineness for the fineness [0-1]
4918 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4919 # same parameters, else (default) - create a new one
4920 # @ingroup l3_hypos_1dhyps
4921 def AutomaticLength(self, fineness=0, UseExisting=0):
4922 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4923 CompareMethod=self.CompareAutomaticLength)
4924 hyp.SetFineness( fineness )
4927 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4928 def CompareAutomaticLength(self, hyp, args):
4929 return IsEqual(hyp.GetFineness(), args[0])
4931 ## Defines "SegmentLengthAroundVertex" hypothesis
4932 # @param length for the segment length
4933 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4934 # Any other integer value means that the hypothesis will be set on the
4935 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4936 # @param UseExisting if ==true - searches for an existing hypothesis created with
4937 # the same parameters, else (default) - creates a new one
4938 # @ingroup l3_algos_segmarv
4939 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4941 store_geom = self.geom
4942 if type(vertex) is types.IntType:
4943 if vertex == 0 or vertex == 1:
4944 vertex = self.mesh.geompyD.ExtractShapes(self.geom, geompyDC.ShapeType["VERTEX"],True)[vertex]
4952 if self.geom is None:
4953 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4954 AssureGeomPublished( self.mesh, self.geom )
4955 name = GetName(self.geom)
4957 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4959 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4961 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4962 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4964 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4965 CompareMethod=self.CompareLengthNearVertex)
4966 self.geom = store_geom
4967 hyp.SetLength( length )
4970 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4971 # @ingroup l3_algos_segmarv
4972 def CompareLengthNearVertex(self, hyp, args):
4973 return IsEqual(hyp.GetLength(), args[0])
4975 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4976 # If the 2D mesher sees that all boundary edges are quadratic,
4977 # it generates quadratic faces, else it generates linear faces using
4978 # medium nodes as if they are vertices.
4979 # The 3D mesher generates quadratic volumes only if all boundary faces
4980 # are quadratic, else it fails.
4982 # @ingroup l3_hypos_additi
4983 def QuadraticMesh(self):
4984 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4987 # Public class: Mesh_CompositeSegment
4988 # --------------------------
4990 ## Defines a segment 1D algorithm for discretization
4992 # @ingroup l3_algos_basic
4993 class Mesh_CompositeSegment(Mesh_Segment):
4995 ## Private constructor.
4996 def __init__(self, mesh, geom=0):
4997 self.Create(mesh, geom, "CompositeSegment_1D")
5000 # Public class: Mesh_Segment_Python
5001 # ---------------------------------
5003 ## Defines a segment 1D algorithm for discretization with python function
5005 # @ingroup l3_algos_basic
5006 class Mesh_Segment_Python(Mesh_Segment):
5008 ## Private constructor.
5009 def __init__(self, mesh, geom=0):
5010 import Python1dPlugin
5011 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
5013 ## Defines "PythonSplit1D" hypothesis
5014 # @param n for the number of segments that cut an edge
5015 # @param func for the python function that calculates the length of all segments
5016 # @param UseExisting if ==true - searches for the existing hypothesis created with
5017 # the same parameters, else (default) - creates a new one
5018 # @ingroup l3_hypos_1dhyps
5019 def PythonSplit1D(self, n, func, UseExisting=0):
5020 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
5021 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
5022 hyp.SetNumberOfSegments(n)
5023 hyp.SetPythonLog10RatioFunction(func)
5026 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
5027 def ComparePythonSplit1D(self, hyp, args):
5028 #if hyp.GetNumberOfSegments() == args[0]:
5029 # if hyp.GetPythonLog10RatioFunction() == args[1]:
5033 # Public class: Mesh_Triangle
5034 # ---------------------------
5036 ## Defines a triangle 2D algorithm
5038 # @ingroup l3_algos_basic
5039 class Mesh_Triangle(Mesh_Algorithm):
5048 ## Private constructor.
5049 def __init__(self, mesh, algoType, geom=0):
5050 Mesh_Algorithm.__init__(self)
5052 if algoType == MEFISTO:
5053 self.Create(mesh, geom, "MEFISTO_2D")
5055 elif algoType == BLSURF:
5057 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
5058 #self.SetPhysicalMesh() - PAL19680
5059 elif algoType == NETGEN:
5061 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
5063 elif algoType == NETGEN_2D:
5065 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
5068 self.algoType = algoType
5070 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
5071 # @param area for the maximum area of each triangle
5072 # @param UseExisting if ==true - searches for an existing hypothesis created with the
5073 # same parameters, else (default) - creates a new one
5075 # Only for algoType == MEFISTO || NETGEN_2D
5076 # @ingroup l3_hypos_2dhyps
5077 def MaxElementArea(self, area, UseExisting=0):
5078 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
5079 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
5080 CompareMethod=self.CompareMaxElementArea)
5081 elif self.algoType == NETGEN:
5082 hyp = self.Parameters(SIMPLE)
5083 hyp.SetMaxElementArea(area)
5086 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
5087 def CompareMaxElementArea(self, hyp, args):
5088 return IsEqual(hyp.GetMaxElementArea(), args[0])
5090 ## Defines "LengthFromEdges" hypothesis to build triangles
5091 # based on the length of the edges taken from the wire
5093 # Only for algoType == MEFISTO || NETGEN_2D
5094 # @ingroup l3_hypos_2dhyps
5095 def LengthFromEdges(self):
5096 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
5097 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
5099 elif self.algoType == NETGEN:
5100 hyp = self.Parameters(SIMPLE)
5101 hyp.LengthFromEdges()
5104 ## Sets a way to define size of mesh elements to generate.
5105 # @param thePhysicalMesh is: DefaultSize, BLSURF_Custom or SizeMap.
5106 # @ingroup l3_hypos_blsurf
5107 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
5108 if self.Parameters():
5109 # Parameter of BLSURF algo
5110 self.params.SetPhysicalMesh(thePhysicalMesh)
5112 ## Sets size of mesh elements to generate.
5113 # @ingroup l3_hypos_blsurf
5114 def SetPhySize(self, theVal):
5115 if self.Parameters():
5116 # Parameter of BLSURF algo
5117 self.params.SetPhySize(theVal)
5119 ## Sets lower boundary of mesh element size (PhySize).
5120 # @ingroup l3_hypos_blsurf
5121 def SetPhyMin(self, theVal=-1):
5122 if self.Parameters():
5123 # Parameter of BLSURF algo
5124 self.params.SetPhyMin(theVal)
5126 ## Sets upper boundary of mesh element size (PhySize).
5127 # @ingroup l3_hypos_blsurf
5128 def SetPhyMax(self, theVal=-1):
5129 if self.Parameters():
5130 # Parameter of BLSURF algo
5131 self.params.SetPhyMax(theVal)
5133 ## Sets a way to define maximum angular deflection of mesh from CAD model.
5134 # @param theGeometricMesh is: 0 (None) or 1 (Custom)
5135 # @ingroup l3_hypos_blsurf
5136 def SetGeometricMesh(self, theGeometricMesh=0):
5137 if self.Parameters():
5138 # Parameter of BLSURF algo
5139 if self.params.GetPhysicalMesh() == 0: theGeometricMesh = 1
5140 self.params.SetGeometricMesh(theGeometricMesh)
5142 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
5143 # @ingroup l3_hypos_blsurf
5144 def SetAngleMeshS(self, theVal=_angleMeshS):
5145 if self.Parameters():
5146 # Parameter of BLSURF algo
5147 if self.params.GetGeometricMesh() == 0: theVal = self._angleMeshS
5148 self.params.SetAngleMeshS(theVal)
5150 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
5151 # @ingroup l3_hypos_blsurf
5152 def SetAngleMeshC(self, theVal=_angleMeshS):
5153 if self.Parameters():
5154 # Parameter of BLSURF algo
5155 if self.params.GetGeometricMesh() == 0: theVal = self._angleMeshS
5156 self.params.SetAngleMeshC(theVal)
5158 ## Sets lower boundary of mesh element size computed to respect angular deflection.
5159 # @ingroup l3_hypos_blsurf
5160 def SetGeoMin(self, theVal=-1):
5161 if self.Parameters():
5162 # Parameter of BLSURF algo
5163 self.params.SetGeoMin(theVal)
5165 ## Sets upper boundary of mesh element size computed to respect angular deflection.
5166 # @ingroup l3_hypos_blsurf
5167 def SetGeoMax(self, theVal=-1):
5168 if self.Parameters():
5169 # Parameter of BLSURF algo
5170 self.params.SetGeoMax(theVal)
5172 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
5173 # @ingroup l3_hypos_blsurf
5174 def SetGradation(self, theVal=_gradation):
5175 if self.Parameters():
5176 # Parameter of BLSURF algo
5177 if self.params.GetGeometricMesh() == 0: theVal = self._gradation
5178 self.params.SetGradation(theVal)
5180 ## Sets topology usage way.
5181 # @param way defines how mesh conformity is assured <ul>
5182 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
5183 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
5184 # <li>PreCAD - by pre-processing with PreCAD a CAD model</li></ul>
5185 # @ingroup l3_hypos_blsurf
5186 def SetTopology(self, way):
5187 if self.Parameters():
5188 # Parameter of BLSURF algo
5189 self.params.SetTopology(way)
5191 ## To respect geometrical edges or not.
5192 # @ingroup l3_hypos_blsurf
5193 def SetDecimesh(self, toIgnoreEdges=False):
5194 if self.Parameters():
5195 # Parameter of BLSURF algo
5196 self.params.SetDecimesh(toIgnoreEdges)
5198 ## Sets verbosity level in the range 0 to 100.
5199 # @ingroup l3_hypos_blsurf
5200 def SetVerbosity(self, level):
5201 if self.Parameters():
5202 # Parameter of BLSURF algo
5203 self.params.SetVerbosity(level)
5205 ## To optimize merges edges.
5206 # @ingroup l3_hypos_blsurf
5207 def SetPreCADMergeEdges(self, toMergeEdges=False):
5208 if self.Parameters():
5209 # Parameter of BLSURF algo
5210 self.params.SetPreCADMergeEdges(toMergeEdges)
5212 ## To remove nano edges.
5213 # @ingroup l3_hypos_blsurf
5214 def SetPreCADRemoveNanoEdges(self, toRemoveNanoEdges=False):
5215 if self.Parameters():
5216 # Parameter of BLSURF algo
5217 self.params.SetPreCADRemoveNanoEdges(toRemoveNanoEdges)
5219 ## To compute topology from scratch
5220 # @ingroup l3_hypos_blsurf
5221 def SetPreCADDiscardInput(self, toDiscardInput=False):
5222 if self.Parameters():
5223 # Parameter of BLSURF algo
5224 self.params.SetPreCADDiscardInput(toDiscardInput)
5226 ## Sets the length below which an edge is considered as nano
5227 # for the topology processing.
5228 # @ingroup l3_hypos_blsurf
5229 def SetPreCADEpsNano(self, epsNano):
5230 if self.Parameters():
5231 # Parameter of BLSURF algo
5232 self.params.SetPreCADEpsNano(epsNano)
5234 ## Sets advanced option value.
5235 # @ingroup l3_hypos_blsurf
5236 def SetOptionValue(self, optionName, level):
5237 if self.Parameters():
5238 # Parameter of BLSURF algo
5239 self.params.SetOptionValue(optionName,level)
5241 ## Sets advanced PreCAD option value.
5242 # Keyword arguments:
5243 # optionName: name of the option
5244 # optionValue: value of the option
5245 # @ingroup l3_hypos_blsurf
5246 def SetPreCADOptionValue(self, optionName, optionValue):
5247 if self.Parameters():
5248 # Parameter of BLSURF algo
5249 self.params.SetPreCADOptionValue(optionName,optionValue)
5251 ## Sets GMF file for export at computation
5252 # @ingroup l3_hypos_blsurf
5253 def SetGMFFile(self, fileName):
5254 if self.Parameters():
5255 # Parameter of BLSURF algo
5256 self.params.SetGMFFile(fileName)
5258 ## Enforced vertices (BLSURF)
5260 ## To get all the enforced vertices
5261 # @ingroup l3_hypos_blsurf
5262 def GetAllEnforcedVertices(self):
5263 if self.Parameters():
5264 # Parameter of BLSURF algo
5265 return self.params.GetAllEnforcedVertices()
5267 ## To get all the enforced vertices sorted by face (or group, compound)
5268 # @ingroup l3_hypos_blsurf
5269 def GetAllEnforcedVerticesByFace(self):
5270 if self.Parameters():
5271 # Parameter of BLSURF algo
5272 return self.params.GetAllEnforcedVerticesByFace()
5274 ## To get all the enforced vertices sorted by coords of input vertices
5275 # @ingroup l3_hypos_blsurf
5276 def GetAllEnforcedVerticesByCoords(self):
5277 if self.Parameters():
5278 # Parameter of BLSURF algo
5279 return self.params.GetAllEnforcedVerticesByCoords()
5281 ## To get all the coords of input vertices sorted by face (or group, compound)
5282 # @ingroup l3_hypos_blsurf
5283 def GetAllCoordsByFace(self):
5284 if self.Parameters():
5285 # Parameter of BLSURF algo
5286 return self.params.GetAllCoordsByFace()
5288 ## To get all the enforced vertices on a face (or group, compound)
5289 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
5290 # @ingroup l3_hypos_blsurf
5291 def GetEnforcedVertices(self, theFace):
5292 if self.Parameters():
5293 # Parameter of BLSURF algo
5294 AssureGeomPublished( self.mesh, theFace )
5295 return self.params.GetEnforcedVertices(theFace)
5297 ## To clear all the enforced vertices
5298 # @ingroup l3_hypos_blsurf
5299 def ClearAllEnforcedVertices(self):
5300 if self.Parameters():
5301 # Parameter of BLSURF algo
5302 return self.params.ClearAllEnforcedVertices()
5304 ## 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.
5305 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
5306 # @param x : x coordinate
5307 # @param y : y coordinate
5308 # @param z : z coordinate
5309 # @param vertexName : name of the enforced vertex
5310 # @param groupName : name of the group
5311 # @ingroup l3_hypos_blsurf
5312 def SetEnforcedVertex(self, theFace, x, y, z, vertexName = "", groupName = ""):
5313 if self.Parameters():
5314 # Parameter of BLSURF algo
5315 AssureGeomPublished( self.mesh, theFace )
5316 if vertexName == "":
5318 return self.params.SetEnforcedVertex(theFace, x, y, z)
5320 return self.params.SetEnforcedVertexWithGroup(theFace, x, y, z, groupName)
5323 return self.params.SetEnforcedVertexNamed(theFace, x, y, z, vertexName)
5325 return self.params.SetEnforcedVertexNamedWithGroup(theFace, x, y, z, vertexName, groupName)
5327 ## To set an enforced vertex on a face (or group, compound) given a GEOM vertex, group or compound.
5328 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
5329 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
5330 # @param groupName : name of the group
5331 # @ingroup l3_hypos_blsurf
5332 def SetEnforcedVertexGeom(self, theFace, theVertex, groupName = ""):
5333 if self.Parameters():
5334 # Parameter of BLSURF algo
5335 AssureGeomPublished( self.mesh, theFace )
5336 AssureGeomPublished( self.mesh, theVertex )
5338 return self.params.SetEnforcedVertexGeom(theFace, theVertex)
5340 return self.params.SetEnforcedVertexGeomWithGroup(theFace, theVertex,groupName)
5342 ## To remove an enforced vertex on a given GEOM face (or group, compound) given the coordinates.
5343 # @param theFace : GEOM face (or group, compound) on which to remove the enforced vertex
5344 # @param x : x coordinate
5345 # @param y : y coordinate
5346 # @param z : z coordinate
5347 # @ingroup l3_hypos_blsurf
5348 def UnsetEnforcedVertex(self, theFace, x, y, z):
5349 if self.Parameters():
5350 # Parameter of BLSURF algo
5351 AssureGeomPublished( self.mesh, theFace )
5352 return self.params.UnsetEnforcedVertex(theFace, x, y, z)
5354 ## To remove an enforced vertex on a given GEOM face (or group, compound) given a GEOM vertex, group or compound.
5355 # @param theFace : GEOM face (or group, compound) on which to remove the enforced vertex
5356 # @param theVertex : GEOM vertex (or group, compound) to remove.
5357 # @ingroup l3_hypos_blsurf
5358 def UnsetEnforcedVertexGeom(self, theFace, theVertex):
5359 if self.Parameters():
5360 # Parameter of BLSURF algo
5361 AssureGeomPublished( self.mesh, theFace )
5362 AssureGeomPublished( self.mesh, theVertex )
5363 return self.params.UnsetEnforcedVertexGeom(theFace, theVertex)
5365 ## To remove all enforced vertices on a given face.
5366 # @param theFace : face (or group/compound of faces) on which to remove all enforced vertices
5367 # @ingroup l3_hypos_blsurf
5368 def UnsetEnforcedVertices(self, theFace):
5369 if self.Parameters():
5370 # Parameter of BLSURF algo
5371 AssureGeomPublished( self.mesh, theFace )
5372 return self.params.UnsetEnforcedVertices(theFace)
5374 ## Attractors (BLSURF)
5376 ## 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 ]
5377 # @param theFace : face on which the attractor will be defined
5378 # @param theAttractor : geometrical object from which the mesh size "h" decreases exponentially
5379 # @param theStartSize : mesh size on theAttractor
5380 # @param theEndSize : maximum size that will be reached on theFace
5381 # @param theInfluenceDistance : influence of the attractor ( the size grow slower on theFace if it's high)
5382 # @param theConstantSizeDistance : distance until which the mesh size will be kept constant on theFace
5383 # @ingroup l3_hypos_blsurf
5384 def SetAttractorGeom(self, theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance):
5385 if self.Parameters():
5386 # Parameter of BLSURF algo
5387 AssureGeomPublished( self.mesh, theFace )
5388 AssureGeomPublished( self.mesh, theAttractor )
5389 self.params.SetAttractorGeom(theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance)
5391 ## Unsets an attractor on the chosen face.
5392 # @param theFace : face on which the attractor has to be removed
5393 # @ingroup l3_hypos_blsurf
5394 def UnsetAttractorGeom(self, theFace):
5395 if self.Parameters():
5396 # Parameter of BLSURF algo
5397 AssureGeomPublished( self.mesh, theFace )
5398 self.params.SetAttractorGeom(theFace)
5400 ## Size maps (BLSURF)
5402 ## To set a size map on a face, edge or vertex (or group, compound) given Python function.
5403 # If theObject is a face, the function can be: def f(u,v): return u+v
5404 # If theObject is an edge, the function can be: def f(t): return t/2
5405 # If theObject is a vertex, the function can be: def f(): return 10
5406 # @param theObject : GEOM face, edge or vertex (or group, compound) on which to define a size map
5407 # @param theSizeMap : Size map defined as a string
5408 # @ingroup l3_hypos_blsurf
5409 def SetSizeMap(self, theObject, theSizeMap):
5410 if self.Parameters():
5411 # Parameter of BLSURF algo
5412 AssureGeomPublished( self.mesh, theObject )
5413 return self.params.SetSizeMap(theObject, theSizeMap)
5415 ## To remove a size map defined on a face, edge or vertex (or group, compound)
5416 # @param theObject : GEOM face, edge or vertex (or group, compound) on which to define a size map
5417 # @ingroup l3_hypos_blsurf
5418 def UnsetSizeMap(self, theObject):
5419 if self.Parameters():
5420 # Parameter of BLSURF algo
5421 AssureGeomPublished( self.mesh, theObject )
5422 return self.params.UnsetSizeMap(theObject)
5424 ## To remove all the size maps
5425 # @ingroup l3_hypos_blsurf
5426 def ClearSizeMaps(self):
5427 if self.Parameters():
5428 # Parameter of BLSURF algo
5429 return self.params.ClearSizeMaps()
5432 ## Sets QuadAllowed flag.
5433 # Only for algoType == NETGEN(NETGEN_1D2D) || NETGEN_2D || BLSURF
5434 # @ingroup l3_hypos_netgen l3_hypos_blsurf
5435 def SetQuadAllowed(self, toAllow=True):
5436 if self.algoType == NETGEN_2D:
5439 hasSimpleHyps = False
5440 simpleHyps = ["QuadranglePreference","LengthFromEdges","MaxElementArea"]
5441 for hyp in self.mesh.GetHypothesisList( self.geom ):
5442 if hyp.GetName() in simpleHyps:
5443 hasSimpleHyps = True
5444 if hyp.GetName() == "QuadranglePreference":
5445 if not toAllow: # remove QuadranglePreference
5446 self.mesh.RemoveHypothesis( self.geom, hyp )
5452 if toAllow: # add QuadranglePreference
5453 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
5458 if self.Parameters():
5459 self.params.SetQuadAllowed(toAllow)
5462 ## Defines hypothesis having several parameters
5464 # @ingroup l3_hypos_netgen
5465 def Parameters(self, which=SOLE):
5467 if self.algoType == NETGEN:
5469 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
5470 "libNETGENEngine.so", UseExisting=0)
5472 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
5473 "libNETGENEngine.so", UseExisting=0)
5474 elif self.algoType == MEFISTO:
5475 print "Mefisto algo support no multi-parameter hypothesis"
5476 elif self.algoType == NETGEN_2D:
5477 self.params = self.Hypothesis("NETGEN_Parameters_2D_ONLY", [],
5478 "libNETGENEngine.so", UseExisting=0)
5479 elif self.algoType == BLSURF:
5480 self.params = self.Hypothesis("BLSURF_Parameters", [],
5481 "libBLSURFEngine.so", UseExisting=0)
5483 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
5488 # Only for algoType == NETGEN
5489 # @ingroup l3_hypos_netgen
5490 def SetMaxSize(self, theSize):
5491 if self.Parameters():
5492 self.params.SetMaxSize(theSize)
5494 ## Sets SecondOrder flag
5496 # Only for algoType == NETGEN
5497 # @ingroup l3_hypos_netgen
5498 def SetSecondOrder(self, theVal):
5499 if self.Parameters():
5500 self.params.SetSecondOrder(theVal)
5502 ## Sets Optimize flag
5504 # Only for algoType == NETGEN
5505 # @ingroup l3_hypos_netgen
5506 def SetOptimize(self, theVal):
5507 if self.Parameters():
5508 self.params.SetOptimize(theVal)
5511 # @param theFineness is:
5512 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5514 # Only for algoType == NETGEN
5515 # @ingroup l3_hypos_netgen
5516 def SetFineness(self, theFineness):
5517 if self.Parameters():
5518 self.params.SetFineness(theFineness)
5522 # Only for algoType == NETGEN
5523 # @ingroup l3_hypos_netgen
5524 def SetGrowthRate(self, theRate):
5525 if self.Parameters():
5526 self.params.SetGrowthRate(theRate)
5528 ## Sets NbSegPerEdge
5530 # Only for algoType == NETGEN
5531 # @ingroup l3_hypos_netgen
5532 def SetNbSegPerEdge(self, theVal):
5533 if self.Parameters():
5534 self.params.SetNbSegPerEdge(theVal)
5536 ## Sets NbSegPerRadius
5538 # Only for algoType == NETGEN
5539 # @ingroup l3_hypos_netgen
5540 def SetNbSegPerRadius(self, theVal):
5541 if self.Parameters():
5542 self.params.SetNbSegPerRadius(theVal)
5544 ## Sets number of segments overriding value set by SetLocalLength()
5546 # Only for algoType == NETGEN
5547 # @ingroup l3_hypos_netgen
5548 def SetNumberOfSegments(self, theVal):
5549 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5551 ## Sets number of segments overriding value set by SetNumberOfSegments()
5553 # Only for algoType == NETGEN
5554 # @ingroup l3_hypos_netgen
5555 def SetLocalLength(self, theVal):
5556 self.Parameters(SIMPLE).SetLocalLength(theVal)
5561 # Public class: Mesh_Quadrangle
5562 # -----------------------------
5564 ## Defines a quadrangle 2D algorithm
5566 # @ingroup l3_algos_basic
5567 class Mesh_Quadrangle(Mesh_Algorithm):
5571 ## Private constructor.
5572 def __init__(self, mesh, geom=0):
5573 Mesh_Algorithm.__init__(self)
5574 self.Create(mesh, geom, "Quadrangle_2D")
5577 ## Defines "QuadrangleParameters" hypothesis
5578 # @param quadType defines the algorithm of transition between differently descretized
5579 # sides of a geometrical face:
5580 # - QUAD_STANDARD - both triangles and quadrangles are possible in the transition
5581 # area along the finer meshed sides.
5582 # - QUAD_TRIANGLE_PREF - only triangles are built in the transition area along the
5583 # finer meshed sides.
5584 # - QUAD_QUADRANGLE_PREF - only quadrangles are built in the transition area along
5585 # the finer meshed sides, iff the total quantity of segments on
5586 # all four sides of the face is even (divisible by 2).
5587 # - QUAD_QUADRANGLE_PREF_REVERSED - same as QUAD_QUADRANGLE_PREF but the transition
5588 # area is located along the coarser meshed sides.
5589 # - QUAD_REDUCED - only quadrangles are built and the transition between the sides
5590 # is made gradually, layer by layer. This type has a limitation on
5591 # the number of segments: one pair of opposite sides must have the
5592 # same number of segments, the other pair must have an even difference
5593 # between the numbers of segments on the sides.
5594 # @param triangleVertex: vertex of a trilateral geometrical face, around which triangles
5595 # will be created while other elements will be quadrangles.
5596 # Vertex can be either a GEOM_Object or a vertex ID within the
5598 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5599 # the same parameters, else (default) - creates a new one
5600 # @ingroup l3_hypos_quad
5601 def QuadrangleParameters(self, quadType=StdMeshers.QUAD_STANDARD, triangleVertex=0, UseExisting=0):
5602 vertexID = triangleVertex
5603 if isinstance( triangleVertex, geompyDC.GEOM._objref_GEOM_Object ):
5604 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, triangleVertex )
5606 compFun = lambda hyp,args: \
5607 hyp.GetQuadType() == args[0] and \
5608 ( hyp.GetTriaVertex()==args[1] or ( hyp.GetTriaVertex()<1 and args[1]<1))
5609 self.params = self.Hypothesis("QuadrangleParams", [quadType,vertexID],
5610 UseExisting = UseExisting, CompareMethod=compFun)
5612 if self.params.GetQuadType() != quadType:
5613 self.params.SetQuadType(quadType)
5615 self.params.SetTriaVertex( vertexID )
5618 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5619 # quadrangles are built in the transition area along the finer meshed sides,
5620 # iff the total quantity of segments on all four sides of the face is even.
5621 # @param reversed if True, transition area is located along the coarser meshed sides.
5622 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5623 # the same parameters, else (default) - creates a new one
5624 # @ingroup l3_hypos_quad
5625 def QuadranglePreference(self, reversed=False, UseExisting=0):
5627 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF_REVERSED,UseExisting=UseExisting)
5628 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF,UseExisting=UseExisting)
5630 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5631 # triangles are built in the transition area along the finer meshed sides.
5632 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5633 # the same parameters, else (default) - creates a new one
5634 # @ingroup l3_hypos_quad
5635 def TrianglePreference(self, UseExisting=0):
5636 return self.QuadrangleParameters(QUAD_TRIANGLE_PREF,UseExisting=UseExisting)
5638 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5639 # quadrangles are built and the transition between the sides is made gradually,
5640 # layer by layer. This type has a limitation on the number of segments: one pair
5641 # of opposite sides must have the same number of segments, the other pair must
5642 # have an even difference between the numbers of segments on the sides.
5643 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5644 # the same parameters, else (default) - creates a new one
5645 # @ingroup l3_hypos_quad
5646 def Reduced(self, UseExisting=0):
5647 return self.QuadrangleParameters(QUAD_REDUCED,UseExisting=UseExisting)
5649 ## Defines "QuadrangleParams" hypothesis with QUAD_STANDARD type of quadrangulation
5650 # @param vertex: vertex of a trilateral geometrical face, around which triangles
5651 # will be created while other elements will be quadrangles.
5652 # Vertex can be either a GEOM_Object or a vertex ID within the
5654 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5655 # the same parameters, else (default) - creates a new one
5656 # @ingroup l3_hypos_quad
5657 def TriangleVertex(self, vertex, UseExisting=0):
5658 return self.QuadrangleParameters(QUAD_STANDARD,vertex,UseExisting)
5661 # Public class: Mesh_Tetrahedron
5662 # ------------------------------
5664 ## Defines a tetrahedron 3D algorithm
5666 # @ingroup l3_algos_basic
5667 class Mesh_Tetrahedron(Mesh_Algorithm):
5672 ## Private constructor.
5673 def __init__(self, mesh, algoType, geom=0):
5674 Mesh_Algorithm.__init__(self)
5676 if algoType == NETGEN:
5678 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
5681 elif algoType == FULL_NETGEN:
5683 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5686 elif algoType == GHS3D:
5688 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
5691 elif algoType == GHS3DPRL:
5692 CheckPlugin(GHS3DPRL)
5693 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
5696 self.algoType = algoType
5698 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
5699 # @param vol for the maximum volume of each tetrahedron
5700 # @param UseExisting if ==true - searches for the existing hypothesis created with
5701 # the same parameters, else (default) - creates a new one
5702 # @ingroup l3_hypos_maxvol
5703 def MaxElementVolume(self, vol, UseExisting=0):
5704 if self.algoType == NETGEN:
5705 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
5706 CompareMethod=self.CompareMaxElementVolume)
5707 hyp.SetMaxElementVolume(vol)
5709 elif self.algoType == FULL_NETGEN:
5710 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
5713 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
5714 def CompareMaxElementVolume(self, hyp, args):
5715 return IsEqual(hyp.GetMaxElementVolume(), args[0])
5717 ## Defines hypothesis having several parameters
5719 # @ingroup l3_hypos_netgen
5720 def Parameters(self, which=SOLE):
5723 if self.algoType == FULL_NETGEN:
5725 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
5726 "libNETGENEngine.so", UseExisting=0)
5728 self.params = self.Hypothesis("NETGEN_Parameters", [],
5729 "libNETGENEngine.so", UseExisting=0)
5731 elif self.algoType == NETGEN:
5732 self.params = self.Hypothesis("NETGEN_Parameters_3D", [],
5733 "libNETGENEngine.so", UseExisting=0)
5735 elif self.algoType == GHS3D:
5736 self.params = self.Hypothesis("GHS3D_Parameters", [],
5737 "libGHS3DEngine.so", UseExisting=0)
5739 elif self.algoType == GHS3DPRL:
5740 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
5741 "libGHS3DPRLEngine.so", UseExisting=0)
5743 print "Warning: %s supports no multi-parameter hypothesis"%self.algo.GetName()
5748 # Parameter of FULL_NETGEN and NETGEN
5749 # @ingroup l3_hypos_netgen
5750 def SetMaxSize(self, theSize):
5751 self.Parameters().SetMaxSize(theSize)
5753 ## Sets SecondOrder flag
5754 # Parameter of FULL_NETGEN
5755 # @ingroup l3_hypos_netgen
5756 def SetSecondOrder(self, theVal):
5757 self.Parameters().SetSecondOrder(theVal)
5759 ## Sets Optimize flag
5760 # Parameter of FULL_NETGEN and NETGEN
5761 # @ingroup l3_hypos_netgen
5762 def SetOptimize(self, theVal):
5763 self.Parameters().SetOptimize(theVal)
5766 # @param theFineness is:
5767 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5768 # Parameter of FULL_NETGEN
5769 # @ingroup l3_hypos_netgen
5770 def SetFineness(self, theFineness):
5771 self.Parameters().SetFineness(theFineness)
5774 # Parameter of FULL_NETGEN
5775 # @ingroup l3_hypos_netgen
5776 def SetGrowthRate(self, theRate):
5777 self.Parameters().SetGrowthRate(theRate)
5779 ## Sets NbSegPerEdge
5780 # Parameter of FULL_NETGEN
5781 # @ingroup l3_hypos_netgen
5782 def SetNbSegPerEdge(self, theVal):
5783 self.Parameters().SetNbSegPerEdge(theVal)
5785 ## Sets NbSegPerRadius
5786 # Parameter of FULL_NETGEN
5787 # @ingroup l3_hypos_netgen
5788 def SetNbSegPerRadius(self, theVal):
5789 self.Parameters().SetNbSegPerRadius(theVal)
5791 ## Sets number of segments overriding value set by SetLocalLength()
5792 # Only for algoType == NETGEN_FULL
5793 # @ingroup l3_hypos_netgen
5794 def SetNumberOfSegments(self, theVal):
5795 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5797 ## Sets number of segments overriding value set by SetNumberOfSegments()
5798 # Only for algoType == NETGEN_FULL
5799 # @ingroup l3_hypos_netgen
5800 def SetLocalLength(self, theVal):
5801 self.Parameters(SIMPLE).SetLocalLength(theVal)
5803 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
5804 # Overrides value set by LengthFromEdges()
5805 # Only for algoType == NETGEN_FULL
5806 # @ingroup l3_hypos_netgen
5807 def MaxElementArea(self, area):
5808 self.Parameters(SIMPLE).SetMaxElementArea(area)
5810 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
5811 # Overrides value set by MaxElementArea()
5812 # Only for algoType == NETGEN_FULL
5813 # @ingroup l3_hypos_netgen
5814 def LengthFromEdges(self):
5815 self.Parameters(SIMPLE).LengthFromEdges()
5817 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
5818 # Overrides value set by MaxElementVolume()
5819 # Only for algoType == NETGEN_FULL
5820 # @ingroup l3_hypos_netgen
5821 def LengthFromFaces(self):
5822 self.Parameters(SIMPLE).LengthFromFaces()
5824 ## To mesh "holes" in a solid or not. Default is to mesh.
5825 # @ingroup l3_hypos_ghs3dh
5826 def SetToMeshHoles(self, toMesh):
5827 # Parameter of GHS3D
5828 if self.Parameters():
5829 self.params.SetToMeshHoles(toMesh)
5831 ## Set Optimization level:
5832 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
5833 # Strong_Optimization.
5834 # Default is Standard_Optimization
5835 # @ingroup l3_hypos_ghs3dh
5836 def SetOptimizationLevel(self, level):
5837 # Parameter of GHS3D
5838 if self.Parameters():
5839 self.params.SetOptimizationLevel(level)
5841 ## Maximal size of memory to be used by the algorithm (in Megabytes).
5842 # @ingroup l3_hypos_ghs3dh
5843 def SetMaximumMemory(self, MB):
5844 # Advanced parameter of GHS3D
5845 if self.Parameters():
5846 self.params.SetMaximumMemory(MB)
5848 ## Initial size of memory to be used by the algorithm (in Megabytes) in
5849 # automatic memory adjustment mode.
5850 # @ingroup l3_hypos_ghs3dh
5851 def SetInitialMemory(self, MB):
5852 # Advanced parameter of GHS3D
5853 if self.Parameters():
5854 self.params.SetInitialMemory(MB)
5856 ## Path to working directory.
5857 # @ingroup l3_hypos_ghs3dh
5858 def SetWorkingDirectory(self, path):
5859 # Advanced parameter of GHS3D
5860 if self.Parameters():
5861 self.params.SetWorkingDirectory(path)
5863 ## To keep working files or remove them. Log file remains in case of errors anyway.
5864 # @ingroup l3_hypos_ghs3dh
5865 def SetKeepFiles(self, toKeep):
5866 # Advanced parameter of GHS3D and GHS3DPRL
5867 if self.Parameters():
5868 self.params.SetKeepFiles(toKeep)
5870 ## To set verbose level [0-10]. <ul>
5871 #<li> 0 - no standard output,
5872 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
5873 # indicates when the final mesh is being saved. In addition the software
5874 # gives indication regarding the CPU time.
5875 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
5876 # histogram of the skin mesh, quality statistics histogram together with
5877 # the characteristics of the final mesh.</ul>
5878 # @ingroup l3_hypos_ghs3dh
5879 def SetVerboseLevel(self, level):
5880 # Advanced parameter of GHS3D
5881 if self.Parameters():
5882 self.params.SetVerboseLevel(level)
5884 ## To create new nodes.
5885 # @ingroup l3_hypos_ghs3dh
5886 def SetToCreateNewNodes(self, toCreate):
5887 # Advanced parameter of GHS3D
5888 if self.Parameters():
5889 self.params.SetToCreateNewNodes(toCreate)
5891 ## To use boundary recovery version which tries to create mesh on a very poor
5892 # quality surface mesh.
5893 # @ingroup l3_hypos_ghs3dh
5894 def SetToUseBoundaryRecoveryVersion(self, toUse):
5895 # Advanced parameter of GHS3D
5896 if self.Parameters():
5897 self.params.SetToUseBoundaryRecoveryVersion(toUse)
5899 ## Applies finite-element correction by replacing overconstrained elements where
5900 # it is possible. The process is cutting first the overconstrained edges and
5901 # second the overconstrained facets. This insure that no edges have two boundary
5902 # vertices and that no facets have three boundary vertices.
5903 # @ingroup l3_hypos_ghs3dh
5904 def SetFEMCorrection(self, toUseFem):
5905 # Advanced parameter of GHS3D
5906 if self.Parameters():
5907 self.params.SetFEMCorrection(toUseFem)
5909 ## To removes initial central point.
5910 # @ingroup l3_hypos_ghs3dh
5911 def SetToRemoveCentralPoint(self, toRemove):
5912 # Advanced parameter of GHS3D
5913 if self.Parameters():
5914 self.params.SetToRemoveCentralPoint(toRemove)
5916 ## To set an enforced vertex.
5917 # @param x : x coordinate
5918 # @param y : y coordinate
5919 # @param z : z coordinate
5920 # @param size : size of 1D element around enforced vertex
5921 # @param vertexName : name of the enforced vertex
5922 # @param groupName : name of the group
5923 # @ingroup l3_hypos_ghs3dh
5924 def SetEnforcedVertex(self, x, y, z, size, vertexName = "", groupName = ""):
5925 # Advanced parameter of GHS3D
5926 if self.Parameters():
5927 if vertexName == "":
5929 return self.params.SetEnforcedVertex(x, y, z, size)
5931 return self.params.SetEnforcedVertexWithGroup(x, y, z, size, groupName)
5934 return self.params.SetEnforcedVertexNamed(x, y, z, size, vertexName)
5936 return self.params.SetEnforcedVertexNamedWithGroup(x, y, z, size, vertexName, groupName)
5938 ## To set an enforced vertex given a GEOM vertex, group or compound.
5939 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
5940 # @param size : size of 1D element around enforced vertex
5941 # @param groupName : name of the group
5942 # @ingroup l3_hypos_ghs3dh
5943 def SetEnforcedVertexGeom(self, theVertex, size, groupName = ""):
5944 AssureGeomPublished( self.mesh, theVertex )
5945 # Advanced parameter of GHS3D
5946 if self.Parameters():
5948 return self.params.SetEnforcedVertexGeom(theVertex, size)
5950 return self.params.SetEnforcedVertexGeomWithGroup(theVertex, size, groupName)
5952 ## To remove an enforced vertex.
5953 # @param x : x coordinate
5954 # @param y : y coordinate
5955 # @param z : z coordinate
5956 # @ingroup l3_hypos_ghs3dh
5957 def RemoveEnforcedVertex(self, x, y, z):
5958 # Advanced parameter of GHS3D
5959 if self.Parameters():
5960 return self.params.RemoveEnforcedVertex(x, y, z)
5962 ## To remove an enforced vertex given a GEOM vertex, group or compound.
5963 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
5964 # @ingroup l3_hypos_ghs3dh
5965 def RemoveEnforcedVertexGeom(self, theVertex):
5966 AssureGeomPublished( self.mesh, theVertex )
5967 # Advanced parameter of GHS3D
5968 if self.Parameters():
5969 return self.params.RemoveEnforcedVertexGeom(theVertex)
5971 ## To set an enforced mesh with given size and add the enforced elements in the group "groupName".
5972 # @param theSource : source mesh which provides constraint elements/nodes
5973 # @param elementType : SMESH.ElementType (NODE, EDGE or FACE)
5974 # @param size : size of elements around enforced elements. Unused if -1.
5975 # @param groupName : group in which enforced elements will be added. Unused if "".
5976 # @ingroup l3_hypos_ghs3dh
5977 def SetEnforcedMesh(self, theSource, elementType, size = -1, groupName = ""):
5978 # Advanced parameter of GHS3D
5979 if self.Parameters():
5982 return self.params.SetEnforcedMesh(theSource, elementType)
5984 return self.params.SetEnforcedMeshWithGroup(theSource, elementType, groupName)
5987 return self.params.SetEnforcedMeshSize(theSource, elementType, size)
5989 return self.params.SetEnforcedMeshSizeWithGroup(theSource, elementType, size, groupName)
5991 ## Sets command line option as text.
5992 # @ingroup l3_hypos_ghs3dh
5993 def SetTextOption(self, option):
5994 # Advanced parameter of GHS3D
5995 if self.Parameters():
5996 self.params.SetTextOption(option)
5998 ## Sets MED files name and path.
5999 def SetMEDName(self, value):
6000 if self.Parameters():
6001 self.params.SetMEDName(value)
6003 ## Sets the number of partition of the initial mesh
6004 def SetNbPart(self, value):
6005 if self.Parameters():
6006 self.params.SetNbPart(value)
6008 ## When big mesh, start tepal in background
6009 def SetBackground(self, value):
6010 if self.Parameters():
6011 self.params.SetBackground(value)
6013 # Public class: Mesh_Hexahedron
6014 # ------------------------------
6016 ## Defines a hexahedron 3D algorithm
6018 # @ingroup l3_algos_basic
6019 class Mesh_Hexahedron(Mesh_Algorithm):
6024 ## Private constructor.
6025 def __init__(self, mesh, algoType=Hexa, geom=0):
6026 Mesh_Algorithm.__init__(self)
6028 self.algoType = algoType
6030 if algoType == Hexa:
6031 self.Create(mesh, geom, "Hexa_3D")
6034 elif algoType == Hexotic:
6035 CheckPlugin(Hexotic)
6036 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
6039 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
6040 # @ingroup l3_hypos_hexotic
6041 def MinMaxQuad(self, min=3, max=8, quad=True):
6042 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
6044 self.params.SetHexesMinLevel(min)
6045 self.params.SetHexesMaxLevel(max)
6046 self.params.SetHexoticQuadrangles(quad)
6049 # Deprecated, only for compatibility!
6050 # Public class: Mesh_Netgen
6051 # ------------------------------
6053 ## Defines a NETGEN-based 2D or 3D algorithm
6054 # that needs no discrete boundary (i.e. independent)
6056 # This class is deprecated, only for compatibility!
6059 # @ingroup l3_algos_basic
6060 class Mesh_Netgen(Mesh_Algorithm):
6064 ## Private constructor.
6065 def __init__(self, mesh, is3D, geom=0):
6066 Mesh_Algorithm.__init__(self)
6072 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
6076 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
6079 ## Defines the hypothesis containing parameters of the algorithm
6080 def Parameters(self):
6082 hyp = self.Hypothesis("NETGEN_Parameters", [],
6083 "libNETGENEngine.so", UseExisting=0)
6085 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
6086 "libNETGENEngine.so", UseExisting=0)
6089 # Public class: Mesh_Projection1D
6090 # ------------------------------
6092 ## Defines a projection 1D algorithm
6093 # @ingroup l3_algos_proj
6095 class Mesh_Projection1D(Mesh_Algorithm):
6097 ## Private constructor.
6098 def __init__(self, mesh, geom=0):
6099 Mesh_Algorithm.__init__(self)
6100 self.Create(mesh, geom, "Projection_1D")
6102 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
6103 # a mesh pattern is taken, and, optionally, the association of vertices
6104 # between the source edge and a target edge (to which a hypothesis is assigned)
6105 # @param edge from which nodes distribution is taken
6106 # @param mesh from which nodes distribution is taken (optional)
6107 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
6108 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
6109 # to associate with \a srcV (optional)
6110 # @param UseExisting if ==true - searches for the existing hypothesis created with
6111 # the same parameters, else (default) - creates a new one
6112 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
6113 AssureGeomPublished( self.mesh, edge )
6114 AssureGeomPublished( self.mesh, srcV )
6115 AssureGeomPublished( self.mesh, tgtV )
6116 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
6118 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
6119 hyp.SetSourceEdge( edge )
6120 if not mesh is None and isinstance(mesh, Mesh):
6121 mesh = mesh.GetMesh()
6122 hyp.SetSourceMesh( mesh )
6123 hyp.SetVertexAssociation( srcV, tgtV )
6126 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
6127 #def CompareSourceEdge(self, hyp, args):
6128 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
6132 # Public class: Mesh_Projection2D
6133 # ------------------------------
6135 ## Defines a projection 2D algorithm
6136 # @ingroup l3_algos_proj
6138 class Mesh_Projection2D(Mesh_Algorithm):
6140 ## Private constructor.
6141 def __init__(self, mesh, geom=0, algoName="Projection_2D"):
6142 Mesh_Algorithm.__init__(self)
6143 self.Create(mesh, geom, algoName)
6145 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
6146 # a mesh pattern is taken, and, optionally, the association of vertices
6147 # between the source face and the target face (to which a hypothesis is assigned)
6148 # @param face from which the mesh pattern is taken
6149 # @param mesh from which the mesh pattern is taken (optional)
6150 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
6151 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
6152 # to associate with \a srcV1 (optional)
6153 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
6154 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
6155 # to associate with \a srcV2 (optional)
6156 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
6157 # the same parameters, else (default) - forces the creation a new one
6159 # Note: all association vertices must belong to one edge of a face
6160 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
6161 srcV2=None, tgtV2=None, UseExisting=0):
6162 for geom in [ face, srcV1, tgtV1, srcV2, tgtV2 ]:
6163 AssureGeomPublished( self.mesh, geom )
6164 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
6166 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
6167 hyp.SetSourceFace( face )
6168 if isinstance(mesh, Mesh):
6169 mesh = mesh.GetMesh()
6170 hyp.SetSourceMesh( mesh )
6171 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
6174 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
6175 #def CompareSourceFace(self, hyp, args):
6176 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
6179 # Public class: Mesh_Projection3D
6180 # ------------------------------
6182 ## Defines a projection 3D algorithm
6183 # @ingroup l3_algos_proj
6185 class Mesh_Projection3D(Mesh_Algorithm):
6187 ## Private constructor.
6188 def __init__(self, mesh, geom=0):
6189 Mesh_Algorithm.__init__(self)
6190 self.Create(mesh, geom, "Projection_3D")
6192 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
6193 # the mesh pattern is taken, and, optionally, the association of vertices
6194 # between the source and the target solid (to which a hipothesis is assigned)
6195 # @param solid from where the mesh pattern is taken
6196 # @param mesh from where the mesh pattern is taken (optional)
6197 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
6198 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
6199 # to associate with \a srcV1 (optional)
6200 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
6201 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
6202 # to associate with \a srcV2 (optional)
6203 # @param UseExisting - if ==true - searches for the existing hypothesis created with
6204 # the same parameters, else (default) - creates a new one
6206 # Note: association vertices must belong to one edge of a solid
6207 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
6208 srcV2=0, tgtV2=0, UseExisting=0):
6209 for geom in [ solid, srcV1, tgtV1, srcV2, tgtV2 ]:
6210 AssureGeomPublished( self.mesh, geom )
6211 hyp = self.Hypothesis("ProjectionSource3D",
6212 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
6214 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
6215 hyp.SetSource3DShape( solid )
6216 if not mesh is None and isinstance(mesh, Mesh):
6217 mesh = mesh.GetMesh()
6218 hyp.SetSourceMesh( mesh )
6219 if srcV1 and srcV2 and tgtV1 and tgtV2:
6220 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
6221 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
6224 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
6225 #def CompareSourceShape3D(self, hyp, args):
6226 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
6230 # Public class: Mesh_Prism
6231 # ------------------------
6233 ## Defines a 3D extrusion algorithm
6234 # @ingroup l3_algos_3dextr
6236 class Mesh_Prism3D(Mesh_Algorithm):
6238 ## Private constructor.
6239 def __init__(self, mesh, geom=0):
6240 Mesh_Algorithm.__init__(self)
6241 self.Create(mesh, geom, "Prism_3D")
6243 # Public class: Mesh_RadialPrism
6244 # -------------------------------
6246 ## Defines a Radial Prism 3D algorithm
6247 # @ingroup l3_algos_radialp
6249 class Mesh_RadialPrism3D(Mesh_Algorithm):
6251 ## Private constructor.
6252 def __init__(self, mesh, geom=0):
6253 Mesh_Algorithm.__init__(self)
6254 self.Create(mesh, geom, "RadialPrism_3D")
6256 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
6257 self.nbLayers = None
6259 ## Return 3D hypothesis holding the 1D one
6260 def Get3DHypothesis(self):
6261 return self.distribHyp
6263 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
6264 # hypothesis. Returns the created hypothesis
6265 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
6266 #print "OwnHypothesis",hypType
6267 if not self.nbLayers is None:
6268 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
6269 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
6270 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
6271 self.mesh.smeshpyD.SetCurrentStudy( None )
6272 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
6273 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
6274 self.distribHyp.SetLayerDistribution( hyp )
6277 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
6278 # prisms to build between the inner and outer shells
6279 # @param n number of layers
6280 # @param UseExisting if ==true - searches for the existing hypothesis created with
6281 # the same parameters, else (default) - creates a new one
6282 def NumberOfLayers(self, n, UseExisting=0):
6283 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
6284 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
6285 CompareMethod=self.CompareNumberOfLayers)
6286 self.nbLayers.SetNumberOfLayers( n )
6287 return self.nbLayers
6289 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
6290 def CompareNumberOfLayers(self, hyp, args):
6291 return IsEqual(hyp.GetNumberOfLayers(), args[0])
6293 ## Defines "LocalLength" hypothesis, specifying the segment length
6294 # to build between the inner and the outer shells
6295 # @param l the length of segments
6296 # @param p the precision of rounding
6297 def LocalLength(self, l, p=1e-07):
6298 hyp = self.OwnHypothesis("LocalLength", [l,p])
6303 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
6304 # prisms to build between the inner and the outer shells.
6305 # @param n the number of layers
6306 # @param s the scale factor (optional)
6307 def NumberOfSegments(self, n, s=[]):
6309 hyp = self.OwnHypothesis("NumberOfSegments", [n])
6311 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
6312 hyp.SetDistrType( 1 )
6313 hyp.SetScaleFactor(s)
6314 hyp.SetNumberOfSegments(n)
6317 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
6318 # to build between the inner and the outer shells with a length that changes in arithmetic progression
6319 # @param start the length of the first segment
6320 # @param end the length of the last segment
6321 def Arithmetic1D(self, start, end ):
6322 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
6323 hyp.SetLength(start, 1)
6324 hyp.SetLength(end , 0)
6327 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
6328 # to build between the inner and the outer shells as geometric length increasing
6329 # @param start for the length of the first segment
6330 # @param end for the length of the last segment
6331 def StartEndLength(self, start, end):
6332 hyp = self.OwnHypothesis("StartEndLength", [start, end])
6333 hyp.SetLength(start, 1)
6334 hyp.SetLength(end , 0)
6337 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
6338 # to build between the inner and outer shells
6339 # @param fineness defines the quality of the mesh within the range [0-1]
6340 def AutomaticLength(self, fineness=0):
6341 hyp = self.OwnHypothesis("AutomaticLength")
6342 hyp.SetFineness( fineness )
6345 # Public class: Mesh_RadialQuadrangle1D2D
6346 # -------------------------------
6348 ## Defines a Radial Quadrangle 1D2D algorithm
6349 # @ingroup l2_algos_radialq
6351 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
6353 ## Private constructor.
6354 def __init__(self, mesh, geom=0):
6355 Mesh_Algorithm.__init__(self)
6356 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
6358 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
6359 self.nbLayers = None
6361 ## Return 2D hypothesis holding the 1D one
6362 def Get2DHypothesis(self):
6363 return self.distribHyp
6365 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
6366 # hypothesis. Returns the created hypothesis
6367 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
6368 #print "OwnHypothesis",hypType
6370 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
6371 if self.distribHyp is None:
6372 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
6374 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
6375 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
6376 self.mesh.smeshpyD.SetCurrentStudy( None )
6377 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
6378 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
6379 self.distribHyp.SetLayerDistribution( hyp )
6382 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
6383 # @param n number of layers
6384 # @param UseExisting if ==true - searches for the existing hypothesis created with
6385 # the same parameters, else (default) - creates a new one
6386 def NumberOfLayers(self, n, UseExisting=0):
6388 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
6389 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
6390 CompareMethod=self.CompareNumberOfLayers)
6391 self.nbLayers.SetNumberOfLayers( n )
6392 return self.nbLayers
6394 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
6395 def CompareNumberOfLayers(self, hyp, args):
6396 return IsEqual(hyp.GetNumberOfLayers(), args[0])
6398 ## Defines "LocalLength" hypothesis, specifying the segment length
6399 # @param l the length of segments
6400 # @param p the precision of rounding
6401 def LocalLength(self, l, p=1e-07):
6402 hyp = self.OwnHypothesis("LocalLength", [l,p])
6407 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
6408 # @param n the number of layers
6409 # @param s the scale factor (optional)
6410 def NumberOfSegments(self, n, s=[]):
6412 hyp = self.OwnHypothesis("NumberOfSegments", [n])
6414 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
6415 hyp.SetDistrType( 1 )
6416 hyp.SetScaleFactor(s)
6417 hyp.SetNumberOfSegments(n)
6420 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
6421 # with a length that changes in arithmetic progression
6422 # @param start the length of the first segment
6423 # @param end the length of the last segment
6424 def Arithmetic1D(self, start, end ):
6425 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
6426 hyp.SetLength(start, 1)
6427 hyp.SetLength(end , 0)
6430 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
6431 # as geometric length increasing
6432 # @param start for the length of the first segment
6433 # @param end for the length of the last segment
6434 def StartEndLength(self, start, end):
6435 hyp = self.OwnHypothesis("StartEndLength", [start, end])
6436 hyp.SetLength(start, 1)
6437 hyp.SetLength(end , 0)
6440 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
6441 # @param fineness defines the quality of the mesh within the range [0-1]
6442 def AutomaticLength(self, fineness=0):
6443 hyp = self.OwnHypothesis("AutomaticLength")
6444 hyp.SetFineness( fineness )
6448 # Public class: Mesh_UseExistingElements
6449 # --------------------------------------
6450 ## Defines a Radial Quadrangle 1D2D algorithm
6451 # @ingroup l3_algos_basic
6453 class Mesh_UseExistingElements(Mesh_Algorithm):
6455 def __init__(self, dim, mesh, geom=0):
6457 self.Create(mesh, geom, "Import_1D")
6459 self.Create(mesh, geom, "Import_1D2D")
6462 ## Defines "Source edges" hypothesis, specifying groups of edges to import
6463 # @param groups list of groups of edges
6464 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
6465 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
6466 # @param UseExisting if ==true - searches for the existing hypothesis created with
6467 # the same parameters, else (default) - creates a new one
6468 def SourceEdges(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
6469 if self.algo.GetName() != "Import_1D":
6470 raise ValueError, "algoritm dimension mismatch"
6471 for group in groups:
6472 AssureGeomPublished( self.mesh, group )
6473 hyp = self.Hypothesis("ImportSource1D", [groups, toCopyMesh, toCopyGroups],
6474 UseExisting=UseExisting, CompareMethod=self._compareHyp)
6475 hyp.SetSourceEdges(groups)
6476 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
6479 ## Defines "Source faces" hypothesis, specifying groups of faces to import
6480 # @param groups list of groups of faces
6481 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
6482 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
6483 # @param UseExisting if ==true - searches for the existing hypothesis created with
6484 # the same parameters, else (default) - creates a new one
6485 def SourceFaces(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
6486 if self.algo.GetName() == "Import_1D":
6487 raise ValueError, "algoritm dimension mismatch"
6488 for group in groups:
6489 AssureGeomPublished( self.mesh, group )
6490 hyp = self.Hypothesis("ImportSource2D", [groups, toCopyMesh, toCopyGroups],
6491 UseExisting=UseExisting, CompareMethod=self._compareHyp)
6492 hyp.SetSourceFaces(groups)
6493 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
6496 def _compareHyp(self,hyp,args):
6497 if hasattr( hyp, "GetSourceEdges"):
6498 entries = hyp.GetSourceEdges()
6500 entries = hyp.GetSourceFaces()
6502 toCopyMesh,toCopyGroups = hyp.GetCopySourceMesh()
6503 if len(entries)==len(groups) and toCopyMesh==args[1] and toCopyGroups==args[2]:
6505 study = self.mesh.smeshpyD.GetCurrentStudy()
6508 ior = salome.orb.object_to_string(g)
6509 sobj = study.FindObjectIOR(ior)
6510 if sobj: entries2.append( sobj.GetID() )
6515 return entries == entries2
6518 # Public class: Mesh_Cartesian_3D
6519 # --------------------------------------
6520 ## Defines a Body Fitting 3D algorithm
6521 # @ingroup l3_algos_basic
6523 class Mesh_Cartesian_3D(Mesh_Algorithm):
6525 def __init__(self, mesh, geom=0):
6526 self.Create(mesh, geom, "Cartesian_3D")
6529 ## Defines "Body Fitting parameters" hypothesis
6530 # @param xCoords coordinates of grid nodes along the X asix
6531 # @param yCoords coordinates of grid nodes along the Y asix
6532 # @param zCoords coordinates of grid nodes along the Z asix
6533 # @param sizeThreshold size (> 1.0) defines a minimal size of a polyhedron so that
6534 # a polyhedron of size less than hexSize/sizeThreshold is not created
6535 # @param UseExisting if ==true - searches for the existing hypothesis created with
6536 # the same parameters, else (default) - creates a new one
6537 def SetGrid(self, xCoords, yCoords, zCoords, sizeThreshold, UseExisting=False):
6538 hyp = self.Hypothesis("CartesianParameters3D", [xCoords, yCoords, zCoords, sizeThreshold],
6539 UseExisting=UseExisting, CompareMethod=self._compareHyp)
6540 hyp.SetGrid(xCoords, 0 )
6541 hyp.SetGrid(yCoords, 1 )
6542 hyp.SetGrid(zCoords, 2 )
6543 hyp.SetSizeThreshold( sizeThreshold )
6546 ## Defines "Body Fitting parameters" hypothesis
6547 # @param xSpaceFuns functions f(t) defining spacing value at given point on X axis.
6548 # Parameter t of \axSpaceFuns is a position [0.,1.] withing bounding box of
6549 # the shape to mesh or withing an interval defined by internal points
6550 # @param ySpaceFuns functions f(t) defining spacing value at given point on Y axis.
6551 # @param zSpaceFuns functions f(t) defining spacing value at given point on Z axis.
6552 # @param xInternalPoints points (0.,1.) dividing a grid into parts along X direction.
6553 # Number of \axInternalPoints must be one less than number of \axSpaceFuns
6554 # @param yInternalPoints points (0.,1.) dividing a grid into parts along Y direction.
6555 # @param zInternalPoints points (0.,1.) dividing a grid into parts along Z direction.
6556 # @param sizeThreshold size (> 1.0) defines a minimal size of a polyhedron so that
6557 # a polyhedron of size less than hexSize/sizeThreshold is not created
6558 # @param UseExisting if ==true - searches for the existing hypothesis created with
6559 # the same parameters, else (default) - creates a new one
6560 def SetSpacing(self,
6561 xSpaceFuns, ySpaceFuns, zSpaceFuns,
6562 xInternalPoints, yInternalPoints, zInternalPoints,
6563 sizeThreshold, UseExisting=False):
6564 hyp = self.Hypothesis("CartesianParameters3D",
6565 [xSpaceFuns, ySpaceFuns, zSpaceFuns, \
6566 xInternalPoints, yInternalPoints, zInternalPoints],
6567 UseExisting=UseExisting, CompareMethod=self._compareHyp)
6568 hyp.SetGridSpacing(xSpaceFuns, xInternalPoints, 0)
6569 hyp.SetGridSpacing(ySpaceFuns, yInternalPoints, 1)
6570 hyp.SetGridSpacing(zSpaceFuns, zInternalPoints, 2)
6571 hyp.SetSizeThreshold( sizeThreshold )
6574 def _compareHyp(self,hyp,args):
6575 # not implemented yet
6578 # Public class: Mesh_UseExisting
6579 # -------------------------------
6580 class Mesh_UseExisting(Mesh_Algorithm):
6582 def __init__(self, dim, mesh, geom=0):
6584 self.Create(mesh, geom, "UseExisting_1D")
6586 self.Create(mesh, geom, "UseExisting_2D")
6589 import salome_notebook
6590 notebook = salome_notebook.notebook
6592 ##Return values of the notebook variables
6593 def ParseParameters(last, nbParams,nbParam, value):
6597 listSize = len(last)
6598 for n in range(0,nbParams):
6600 if counter < listSize:
6601 strResult = strResult + last[counter]
6603 strResult = strResult + ""
6605 if isinstance(value, str):
6606 if notebook.isVariable(value):
6607 result = notebook.get(value)
6608 strResult=strResult+value
6610 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
6612 strResult=strResult+str(value)
6614 if nbParams - 1 != counter:
6615 strResult=strResult+var_separator #":"
6617 return result, strResult
6619 #Wrapper class for StdMeshers_LocalLength hypothesis
6620 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
6622 ## Set Length parameter value
6623 # @param length numerical value or name of variable from notebook
6624 def SetLength(self, length):
6625 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
6626 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6627 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
6629 ## Set Precision parameter value
6630 # @param precision numerical value or name of variable from notebook
6631 def SetPrecision(self, precision):
6632 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
6633 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6634 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
6636 #Registering the new proxy for LocalLength
6637 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
6640 #Wrapper class for StdMeshers_LayerDistribution hypothesis
6641 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
6643 def SetLayerDistribution(self, hypo):
6644 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
6645 hypo.ClearParameters();
6646 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
6648 #Registering the new proxy for LayerDistribution
6649 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
6651 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
6652 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
6654 ## Set Length parameter value
6655 # @param length numerical value or name of variable from notebook
6656 def SetLength(self, length):
6657 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
6658 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
6659 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
6661 #Registering the new proxy for SegmentLengthAroundVertex
6662 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
6665 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
6666 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
6668 ## Set Length parameter value
6669 # @param length numerical value or name of variable from notebook
6670 # @param isStart true is length is Start Length, otherwise false
6671 def SetLength(self, length, isStart):
6675 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
6676 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
6677 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
6679 #Registering the new proxy for Arithmetic1D
6680 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
6682 #Wrapper class for StdMeshers_Deflection1D hypothesis
6683 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
6685 ## Set Deflection parameter value
6686 # @param deflection numerical value or name of variable from notebook
6687 def SetDeflection(self, deflection):
6688 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
6689 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
6690 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
6692 #Registering the new proxy for Deflection1D
6693 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
6695 #Wrapper class for StdMeshers_StartEndLength hypothesis
6696 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
6698 ## Set Length parameter value
6699 # @param length numerical value or name of variable from notebook
6700 # @param isStart true is length is Start Length, otherwise false
6701 def SetLength(self, length, isStart):
6705 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
6706 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
6707 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
6709 #Registering the new proxy for StartEndLength
6710 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
6712 #Wrapper class for StdMeshers_MaxElementArea hypothesis
6713 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
6715 ## Set Max Element Area parameter value
6716 # @param area numerical value or name of variable from notebook
6717 def SetMaxElementArea(self, area):
6718 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
6719 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
6720 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
6722 #Registering the new proxy for MaxElementArea
6723 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
6726 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
6727 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
6729 ## Set Max Element Volume parameter value
6730 # @param volume numerical value or name of variable from notebook
6731 def SetMaxElementVolume(self, volume):
6732 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
6733 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
6734 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
6736 #Registering the new proxy for MaxElementVolume
6737 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
6740 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
6741 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
6743 ## Set Number Of Layers parameter value
6744 # @param nbLayers numerical value or name of variable from notebook
6745 def SetNumberOfLayers(self, nbLayers):
6746 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
6747 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
6748 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
6750 #Registering the new proxy for NumberOfLayers
6751 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
6753 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
6754 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
6756 ## Set Number Of Segments parameter value
6757 # @param nbSeg numerical value or name of variable from notebook
6758 def SetNumberOfSegments(self, nbSeg):
6759 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
6760 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
6761 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6762 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
6764 ## Set Scale Factor parameter value
6765 # @param factor numerical value or name of variable from notebook
6766 def SetScaleFactor(self, factor):
6767 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
6768 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6769 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
6771 #Registering the new proxy for NumberOfSegments
6772 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
6774 if not noNETGENPlugin:
6775 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
6776 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
6778 ## Set Max Size parameter value
6779 # @param maxsize numerical value or name of variable from notebook
6780 def SetMaxSize(self, maxsize):
6781 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6782 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
6783 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6784 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
6786 ## Set Growth Rate parameter value
6787 # @param value numerical value or name of variable from notebook
6788 def SetGrowthRate(self, value):
6789 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6790 value, parameters = ParseParameters(lastParameters,4,2,value)
6791 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6792 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
6794 ## Set Number of Segments per Edge parameter value
6795 # @param value numerical value or name of variable from notebook
6796 def SetNbSegPerEdge(self, value):
6797 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6798 value, parameters = ParseParameters(lastParameters,4,3,value)
6799 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6800 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
6802 ## Set Number of Segments per Radius parameter value
6803 # @param value numerical value or name of variable from notebook
6804 def SetNbSegPerRadius(self, value):
6805 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6806 value, parameters = ParseParameters(lastParameters,4,4,value)
6807 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6808 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
6810 #Registering the new proxy for NETGENPlugin_Hypothesis
6811 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
6814 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
6815 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
6818 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
6819 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
6821 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
6822 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
6824 ## Set Number of Segments parameter value
6825 # @param nbSeg numerical value or name of variable from notebook
6826 def SetNumberOfSegments(self, nbSeg):
6827 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6828 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
6829 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6830 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
6832 ## Set Local Length parameter value
6833 # @param length numerical value or name of variable from notebook
6834 def SetLocalLength(self, length):
6835 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6836 length, parameters = ParseParameters(lastParameters,2,1,length)
6837 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6838 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
6840 ## Set Max Element Area parameter value
6841 # @param area numerical value or name of variable from notebook
6842 def SetMaxElementArea(self, area):
6843 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6844 area, parameters = ParseParameters(lastParameters,2,2,area)
6845 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6846 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
6848 def LengthFromEdges(self):
6849 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6851 value, parameters = ParseParameters(lastParameters,2,2,value)
6852 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6853 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
6855 #Registering the new proxy for NETGEN_SimpleParameters_2D
6856 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
6859 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
6860 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
6861 ## Set Max Element Volume parameter value
6862 # @param volume numerical value or name of variable from notebook
6863 def SetMaxElementVolume(self, volume):
6864 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6865 volume, parameters = ParseParameters(lastParameters,3,3,volume)
6866 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6867 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
6869 def LengthFromFaces(self):
6870 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6872 value, parameters = ParseParameters(lastParameters,3,3,value)
6873 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6874 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
6876 #Registering the new proxy for NETGEN_SimpleParameters_3D
6877 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
6879 pass # if not noNETGENPlugin:
6881 class Pattern(SMESH._objref_SMESH_Pattern):
6883 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
6885 if isinstance(theNodeIndexOnKeyPoint1,str):
6887 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
6889 theNodeIndexOnKeyPoint1 -= 1
6890 theMesh.SetParameters(Parameters)
6891 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
6893 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
6896 if isinstance(theNode000Index,str):
6898 if isinstance(theNode001Index,str):
6900 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
6902 theNode000Index -= 1
6904 theNode001Index -= 1
6905 theMesh.SetParameters(Parameters)
6906 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
6908 #Registering the new proxy for Pattern
6909 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)