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 ## Return True if an algorithm of hypothesis is assigned to a given shape
1716 # @param hyp a hypothesis to check
1717 # @param geom a subhape of mesh geometry
1718 # @return True of False
1719 # @ingroup l2_hypotheses
1720 def IsUsedHypothesis(self, hyp, geom):
1721 if not hyp or not geom:
1723 if isinstance( hyp, Mesh_Algorithm ):
1724 hyp = hyp.GetAlgorithm()
1726 hyps = self.GetHypothesisList(geom)
1728 if h.GetId() == hyp.GetId():
1732 ## Unassigns a hypothesis
1733 # @param hyp a hypothesis to unassign
1734 # @param geom a subshape of mesh geometry
1735 # @return SMESH.Hypothesis_Status
1736 # @ingroup l2_hypotheses
1737 def RemoveHypothesis(self, hyp, geom=0):
1738 if isinstance( hyp, Mesh_Algorithm ):
1739 hyp = hyp.GetAlgorithm()
1744 status = self.mesh.RemoveHypothesis(geom, hyp)
1747 ## Gets the list of hypotheses added on a geometry
1748 # @param geom a subshape of mesh geometry
1749 # @return the sequence of SMESH_Hypothesis
1750 # @ingroup l2_hypotheses
1751 def GetHypothesisList(self, geom):
1752 return self.mesh.GetHypothesisList( geom )
1754 ## Removes all global hypotheses
1755 # @ingroup l2_hypotheses
1756 def RemoveGlobalHypotheses(self):
1757 current_hyps = self.mesh.GetHypothesisList( self.geom )
1758 for hyp in current_hyps:
1759 self.mesh.RemoveHypothesis( self.geom, hyp )
1763 ## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead.
1764 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1765 ## allowing to overwrite the file if it exists or add the exported data to its contents
1766 # @param f the file name
1767 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1768 # @param opt boolean parameter for creating/not creating
1769 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1770 # @param overwrite boolean parameter for overwriting/not overwriting the file
1771 # @ingroup l2_impexp
1772 def ExportToMED(self, f, version, opt=0, overwrite=1):
1773 self.mesh.ExportToMEDX(f, opt, version, overwrite)
1775 ## Exports the mesh in a file in MED format and chooses the \a version of MED format
1776 ## allowing to overwrite the file if it exists or add the exported data to its contents
1777 # @param f 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 # @param version MED format version(MED_V2_1 or MED_V2_2)
1782 # @param overwrite boolean parameter for overwriting/not overwriting the file
1783 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1784 # @ingroup l2_impexp
1785 def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1, meshPart=None):
1787 if isinstance( meshPart, list ):
1788 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1789 self.mesh.ExportPartToMED( meshPart, f, auto_groups, version, overwrite )
1791 self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
1793 ## Exports the mesh in a file in SAUV format
1794 # @param f is the file name
1795 # @param auto_groups boolean parameter for creating/not creating
1796 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1797 # the typical use is auto_groups=false.
1798 # @ingroup l2_impexp
1799 def ExportSAUV(self, f, auto_groups=0):
1800 self.mesh.ExportSAUV(f, auto_groups)
1802 ## Exports the mesh in a file in DAT format
1803 # @param f the file name
1804 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1805 # @ingroup l2_impexp
1806 def ExportDAT(self, f, meshPart=None):
1808 if isinstance( meshPart, list ):
1809 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1810 self.mesh.ExportPartToDAT( meshPart, f )
1812 self.mesh.ExportDAT(f)
1814 ## Exports the mesh in a file in UNV format
1815 # @param f the file name
1816 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1817 # @ingroup l2_impexp
1818 def ExportUNV(self, f, meshPart=None):
1820 if isinstance( meshPart, list ):
1821 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1822 self.mesh.ExportPartToUNV( meshPart, f )
1824 self.mesh.ExportUNV(f)
1826 ## Export the mesh in a file in STL format
1827 # @param f the file name
1828 # @param ascii defines the file encoding
1829 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1830 # @ingroup l2_impexp
1831 def ExportSTL(self, f, ascii=1, meshPart=None):
1833 if isinstance( meshPart, list ):
1834 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1835 self.mesh.ExportPartToSTL( meshPart, f, ascii )
1837 self.mesh.ExportSTL(f, ascii)
1839 ## Exports the mesh in a file in CGNS format
1840 # @param f is the file name
1841 # @param overwrite boolean parameter for overwriting/not overwriting the file
1842 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1843 # @ingroup l2_impexp
1844 def ExportCGNS(self, f, overwrite=1, meshPart=None):
1845 if isinstance( meshPart, list ):
1846 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1847 if isinstance( meshPart, Mesh ):
1848 meshPart = meshPart.mesh
1850 meshPart = self.mesh
1851 self.mesh.ExportCGNS(meshPart, f, overwrite)
1853 # Operations with groups:
1854 # ----------------------
1856 ## Creates an empty mesh group
1857 # @param elementType the type of elements in the group
1858 # @param name the name of the mesh group
1859 # @return SMESH_Group
1860 # @ingroup l2_grps_create
1861 def CreateEmptyGroup(self, elementType, name):
1862 return self.mesh.CreateGroup(elementType, name)
1864 ## Creates a mesh group based on the geometric object \a grp
1865 # and gives a \a name, \n if this parameter is not defined
1866 # the name is the same as the geometric group name \n
1867 # Note: Works like GroupOnGeom().
1868 # @param grp a geometric group, a vertex, an edge, a face or a solid
1869 # @param name the name of the mesh group
1870 # @return SMESH_GroupOnGeom
1871 # @ingroup l2_grps_create
1872 def Group(self, grp, name=""):
1873 return self.GroupOnGeom(grp, name)
1875 ## Creates a mesh group based on the geometrical object \a grp
1876 # and gives a \a name, \n if this parameter is not defined
1877 # the name is the same as the geometrical group name
1878 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1879 # @param name the name of the mesh group
1880 # @param typ the type of elements in the group. If not set, it is
1881 # automatically detected by the type of the geometry
1882 # @return SMESH_GroupOnGeom
1883 # @ingroup l2_grps_create
1884 def GroupOnGeom(self, grp, name="", typ=None):
1885 AssureGeomPublished( self, grp, name )
1887 name = grp.GetName()
1889 typ = self._groupTypeFromShape( grp )
1890 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1892 ## Pivate method to get a type of group on geometry
1893 def _groupTypeFromShape( self, shape ):
1894 tgeo = str(shape.GetShapeType())
1895 if tgeo == "VERTEX":
1897 elif tgeo == "EDGE":
1899 elif tgeo == "FACE" or tgeo == "SHELL":
1901 elif tgeo == "SOLID" or tgeo == "COMPSOLID":
1903 elif tgeo == "COMPOUND":
1904 sub = self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHAPE"])
1906 raise ValueError,"_groupTypeFromShape(): empty geometric group or compound '%s'" % GetName(shape)
1907 return self._groupTypeFromShape( sub[0] )
1910 "_groupTypeFromShape(): invalid geometry '%s'" % GetName(shape)
1913 ## Creates a mesh group with given \a name based on the \a filter which
1914 ## is a special type of group dynamically updating it's contents during
1915 ## mesh modification
1916 # @param typ the type of elements in the group
1917 # @param name the name of the mesh group
1918 # @param filter the filter defining group contents
1919 # @return SMESH_GroupOnFilter
1920 # @ingroup l2_grps_create
1921 def GroupOnFilter(self, typ, name, filter):
1922 return self.mesh.CreateGroupFromFilter(typ, name, filter)
1924 ## Creates a mesh group by the given ids of elements
1925 # @param groupName the name of the mesh group
1926 # @param elementType the type of elements in the group
1927 # @param elemIDs the list of ids
1928 # @return SMESH_Group
1929 # @ingroup l2_grps_create
1930 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1931 group = self.mesh.CreateGroup(elementType, groupName)
1935 ## Creates a mesh group by the given conditions
1936 # @param groupName the name of the mesh group
1937 # @param elementType the type of elements in the group
1938 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1939 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1940 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1941 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1942 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
1943 # FT_LyingOnGeom, FT_CoplanarFaces criteria
1944 # @return SMESH_Group
1945 # @ingroup l2_grps_create
1949 CritType=FT_Undefined,
1952 UnaryOp=FT_Undefined,
1954 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined,Tolerance)
1955 group = self.MakeGroupByCriterion(groupName, aCriterion)
1958 ## Creates a mesh group by the given criterion
1959 # @param groupName the name of the mesh group
1960 # @param Criterion the instance of Criterion class
1961 # @return SMESH_Group
1962 # @ingroup l2_grps_create
1963 def MakeGroupByCriterion(self, groupName, Criterion):
1964 aFilterMgr = self.smeshpyD.CreateFilterManager()
1965 aFilter = aFilterMgr.CreateFilter()
1967 aCriteria.append(Criterion)
1968 aFilter.SetCriteria(aCriteria)
1969 group = self.MakeGroupByFilter(groupName, aFilter)
1970 aFilterMgr.UnRegister()
1973 ## Creates a mesh group by the given criteria (list of criteria)
1974 # @param groupName the name of the mesh group
1975 # @param theCriteria the list of criteria
1976 # @return SMESH_Group
1977 # @ingroup l2_grps_create
1978 def MakeGroupByCriteria(self, groupName, theCriteria):
1979 aFilterMgr = self.smeshpyD.CreateFilterManager()
1980 aFilter = aFilterMgr.CreateFilter()
1981 aFilter.SetCriteria(theCriteria)
1982 group = self.MakeGroupByFilter(groupName, aFilter)
1983 aFilterMgr.UnRegister()
1986 ## Creates a mesh group by the given filter
1987 # @param groupName the name of the mesh group
1988 # @param theFilter the instance of Filter class
1989 # @return SMESH_Group
1990 # @ingroup l2_grps_create
1991 def MakeGroupByFilter(self, groupName, theFilter):
1992 group = self.CreateEmptyGroup(theFilter.GetElementType(), groupName)
1993 theFilter.SetMesh( self.mesh )
1994 group.AddFrom( theFilter )
1997 ## Passes mesh elements through the given filter and return IDs of fitting elements
1998 # @param theFilter SMESH_Filter
1999 # @return a list of ids
2000 # @ingroup l1_controls
2001 def GetIdsFromFilter(self, theFilter):
2002 theFilter.SetMesh( self.mesh )
2003 return theFilter.GetIDs()
2005 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
2006 # Returns a list of special structures (borders).
2007 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
2008 # @ingroup l1_controls
2009 def GetFreeBorders(self):
2010 aFilterMgr = self.smeshpyD.CreateFilterManager()
2011 aPredicate = aFilterMgr.CreateFreeEdges()
2012 aPredicate.SetMesh(self.mesh)
2013 aBorders = aPredicate.GetBorders()
2014 aFilterMgr.UnRegister()
2018 # @ingroup l2_grps_delete
2019 def RemoveGroup(self, group):
2020 self.mesh.RemoveGroup(group)
2022 ## Removes a group with its contents
2023 # @ingroup l2_grps_delete
2024 def RemoveGroupWithContents(self, group):
2025 self.mesh.RemoveGroupWithContents(group)
2027 ## Gets the list of groups existing in the mesh
2028 # @return a sequence of SMESH_GroupBase
2029 # @ingroup l2_grps_create
2030 def GetGroups(self):
2031 return self.mesh.GetGroups()
2033 ## Gets the number of groups existing in the mesh
2034 # @return the quantity of groups as an integer value
2035 # @ingroup l2_grps_create
2037 return self.mesh.NbGroups()
2039 ## Gets the list of names of groups existing in the mesh
2040 # @return list of strings
2041 # @ingroup l2_grps_create
2042 def GetGroupNames(self):
2043 groups = self.GetGroups()
2045 for group in groups:
2046 names.append(group.GetName())
2049 ## Produces a union of two groups
2050 # A new group is created. All mesh elements that are
2051 # present in the initial groups are added to the new one
2052 # @return an instance of SMESH_Group
2053 # @ingroup l2_grps_operon
2054 def UnionGroups(self, group1, group2, name):
2055 return self.mesh.UnionGroups(group1, group2, name)
2057 ## Produces a union list of groups
2058 # New group is created. All mesh elements that are present in
2059 # initial groups are added to the new one
2060 # @return an instance of SMESH_Group
2061 # @ingroup l2_grps_operon
2062 def UnionListOfGroups(self, groups, name):
2063 return self.mesh.UnionListOfGroups(groups, name)
2065 ## Prodices an intersection of two groups
2066 # A new group is created. All mesh elements that are common
2067 # for the two initial groups are added to the new one.
2068 # @return an instance of SMESH_Group
2069 # @ingroup l2_grps_operon
2070 def IntersectGroups(self, group1, group2, name):
2071 return self.mesh.IntersectGroups(group1, group2, name)
2073 ## Produces an intersection of groups
2074 # New group is created. All mesh elements that are present in all
2075 # initial groups simultaneously are added to the new one
2076 # @return an instance of SMESH_Group
2077 # @ingroup l2_grps_operon
2078 def IntersectListOfGroups(self, groups, name):
2079 return self.mesh.IntersectListOfGroups(groups, name)
2081 ## Produces a cut of two groups
2082 # A new group is created. All mesh elements that are present in
2083 # the main group but are not present in the tool group are added to the new one
2084 # @return an instance of SMESH_Group
2085 # @ingroup l2_grps_operon
2086 def CutGroups(self, main_group, tool_group, name):
2087 return self.mesh.CutGroups(main_group, tool_group, name)
2089 ## Produces a cut of groups
2090 # A new group is created. All mesh elements that are present in main groups
2091 # but do not present in tool groups are added to the new one
2092 # @return an instance of SMESH_Group
2093 # @ingroup l2_grps_operon
2094 def CutListOfGroups(self, main_groups, tool_groups, name):
2095 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
2097 ## Produces a group of elements of specified type using list of existing groups
2098 # A new group is created. System
2099 # 1) extracts all nodes on which groups elements are built
2100 # 2) combines all elements of specified dimension laying on these nodes
2101 # @return an instance of SMESH_Group
2102 # @ingroup l2_grps_operon
2103 def CreateDimGroup(self, groups, elem_type, name):
2104 return self.mesh.CreateDimGroup(groups, elem_type, name)
2107 ## Convert group on geom into standalone group
2108 # @ingroup l2_grps_delete
2109 def ConvertToStandalone(self, group):
2110 return self.mesh.ConvertToStandalone(group)
2112 # Get some info about mesh:
2113 # ------------------------
2115 ## Returns the log of nodes and elements added or removed
2116 # since the previous clear of the log.
2117 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
2118 # @return list of log_block structures:
2123 # @ingroup l1_auxiliary
2124 def GetLog(self, clearAfterGet):
2125 return self.mesh.GetLog(clearAfterGet)
2127 ## Clears the log of nodes and elements added or removed since the previous
2128 # clear. Must be used immediately after GetLog if clearAfterGet is false.
2129 # @ingroup l1_auxiliary
2131 self.mesh.ClearLog()
2133 ## Toggles auto color mode on the object.
2134 # @param theAutoColor the flag which toggles auto color mode.
2135 # @ingroup l1_auxiliary
2136 def SetAutoColor(self, theAutoColor):
2137 self.mesh.SetAutoColor(theAutoColor)
2139 ## Gets flag of object auto color mode.
2140 # @return True or False
2141 # @ingroup l1_auxiliary
2142 def GetAutoColor(self):
2143 return self.mesh.GetAutoColor()
2145 ## Gets the internal ID
2146 # @return integer value, which is the internal Id of the mesh
2147 # @ingroup l1_auxiliary
2149 return self.mesh.GetId()
2152 # @return integer value, which is the study Id of the mesh
2153 # @ingroup l1_auxiliary
2154 def GetStudyId(self):
2155 return self.mesh.GetStudyId()
2157 ## Checks the group names for duplications.
2158 # Consider the maximum group name length stored in MED file.
2159 # @return True or False
2160 # @ingroup l1_auxiliary
2161 def HasDuplicatedGroupNamesMED(self):
2162 return self.mesh.HasDuplicatedGroupNamesMED()
2164 ## Obtains the mesh editor tool
2165 # @return an instance of SMESH_MeshEditor
2166 # @ingroup l1_modifying
2167 def GetMeshEditor(self):
2168 return self.mesh.GetMeshEditor()
2170 ## Wrap a list of IDs of elements or nodes into SMESH_IDSource which
2171 # can be passed as argument to accepting mesh, group or sub-mesh
2172 # @return an instance of SMESH_IDSource
2173 # @ingroup l1_auxiliary
2174 def GetIDSource(self, ids, elemType):
2175 return self.GetMeshEditor().MakeIDSource(ids, elemType)
2178 # @return an instance of SALOME_MED::MESH
2179 # @ingroup l1_auxiliary
2180 def GetMEDMesh(self):
2181 return self.mesh.GetMEDMesh()
2184 # Get informations about mesh contents:
2185 # ------------------------------------
2187 ## Gets the mesh stattistic
2188 # @return dictionary type element - count of elements
2189 # @ingroup l1_meshinfo
2190 def GetMeshInfo(self, obj = None):
2191 if not obj: obj = self.mesh
2192 return self.smeshpyD.GetMeshInfo(obj)
2194 ## Returns the number of nodes in the mesh
2195 # @return an integer value
2196 # @ingroup l1_meshinfo
2198 return self.mesh.NbNodes()
2200 ## Returns the number of elements in the mesh
2201 # @return an integer value
2202 # @ingroup l1_meshinfo
2203 def NbElements(self):
2204 return self.mesh.NbElements()
2206 ## Returns the number of 0d elements in the mesh
2207 # @return an integer value
2208 # @ingroup l1_meshinfo
2209 def Nb0DElements(self):
2210 return self.mesh.Nb0DElements()
2212 ## Returns the number of edges in the mesh
2213 # @return an integer value
2214 # @ingroup l1_meshinfo
2216 return self.mesh.NbEdges()
2218 ## Returns the number of edges with the given order in the mesh
2219 # @param elementOrder the order of elements:
2220 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2221 # @return an integer value
2222 # @ingroup l1_meshinfo
2223 def NbEdgesOfOrder(self, elementOrder):
2224 return self.mesh.NbEdgesOfOrder(elementOrder)
2226 ## Returns the number of faces in the mesh
2227 # @return an integer value
2228 # @ingroup l1_meshinfo
2230 return self.mesh.NbFaces()
2232 ## Returns the number of faces with the given order in the mesh
2233 # @param elementOrder the order of elements:
2234 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2235 # @return an integer value
2236 # @ingroup l1_meshinfo
2237 def NbFacesOfOrder(self, elementOrder):
2238 return self.mesh.NbFacesOfOrder(elementOrder)
2240 ## Returns the number of triangles in the mesh
2241 # @return an integer value
2242 # @ingroup l1_meshinfo
2243 def NbTriangles(self):
2244 return self.mesh.NbTriangles()
2246 ## Returns the number of triangles with the given order in the mesh
2247 # @param elementOrder is the order of elements:
2248 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2249 # @return an integer value
2250 # @ingroup l1_meshinfo
2251 def NbTrianglesOfOrder(self, elementOrder):
2252 return self.mesh.NbTrianglesOfOrder(elementOrder)
2254 ## Returns the number of quadrangles in the mesh
2255 # @return an integer value
2256 # @ingroup l1_meshinfo
2257 def NbQuadrangles(self):
2258 return self.mesh.NbQuadrangles()
2260 ## Returns the number of quadrangles with the given order in the mesh
2261 # @param elementOrder the order of elements:
2262 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2263 # @return an integer value
2264 # @ingroup l1_meshinfo
2265 def NbQuadranglesOfOrder(self, elementOrder):
2266 return self.mesh.NbQuadranglesOfOrder(elementOrder)
2268 ## Returns the number of polygons in the mesh
2269 # @return an integer value
2270 # @ingroup l1_meshinfo
2271 def NbPolygons(self):
2272 return self.mesh.NbPolygons()
2274 ## Returns the number of volumes in the mesh
2275 # @return an integer value
2276 # @ingroup l1_meshinfo
2277 def NbVolumes(self):
2278 return self.mesh.NbVolumes()
2280 ## Returns the number of volumes with the given order in the mesh
2281 # @param elementOrder the order of elements:
2282 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2283 # @return an integer value
2284 # @ingroup l1_meshinfo
2285 def NbVolumesOfOrder(self, elementOrder):
2286 return self.mesh.NbVolumesOfOrder(elementOrder)
2288 ## Returns the number of tetrahedrons in the mesh
2289 # @return an integer value
2290 # @ingroup l1_meshinfo
2292 return self.mesh.NbTetras()
2294 ## Returns the number of tetrahedrons with the given order in the mesh
2295 # @param elementOrder the order of elements:
2296 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2297 # @return an integer value
2298 # @ingroup l1_meshinfo
2299 def NbTetrasOfOrder(self, elementOrder):
2300 return self.mesh.NbTetrasOfOrder(elementOrder)
2302 ## Returns the number of hexahedrons in the mesh
2303 # @return an integer value
2304 # @ingroup l1_meshinfo
2306 return self.mesh.NbHexas()
2308 ## Returns the number of hexahedrons with the given order in the mesh
2309 # @param elementOrder the order of elements:
2310 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2311 # @return an integer value
2312 # @ingroup l1_meshinfo
2313 def NbHexasOfOrder(self, elementOrder):
2314 return self.mesh.NbHexasOfOrder(elementOrder)
2316 ## Returns the number of pyramids in the mesh
2317 # @return an integer value
2318 # @ingroup l1_meshinfo
2319 def NbPyramids(self):
2320 return self.mesh.NbPyramids()
2322 ## Returns the number of pyramids with the given order in the mesh
2323 # @param elementOrder the order of elements:
2324 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2325 # @return an integer value
2326 # @ingroup l1_meshinfo
2327 def NbPyramidsOfOrder(self, elementOrder):
2328 return self.mesh.NbPyramidsOfOrder(elementOrder)
2330 ## Returns the number of prisms in the mesh
2331 # @return an integer value
2332 # @ingroup l1_meshinfo
2334 return self.mesh.NbPrisms()
2336 ## Returns the number of prisms with the given order in the mesh
2337 # @param elementOrder the order of elements:
2338 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2339 # @return an integer value
2340 # @ingroup l1_meshinfo
2341 def NbPrismsOfOrder(self, elementOrder):
2342 return self.mesh.NbPrismsOfOrder(elementOrder)
2344 ## Returns the number of polyhedrons in the mesh
2345 # @return an integer value
2346 # @ingroup l1_meshinfo
2347 def NbPolyhedrons(self):
2348 return self.mesh.NbPolyhedrons()
2350 ## Returns the number of submeshes in the mesh
2351 # @return an integer value
2352 # @ingroup l1_meshinfo
2353 def NbSubMesh(self):
2354 return self.mesh.NbSubMesh()
2356 ## Returns the list of mesh elements IDs
2357 # @return the list of integer values
2358 # @ingroup l1_meshinfo
2359 def GetElementsId(self):
2360 return self.mesh.GetElementsId()
2362 ## Returns the list of IDs of mesh elements with the given type
2363 # @param elementType the required type of elements (SMESH.NODE, SMESH.EDGE, SMESH.FACE or SMESH.VOLUME)
2364 # @return list of integer values
2365 # @ingroup l1_meshinfo
2366 def GetElementsByType(self, elementType):
2367 return self.mesh.GetElementsByType(elementType)
2369 ## Returns the list of mesh nodes IDs
2370 # @return the list of integer values
2371 # @ingroup l1_meshinfo
2372 def GetNodesId(self):
2373 return self.mesh.GetNodesId()
2375 # Get the information about mesh elements:
2376 # ------------------------------------
2378 ## Returns the type of mesh element
2379 # @return the value from SMESH::ElementType enumeration
2380 # @ingroup l1_meshinfo
2381 def GetElementType(self, id, iselem):
2382 return self.mesh.GetElementType(id, iselem)
2384 ## Returns the geometric type of mesh element
2385 # @return the value from SMESH::EntityType enumeration
2386 # @ingroup l1_meshinfo
2387 def GetElementGeomType(self, id):
2388 return self.mesh.GetElementGeomType(id)
2390 ## Returns the list of submesh elements IDs
2391 # @param Shape a geom object(subshape) IOR
2392 # Shape must be the subshape of a ShapeToMesh()
2393 # @return the list of integer values
2394 # @ingroup l1_meshinfo
2395 def GetSubMeshElementsId(self, Shape):
2396 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2397 ShapeID = Shape.GetSubShapeIndices()[0]
2400 return self.mesh.GetSubMeshElementsId(ShapeID)
2402 ## Returns the list of submesh nodes IDs
2403 # @param Shape a geom object(subshape) IOR
2404 # Shape must be the subshape of a ShapeToMesh()
2405 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
2406 # @return the list of integer values
2407 # @ingroup l1_meshinfo
2408 def GetSubMeshNodesId(self, Shape, all):
2409 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2410 ShapeID = Shape.GetSubShapeIndices()[0]
2413 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2415 ## Returns type of elements on given shape
2416 # @param Shape a geom object(subshape) IOR
2417 # Shape must be a subshape of a ShapeToMesh()
2418 # @return element type
2419 # @ingroup l1_meshinfo
2420 def GetSubMeshElementType(self, Shape):
2421 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2422 ShapeID = Shape.GetSubShapeIndices()[0]
2425 return self.mesh.GetSubMeshElementType(ShapeID)
2427 ## Gets the mesh description
2428 # @return string value
2429 # @ingroup l1_meshinfo
2431 return self.mesh.Dump()
2434 # Get the information about nodes and elements of a mesh by its IDs:
2435 # -----------------------------------------------------------
2437 ## Gets XYZ coordinates of a node
2438 # \n If there is no nodes for the given ID - returns an empty list
2439 # @return a list of double precision values
2440 # @ingroup l1_meshinfo
2441 def GetNodeXYZ(self, id):
2442 return self.mesh.GetNodeXYZ(id)
2444 ## Returns list of IDs of inverse elements for the given node
2445 # \n If there is no node for the given ID - returns an empty list
2446 # @return a list of integer values
2447 # @ingroup l1_meshinfo
2448 def GetNodeInverseElements(self, id):
2449 return self.mesh.GetNodeInverseElements(id)
2451 ## @brief Returns the position of a node on the shape
2452 # @return SMESH::NodePosition
2453 # @ingroup l1_meshinfo
2454 def GetNodePosition(self,NodeID):
2455 return self.mesh.GetNodePosition(NodeID)
2457 ## If the given element is a node, returns the ID of shape
2458 # \n If there is no node for the given ID - returns -1
2459 # @return an integer value
2460 # @ingroup l1_meshinfo
2461 def GetShapeID(self, id):
2462 return self.mesh.GetShapeID(id)
2464 ## Returns the ID of the result shape after
2465 # FindShape() from SMESH_MeshEditor for the given element
2466 # \n If there is no element for the given ID - returns -1
2467 # @return an integer value
2468 # @ingroup l1_meshinfo
2469 def GetShapeIDForElem(self,id):
2470 return self.mesh.GetShapeIDForElem(id)
2472 ## Returns the number of nodes for the given element
2473 # \n If there is no element for the given ID - returns -1
2474 # @return an integer value
2475 # @ingroup l1_meshinfo
2476 def GetElemNbNodes(self, id):
2477 return self.mesh.GetElemNbNodes(id)
2479 ## Returns the node ID the given index for the given element
2480 # \n If there is no element for the given ID - returns -1
2481 # \n If there is no node for the given index - returns -2
2482 # @return an integer value
2483 # @ingroup l1_meshinfo
2484 def GetElemNode(self, id, index):
2485 return self.mesh.GetElemNode(id, index)
2487 ## Returns the IDs of nodes of the given element
2488 # @return a list of integer values
2489 # @ingroup l1_meshinfo
2490 def GetElemNodes(self, id):
2491 return self.mesh.GetElemNodes(id)
2493 ## Returns true if the given node is the medium node in the given quadratic element
2494 # @ingroup l1_meshinfo
2495 def IsMediumNode(self, elementID, nodeID):
2496 return self.mesh.IsMediumNode(elementID, nodeID)
2498 ## Returns true if the given node is the medium node in one of quadratic elements
2499 # @ingroup l1_meshinfo
2500 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2501 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2503 ## Returns the number of edges for the given element
2504 # @ingroup l1_meshinfo
2505 def ElemNbEdges(self, id):
2506 return self.mesh.ElemNbEdges(id)
2508 ## Returns the number of faces for the given element
2509 # @ingroup l1_meshinfo
2510 def ElemNbFaces(self, id):
2511 return self.mesh.ElemNbFaces(id)
2513 ## Returns nodes of given face (counted from zero) for given volumic element.
2514 # @ingroup l1_meshinfo
2515 def GetElemFaceNodes(self,elemId, faceIndex):
2516 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2518 ## Returns an element based on all given nodes.
2519 # @ingroup l1_meshinfo
2520 def FindElementByNodes(self,nodes):
2521 return self.mesh.FindElementByNodes(nodes)
2523 ## Returns true if the given element is a polygon
2524 # @ingroup l1_meshinfo
2525 def IsPoly(self, id):
2526 return self.mesh.IsPoly(id)
2528 ## Returns true if the given element is quadratic
2529 # @ingroup l1_meshinfo
2530 def IsQuadratic(self, id):
2531 return self.mesh.IsQuadratic(id)
2533 ## Returns XYZ coordinates of the barycenter of the given element
2534 # \n If there is no element for the given ID - returns an empty list
2535 # @return a list of three double values
2536 # @ingroup l1_meshinfo
2537 def BaryCenter(self, id):
2538 return self.mesh.BaryCenter(id)
2541 # Get mesh measurements information:
2542 # ------------------------------------
2544 ## Get minimum distance between two nodes, elements or distance to the origin
2545 # @param id1 first node/element id
2546 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2547 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2548 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2549 # @return minimum distance value
2550 # @sa GetMinDistance()
2551 def MinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2552 aMeasure = self.GetMinDistance(id1, id2, isElem1, isElem2)
2553 return aMeasure.value
2555 ## Get measure structure specifying minimum distance data between two objects
2556 # @param id1 first node/element id
2557 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2558 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2559 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2560 # @return Measure structure
2562 def GetMinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2564 id1 = self.editor.MakeIDSource([id1], SMESH.FACE)
2566 id1 = self.editor.MakeIDSource([id1], SMESH.NODE)
2569 id2 = self.editor.MakeIDSource([id2], SMESH.FACE)
2571 id2 = self.editor.MakeIDSource([id2], SMESH.NODE)
2576 aMeasurements = self.smeshpyD.CreateMeasurements()
2577 aMeasure = aMeasurements.MinDistance(id1, id2)
2578 aMeasurements.UnRegister()
2581 ## Get bounding box of the specified object(s)
2582 # @param objects single source object or list of source objects or list of nodes/elements IDs
2583 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2584 # @c False specifies that @a objects are nodes
2585 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
2586 # @sa GetBoundingBox()
2587 def BoundingBox(self, objects=None, isElem=False):
2588 result = self.GetBoundingBox(objects, isElem)
2592 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
2595 ## Get measure structure specifying bounding box data of the specified object(s)
2596 # @param IDs single source object or list of source objects or list of nodes/elements IDs
2597 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2598 # @c False specifies that @a objects are nodes
2599 # @return Measure structure
2601 def GetBoundingBox(self, IDs=None, isElem=False):
2604 elif isinstance(IDs, tuple):
2606 if not isinstance(IDs, list):
2608 if len(IDs) > 0 and isinstance(IDs[0], int):
2612 if isinstance(o, Mesh):
2613 srclist.append(o.mesh)
2614 elif hasattr(o, "_narrow"):
2615 src = o._narrow(SMESH.SMESH_IDSource)
2616 if src: srclist.append(src)
2618 elif isinstance(o, list):
2620 srclist.append(self.editor.MakeIDSource(o, SMESH.FACE))
2622 srclist.append(self.editor.MakeIDSource(o, SMESH.NODE))
2625 aMeasurements = self.smeshpyD.CreateMeasurements()
2626 aMeasure = aMeasurements.BoundingBox(srclist)
2627 aMeasurements.UnRegister()
2630 # Mesh edition (SMESH_MeshEditor functionality):
2631 # ---------------------------------------------
2633 ## Removes the elements from the mesh by ids
2634 # @param IDsOfElements is a list of ids of elements to remove
2635 # @return True or False
2636 # @ingroup l2_modif_del
2637 def RemoveElements(self, IDsOfElements):
2638 return self.editor.RemoveElements(IDsOfElements)
2640 ## Removes nodes from mesh by ids
2641 # @param IDsOfNodes is a list of ids of nodes to remove
2642 # @return True or False
2643 # @ingroup l2_modif_del
2644 def RemoveNodes(self, IDsOfNodes):
2645 return self.editor.RemoveNodes(IDsOfNodes)
2647 ## Removes all orphan (free) nodes from mesh
2648 # @return number of the removed nodes
2649 # @ingroup l2_modif_del
2650 def RemoveOrphanNodes(self):
2651 return self.editor.RemoveOrphanNodes()
2653 ## Add a node to the mesh by coordinates
2654 # @return Id of the new node
2655 # @ingroup l2_modif_add
2656 def AddNode(self, x, y, z):
2657 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2658 self.mesh.SetParameters(Parameters)
2659 return self.editor.AddNode( x, y, z)
2661 ## Creates a 0D element on a node with given number.
2662 # @param IDOfNode the ID of node for creation of the element.
2663 # @return the Id of the new 0D element
2664 # @ingroup l2_modif_add
2665 def Add0DElement(self, IDOfNode):
2666 return self.editor.Add0DElement(IDOfNode)
2668 ## Creates a linear or quadratic edge (this is determined
2669 # by the number of given nodes).
2670 # @param IDsOfNodes the list of node IDs for creation of the element.
2671 # The order of nodes in this list should correspond to the description
2672 # of MED. \n This description is located by the following link:
2673 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2674 # @return the Id of the new edge
2675 # @ingroup l2_modif_add
2676 def AddEdge(self, IDsOfNodes):
2677 return self.editor.AddEdge(IDsOfNodes)
2679 ## Creates a linear or quadratic face (this is determined
2680 # by the number of given nodes).
2681 # @param IDsOfNodes the list of node IDs for creation of the element.
2682 # The order of nodes in this list should correspond to the description
2683 # of MED. \n This description is located by the following link:
2684 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2685 # @return the Id of the new face
2686 # @ingroup l2_modif_add
2687 def AddFace(self, IDsOfNodes):
2688 return self.editor.AddFace(IDsOfNodes)
2690 ## Adds a polygonal face to the mesh by the list of node IDs
2691 # @param IdsOfNodes the list of node IDs for creation of the element.
2692 # @return the Id of the new face
2693 # @ingroup l2_modif_add
2694 def AddPolygonalFace(self, IdsOfNodes):
2695 return self.editor.AddPolygonalFace(IdsOfNodes)
2697 ## Creates both simple and quadratic volume (this is determined
2698 # by the number of given nodes).
2699 # @param IDsOfNodes the list of node IDs for creation of the element.
2700 # The order of nodes in this list should correspond to the description
2701 # of MED. \n This description is located by the following link:
2702 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2703 # @return the Id of the new volumic element
2704 # @ingroup l2_modif_add
2705 def AddVolume(self, IDsOfNodes):
2706 return self.editor.AddVolume(IDsOfNodes)
2708 ## Creates a volume of many faces, giving nodes for each face.
2709 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2710 # @param Quantities the list of integer values, Quantities[i]
2711 # gives the quantity of nodes in face number i.
2712 # @return the Id of the new volumic element
2713 # @ingroup l2_modif_add
2714 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2715 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2717 ## Creates a volume of many faces, giving the IDs of the existing faces.
2718 # @param IdsOfFaces the list of face IDs for volume creation.
2720 # Note: The created volume will refer only to the nodes
2721 # of the given faces, not to the faces themselves.
2722 # @return the Id of the new volumic element
2723 # @ingroup l2_modif_add
2724 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2725 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2728 ## @brief Binds a node to a vertex
2729 # @param NodeID a node ID
2730 # @param Vertex a vertex or vertex ID
2731 # @return True if succeed else raises an exception
2732 # @ingroup l2_modif_add
2733 def SetNodeOnVertex(self, NodeID, Vertex):
2734 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2735 VertexID = Vertex.GetSubShapeIndices()[0]
2739 self.editor.SetNodeOnVertex(NodeID, VertexID)
2740 except SALOME.SALOME_Exception, inst:
2741 raise ValueError, inst.details.text
2745 ## @brief Stores the node position on an edge
2746 # @param NodeID a node ID
2747 # @param Edge an edge or edge ID
2748 # @param paramOnEdge a parameter on the edge where the node is located
2749 # @return True if succeed else raises an exception
2750 # @ingroup l2_modif_add
2751 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2752 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2753 EdgeID = Edge.GetSubShapeIndices()[0]
2757 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2758 except SALOME.SALOME_Exception, inst:
2759 raise ValueError, inst.details.text
2762 ## @brief Stores node position on a face
2763 # @param NodeID a node ID
2764 # @param Face a face or face ID
2765 # @param u U parameter on the face where the node is located
2766 # @param v V parameter on the face where the node is located
2767 # @return True if succeed else raises an exception
2768 # @ingroup l2_modif_add
2769 def SetNodeOnFace(self, NodeID, Face, u, v):
2770 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2771 FaceID = Face.GetSubShapeIndices()[0]
2775 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2776 except SALOME.SALOME_Exception, inst:
2777 raise ValueError, inst.details.text
2780 ## @brief Binds a node to a solid
2781 # @param NodeID a node ID
2782 # @param Solid a solid or solid ID
2783 # @return True if succeed else raises an exception
2784 # @ingroup l2_modif_add
2785 def SetNodeInVolume(self, NodeID, Solid):
2786 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2787 SolidID = Solid.GetSubShapeIndices()[0]
2791 self.editor.SetNodeInVolume(NodeID, SolidID)
2792 except SALOME.SALOME_Exception, inst:
2793 raise ValueError, inst.details.text
2796 ## @brief Bind an element to a shape
2797 # @param ElementID an element ID
2798 # @param Shape a shape or shape ID
2799 # @return True if succeed else raises an exception
2800 # @ingroup l2_modif_add
2801 def SetMeshElementOnShape(self, ElementID, Shape):
2802 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2803 ShapeID = Shape.GetSubShapeIndices()[0]
2807 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2808 except SALOME.SALOME_Exception, inst:
2809 raise ValueError, inst.details.text
2813 ## Moves the node with the given id
2814 # @param NodeID the id of the node
2815 # @param x a new X coordinate
2816 # @param y a new Y coordinate
2817 # @param z a new Z coordinate
2818 # @return True if succeed else False
2819 # @ingroup l2_modif_movenode
2820 def MoveNode(self, NodeID, x, y, z):
2821 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2822 self.mesh.SetParameters(Parameters)
2823 return self.editor.MoveNode(NodeID, x, y, z)
2825 ## Finds the node closest to a point and moves it to a point location
2826 # @param x the X coordinate of a point
2827 # @param y the Y coordinate of a point
2828 # @param z the Z coordinate of a point
2829 # @param NodeID if specified (>0), the node with this ID is moved,
2830 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2831 # @return the ID of a node
2832 # @ingroup l2_modif_throughp
2833 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2834 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2835 self.mesh.SetParameters(Parameters)
2836 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2838 ## Finds the node closest to a point
2839 # @param x the X coordinate of a point
2840 # @param y the Y coordinate of a point
2841 # @param z the Z coordinate of a point
2842 # @return the ID of a node
2843 # @ingroup l2_modif_throughp
2844 def FindNodeClosestTo(self, x, y, z):
2845 #preview = self.mesh.GetMeshEditPreviewer()
2846 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2847 return self.editor.FindNodeClosestTo(x, y, z)
2849 ## Finds the elements where a point lays IN or ON
2850 # @param x the X coordinate of a point
2851 # @param y the Y coordinate of a point
2852 # @param z the Z coordinate of a point
2853 # @param elementType type of elements to find (SMESH.ALL type
2854 # means elements of any type excluding nodes and 0D elements)
2855 # @param meshPart a part of mesh (group, sub-mesh) to search within
2856 # @return list of IDs of found elements
2857 # @ingroup l2_modif_throughp
2858 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL, meshPart=None):
2860 return self.editor.FindAmongElementsByPoint( meshPart, x, y, z, elementType );
2862 return self.editor.FindElementsByPoint(x, y, z, elementType)
2864 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2865 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2867 def GetPointState(self, x, y, z):
2868 return self.editor.GetPointState(x, y, z)
2870 ## Finds the node closest to a point and moves it to a point location
2871 # @param x the X coordinate of a point
2872 # @param y the Y coordinate of a point
2873 # @param z the Z coordinate of a point
2874 # @return the ID of a moved node
2875 # @ingroup l2_modif_throughp
2876 def MeshToPassThroughAPoint(self, x, y, z):
2877 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2879 ## Replaces two neighbour triangles sharing Node1-Node2 link
2880 # with the triangles built on the same 4 nodes but having other common link.
2881 # @param NodeID1 the ID of the first node
2882 # @param NodeID2 the ID of the second node
2883 # @return false if proper faces were not found
2884 # @ingroup l2_modif_invdiag
2885 def InverseDiag(self, NodeID1, NodeID2):
2886 return self.editor.InverseDiag(NodeID1, NodeID2)
2888 ## Replaces two neighbour triangles sharing Node1-Node2 link
2889 # with a quadrangle built on the same 4 nodes.
2890 # @param NodeID1 the ID of the first node
2891 # @param NodeID2 the ID of the second node
2892 # @return false if proper faces were not found
2893 # @ingroup l2_modif_unitetri
2894 def DeleteDiag(self, NodeID1, NodeID2):
2895 return self.editor.DeleteDiag(NodeID1, NodeID2)
2897 ## Reorients elements by ids
2898 # @param IDsOfElements if undefined reorients all mesh elements
2899 # @return True if succeed else False
2900 # @ingroup l2_modif_changori
2901 def Reorient(self, IDsOfElements=None):
2902 if IDsOfElements == None:
2903 IDsOfElements = self.GetElementsId()
2904 return self.editor.Reorient(IDsOfElements)
2906 ## Reorients all elements of the object
2907 # @param theObject mesh, submesh or group
2908 # @return True if succeed else False
2909 # @ingroup l2_modif_changori
2910 def ReorientObject(self, theObject):
2911 if ( isinstance( theObject, Mesh )):
2912 theObject = theObject.GetMesh()
2913 return self.editor.ReorientObject(theObject)
2915 ## Fuses the neighbouring triangles into quadrangles.
2916 # @param IDsOfElements The triangles to be fused,
2917 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2918 # @param MaxAngle is the maximum angle between element normals at which the fusion
2919 # is still performed; theMaxAngle is mesured in radians.
2920 # Also it could be a name of variable which defines angle in degrees.
2921 # @return TRUE in case of success, FALSE otherwise.
2922 # @ingroup l2_modif_unitetri
2923 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2925 if isinstance(MaxAngle,str):
2927 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2929 MaxAngle = DegreesToRadians(MaxAngle)
2930 if IDsOfElements == []:
2931 IDsOfElements = self.GetElementsId()
2932 self.mesh.SetParameters(Parameters)
2934 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2935 Functor = theCriterion
2937 Functor = self.smeshpyD.GetFunctor(theCriterion)
2938 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2940 ## Fuses the neighbouring triangles of the object into quadrangles
2941 # @param theObject is mesh, submesh or group
2942 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2943 # @param MaxAngle a max angle between element normals at which the fusion
2944 # is still performed; theMaxAngle is mesured in radians.
2945 # @return TRUE in case of success, FALSE otherwise.
2946 # @ingroup l2_modif_unitetri
2947 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2948 if ( isinstance( theObject, Mesh )):
2949 theObject = theObject.GetMesh()
2950 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2952 ## Splits quadrangles into triangles.
2953 # @param IDsOfElements the faces to be splitted.
2954 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2955 # @return TRUE in case of success, FALSE otherwise.
2956 # @ingroup l2_modif_cutquadr
2957 def QuadToTri (self, IDsOfElements, theCriterion):
2958 if IDsOfElements == []:
2959 IDsOfElements = self.GetElementsId()
2960 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2962 ## Splits quadrangles into triangles.
2963 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2964 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2965 # @return TRUE in case of success, FALSE otherwise.
2966 # @ingroup l2_modif_cutquadr
2967 def QuadToTriObject (self, theObject, theCriterion):
2968 if ( isinstance( theObject, Mesh )):
2969 theObject = theObject.GetMesh()
2970 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2972 ## Splits quadrangles into triangles.
2973 # @param IDsOfElements the faces to be splitted
2974 # @param Diag13 is used to choose a diagonal for splitting.
2975 # @return TRUE in case of success, FALSE otherwise.
2976 # @ingroup l2_modif_cutquadr
2977 def SplitQuad (self, IDsOfElements, Diag13):
2978 if IDsOfElements == []:
2979 IDsOfElements = self.GetElementsId()
2980 return self.editor.SplitQuad(IDsOfElements, Diag13)
2982 ## Splits quadrangles into triangles.
2983 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2984 # @param Diag13 is used to choose a diagonal for splitting.
2985 # @return TRUE in case of success, FALSE otherwise.
2986 # @ingroup l2_modif_cutquadr
2987 def SplitQuadObject (self, theObject, Diag13):
2988 if ( isinstance( theObject, Mesh )):
2989 theObject = theObject.GetMesh()
2990 return self.editor.SplitQuadObject(theObject, Diag13)
2992 ## Finds a better splitting of the given quadrangle.
2993 # @param IDOfQuad the ID of the quadrangle to be splitted.
2994 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2995 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2996 # diagonal is better, 0 if error occurs.
2997 # @ingroup l2_modif_cutquadr
2998 def BestSplit (self, IDOfQuad, theCriterion):
2999 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
3001 ## Splits volumic elements into tetrahedrons
3002 # @param elemIDs either list of elements or mesh or group or submesh
3003 # @param method flags passing splitting method: Hex_5Tet, Hex_6Tet, Hex_24Tet
3004 # Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc
3005 # @ingroup l2_modif_cutquadr
3006 def SplitVolumesIntoTetra(self, elemIDs, method=Hex_5Tet ):
3007 if isinstance( elemIDs, Mesh ):
3008 elemIDs = elemIDs.GetMesh()
3009 if ( isinstance( elemIDs, list )):
3010 elemIDs = self.editor.MakeIDSource(elemIDs, SMESH.VOLUME)
3011 self.editor.SplitVolumesIntoTetra(elemIDs, method)
3013 ## Splits quadrangle faces near triangular facets of volumes
3015 # @ingroup l1_auxiliary
3016 def SplitQuadsNearTriangularFacets(self):
3017 faces_array = self.GetElementsByType(SMESH.FACE)
3018 for face_id in faces_array:
3019 if self.GetElemNbNodes(face_id) == 4: # quadrangle
3020 quad_nodes = self.mesh.GetElemNodes(face_id)
3021 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
3022 isVolumeFound = False
3023 for node1_elem in node1_elems:
3024 if not isVolumeFound:
3025 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
3026 nb_nodes = self.GetElemNbNodes(node1_elem)
3027 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
3028 volume_elem = node1_elem
3029 volume_nodes = self.mesh.GetElemNodes(volume_elem)
3030 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
3031 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
3032 isVolumeFound = True
3033 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
3034 self.SplitQuad([face_id], False) # diagonal 2-4
3035 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
3036 isVolumeFound = True
3037 self.SplitQuad([face_id], True) # diagonal 1-3
3038 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
3039 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
3040 isVolumeFound = True
3041 self.SplitQuad([face_id], True) # diagonal 1-3
3043 ## @brief Splits hexahedrons into tetrahedrons.
3045 # This operation uses pattern mapping functionality for splitting.
3046 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
3047 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
3048 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
3049 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
3050 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
3051 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
3052 # @return TRUE in case of success, FALSE otherwise.
3053 # @ingroup l1_auxiliary
3054 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
3055 # Pattern: 5.---------.6
3060 # (0,0,1) 4.---------.7 * |
3067 # (0,0,0) 0.---------.3
3068 pattern_tetra = "!!! Nb of points: \n 8 \n\
3078 !!! Indices of points of 6 tetras: \n\
3086 pattern = self.smeshpyD.GetPattern()
3087 isDone = pattern.LoadFromFile(pattern_tetra)
3089 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
3092 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
3093 isDone = pattern.MakeMesh(self.mesh, False, False)
3094 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
3096 # split quafrangle faces near triangular facets of volumes
3097 self.SplitQuadsNearTriangularFacets()
3101 ## @brief Split hexahedrons into prisms.
3103 # Uses the pattern mapping functionality for splitting.
3104 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
3105 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
3106 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
3107 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
3108 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
3109 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
3110 # @return TRUE in case of success, FALSE otherwise.
3111 # @ingroup l1_auxiliary
3112 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
3113 # Pattern: 5.---------.6
3118 # (0,0,1) 4.---------.7 |
3125 # (0,0,0) 0.---------.3
3126 pattern_prism = "!!! Nb of points: \n 8 \n\
3136 !!! Indices of points of 2 prisms: \n\
3140 pattern = self.smeshpyD.GetPattern()
3141 isDone = pattern.LoadFromFile(pattern_prism)
3143 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
3146 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
3147 isDone = pattern.MakeMesh(self.mesh, False, False)
3148 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
3150 # Splits quafrangle faces near triangular facets of volumes
3151 self.SplitQuadsNearTriangularFacets()
3155 ## Smoothes elements
3156 # @param IDsOfElements the list if ids of elements to smooth
3157 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3158 # Note that nodes built on edges and boundary nodes are always fixed.
3159 # @param MaxNbOfIterations the maximum number of iterations
3160 # @param MaxAspectRatio varies in range [1.0, inf]
3161 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3162 # @return TRUE in case of success, FALSE otherwise.
3163 # @ingroup l2_modif_smooth
3164 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
3165 MaxNbOfIterations, MaxAspectRatio, Method):
3166 if IDsOfElements == []:
3167 IDsOfElements = self.GetElementsId()
3168 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
3169 self.mesh.SetParameters(Parameters)
3170 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
3171 MaxNbOfIterations, MaxAspectRatio, Method)
3173 ## Smoothes elements which belong to the given object
3174 # @param theObject the object to smooth
3175 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3176 # Note that nodes built on edges and boundary nodes are always fixed.
3177 # @param MaxNbOfIterations the maximum number of iterations
3178 # @param MaxAspectRatio varies in range [1.0, inf]
3179 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3180 # @return TRUE in case of success, FALSE otherwise.
3181 # @ingroup l2_modif_smooth
3182 def SmoothObject(self, theObject, IDsOfFixedNodes,
3183 MaxNbOfIterations, MaxAspectRatio, Method):
3184 if ( isinstance( theObject, Mesh )):
3185 theObject = theObject.GetMesh()
3186 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
3187 MaxNbOfIterations, MaxAspectRatio, Method)
3189 ## Parametrically smoothes the given elements
3190 # @param IDsOfElements the list if ids of elements to smooth
3191 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3192 # Note that nodes built on edges and boundary nodes are always fixed.
3193 # @param MaxNbOfIterations the maximum number of iterations
3194 # @param MaxAspectRatio varies in range [1.0, inf]
3195 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3196 # @return TRUE in case of success, FALSE otherwise.
3197 # @ingroup l2_modif_smooth
3198 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
3199 MaxNbOfIterations, MaxAspectRatio, Method):
3200 if IDsOfElements == []:
3201 IDsOfElements = self.GetElementsId()
3202 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
3203 self.mesh.SetParameters(Parameters)
3204 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
3205 MaxNbOfIterations, MaxAspectRatio, Method)
3207 ## Parametrically smoothes the elements which belong to the given object
3208 # @param theObject the object to smooth
3209 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3210 # Note that nodes built on edges and boundary nodes are always fixed.
3211 # @param MaxNbOfIterations the maximum number of iterations
3212 # @param MaxAspectRatio varies in range [1.0, inf]
3213 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3214 # @return TRUE in case of success, FALSE otherwise.
3215 # @ingroup l2_modif_smooth
3216 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
3217 MaxNbOfIterations, MaxAspectRatio, Method):
3218 if ( isinstance( theObject, Mesh )):
3219 theObject = theObject.GetMesh()
3220 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
3221 MaxNbOfIterations, MaxAspectRatio, Method)
3223 ## Converts the mesh to quadratic, deletes old elements, replacing
3224 # them with quadratic with the same id.
3225 # @param theForce3d new node creation method:
3226 # 0 - the medium node lies at the geometrical entity from which the mesh element is built
3227 # 1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element
3228 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
3229 # @ingroup l2_modif_tofromqu
3230 def ConvertToQuadratic(self, theForce3d, theSubMesh=None):
3232 self.editor.ConvertToQuadraticObject(theForce3d,theSubMesh)
3234 self.editor.ConvertToQuadratic(theForce3d)
3236 ## Converts the mesh from quadratic to ordinary,
3237 # deletes old quadratic elements, \n replacing
3238 # them with ordinary mesh elements with the same id.
3239 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
3240 # @ingroup l2_modif_tofromqu
3241 def ConvertFromQuadratic(self, theSubMesh=None):
3243 self.editor.ConvertFromQuadraticObject(theSubMesh)
3245 return self.editor.ConvertFromQuadratic()
3247 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
3248 # @return TRUE if operation has been completed successfully, FALSE otherwise
3249 # @ingroup l2_modif_edit
3250 def Make2DMeshFrom3D(self):
3251 return self.editor. Make2DMeshFrom3D()
3253 ## Creates missing boundary elements
3254 # @param elements - elements whose boundary is to be checked:
3255 # mesh, group, sub-mesh or list of elements
3256 # if elements is mesh, it must be the mesh whose MakeBoundaryMesh() is called
3257 # @param dimension - defines type of boundary elements to create:
3258 # SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D
3259 # SMESH.BND_1DFROM3D creates mesh edges on all borders of free facets of 3D cells
3260 # @param groupName - a name of group to store created boundary elements in,
3261 # "" means not to create the group
3262 # @param meshName - a name of new mesh to store created boundary elements in,
3263 # "" means not to create the new mesh
3264 # @param toCopyElements - if true, the checked elements will be copied into
3265 # the new mesh else only boundary elements will be copied into the new mesh
3266 # @param toCopyExistingBondary - if true, not only new but also pre-existing
3267 # boundary elements will be copied into the new mesh
3268 # @return tuple (mesh, group) where bondary elements were added to
3269 # @ingroup l2_modif_edit
3270 def MakeBoundaryMesh(self, elements, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3271 toCopyElements=False, toCopyExistingBondary=False):
3272 if isinstance( elements, Mesh ):
3273 elements = elements.GetMesh()
3274 if ( isinstance( elements, list )):
3275 elemType = SMESH.ALL
3276 if elements: elemType = self.GetElementType( elements[0], iselem=True)
3277 elements = self.editor.MakeIDSource(elements, elemType)
3278 mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName,
3279 toCopyElements,toCopyExistingBondary)
3280 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3284 # @brief Creates missing boundary elements around either the whole mesh or
3285 # groups of 2D elements
3286 # @param dimension - defines type of boundary elements to create
3287 # @param groupName - a name of group to store all boundary elements in,
3288 # "" means not to create the group
3289 # @param meshName - a name of a new mesh, which is a copy of the initial
3290 # mesh + created boundary elements; "" means not to create the new mesh
3291 # @param toCopyAll - if true, the whole initial mesh will be copied into
3292 # the new mesh else only boundary elements will be copied into the new mesh
3293 # @param groups - groups of 2D elements to make boundary around
3294 # @retval tuple( long, mesh, groups )
3295 # long - number of added boundary elements
3296 # mesh - the mesh where elements were added to
3297 # group - the group of boundary elements or None
3299 def MakeBoundaryElements(self, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3300 toCopyAll=False, groups=[]):
3301 nb, mesh, group = self.editor.MakeBoundaryElements(dimension,groupName,meshName,
3303 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3304 return nb, mesh, group
3306 ## Renumber mesh nodes
3307 # @ingroup l2_modif_renumber
3308 def RenumberNodes(self):
3309 self.editor.RenumberNodes()
3311 ## Renumber mesh elements
3312 # @ingroup l2_modif_renumber
3313 def RenumberElements(self):
3314 self.editor.RenumberElements()
3316 ## Generates new elements by rotation of the elements around the axis
3317 # @param IDsOfElements the list of ids of elements to sweep
3318 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3319 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
3320 # @param NbOfSteps the number of steps
3321 # @param Tolerance tolerance
3322 # @param MakeGroups forces the generation of new groups from existing ones
3323 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3324 # of all steps, else - size of each step
3325 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3326 # @ingroup l2_modif_extrurev
3327 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
3328 MakeGroups=False, TotalAngle=False):
3330 if isinstance(AngleInRadians,str):
3332 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3334 AngleInRadians = DegreesToRadians(AngleInRadians)
3335 if IDsOfElements == []:
3336 IDsOfElements = self.GetElementsId()
3337 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3338 Axis = self.smeshpyD.GetAxisStruct(Axis)
3339 Axis,AxisParameters = ParseAxisStruct(Axis)
3340 if TotalAngle and NbOfSteps:
3341 AngleInRadians /= NbOfSteps
3342 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3343 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3344 self.mesh.SetParameters(Parameters)
3346 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
3347 AngleInRadians, NbOfSteps, Tolerance)
3348 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
3351 ## Generates new elements by rotation of the elements of object around the axis
3352 # @param theObject object which elements should be sweeped.
3353 # It can be a mesh, a sub mesh or a group.
3354 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3355 # @param AngleInRadians the angle of Rotation
3356 # @param NbOfSteps number of steps
3357 # @param Tolerance tolerance
3358 # @param MakeGroups forces the generation of new groups from existing ones
3359 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3360 # of all steps, else - size of each step
3361 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3362 # @ingroup l2_modif_extrurev
3363 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3364 MakeGroups=False, TotalAngle=False):
3366 if isinstance(AngleInRadians,str):
3368 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3370 AngleInRadians = DegreesToRadians(AngleInRadians)
3371 if ( isinstance( theObject, Mesh )):
3372 theObject = theObject.GetMesh()
3373 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3374 Axis = self.smeshpyD.GetAxisStruct(Axis)
3375 Axis,AxisParameters = ParseAxisStruct(Axis)
3376 if TotalAngle and NbOfSteps:
3377 AngleInRadians /= NbOfSteps
3378 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3379 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3380 self.mesh.SetParameters(Parameters)
3382 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
3383 NbOfSteps, Tolerance)
3384 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3387 ## Generates new elements by rotation of the elements of object around the axis
3388 # @param theObject object which elements should be sweeped.
3389 # It can be a mesh, a sub mesh or a group.
3390 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3391 # @param AngleInRadians the angle of Rotation
3392 # @param NbOfSteps number of steps
3393 # @param Tolerance tolerance
3394 # @param MakeGroups forces the generation of new groups from existing ones
3395 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3396 # of all steps, else - size of each step
3397 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3398 # @ingroup l2_modif_extrurev
3399 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3400 MakeGroups=False, TotalAngle=False):
3402 if isinstance(AngleInRadians,str):
3404 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3406 AngleInRadians = DegreesToRadians(AngleInRadians)
3407 if ( isinstance( theObject, Mesh )):
3408 theObject = theObject.GetMesh()
3409 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3410 Axis = self.smeshpyD.GetAxisStruct(Axis)
3411 Axis,AxisParameters = ParseAxisStruct(Axis)
3412 if TotalAngle and NbOfSteps:
3413 AngleInRadians /= NbOfSteps
3414 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3415 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3416 self.mesh.SetParameters(Parameters)
3418 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
3419 NbOfSteps, Tolerance)
3420 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3423 ## Generates new elements by rotation of the elements of object around the axis
3424 # @param theObject object which elements should be sweeped.
3425 # It can be a mesh, a sub mesh or a group.
3426 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3427 # @param AngleInRadians the angle of Rotation
3428 # @param NbOfSteps number of steps
3429 # @param Tolerance tolerance
3430 # @param MakeGroups forces the generation of new groups from existing ones
3431 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3432 # of all steps, else - size of each step
3433 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3434 # @ingroup l2_modif_extrurev
3435 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3436 MakeGroups=False, TotalAngle=False):
3438 if isinstance(AngleInRadians,str):
3440 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3442 AngleInRadians = DegreesToRadians(AngleInRadians)
3443 if ( isinstance( theObject, Mesh )):
3444 theObject = theObject.GetMesh()
3445 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3446 Axis = self.smeshpyD.GetAxisStruct(Axis)
3447 Axis,AxisParameters = ParseAxisStruct(Axis)
3448 if TotalAngle and NbOfSteps:
3449 AngleInRadians /= NbOfSteps
3450 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3451 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3452 self.mesh.SetParameters(Parameters)
3454 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
3455 NbOfSteps, Tolerance)
3456 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3459 ## Generates new elements by extrusion of the elements with given ids
3460 # @param IDsOfElements the list of elements ids for extrusion
3461 # @param StepVector vector or DirStruct, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3462 # @param NbOfSteps the number of steps
3463 # @param MakeGroups forces the generation of new groups from existing ones
3464 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3465 # @ingroup l2_modif_extrurev
3466 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
3467 if IDsOfElements == []:
3468 IDsOfElements = self.GetElementsId()
3469 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3470 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3471 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3472 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3473 Parameters = StepVectorParameters + var_separator + Parameters
3474 self.mesh.SetParameters(Parameters)
3476 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
3477 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
3480 ## Generates new elements by extrusion of the elements with given ids
3481 # @param IDsOfElements is ids of elements
3482 # @param StepVector vector, defining the direction and value of extrusion
3483 # @param NbOfSteps the number of steps
3484 # @param ExtrFlags sets flags for extrusion
3485 # @param SewTolerance uses for comparing locations of nodes if flag
3486 # EXTRUSION_FLAG_SEW is set
3487 # @param MakeGroups forces the generation of new groups from existing ones
3488 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3489 # @ingroup l2_modif_extrurev
3490 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
3491 ExtrFlags, SewTolerance, MakeGroups=False):
3492 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3493 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3495 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
3496 ExtrFlags, SewTolerance)
3497 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
3498 ExtrFlags, SewTolerance)
3501 ## Generates new elements by extrusion of the elements which belong to the object
3502 # @param theObject the object which elements should be processed.
3503 # It can be a mesh, a sub mesh or a group.
3504 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3505 # @param NbOfSteps the number of steps
3506 # @param MakeGroups forces the generation of new groups from existing ones
3507 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3508 # @ingroup l2_modif_extrurev
3509 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3510 if ( isinstance( theObject, Mesh )):
3511 theObject = theObject.GetMesh()
3512 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3513 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3514 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3515 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3516 Parameters = StepVectorParameters + var_separator + Parameters
3517 self.mesh.SetParameters(Parameters)
3519 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3520 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
3523 ## Generates new elements by extrusion of the elements which belong to the object
3524 # @param theObject object which elements should be processed.
3525 # It can be a mesh, a sub mesh or a group.
3526 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3527 # @param NbOfSteps the number of steps
3528 # @param MakeGroups to generate new groups from existing ones
3529 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3530 # @ingroup l2_modif_extrurev
3531 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3532 if ( isinstance( theObject, Mesh )):
3533 theObject = theObject.GetMesh()
3534 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3535 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3536 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3537 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3538 Parameters = StepVectorParameters + var_separator + Parameters
3539 self.mesh.SetParameters(Parameters)
3541 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3542 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3545 ## Generates new elements by extrusion of the elements which belong to the object
3546 # @param theObject object which elements should be processed.
3547 # It can be a mesh, a sub mesh or a group.
3548 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3549 # @param NbOfSteps the number of steps
3550 # @param MakeGroups forces the generation of new groups from existing ones
3551 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3552 # @ingroup l2_modif_extrurev
3553 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3554 if ( isinstance( theObject, Mesh )):
3555 theObject = theObject.GetMesh()
3556 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3557 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3558 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3559 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3560 Parameters = StepVectorParameters + var_separator + Parameters
3561 self.mesh.SetParameters(Parameters)
3563 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3564 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3569 ## Generates new elements by extrusion of the given elements
3570 # The path of extrusion must be a meshed edge.
3571 # @param Base mesh or group, or submesh, or list of ids of elements for extrusion
3572 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3573 # @param NodeStart the start node from Path. Defines the direction of extrusion
3574 # @param HasAngles allows the shape to be rotated around the path
3575 # to get the resulting mesh in a helical fashion
3576 # @param Angles list of angles in radians
3577 # @param LinearVariation forces the computation of rotation angles as linear
3578 # variation of the given Angles along path steps
3579 # @param HasRefPoint allows using the reference point
3580 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3581 # The User can specify any point as the Reference Point.
3582 # @param MakeGroups forces the generation of new groups from existing ones
3583 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3584 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3585 # only SMESH::Extrusion_Error otherwise
3586 # @ingroup l2_modif_extrurev
3587 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3588 HasAngles, Angles, LinearVariation,
3589 HasRefPoint, RefPoint, MakeGroups, ElemType):
3590 Angles,AnglesParameters = ParseAngles(Angles)
3591 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3592 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3593 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3595 Parameters = AnglesParameters + var_separator + RefPointParameters
3596 self.mesh.SetParameters(Parameters)
3598 if (isinstance(Path, Mesh)): Path = Path.GetMesh()
3600 if isinstance(Base, list):
3602 if Base == []: IDsOfElements = self.GetElementsId()
3603 else: IDsOfElements = Base
3604 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3605 HasAngles, Angles, LinearVariation,
3606 HasRefPoint, RefPoint, MakeGroups, ElemType)
3608 if isinstance(Base, Mesh): Base = Base.GetMesh()
3609 if isinstance(Base, SMESH._objref_SMESH_Mesh) or isinstance(Base, SMESH._objref_SMESH_Group) or isinstance(Base, SMESH._objref_SMESH_subMesh):
3610 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3611 HasAngles, Angles, LinearVariation,
3612 HasRefPoint, RefPoint, MakeGroups, ElemType)
3614 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3617 ## Generates new elements by extrusion of the given elements
3618 # The path of extrusion must be a meshed edge.
3619 # @param IDsOfElements ids of elements
3620 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3621 # @param PathShape shape(edge) defines the sub-mesh for the path
3622 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3623 # @param HasAngles allows the shape to be rotated around the path
3624 # to get the resulting mesh in a helical fashion
3625 # @param Angles list of angles in radians
3626 # @param HasRefPoint allows using the reference point
3627 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3628 # The User can specify any point as the Reference Point.
3629 # @param MakeGroups forces the generation of new groups from existing ones
3630 # @param LinearVariation forces the computation of rotation angles as linear
3631 # variation of the given Angles along path steps
3632 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3633 # only SMESH::Extrusion_Error otherwise
3634 # @ingroup l2_modif_extrurev
3635 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3636 HasAngles, Angles, HasRefPoint, RefPoint,
3637 MakeGroups=False, LinearVariation=False):
3638 Angles,AnglesParameters = ParseAngles(Angles)
3639 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3640 if IDsOfElements == []:
3641 IDsOfElements = self.GetElementsId()
3642 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3643 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3645 if ( isinstance( PathMesh, Mesh )):
3646 PathMesh = PathMesh.GetMesh()
3647 if HasAngles and Angles and LinearVariation:
3648 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3650 Parameters = AnglesParameters + var_separator + RefPointParameters
3651 self.mesh.SetParameters(Parameters)
3653 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3654 PathShape, NodeStart, HasAngles,
3655 Angles, HasRefPoint, RefPoint)
3656 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3657 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3659 ## Generates new elements by extrusion of the elements which belong to the object
3660 # The path of extrusion must be a meshed edge.
3661 # @param theObject the object which elements should be processed.
3662 # It can be a mesh, a sub mesh or a group.
3663 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3664 # @param PathShape shape(edge) defines the sub-mesh for the path
3665 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3666 # @param HasAngles allows the shape to be rotated around the path
3667 # to get the resulting mesh in a helical fashion
3668 # @param Angles list of angles
3669 # @param HasRefPoint allows using the reference point
3670 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3671 # The User can specify any point as the Reference Point.
3672 # @param MakeGroups forces the generation of new groups from existing ones
3673 # @param LinearVariation forces the computation of rotation angles as linear
3674 # variation of the given Angles along path steps
3675 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3676 # only SMESH::Extrusion_Error otherwise
3677 # @ingroup l2_modif_extrurev
3678 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3679 HasAngles, Angles, HasRefPoint, RefPoint,
3680 MakeGroups=False, LinearVariation=False):
3681 Angles,AnglesParameters = ParseAngles(Angles)
3682 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3683 if ( isinstance( theObject, Mesh )):
3684 theObject = theObject.GetMesh()
3685 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3686 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3687 if ( isinstance( PathMesh, Mesh )):
3688 PathMesh = PathMesh.GetMesh()
3689 if HasAngles and Angles and LinearVariation:
3690 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3692 Parameters = AnglesParameters + var_separator + RefPointParameters
3693 self.mesh.SetParameters(Parameters)
3695 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3696 PathShape, NodeStart, HasAngles,
3697 Angles, HasRefPoint, RefPoint)
3698 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3699 NodeStart, HasAngles, Angles, HasRefPoint,
3702 ## Generates new elements by extrusion of the elements which belong to the object
3703 # The path of extrusion must be a meshed edge.
3704 # @param theObject the object which elements should be processed.
3705 # It can be a mesh, a sub mesh or a group.
3706 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3707 # @param PathShape shape(edge) defines the sub-mesh for the path
3708 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3709 # @param HasAngles allows the shape to be rotated around the path
3710 # to get the resulting mesh in a helical fashion
3711 # @param Angles list of angles
3712 # @param HasRefPoint allows using the reference point
3713 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3714 # The User can specify any point as the Reference Point.
3715 # @param MakeGroups forces the generation of new groups from existing ones
3716 # @param LinearVariation forces the computation of rotation angles as linear
3717 # variation of the given Angles along path steps
3718 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3719 # only SMESH::Extrusion_Error otherwise
3720 # @ingroup l2_modif_extrurev
3721 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3722 HasAngles, Angles, HasRefPoint, RefPoint,
3723 MakeGroups=False, LinearVariation=False):
3724 Angles,AnglesParameters = ParseAngles(Angles)
3725 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3726 if ( isinstance( theObject, Mesh )):
3727 theObject = theObject.GetMesh()
3728 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3729 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3730 if ( isinstance( PathMesh, Mesh )):
3731 PathMesh = PathMesh.GetMesh()
3732 if HasAngles and Angles and LinearVariation:
3733 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3735 Parameters = AnglesParameters + var_separator + RefPointParameters
3736 self.mesh.SetParameters(Parameters)
3738 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3739 PathShape, NodeStart, HasAngles,
3740 Angles, HasRefPoint, RefPoint)
3741 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3742 NodeStart, HasAngles, Angles, HasRefPoint,
3745 ## Generates new elements by extrusion of the elements which belong to the object
3746 # The path of extrusion must be a meshed edge.
3747 # @param theObject the object which elements should be processed.
3748 # It can be a mesh, a sub mesh or a group.
3749 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3750 # @param PathShape shape(edge) defines the sub-mesh for the path
3751 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3752 # @param HasAngles allows the shape to be rotated around the path
3753 # to get the resulting mesh in a helical fashion
3754 # @param Angles list of angles
3755 # @param HasRefPoint allows using the reference point
3756 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3757 # The User can specify any point as the Reference Point.
3758 # @param MakeGroups forces the generation of new groups from existing ones
3759 # @param LinearVariation forces the computation of rotation angles as linear
3760 # variation of the given Angles along path steps
3761 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3762 # only SMESH::Extrusion_Error otherwise
3763 # @ingroup l2_modif_extrurev
3764 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3765 HasAngles, Angles, HasRefPoint, RefPoint,
3766 MakeGroups=False, LinearVariation=False):
3767 Angles,AnglesParameters = ParseAngles(Angles)
3768 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3769 if ( isinstance( theObject, Mesh )):
3770 theObject = theObject.GetMesh()
3771 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3772 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3773 if ( isinstance( PathMesh, Mesh )):
3774 PathMesh = PathMesh.GetMesh()
3775 if HasAngles and Angles and LinearVariation:
3776 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3778 Parameters = AnglesParameters + var_separator + RefPointParameters
3779 self.mesh.SetParameters(Parameters)
3781 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3782 PathShape, NodeStart, HasAngles,
3783 Angles, HasRefPoint, RefPoint)
3784 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3785 NodeStart, HasAngles, Angles, HasRefPoint,
3788 ## Creates a symmetrical copy of mesh elements
3789 # @param IDsOfElements list of elements ids
3790 # @param Mirror is AxisStruct or geom object(point, line, plane)
3791 # @param theMirrorType is POINT, AXIS or PLANE
3792 # If the Mirror is a geom object this parameter is unnecessary
3793 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3794 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3795 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3796 # @ingroup l2_modif_trsf
3797 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3798 if IDsOfElements == []:
3799 IDsOfElements = self.GetElementsId()
3800 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3801 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3802 Mirror,Parameters = ParseAxisStruct(Mirror)
3803 self.mesh.SetParameters(Parameters)
3804 if Copy and MakeGroups:
3805 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3806 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3809 ## Creates a new mesh by a symmetrical copy of mesh elements
3810 # @param IDsOfElements the list of elements ids
3811 # @param Mirror is AxisStruct or geom object (point, line, plane)
3812 # @param theMirrorType is POINT, AXIS or PLANE
3813 # If the Mirror is a geom object this parameter is unnecessary
3814 # @param MakeGroups to generate new groups from existing ones
3815 # @param NewMeshName a name of the new mesh to create
3816 # @return instance of Mesh class
3817 # @ingroup l2_modif_trsf
3818 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3819 if IDsOfElements == []:
3820 IDsOfElements = self.GetElementsId()
3821 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3822 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3823 Mirror,Parameters = ParseAxisStruct(Mirror)
3824 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3825 MakeGroups, NewMeshName)
3826 mesh.SetParameters(Parameters)
3827 return Mesh(self.smeshpyD,self.geompyD,mesh)
3829 ## Creates a symmetrical copy of the object
3830 # @param theObject mesh, submesh or group
3831 # @param Mirror AxisStruct or geom object (point, line, plane)
3832 # @param theMirrorType is POINT, AXIS or PLANE
3833 # If the Mirror is a geom object this parameter is unnecessary
3834 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3835 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3836 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3837 # @ingroup l2_modif_trsf
3838 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3839 if ( isinstance( theObject, Mesh )):
3840 theObject = theObject.GetMesh()
3841 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3842 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3843 Mirror,Parameters = ParseAxisStruct(Mirror)
3844 self.mesh.SetParameters(Parameters)
3845 if Copy and MakeGroups:
3846 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3847 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3850 ## Creates a new mesh by a symmetrical copy of the object
3851 # @param theObject mesh, submesh or group
3852 # @param Mirror AxisStruct or geom object (point, line, plane)
3853 # @param theMirrorType POINT, AXIS or PLANE
3854 # If the Mirror is a geom object this parameter is unnecessary
3855 # @param MakeGroups forces the generation of new groups from existing ones
3856 # @param NewMeshName the name of the new mesh to create
3857 # @return instance of Mesh class
3858 # @ingroup l2_modif_trsf
3859 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3860 if ( isinstance( theObject, Mesh )):
3861 theObject = theObject.GetMesh()
3862 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3863 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3864 Mirror,Parameters = ParseAxisStruct(Mirror)
3865 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3866 MakeGroups, NewMeshName)
3867 mesh.SetParameters(Parameters)
3868 return Mesh( self.smeshpyD,self.geompyD,mesh )
3870 ## Translates the elements
3871 # @param IDsOfElements list of elements ids
3872 # @param Vector the direction of translation (DirStruct or vector)
3873 # @param Copy allows copying the translated elements
3874 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3875 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3876 # @ingroup l2_modif_trsf
3877 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3878 if IDsOfElements == []:
3879 IDsOfElements = self.GetElementsId()
3880 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3881 Vector = self.smeshpyD.GetDirStruct(Vector)
3882 Vector,Parameters = ParseDirStruct(Vector)
3883 self.mesh.SetParameters(Parameters)
3884 if Copy and MakeGroups:
3885 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3886 self.editor.Translate(IDsOfElements, Vector, Copy)
3889 ## Creates a new mesh of translated elements
3890 # @param IDsOfElements list of elements ids
3891 # @param Vector the direction of translation (DirStruct or vector)
3892 # @param MakeGroups forces the generation of new groups from existing ones
3893 # @param NewMeshName the name of the newly created mesh
3894 # @return instance of Mesh class
3895 # @ingroup l2_modif_trsf
3896 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3897 if IDsOfElements == []:
3898 IDsOfElements = self.GetElementsId()
3899 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3900 Vector = self.smeshpyD.GetDirStruct(Vector)
3901 Vector,Parameters = ParseDirStruct(Vector)
3902 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3903 mesh.SetParameters(Parameters)
3904 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3906 ## Translates the object
3907 # @param theObject the object to translate (mesh, submesh, or group)
3908 # @param Vector direction of translation (DirStruct or geom vector)
3909 # @param Copy allows copying the translated elements
3910 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3911 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3912 # @ingroup l2_modif_trsf
3913 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3914 if ( isinstance( theObject, Mesh )):
3915 theObject = theObject.GetMesh()
3916 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3917 Vector = self.smeshpyD.GetDirStruct(Vector)
3918 Vector,Parameters = ParseDirStruct(Vector)
3919 self.mesh.SetParameters(Parameters)
3920 if Copy and MakeGroups:
3921 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3922 self.editor.TranslateObject(theObject, Vector, Copy)
3925 ## Creates a new mesh from the translated object
3926 # @param theObject the object to translate (mesh, submesh, or group)
3927 # @param Vector the direction of translation (DirStruct or geom vector)
3928 # @param MakeGroups forces the generation of new groups from existing ones
3929 # @param NewMeshName the name of the newly created mesh
3930 # @return instance of Mesh class
3931 # @ingroup l2_modif_trsf
3932 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3933 if (isinstance(theObject, Mesh)):
3934 theObject = theObject.GetMesh()
3935 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3936 Vector = self.smeshpyD.GetDirStruct(Vector)
3937 Vector,Parameters = ParseDirStruct(Vector)
3938 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3939 mesh.SetParameters(Parameters)
3940 return Mesh( self.smeshpyD, self.geompyD, mesh )
3944 ## Scales the object
3945 # @param theObject - the object to translate (mesh, submesh, or group)
3946 # @param thePoint - base point for scale
3947 # @param theScaleFact - list of 1-3 scale factors for axises
3948 # @param Copy - allows copying the translated elements
3949 # @param MakeGroups - forces the generation of new groups from existing
3951 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3952 # empty list otherwise
3953 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3954 if ( isinstance( theObject, Mesh )):
3955 theObject = theObject.GetMesh()
3956 if ( isinstance( theObject, list )):
3957 theObject = self.GetIDSource(theObject, SMESH.ALL)
3959 thePoint, Parameters = ParsePointStruct(thePoint)
3960 self.mesh.SetParameters(Parameters)
3962 if Copy and MakeGroups:
3963 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3964 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3967 ## Creates a new mesh from the translated object
3968 # @param theObject - the object to translate (mesh, submesh, or group)
3969 # @param thePoint - base point for scale
3970 # @param theScaleFact - list of 1-3 scale factors for axises
3971 # @param MakeGroups - forces the generation of new groups from existing ones
3972 # @param NewMeshName - the name of the newly created mesh
3973 # @return instance of Mesh class
3974 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3975 if (isinstance(theObject, Mesh)):
3976 theObject = theObject.GetMesh()
3977 if ( isinstance( theObject, list )):
3978 theObject = self.GetIDSource(theObject,SMESH.ALL)
3980 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3981 MakeGroups, NewMeshName)
3982 #mesh.SetParameters(Parameters)
3983 return Mesh( self.smeshpyD, self.geompyD, mesh )
3987 ## Rotates the elements
3988 # @param IDsOfElements list of elements ids
3989 # @param Axis the axis of rotation (AxisStruct or geom line)
3990 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3991 # @param Copy allows copying the rotated elements
3992 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3993 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3994 # @ingroup l2_modif_trsf
3995 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3997 if isinstance(AngleInRadians,str):
3999 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
4001 AngleInRadians = DegreesToRadians(AngleInRadians)
4002 if IDsOfElements == []:
4003 IDsOfElements = self.GetElementsId()
4004 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
4005 Axis = self.smeshpyD.GetAxisStruct(Axis)
4006 Axis,AxisParameters = ParseAxisStruct(Axis)
4007 Parameters = AxisParameters + var_separator + Parameters
4008 self.mesh.SetParameters(Parameters)
4009 if Copy and MakeGroups:
4010 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
4011 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
4014 ## Creates a new mesh of rotated elements
4015 # @param IDsOfElements list of element ids
4016 # @param Axis the axis of rotation (AxisStruct or geom line)
4017 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
4018 # @param MakeGroups forces the generation of new groups from existing ones
4019 # @param NewMeshName the name of the newly created mesh
4020 # @return instance of Mesh class
4021 # @ingroup l2_modif_trsf
4022 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
4024 if isinstance(AngleInRadians,str):
4026 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
4028 AngleInRadians = DegreesToRadians(AngleInRadians)
4029 if IDsOfElements == []:
4030 IDsOfElements = self.GetElementsId()
4031 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
4032 Axis = self.smeshpyD.GetAxisStruct(Axis)
4033 Axis,AxisParameters = ParseAxisStruct(Axis)
4034 Parameters = AxisParameters + var_separator + Parameters
4035 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
4036 MakeGroups, NewMeshName)
4037 mesh.SetParameters(Parameters)
4038 return Mesh( self.smeshpyD, self.geompyD, mesh )
4040 ## Rotates the object
4041 # @param theObject the object to rotate( mesh, submesh, or group)
4042 # @param Axis the axis of rotation (AxisStruct or geom line)
4043 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
4044 # @param Copy allows copying the rotated elements
4045 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
4046 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
4047 # @ingroup l2_modif_trsf
4048 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
4050 if isinstance(AngleInRadians,str):
4052 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
4054 AngleInRadians = DegreesToRadians(AngleInRadians)
4055 if (isinstance(theObject, Mesh)):
4056 theObject = theObject.GetMesh()
4057 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
4058 Axis = self.smeshpyD.GetAxisStruct(Axis)
4059 Axis,AxisParameters = ParseAxisStruct(Axis)
4060 Parameters = AxisParameters + ":" + Parameters
4061 self.mesh.SetParameters(Parameters)
4062 if Copy and MakeGroups:
4063 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
4064 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
4067 ## Creates a new mesh from the rotated object
4068 # @param theObject the object to rotate (mesh, submesh, or group)
4069 # @param Axis the axis of rotation (AxisStruct or geom line)
4070 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
4071 # @param MakeGroups forces the generation of new groups from existing ones
4072 # @param NewMeshName the name of the newly created mesh
4073 # @return instance of Mesh class
4074 # @ingroup l2_modif_trsf
4075 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
4077 if isinstance(AngleInRadians,str):
4079 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
4081 AngleInRadians = DegreesToRadians(AngleInRadians)
4082 if (isinstance( theObject, Mesh )):
4083 theObject = theObject.GetMesh()
4084 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
4085 Axis = self.smeshpyD.GetAxisStruct(Axis)
4086 Axis,AxisParameters = ParseAxisStruct(Axis)
4087 Parameters = AxisParameters + ":" + Parameters
4088 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
4089 MakeGroups, NewMeshName)
4090 mesh.SetParameters(Parameters)
4091 return Mesh( self.smeshpyD, self.geompyD, mesh )
4093 ## Finds groups of ajacent nodes within Tolerance.
4094 # @param Tolerance the value of tolerance
4095 # @return the list of groups of nodes
4096 # @ingroup l2_modif_trsf
4097 def FindCoincidentNodes (self, Tolerance):
4098 return self.editor.FindCoincidentNodes(Tolerance)
4100 ## Finds groups of ajacent nodes within Tolerance.
4101 # @param Tolerance the value of tolerance
4102 # @param SubMeshOrGroup SubMesh or Group
4103 # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
4104 # @return the list of groups of nodes
4105 # @ingroup l2_modif_trsf
4106 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
4107 if (isinstance( SubMeshOrGroup, Mesh )):
4108 SubMeshOrGroup = SubMeshOrGroup.GetMesh()
4109 if not isinstance( exceptNodes, list):
4110 exceptNodes = [ exceptNodes ]
4111 if exceptNodes and isinstance( exceptNodes[0], int):
4112 exceptNodes = [ self.GetIDSource( exceptNodes, SMESH.NODE)]
4113 return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes)
4116 # @param GroupsOfNodes the list of groups of nodes
4117 # @ingroup l2_modif_trsf
4118 def MergeNodes (self, GroupsOfNodes):
4119 self.editor.MergeNodes(GroupsOfNodes)
4121 ## Finds the elements built on the same nodes.
4122 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
4123 # @return a list of groups of equal elements
4124 # @ingroup l2_modif_trsf
4125 def FindEqualElements (self, MeshOrSubMeshOrGroup):
4126 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
4127 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
4128 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
4130 ## Merges elements in each given group.
4131 # @param GroupsOfElementsID groups of elements for merging
4132 # @ingroup l2_modif_trsf
4133 def MergeElements(self, GroupsOfElementsID):
4134 self.editor.MergeElements(GroupsOfElementsID)
4136 ## Leaves one element and removes all other elements built on the same nodes.
4137 # @ingroup l2_modif_trsf
4138 def MergeEqualElements(self):
4139 self.editor.MergeEqualElements()
4141 ## Sews free borders
4142 # @return SMESH::Sew_Error
4143 # @ingroup l2_modif_trsf
4144 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
4145 FirstNodeID2, SecondNodeID2, LastNodeID2,
4146 CreatePolygons, CreatePolyedrs):
4147 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
4148 FirstNodeID2, SecondNodeID2, LastNodeID2,
4149 CreatePolygons, CreatePolyedrs)
4151 ## Sews conform free borders
4152 # @return SMESH::Sew_Error
4153 # @ingroup l2_modif_trsf
4154 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
4155 FirstNodeID2, SecondNodeID2):
4156 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
4157 FirstNodeID2, SecondNodeID2)
4159 ## Sews border to side
4160 # @return SMESH::Sew_Error
4161 # @ingroup l2_modif_trsf
4162 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
4163 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
4164 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
4165 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
4167 ## Sews two sides of a mesh. The nodes belonging to Side1 are
4168 # merged with the nodes of elements of Side2.
4169 # The number of elements in theSide1 and in theSide2 must be
4170 # equal and they should have similar nodal connectivity.
4171 # The nodes to merge should belong to side borders and
4172 # the first node should be linked to the second.
4173 # @return SMESH::Sew_Error
4174 # @ingroup l2_modif_trsf
4175 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
4176 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
4177 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
4178 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
4179 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
4180 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
4182 ## Sets new nodes for the given element.
4183 # @param ide the element id
4184 # @param newIDs nodes ids
4185 # @return If the number of nodes does not correspond to the type of element - returns false
4186 # @ingroup l2_modif_edit
4187 def ChangeElemNodes(self, ide, newIDs):
4188 return self.editor.ChangeElemNodes(ide, newIDs)
4190 ## If during the last operation of MeshEditor some nodes were
4191 # created, this method returns the list of their IDs, \n
4192 # if new nodes were not created - returns empty list
4193 # @return the list of integer values (can be empty)
4194 # @ingroup l1_auxiliary
4195 def GetLastCreatedNodes(self):
4196 return self.editor.GetLastCreatedNodes()
4198 ## If during the last operation of MeshEditor some elements were
4199 # created this method returns the list of their IDs, \n
4200 # if new elements were not created - returns empty list
4201 # @return the list of integer values (can be empty)
4202 # @ingroup l1_auxiliary
4203 def GetLastCreatedElems(self):
4204 return self.editor.GetLastCreatedElems()
4206 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4207 # @param theNodes identifiers of nodes to be doubled
4208 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
4209 # nodes. If list of element identifiers is empty then nodes are doubled but
4210 # they not assigned to elements
4211 # @return TRUE if operation has been completed successfully, FALSE otherwise
4212 # @ingroup l2_modif_edit
4213 def DoubleNodes(self, theNodes, theModifiedElems):
4214 return self.editor.DoubleNodes(theNodes, theModifiedElems)
4216 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4217 # This method provided for convenience works as DoubleNodes() described above.
4218 # @param theNodeId identifiers of node to be doubled
4219 # @param theModifiedElems identifiers of elements to be updated
4220 # @return TRUE if operation has been completed successfully, FALSE otherwise
4221 # @ingroup l2_modif_edit
4222 def DoubleNode(self, theNodeId, theModifiedElems):
4223 return self.editor.DoubleNode(theNodeId, theModifiedElems)
4225 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4226 # This method provided for convenience works as DoubleNodes() described above.
4227 # @param theNodes group of nodes to be doubled
4228 # @param theModifiedElems group of elements to be updated.
4229 # @param theMakeGroup forces the generation of a group containing new nodes.
4230 # @return TRUE or a created group if operation has been completed successfully,
4231 # FALSE or None otherwise
4232 # @ingroup l2_modif_edit
4233 def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
4235 return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
4236 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
4238 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4239 # This method provided for convenience works as DoubleNodes() described above.
4240 # @param theNodes list of groups of nodes to be doubled
4241 # @param theModifiedElems list of groups of elements to be updated.
4242 # @param theMakeGroup forces the generation of a group containing new nodes.
4243 # @return TRUE if operation has been completed successfully, FALSE otherwise
4244 # @ingroup l2_modif_edit
4245 def DoubleNodeGroups(self, theNodes, theModifiedElems, theMakeGroup=False):
4247 return self.editor.DoubleNodeGroupsNew(theNodes, theModifiedElems)
4248 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
4250 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4251 # @param theElems - the list of elements (edges or faces) to be replicated
4252 # The nodes for duplication could be found from these elements
4253 # @param theNodesNot - list of nodes to NOT replicate
4254 # @param theAffectedElems - the list of elements (cells and edges) to which the
4255 # replicated nodes should be associated to.
4256 # @return TRUE if operation has been completed successfully, FALSE otherwise
4257 # @ingroup l2_modif_edit
4258 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
4259 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
4261 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4262 # @param theElems - the list of elements (edges or faces) to be replicated
4263 # The nodes for duplication could be found from these elements
4264 # @param theNodesNot - list of nodes to NOT replicate
4265 # @param theShape - shape to detect affected elements (element which geometric center
4266 # located on or inside shape).
4267 # The replicated nodes should be associated to affected elements.
4268 # @return TRUE if operation has been completed successfully, FALSE otherwise
4269 # @ingroup l2_modif_edit
4270 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
4271 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
4273 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4274 # This method provided for convenience works as DoubleNodes() described above.
4275 # @param theElems - group of of elements (edges or faces) to be replicated
4276 # @param theNodesNot - group of nodes not to replicated
4277 # @param theAffectedElems - group of elements to which the replicated nodes
4278 # should be associated to.
4279 # @param theMakeGroup forces the generation of a group containing new elements.
4280 # @return TRUE or a created group if operation has been completed successfully,
4281 # FALSE or None otherwise
4282 # @ingroup l2_modif_edit
4283 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4285 return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
4286 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
4288 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4289 # This method provided for convenience works as DoubleNodes() described above.
4290 # @param theElems - group of of elements (edges or faces) to be replicated
4291 # @param theNodesNot - group of nodes not to replicated
4292 # @param theShape - shape to detect affected elements (element which geometric center
4293 # located on or inside shape).
4294 # The replicated nodes should be associated to affected elements.
4295 # @ingroup l2_modif_edit
4296 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
4297 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
4299 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4300 # This method provided for convenience works as DoubleNodes() described above.
4301 # @param theElems - list of groups of elements (edges or faces) to be replicated
4302 # @param theNodesNot - list of groups of nodes not to replicated
4303 # @param theAffectedElems - group of elements to which the replicated nodes
4304 # should be associated to.
4305 # @param theMakeGroup forces the generation of a group containing new elements.
4306 # @return TRUE or a created group if operation has been completed successfully,
4307 # FALSE or None otherwise
4308 # @ingroup l2_modif_edit
4309 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4311 return self.editor.DoubleNodeElemGroupsNew(theElems, theNodesNot, theAffectedElems)
4312 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
4314 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4315 # This method provided for convenience works as DoubleNodes() described above.
4316 # @param theElems - list of groups of elements (edges or faces) to be replicated
4317 # @param theNodesNot - list of groups of nodes not to replicated
4318 # @param theShape - shape to detect affected elements (element which geometric center
4319 # located on or inside shape).
4320 # The replicated nodes should be associated to affected elements.
4321 # @return TRUE if operation has been completed successfully, FALSE otherwise
4322 # @ingroup l2_modif_edit
4323 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
4324 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
4326 ## Double nodes on shared faces between groups of volumes and create flat elements on demand.
4327 # The list of groups must describe a partition of the mesh volumes.
4328 # The nodes of the internal faces at the boundaries of the groups are doubled.
4329 # In option, the internal faces are replaced by flat elements.
4330 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4331 # @param theDomains - list of groups of volumes
4332 # @param createJointElems - if TRUE, create the elements
4333 # @return TRUE if operation has been completed successfully, FALSE otherwise
4334 def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems ):
4335 return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems )
4337 ## Double nodes on some external faces and create flat elements.
4338 # Flat elements are mainly used by some types of mechanic calculations.
4340 # Each group of the list must be constituted of faces.
4341 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4342 # @param theGroupsOfFaces - list of groups of faces
4343 # @return TRUE if operation has been completed successfully, FALSE otherwise
4344 def CreateFlatElementsOnFacesGroups(self, theGroupsOfFaces ):
4345 return self.editor.CreateFlatElementsOnFacesGroups( theGroupsOfFaces )
4347 def _valueFromFunctor(self, funcType, elemId):
4348 fn = self.smeshpyD.GetFunctor(funcType)
4349 fn.SetMesh(self.mesh)
4350 if fn.GetElementType() == self.GetElementType(elemId, True):
4351 val = fn.GetValue(elemId)
4356 ## Get length of 1D element.
4357 # @param elemId mesh element ID
4358 # @return element's length value
4359 # @ingroup l1_measurements
4360 def GetLength(self, elemId):
4361 return self._valueFromFunctor(SMESH.FT_Length, elemId)
4363 ## Get area of 2D element.
4364 # @param elemId mesh element ID
4365 # @return element's area value
4366 # @ingroup l1_measurements
4367 def GetArea(self, elemId):
4368 return self._valueFromFunctor(SMESH.FT_Area, elemId)
4370 ## Get volume of 3D element.
4371 # @param elemId mesh element ID
4372 # @return element's volume value
4373 # @ingroup l1_measurements
4374 def GetVolume(self, elemId):
4375 return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
4377 ## Get maximum element length.
4378 # @param elemId mesh element ID
4379 # @return element's maximum length value
4380 # @ingroup l1_measurements
4381 def GetMaxElementLength(self, elemId):
4382 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4383 ftype = SMESH.FT_MaxElementLength3D
4385 ftype = SMESH.FT_MaxElementLength2D
4386 return self._valueFromFunctor(ftype, elemId)
4388 ## Get aspect ratio of 2D or 3D element.
4389 # @param elemId mesh element ID
4390 # @return element's aspect ratio value
4391 # @ingroup l1_measurements
4392 def GetAspectRatio(self, elemId):
4393 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4394 ftype = SMESH.FT_AspectRatio3D
4396 ftype = SMESH.FT_AspectRatio
4397 return self._valueFromFunctor(ftype, elemId)
4399 ## Get warping angle of 2D element.
4400 # @param elemId mesh element ID
4401 # @return element's warping angle value
4402 # @ingroup l1_measurements
4403 def GetWarping(self, elemId):
4404 return self._valueFromFunctor(SMESH.FT_Warping, elemId)
4406 ## Get minimum angle of 2D element.
4407 # @param elemId mesh element ID
4408 # @return element's minimum angle value
4409 # @ingroup l1_measurements
4410 def GetMinimumAngle(self, elemId):
4411 return self._valueFromFunctor(SMESH.FT_MinimumAngle, elemId)
4413 ## Get taper of 2D element.
4414 # @param elemId mesh element ID
4415 # @return element's taper value
4416 # @ingroup l1_measurements
4417 def GetTaper(self, elemId):
4418 return self._valueFromFunctor(SMESH.FT_Taper, elemId)
4420 ## Get skew of 2D element.
4421 # @param elemId mesh element ID
4422 # @return element's skew value
4423 # @ingroup l1_measurements
4424 def GetSkew(self, elemId):
4425 return self._valueFromFunctor(SMESH.FT_Skew, elemId)
4427 ## The mother class to define algorithm, it is not recommended to use it directly.
4430 # @ingroup l2_algorithms
4431 class Mesh_Algorithm:
4432 # @class Mesh_Algorithm
4433 # @brief Class Mesh_Algorithm
4435 #def __init__(self,smesh):
4443 ## Finds a hypothesis in the study by its type name and parameters.
4444 # Finds only the hypotheses created in smeshpyD engine.
4445 # @return SMESH.SMESH_Hypothesis
4446 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
4447 study = smeshpyD.GetCurrentStudy()
4448 #to do: find component by smeshpyD object, not by its data type
4449 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4450 if scomp is not None:
4451 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
4452 # Check if the root label of the hypotheses exists
4453 if res and hypRoot is not None:
4454 iter = study.NewChildIterator(hypRoot)
4455 # Check all published hypotheses
4457 hypo_so_i = iter.Value()
4458 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
4459 if attr is not None:
4460 anIOR = attr.Value()
4461 hypo_o_i = salome.orb.string_to_object(anIOR)
4462 if hypo_o_i is not None:
4463 # Check if this is a hypothesis
4464 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
4465 if hypo_i is not None:
4466 # Check if the hypothesis belongs to current engine
4467 if smeshpyD.GetObjectId(hypo_i) > 0:
4468 # Check if this is the required hypothesis
4469 if hypo_i.GetName() == hypname:
4471 if CompareMethod(hypo_i, args):
4485 ## Finds the algorithm in the study by its type name.
4486 # Finds only the algorithms, which have been created in smeshpyD engine.
4487 # @return SMESH.SMESH_Algo
4488 def FindAlgorithm (self, algoname, smeshpyD):
4489 study = smeshpyD.GetCurrentStudy()
4490 #to do: find component by smeshpyD object, not by its data type
4491 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4492 if scomp is not None:
4493 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
4494 # Check if the root label of the algorithms exists
4495 if res and hypRoot is not None:
4496 iter = study.NewChildIterator(hypRoot)
4497 # Check all published algorithms
4499 algo_so_i = iter.Value()
4500 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
4501 if attr is not None:
4502 anIOR = attr.Value()
4503 algo_o_i = salome.orb.string_to_object(anIOR)
4504 if algo_o_i is not None:
4505 # Check if this is an algorithm
4506 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
4507 if algo_i is not None:
4508 # Checks if the algorithm belongs to the current engine
4509 if smeshpyD.GetObjectId(algo_i) > 0:
4510 # Check if this is the required algorithm
4511 if algo_i.GetName() == algoname:
4524 ## If the algorithm is global, returns 0; \n
4525 # else returns the submesh associated to this algorithm.
4526 def GetSubMesh(self):
4529 ## Returns the wrapped mesher.
4530 def GetAlgorithm(self):
4533 ## Gets the list of hypothesis that can be used with this algorithm
4534 def GetCompatibleHypothesis(self):
4537 mylist = self.algo.GetCompatibleHypothesis()
4540 ## Gets the name of the algorithm
4544 ## Sets the name to the algorithm
4545 def SetName(self, name):
4546 self.mesh.smeshpyD.SetName(self.algo, name)
4548 ## Gets the id of the algorithm
4550 return self.algo.GetId()
4553 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
4555 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
4556 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
4558 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
4560 self.Assign(algo, mesh, geom)
4564 def Assign(self, algo, mesh, geom):
4566 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
4570 self.geom = mesh.geom
4573 AssureGeomPublished( mesh, geom )
4575 name = GetName(geom)
4579 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
4581 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
4582 TreatHypoStatus( status, algo.GetName(), name, True )
4585 def CompareHyp (self, hyp, args):
4586 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
4589 def CompareEqualHyp (self, hyp, args):
4593 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
4594 UseExisting=0, CompareMethod=""):
4597 if CompareMethod == "": CompareMethod = self.CompareHyp
4598 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
4601 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
4606 if isinstance( arg, geompyDC.GEOM._objref_GEOM_Object ):
4607 argStr = arg.GetStudyEntry()
4608 if not argStr: argStr = "GEOM_Obj_%s", arg.GetEntry()
4609 if len( argStr ) > 10:
4610 argStr = argStr[:7]+"..."
4611 if argStr[0] == '[': argStr += ']'
4617 self.mesh.smeshpyD.SetName(hypo, hyp + a)
4621 geomName = GetName(self.geom)
4622 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
4623 TreatHypoStatus( status, GetName(hypo), geomName, 0 )
4626 ## Returns entry of the shape to mesh in the study
4627 def MainShapeEntry(self):
4629 if not self.mesh or not self.mesh.GetMesh(): return entry
4630 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
4631 study = self.mesh.smeshpyD.GetCurrentStudy()
4632 ior = salome.orb.object_to_string( self.mesh.GetShape() )
4633 sobj = study.FindObjectIOR(ior)
4634 if sobj: entry = sobj.GetID()
4635 if not entry: return ""
4638 ## Defines "ViscousLayers" hypothesis to give parameters of layers of prisms to build
4639 # near mesh boundary. This hypothesis can be used by several 3D algorithms:
4640 # NETGEN 3D, GHS3D, Hexahedron(i,j,k)
4641 # @param thickness total thickness of layers of prisms
4642 # @param numberOfLayers number of layers of prisms
4643 # @param stretchFactor factor (>1.0) of growth of layer thickness towards inside of mesh
4644 # @param ignoreFaces list of geometrical faces (or their ids) not to generate layers on
4645 # @ingroup l3_hypos_additi
4646 def ViscousLayers(self, thickness, numberOfLayers, stretchFactor, ignoreFaces=[]):
4647 if not isinstance(self.algo, SMESH._objref_SMESH_3D_Algo):
4648 raise TypeError, "ViscousLayers are supported by 3D algorithms only"
4649 if not "ViscousLayers" in self.GetCompatibleHypothesis():
4650 raise TypeError, "ViscousLayers are not supported by %s"%self.algo.GetName()
4651 if ignoreFaces and isinstance( ignoreFaces[0], geompyDC.GEOM._objref_GEOM_Object ):
4652 ignoreFaces = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, f) for f in ignoreFaces ]
4653 hyp = self.Hypothesis("ViscousLayers",
4654 [thickness, numberOfLayers, stretchFactor, ignoreFaces])
4655 hyp.SetTotalThickness(thickness)
4656 hyp.SetNumberLayers(numberOfLayers)
4657 hyp.SetStretchFactor(stretchFactor)
4658 hyp.SetIgnoreFaces(ignoreFaces)
4661 ## Transform a list of ether edges or tuples (edge 1st_vertex_of_edge)
4662 # into a list acceptable to SetReversedEdges() of some 1D hypotheses
4663 # @ingroupl3_hypos_1dhyps
4664 def ReversedEdgeIndices(self, reverseList):
4666 geompy = self.mesh.geompyD
4667 for i in reverseList:
4668 if isinstance( i, int ):
4669 s = geompy.SubShapes(self.mesh.geom, [i])[0]
4670 if s.GetShapeType() != geompyDC.GEOM.EDGE:
4671 raise TypeError, "Not EDGE index given"
4673 elif isinstance( i, geompyDC.GEOM._objref_GEOM_Object ):
4674 if i.GetShapeType() != geompyDC.GEOM.EDGE:
4675 raise TypeError, "Not an EDGE given"
4676 resList.append( geompy.GetSubShapeID(self.mesh.geom, i ))
4680 if not isinstance( e, geompyDC.GEOM._objref_GEOM_Object ) or \
4681 not isinstance( v, geompyDC.GEOM._objref_GEOM_Object ):
4682 raise TypeError, "A list item must be a tuple (edge 1st_vertex_of_edge)"
4683 if v.GetShapeType() == geompyDC.GEOM.EDGE and \
4684 e.GetShapeType() == geompyDC.GEOM.VERTEX:
4686 if e.GetShapeType() != geompyDC.GEOM.EDGE or \
4687 v.GetShapeType() != geompyDC.GEOM.VERTEX:
4688 raise TypeError, "A list item must be a tuple (edge 1st_vertex_of_edge)"
4689 vFirst = FirstVertexOnCurve( e )
4690 tol = geompy.Tolerance( vFirst )[-1]
4691 if geompy.MinDistance( v, vFirst ) > 1.5*tol:
4692 resList.append( geompy.GetSubShapeID(self.mesh.geom, e ))
4694 raise TypeError, "Item must be either an edge or tuple (edge 1st_vertex_of_edge)"
4697 # Public class: Mesh_Segment
4698 # --------------------------
4700 ## Class to define a segment 1D algorithm for discretization
4703 # @ingroup l3_algos_basic
4704 class Mesh_Segment(Mesh_Algorithm):
4706 ## Private constructor.
4707 def __init__(self, mesh, geom=0):
4708 Mesh_Algorithm.__init__(self)
4709 self.Create(mesh, geom, "Regular_1D")
4711 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
4712 # @param l for the length of segments that cut an edge
4713 # @param UseExisting if ==true - searches for an existing hypothesis created with
4714 # the same parameters, else (default) - creates a new one
4715 # @param p precision, used for calculation of the number of segments.
4716 # The precision should be a positive, meaningful value within the range [0,1].
4717 # In general, the number of segments is calculated with the formula:
4718 # nb = ceil((edge_length / l) - p)
4719 # Function ceil rounds its argument to the higher integer.
4720 # So, p=0 means rounding of (edge_length / l) to the higher integer,
4721 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
4722 # p=1 means rounding of (edge_length / l) to the lower integer.
4723 # Default value is 1e-07.
4724 # @return an instance of StdMeshers_LocalLength hypothesis
4725 # @ingroup l3_hypos_1dhyps
4726 def LocalLength(self, l, UseExisting=0, p=1e-07):
4727 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
4728 CompareMethod=self.CompareLocalLength)
4734 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
4735 def CompareLocalLength(self, hyp, args):
4736 if IsEqual(hyp.GetLength(), args[0]):
4737 return IsEqual(hyp.GetPrecision(), args[1])
4740 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
4741 # @param length is optional maximal allowed length of segment, if it is omitted
4742 # the preestimated length is used that depends on geometry size
4743 # @param UseExisting if ==true - searches for an existing hypothesis created with
4744 # the same parameters, else (default) - create a new one
4745 # @return an instance of StdMeshers_MaxLength hypothesis
4746 # @ingroup l3_hypos_1dhyps
4747 def MaxSize(self, length=0.0, UseExisting=0):
4748 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
4751 hyp.SetLength(length)
4753 # set preestimated length
4754 gen = self.mesh.smeshpyD
4755 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
4756 self.mesh.GetMesh(), self.mesh.GetShape(),
4758 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
4760 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
4763 hyp.SetUsePreestimatedLength( length == 0.0 )
4766 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
4767 # @param n for the number of segments that cut an edge
4768 # @param s for the scale factor (optional)
4769 # @param reversedEdges is a list of edges to mesh using reversed orientation.
4770 # A list item can also be a tuple (edge 1st_vertex_of_edge)
4771 # @param UseExisting if ==true - searches for an existing hypothesis created with
4772 # the same parameters, else (default) - create a new one
4773 # @return an instance of StdMeshers_NumberOfSegments hypothesis
4774 # @ingroup l3_hypos_1dhyps
4775 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4776 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4777 reversedEdges, UseExisting = [], reversedEdges
4778 entry = self.MainShapeEntry()
4779 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
4781 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdgeInd, entry],
4782 UseExisting=UseExisting,
4783 CompareMethod=self.CompareNumberOfSegments)
4785 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdgeInd, entry],
4786 UseExisting=UseExisting,
4787 CompareMethod=self.CompareNumberOfSegments)
4788 hyp.SetDistrType( 1 )
4789 hyp.SetScaleFactor(s)
4790 hyp.SetNumberOfSegments(n)
4791 hyp.SetReversedEdges( reversedEdgeInd )
4792 hyp.SetObjectEntry( entry )
4796 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4797 def CompareNumberOfSegments(self, hyp, args):
4798 if hyp.GetNumberOfSegments() == args[0]:
4800 if hyp.GetReversedEdges() == args[1]:
4801 if not args[1] or hyp.GetObjectEntry() == args[2]:
4804 if hyp.GetReversedEdges() == args[2]:
4805 if not args[2] or hyp.GetObjectEntry() == args[3]:
4806 if hyp.GetDistrType() == 1:
4807 if IsEqual(hyp.GetScaleFactor(), args[1]):
4811 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4812 # @param start defines the length of the first segment
4813 # @param end defines the length of the last segment
4814 # @param reversedEdges is a list of edges to mesh using reversed orientation.
4815 # A list item can also be a tuple (edge 1st_vertex_of_edge)
4816 # @param UseExisting if ==true - searches for an existing hypothesis created with
4817 # the same parameters, else (default) - creates a new one
4818 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4819 # @ingroup l3_hypos_1dhyps
4820 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4821 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4822 reversedEdges, UseExisting = [], reversedEdges
4823 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
4824 entry = self.MainShapeEntry()
4825 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdgeInd, entry],
4826 UseExisting=UseExisting,
4827 CompareMethod=self.CompareArithmetic1D)
4828 hyp.SetStartLength(start)
4829 hyp.SetEndLength(end)
4830 hyp.SetReversedEdges( reversedEdgeInd )
4831 hyp.SetObjectEntry( entry )
4835 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4836 def CompareArithmetic1D(self, hyp, args):
4837 if IsEqual(hyp.GetLength(1), args[0]):
4838 if IsEqual(hyp.GetLength(0), args[1]):
4839 if hyp.GetReversedEdges() == args[2]:
4840 if not args[2] or hyp.GetObjectEntry() == args[3]:
4845 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4846 # on curve from 0 to 1 (additionally it is neecessary to check
4847 # orientation of edges and create list of reversed edges if it is
4848 # needed) and sets numbers of segments between given points (default
4849 # values are equals 1
4850 # @param points defines the list of parameters on curve
4851 # @param nbSegs defines the list of numbers of segments
4852 # @param reversedEdges is a list of edges to mesh using reversed orientation.
4853 # A list item can also be a tuple (edge 1st_vertex_of_edge)
4854 # @param UseExisting if ==true - searches for an existing hypothesis created with
4855 # the same parameters, else (default) - creates a new one
4856 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4857 # @ingroup l3_hypos_1dhyps
4858 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4859 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4860 reversedEdges, UseExisting = [], reversedEdges
4861 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
4862 entry = self.MainShapeEntry()
4863 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdgeInd, entry],
4864 UseExisting=UseExisting,
4865 CompareMethod=self.CompareFixedPoints1D)
4866 hyp.SetPoints(points)
4867 hyp.SetNbSegments(nbSegs)
4868 hyp.SetReversedEdges(reversedEdgeInd)
4869 hyp.SetObjectEntry(entry)
4873 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4874 ## as the given arguments
4875 def CompareFixedPoints1D(self, hyp, args):
4876 if hyp.GetPoints() == args[0]:
4877 if hyp.GetNbSegments() == args[1]:
4878 if hyp.GetReversedEdges() == args[2]:
4879 if not args[2] or hyp.GetObjectEntry() == args[3]:
4885 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4886 # @param start defines the length of the first segment
4887 # @param end defines the length of the last segment
4888 # @param reversedEdges is a list of edges to mesh using reversed orientation.
4889 # A list item can also be a tuple (edge 1st_vertex_of_edge)
4890 # @param UseExisting if ==true - searches for an existing hypothesis created with
4891 # the same parameters, else (default) - creates a new one
4892 # @return an instance of StdMeshers_StartEndLength hypothesis
4893 # @ingroup l3_hypos_1dhyps
4894 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4895 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4896 reversedEdges, UseExisting = [], reversedEdges
4897 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
4898 entry = self.MainShapeEntry()
4899 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdgeInd, entry],
4900 UseExisting=UseExisting,
4901 CompareMethod=self.CompareStartEndLength)
4902 hyp.SetStartLength(start)
4903 hyp.SetEndLength(end)
4904 hyp.SetReversedEdges( reversedEdgeInd )
4905 hyp.SetObjectEntry( entry )
4908 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4909 def CompareStartEndLength(self, hyp, args):
4910 if IsEqual(hyp.GetLength(1), args[0]):
4911 if IsEqual(hyp.GetLength(0), args[1]):
4912 if hyp.GetReversedEdges() == args[2]:
4913 if not args[2] or hyp.GetObjectEntry() == args[3]:
4917 ## Defines "Deflection1D" hypothesis
4918 # @param d for the deflection
4919 # @param UseExisting if ==true - searches for an existing hypothesis created with
4920 # the same parameters, else (default) - create a new one
4921 # @ingroup l3_hypos_1dhyps
4922 def Deflection1D(self, d, UseExisting=0):
4923 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4924 CompareMethod=self.CompareDeflection1D)
4925 hyp.SetDeflection(d)
4928 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4929 def CompareDeflection1D(self, hyp, args):
4930 return IsEqual(hyp.GetDeflection(), args[0])
4932 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4933 # the opposite side in case of quadrangular faces
4934 # @ingroup l3_hypos_additi
4935 def Propagation(self):
4936 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4938 ## Defines "AutomaticLength" hypothesis
4939 # @param fineness for the fineness [0-1]
4940 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4941 # same parameters, else (default) - create a new one
4942 # @ingroup l3_hypos_1dhyps
4943 def AutomaticLength(self, fineness=0, UseExisting=0):
4944 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4945 CompareMethod=self.CompareAutomaticLength)
4946 hyp.SetFineness( fineness )
4949 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4950 def CompareAutomaticLength(self, hyp, args):
4951 return IsEqual(hyp.GetFineness(), args[0])
4953 ## Defines "SegmentLengthAroundVertex" hypothesis
4954 # @param length for the segment length
4955 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4956 # Any other integer value means that the hypothesis will be set on the
4957 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4958 # @param UseExisting if ==true - searches for an existing hypothesis created with
4959 # the same parameters, else (default) - creates a new one
4960 # @ingroup l3_algos_segmarv
4961 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4963 store_geom = self.geom
4964 if type(vertex) is types.IntType:
4965 if vertex == 0 or vertex == 1:
4966 vertex = self.mesh.geompyD.ExtractShapes(self.geom, geompyDC.ShapeType["VERTEX"],True)[vertex]
4974 if self.geom is None:
4975 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4976 AssureGeomPublished( self.mesh, self.geom )
4977 name = GetName(self.geom)
4979 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4981 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4983 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4984 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4986 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4987 CompareMethod=self.CompareLengthNearVertex)
4988 self.geom = store_geom
4989 hyp.SetLength( length )
4992 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4993 # @ingroup l3_algos_segmarv
4994 def CompareLengthNearVertex(self, hyp, args):
4995 return IsEqual(hyp.GetLength(), args[0])
4997 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4998 # If the 2D mesher sees that all boundary edges are quadratic,
4999 # it generates quadratic faces, else it generates linear faces using
5000 # medium nodes as if they are vertices.
5001 # The 3D mesher generates quadratic volumes only if all boundary faces
5002 # are quadratic, else it fails.
5004 # @ingroup l3_hypos_additi
5005 def QuadraticMesh(self):
5006 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
5009 # Public class: Mesh_CompositeSegment
5010 # --------------------------
5012 ## Defines a segment 1D algorithm for discretization
5014 # @ingroup l3_algos_basic
5015 class Mesh_CompositeSegment(Mesh_Segment):
5017 ## Private constructor.
5018 def __init__(self, mesh, geom=0):
5019 self.Create(mesh, geom, "CompositeSegment_1D")
5022 # Public class: Mesh_Segment_Python
5023 # ---------------------------------
5025 ## Defines a segment 1D algorithm for discretization with python function
5027 # @ingroup l3_algos_basic
5028 class Mesh_Segment_Python(Mesh_Segment):
5030 ## Private constructor.
5031 def __init__(self, mesh, geom=0):
5032 import Python1dPlugin
5033 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
5035 ## Defines "PythonSplit1D" hypothesis
5036 # @param n for the number of segments that cut an edge
5037 # @param func for the python function that calculates the length of all segments
5038 # @param UseExisting if ==true - searches for the existing hypothesis created with
5039 # the same parameters, else (default) - creates a new one
5040 # @ingroup l3_hypos_1dhyps
5041 def PythonSplit1D(self, n, func, UseExisting=0):
5042 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
5043 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
5044 hyp.SetNumberOfSegments(n)
5045 hyp.SetPythonLog10RatioFunction(func)
5048 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
5049 def ComparePythonSplit1D(self, hyp, args):
5050 #if hyp.GetNumberOfSegments() == args[0]:
5051 # if hyp.GetPythonLog10RatioFunction() == args[1]:
5055 # Public class: Mesh_Triangle
5056 # ---------------------------
5058 ## Defines a triangle 2D algorithm
5060 # @ingroup l3_algos_basic
5061 class Mesh_Triangle(Mesh_Algorithm):
5070 ## Private constructor.
5071 def __init__(self, mesh, algoType, geom=0):
5072 Mesh_Algorithm.__init__(self)
5074 if algoType == MEFISTO:
5075 self.Create(mesh, geom, "MEFISTO_2D")
5077 elif algoType == BLSURF:
5079 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
5080 #self.SetPhysicalMesh() - PAL19680
5081 elif algoType == NETGEN:
5083 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
5085 elif algoType == NETGEN_2D:
5087 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
5090 self.algoType = algoType
5092 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
5093 # @param area for the maximum area of each triangle
5094 # @param UseExisting if ==true - searches for an existing hypothesis created with the
5095 # same parameters, else (default) - creates a new one
5097 # Only for algoType == MEFISTO || NETGEN_2D
5098 # @ingroup l3_hypos_2dhyps
5099 def MaxElementArea(self, area, UseExisting=0):
5100 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
5101 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
5102 CompareMethod=self.CompareMaxElementArea)
5103 elif self.algoType == NETGEN:
5104 hyp = self.Parameters(SIMPLE)
5105 hyp.SetMaxElementArea(area)
5108 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
5109 def CompareMaxElementArea(self, hyp, args):
5110 return IsEqual(hyp.GetMaxElementArea(), args[0])
5112 ## Defines "LengthFromEdges" hypothesis to build triangles
5113 # based on the length of the edges taken from the wire
5115 # Only for algoType == MEFISTO || NETGEN_2D
5116 # @ingroup l3_hypos_2dhyps
5117 def LengthFromEdges(self):
5118 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
5119 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
5121 elif self.algoType == NETGEN:
5122 hyp = self.Parameters(SIMPLE)
5123 hyp.LengthFromEdges()
5126 ## Sets a way to define size of mesh elements to generate.
5127 # @param thePhysicalMesh is: DefaultSize, BLSURF_Custom or SizeMap.
5128 # @ingroup l3_hypos_blsurf
5129 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
5130 if self.Parameters():
5131 # Parameter of BLSURF algo
5132 self.params.SetPhysicalMesh(thePhysicalMesh)
5134 ## Sets size of mesh elements to generate.
5135 # @ingroup l3_hypos_blsurf
5136 def SetPhySize(self, theVal):
5137 if self.Parameters():
5138 # Parameter of BLSURF algo
5139 self.params.SetPhySize(theVal)
5141 ## Sets lower boundary of mesh element size (PhySize).
5142 # @ingroup l3_hypos_blsurf
5143 def SetPhyMin(self, theVal=-1):
5144 if self.Parameters():
5145 # Parameter of BLSURF algo
5146 self.params.SetPhyMin(theVal)
5148 ## Sets upper boundary of mesh element size (PhySize).
5149 # @ingroup l3_hypos_blsurf
5150 def SetPhyMax(self, theVal=-1):
5151 if self.Parameters():
5152 # Parameter of BLSURF algo
5153 self.params.SetPhyMax(theVal)
5155 ## Sets a way to define maximum angular deflection of mesh from CAD model.
5156 # @param theGeometricMesh is: 0 (None) or 1 (Custom)
5157 # @ingroup l3_hypos_blsurf
5158 def SetGeometricMesh(self, theGeometricMesh=0):
5159 if self.Parameters():
5160 # Parameter of BLSURF algo
5161 if self.params.GetPhysicalMesh() == 0: theGeometricMesh = 1
5162 self.params.SetGeometricMesh(theGeometricMesh)
5164 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
5165 # @ingroup l3_hypos_blsurf
5166 def SetAngleMeshS(self, theVal=_angleMeshS):
5167 if self.Parameters():
5168 # Parameter of BLSURF algo
5169 if self.params.GetGeometricMesh() == 0: theVal = self._angleMeshS
5170 self.params.SetAngleMeshS(theVal)
5172 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
5173 # @ingroup l3_hypos_blsurf
5174 def SetAngleMeshC(self, theVal=_angleMeshS):
5175 if self.Parameters():
5176 # Parameter of BLSURF algo
5177 if self.params.GetGeometricMesh() == 0: theVal = self._angleMeshS
5178 self.params.SetAngleMeshC(theVal)
5180 ## Sets lower boundary of mesh element size computed to respect angular deflection.
5181 # @ingroup l3_hypos_blsurf
5182 def SetGeoMin(self, theVal=-1):
5183 if self.Parameters():
5184 # Parameter of BLSURF algo
5185 self.params.SetGeoMin(theVal)
5187 ## Sets upper boundary of mesh element size computed to respect angular deflection.
5188 # @ingroup l3_hypos_blsurf
5189 def SetGeoMax(self, theVal=-1):
5190 if self.Parameters():
5191 # Parameter of BLSURF algo
5192 self.params.SetGeoMax(theVal)
5194 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
5195 # @ingroup l3_hypos_blsurf
5196 def SetGradation(self, theVal=_gradation):
5197 if self.Parameters():
5198 # Parameter of BLSURF algo
5199 if self.params.GetGeometricMesh() == 0: theVal = self._gradation
5200 self.params.SetGradation(theVal)
5202 ## Sets topology usage way.
5203 # @param way defines how mesh conformity is assured <ul>
5204 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
5205 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
5206 # <li>PreCAD - by pre-processing with PreCAD a CAD model</li></ul>
5207 # @ingroup l3_hypos_blsurf
5208 def SetTopology(self, way):
5209 if self.Parameters():
5210 # Parameter of BLSURF algo
5211 self.params.SetTopology(way)
5213 ## To respect geometrical edges or not.
5214 # @ingroup l3_hypos_blsurf
5215 def SetDecimesh(self, toIgnoreEdges=False):
5216 if self.Parameters():
5217 # Parameter of BLSURF algo
5218 self.params.SetDecimesh(toIgnoreEdges)
5220 ## Sets verbosity level in the range 0 to 100.
5221 # @ingroup l3_hypos_blsurf
5222 def SetVerbosity(self, level):
5223 if self.Parameters():
5224 # Parameter of BLSURF algo
5225 self.params.SetVerbosity(level)
5227 ## To optimize merges edges.
5228 # @ingroup l3_hypos_blsurf
5229 def SetPreCADMergeEdges(self, toMergeEdges=False):
5230 if self.Parameters():
5231 # Parameter of BLSURF algo
5232 self.params.SetPreCADMergeEdges(toMergeEdges)
5234 ## To remove nano edges.
5235 # @ingroup l3_hypos_blsurf
5236 def SetPreCADRemoveNanoEdges(self, toRemoveNanoEdges=False):
5237 if self.Parameters():
5238 # Parameter of BLSURF algo
5239 self.params.SetPreCADRemoveNanoEdges(toRemoveNanoEdges)
5241 ## To compute topology from scratch
5242 # @ingroup l3_hypos_blsurf
5243 def SetPreCADDiscardInput(self, toDiscardInput=False):
5244 if self.Parameters():
5245 # Parameter of BLSURF algo
5246 self.params.SetPreCADDiscardInput(toDiscardInput)
5248 ## Sets the length below which an edge is considered as nano
5249 # for the topology processing.
5250 # @ingroup l3_hypos_blsurf
5251 def SetPreCADEpsNano(self, epsNano):
5252 if self.Parameters():
5253 # Parameter of BLSURF algo
5254 self.params.SetPreCADEpsNano(epsNano)
5256 ## Sets advanced option value.
5257 # @ingroup l3_hypos_blsurf
5258 def SetOptionValue(self, optionName, level):
5259 if self.Parameters():
5260 # Parameter of BLSURF algo
5261 self.params.SetOptionValue(optionName,level)
5263 ## Sets advanced PreCAD option value.
5264 # Keyword arguments:
5265 # optionName: name of the option
5266 # optionValue: value of the option
5267 # @ingroup l3_hypos_blsurf
5268 def SetPreCADOptionValue(self, optionName, optionValue):
5269 if self.Parameters():
5270 # Parameter of BLSURF algo
5271 self.params.SetPreCADOptionValue(optionName,optionValue)
5273 ## Sets GMF file for export at computation
5274 # @ingroup l3_hypos_blsurf
5275 def SetGMFFile(self, fileName):
5276 if self.Parameters():
5277 # Parameter of BLSURF algo
5278 self.params.SetGMFFile(fileName)
5280 ## Enforced vertices (BLSURF)
5282 ## To get all the enforced vertices
5283 # @ingroup l3_hypos_blsurf
5284 def GetAllEnforcedVertices(self):
5285 if self.Parameters():
5286 # Parameter of BLSURF algo
5287 return self.params.GetAllEnforcedVertices()
5289 ## To get all the enforced vertices sorted by face (or group, compound)
5290 # @ingroup l3_hypos_blsurf
5291 def GetAllEnforcedVerticesByFace(self):
5292 if self.Parameters():
5293 # Parameter of BLSURF algo
5294 return self.params.GetAllEnforcedVerticesByFace()
5296 ## To get all the enforced vertices sorted by coords of input vertices
5297 # @ingroup l3_hypos_blsurf
5298 def GetAllEnforcedVerticesByCoords(self):
5299 if self.Parameters():
5300 # Parameter of BLSURF algo
5301 return self.params.GetAllEnforcedVerticesByCoords()
5303 ## To get all the coords of input vertices sorted by face (or group, compound)
5304 # @ingroup l3_hypos_blsurf
5305 def GetAllCoordsByFace(self):
5306 if self.Parameters():
5307 # Parameter of BLSURF algo
5308 return self.params.GetAllCoordsByFace()
5310 ## To get all the enforced vertices on a face (or group, compound)
5311 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
5312 # @ingroup l3_hypos_blsurf
5313 def GetEnforcedVertices(self, theFace):
5314 if self.Parameters():
5315 # Parameter of BLSURF algo
5316 AssureGeomPublished( self.mesh, theFace )
5317 return self.params.GetEnforcedVertices(theFace)
5319 ## To clear all the enforced vertices
5320 # @ingroup l3_hypos_blsurf
5321 def ClearAllEnforcedVertices(self):
5322 if self.Parameters():
5323 # Parameter of BLSURF algo
5324 return self.params.ClearAllEnforcedVertices()
5326 ## 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.
5327 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
5328 # @param x : x coordinate
5329 # @param y : y coordinate
5330 # @param z : z coordinate
5331 # @param vertexName : name of the enforced vertex
5332 # @param groupName : name of the group
5333 # @ingroup l3_hypos_blsurf
5334 def SetEnforcedVertex(self, theFace, x, y, z, vertexName = "", groupName = ""):
5335 if self.Parameters():
5336 # Parameter of BLSURF algo
5337 AssureGeomPublished( self.mesh, theFace )
5338 if vertexName == "":
5340 return self.params.SetEnforcedVertex(theFace, x, y, z)
5342 return self.params.SetEnforcedVertexWithGroup(theFace, x, y, z, groupName)
5345 return self.params.SetEnforcedVertexNamed(theFace, x, y, z, vertexName)
5347 return self.params.SetEnforcedVertexNamedWithGroup(theFace, x, y, z, vertexName, groupName)
5349 ## To set an enforced vertex on a face (or group, compound) given a GEOM vertex, group or compound.
5350 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
5351 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
5352 # @param groupName : name of the group
5353 # @ingroup l3_hypos_blsurf
5354 def SetEnforcedVertexGeom(self, theFace, theVertex, groupName = ""):
5355 if self.Parameters():
5356 # Parameter of BLSURF algo
5357 AssureGeomPublished( self.mesh, theFace )
5358 AssureGeomPublished( self.mesh, theVertex )
5360 return self.params.SetEnforcedVertexGeom(theFace, theVertex)
5362 return self.params.SetEnforcedVertexGeomWithGroup(theFace, theVertex,groupName)
5364 ## To remove an enforced vertex on a given GEOM face (or group, compound) given the coordinates.
5365 # @param theFace : GEOM face (or group, compound) on which to remove the enforced vertex
5366 # @param x : x coordinate
5367 # @param y : y coordinate
5368 # @param z : z coordinate
5369 # @ingroup l3_hypos_blsurf
5370 def UnsetEnforcedVertex(self, theFace, x, y, z):
5371 if self.Parameters():
5372 # Parameter of BLSURF algo
5373 AssureGeomPublished( self.mesh, theFace )
5374 return self.params.UnsetEnforcedVertex(theFace, x, y, z)
5376 ## To remove an enforced vertex on a given GEOM face (or group, compound) given a GEOM vertex, group or compound.
5377 # @param theFace : GEOM face (or group, compound) on which to remove the enforced vertex
5378 # @param theVertex : GEOM vertex (or group, compound) to remove.
5379 # @ingroup l3_hypos_blsurf
5380 def UnsetEnforcedVertexGeom(self, theFace, theVertex):
5381 if self.Parameters():
5382 # Parameter of BLSURF algo
5383 AssureGeomPublished( self.mesh, theFace )
5384 AssureGeomPublished( self.mesh, theVertex )
5385 return self.params.UnsetEnforcedVertexGeom(theFace, theVertex)
5387 ## To remove all enforced vertices on a given face.
5388 # @param theFace : face (or group/compound of faces) on which to remove all enforced vertices
5389 # @ingroup l3_hypos_blsurf
5390 def UnsetEnforcedVertices(self, theFace):
5391 if self.Parameters():
5392 # Parameter of BLSURF algo
5393 AssureGeomPublished( self.mesh, theFace )
5394 return self.params.UnsetEnforcedVertices(theFace)
5396 ## Attractors (BLSURF)
5398 ## 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 ]
5399 # @param theFace : face on which the attractor will be defined
5400 # @param theAttractor : geometrical object from which the mesh size "h" decreases exponentially
5401 # @param theStartSize : mesh size on theAttractor
5402 # @param theEndSize : maximum size that will be reached on theFace
5403 # @param theInfluenceDistance : influence of the attractor ( the size grow slower on theFace if it's high)
5404 # @param theConstantSizeDistance : distance until which the mesh size will be kept constant on theFace
5405 # @ingroup l3_hypos_blsurf
5406 def SetAttractorGeom(self, theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance):
5407 if self.Parameters():
5408 # Parameter of BLSURF algo
5409 AssureGeomPublished( self.mesh, theFace )
5410 AssureGeomPublished( self.mesh, theAttractor )
5411 self.params.SetAttractorGeom(theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance)
5413 ## Unsets an attractor on the chosen face.
5414 # @param theFace : face on which the attractor has to be removed
5415 # @ingroup l3_hypos_blsurf
5416 def UnsetAttractorGeom(self, theFace):
5417 if self.Parameters():
5418 # Parameter of BLSURF algo
5419 AssureGeomPublished( self.mesh, theFace )
5420 self.params.SetAttractorGeom(theFace)
5422 ## Size maps (BLSURF)
5424 ## To set a size map on a face, edge or vertex (or group, compound) given Python function.
5425 # If theObject is a face, the function can be: def f(u,v): return u+v
5426 # If theObject is an edge, the function can be: def f(t): return t/2
5427 # If theObject is a vertex, the function can be: def f(): return 10
5428 # @param theObject : GEOM face, edge or vertex (or group, compound) on which to define a size map
5429 # @param theSizeMap : Size map defined as a string
5430 # @ingroup l3_hypos_blsurf
5431 def SetSizeMap(self, theObject, theSizeMap):
5432 if self.Parameters():
5433 # Parameter of BLSURF algo
5434 AssureGeomPublished( self.mesh, theObject )
5435 return self.params.SetSizeMap(theObject, theSizeMap)
5437 ## To remove a size map defined on a face, edge or vertex (or group, compound)
5438 # @param theObject : GEOM face, edge or vertex (or group, compound) on which to define a size map
5439 # @ingroup l3_hypos_blsurf
5440 def UnsetSizeMap(self, theObject):
5441 if self.Parameters():
5442 # Parameter of BLSURF algo
5443 AssureGeomPublished( self.mesh, theObject )
5444 return self.params.UnsetSizeMap(theObject)
5446 ## To remove all the size maps
5447 # @ingroup l3_hypos_blsurf
5448 def ClearSizeMaps(self):
5449 if self.Parameters():
5450 # Parameter of BLSURF algo
5451 return self.params.ClearSizeMaps()
5454 ## Sets QuadAllowed flag.
5455 # Only for algoType == NETGEN(NETGEN_1D2D) || NETGEN_2D || BLSURF
5456 # @ingroup l3_hypos_netgen l3_hypos_blsurf
5457 def SetQuadAllowed(self, toAllow=True):
5458 if self.algoType == NETGEN_2D:
5461 hasSimpleHyps = False
5462 simpleHyps = ["QuadranglePreference","LengthFromEdges","MaxElementArea"]
5463 for hyp in self.mesh.GetHypothesisList( self.geom ):
5464 if hyp.GetName() in simpleHyps:
5465 hasSimpleHyps = True
5466 if hyp.GetName() == "QuadranglePreference":
5467 if not toAllow: # remove QuadranglePreference
5468 self.mesh.RemoveHypothesis( self.geom, hyp )
5474 if toAllow: # add QuadranglePreference
5475 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
5480 if self.Parameters():
5481 self.params.SetQuadAllowed(toAllow)
5484 ## Defines hypothesis having several parameters
5486 # @ingroup l3_hypos_netgen
5487 def Parameters(self, which=SOLE):
5489 if self.algoType == NETGEN:
5491 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
5492 "libNETGENEngine.so", UseExisting=0)
5494 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
5495 "libNETGENEngine.so", UseExisting=0)
5496 elif self.algoType == MEFISTO:
5497 print "Mefisto algo support no multi-parameter hypothesis"
5498 elif self.algoType == NETGEN_2D:
5499 self.params = self.Hypothesis("NETGEN_Parameters_2D_ONLY", [],
5500 "libNETGENEngine.so", UseExisting=0)
5501 elif self.algoType == BLSURF:
5502 self.params = self.Hypothesis("BLSURF_Parameters", [],
5503 "libBLSURFEngine.so", UseExisting=0)
5505 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
5510 # Only for algoType == NETGEN
5511 # @ingroup l3_hypos_netgen
5512 def SetMaxSize(self, theSize):
5513 if self.Parameters():
5514 self.params.SetMaxSize(theSize)
5516 ## Sets SecondOrder flag
5518 # Only for algoType == NETGEN
5519 # @ingroup l3_hypos_netgen
5520 def SetSecondOrder(self, theVal):
5521 if self.Parameters():
5522 self.params.SetSecondOrder(theVal)
5524 ## Sets Optimize flag
5526 # Only for algoType == NETGEN
5527 # @ingroup l3_hypos_netgen
5528 def SetOptimize(self, theVal):
5529 if self.Parameters():
5530 self.params.SetOptimize(theVal)
5533 # @param theFineness is:
5534 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5536 # Only for algoType == NETGEN
5537 # @ingroup l3_hypos_netgen
5538 def SetFineness(self, theFineness):
5539 if self.Parameters():
5540 self.params.SetFineness(theFineness)
5544 # Only for algoType == NETGEN
5545 # @ingroup l3_hypos_netgen
5546 def SetGrowthRate(self, theRate):
5547 if self.Parameters():
5548 self.params.SetGrowthRate(theRate)
5550 ## Sets NbSegPerEdge
5552 # Only for algoType == NETGEN
5553 # @ingroup l3_hypos_netgen
5554 def SetNbSegPerEdge(self, theVal):
5555 if self.Parameters():
5556 self.params.SetNbSegPerEdge(theVal)
5558 ## Sets NbSegPerRadius
5560 # Only for algoType == NETGEN
5561 # @ingroup l3_hypos_netgen
5562 def SetNbSegPerRadius(self, theVal):
5563 if self.Parameters():
5564 self.params.SetNbSegPerRadius(theVal)
5566 ## Sets number of segments overriding value set by SetLocalLength()
5568 # Only for algoType == NETGEN
5569 # @ingroup l3_hypos_netgen
5570 def SetNumberOfSegments(self, theVal):
5571 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5573 ## Sets number of segments overriding value set by SetNumberOfSegments()
5575 # Only for algoType == NETGEN
5576 # @ingroup l3_hypos_netgen
5577 def SetLocalLength(self, theVal):
5578 self.Parameters(SIMPLE).SetLocalLength(theVal)
5583 # Public class: Mesh_Quadrangle
5584 # -----------------------------
5586 ## Defines a quadrangle 2D algorithm
5588 # @ingroup l3_algos_basic
5589 class Mesh_Quadrangle(Mesh_Algorithm):
5593 ## Private constructor.
5594 def __init__(self, mesh, geom=0):
5595 Mesh_Algorithm.__init__(self)
5596 self.Create(mesh, geom, "Quadrangle_2D")
5599 ## Defines "QuadrangleParameters" hypothesis
5600 # @param quadType defines the algorithm of transition between differently descretized
5601 # sides of a geometrical face:
5602 # - QUAD_STANDARD - both triangles and quadrangles are possible in the transition
5603 # area along the finer meshed sides.
5604 # - QUAD_TRIANGLE_PREF - only triangles are built in the transition area along the
5605 # finer meshed sides.
5606 # - QUAD_QUADRANGLE_PREF - only quadrangles are built in the transition area along
5607 # the finer meshed sides, iff the total quantity of segments on
5608 # all four sides of the face is even (divisible by 2).
5609 # - QUAD_QUADRANGLE_PREF_REVERSED - same as QUAD_QUADRANGLE_PREF but the transition
5610 # area is located along the coarser meshed sides.
5611 # - QUAD_REDUCED - only quadrangles are built and the transition between the sides
5612 # is made gradually, layer by layer. This type has a limitation on
5613 # the number of segments: one pair of opposite sides must have the
5614 # same number of segments, the other pair must have an even difference
5615 # between the numbers of segments on the sides.
5616 # @param triangleVertex: vertex of a trilateral geometrical face, around which triangles
5617 # will be created while other elements will be quadrangles.
5618 # Vertex can be either a GEOM_Object or a vertex ID within the
5620 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5621 # the same parameters, else (default) - creates a new one
5622 # @ingroup l3_hypos_quad
5623 def QuadrangleParameters(self, quadType=StdMeshers.QUAD_STANDARD, triangleVertex=0, UseExisting=0):
5624 vertexID = triangleVertex
5625 if isinstance( triangleVertex, geompyDC.GEOM._objref_GEOM_Object ):
5626 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, triangleVertex )
5628 compFun = lambda hyp,args: \
5629 hyp.GetQuadType() == args[0] and \
5630 ( hyp.GetTriaVertex()==args[1] or ( hyp.GetTriaVertex()<1 and args[1]<1))
5631 self.params = self.Hypothesis("QuadrangleParams", [quadType,vertexID],
5632 UseExisting = UseExisting, CompareMethod=compFun)
5634 if self.params.GetQuadType() != quadType:
5635 self.params.SetQuadType(quadType)
5637 self.params.SetTriaVertex( vertexID )
5640 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5641 # quadrangles are built in the transition area along the finer meshed sides,
5642 # iff the total quantity of segments on all four sides of the face is even.
5643 # @param reversed if True, transition area is located along the coarser meshed sides.
5644 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5645 # the same parameters, else (default) - creates a new one
5646 # @ingroup l3_hypos_quad
5647 def QuadranglePreference(self, reversed=False, UseExisting=0):
5649 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF_REVERSED,UseExisting=UseExisting)
5650 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF,UseExisting=UseExisting)
5652 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5653 # triangles are built in the transition area along the finer meshed sides.
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 TrianglePreference(self, UseExisting=0):
5658 return self.QuadrangleParameters(QUAD_TRIANGLE_PREF,UseExisting=UseExisting)
5660 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5661 # quadrangles are built and the transition between the sides is made gradually,
5662 # layer by layer. This type has a limitation on the number of segments: one pair
5663 # of opposite sides must have the same number of segments, the other pair must
5664 # have an even difference between the numbers of segments on the sides.
5665 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5666 # the same parameters, else (default) - creates a new one
5667 # @ingroup l3_hypos_quad
5668 def Reduced(self, UseExisting=0):
5669 return self.QuadrangleParameters(QUAD_REDUCED,UseExisting=UseExisting)
5671 ## Defines "QuadrangleParams" hypothesis with QUAD_STANDARD type of quadrangulation
5672 # @param vertex: vertex of a trilateral geometrical face, around which triangles
5673 # will be created while other elements will be quadrangles.
5674 # Vertex can be either a GEOM_Object or a vertex ID within the
5676 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5677 # the same parameters, else (default) - creates a new one
5678 # @ingroup l3_hypos_quad
5679 def TriangleVertex(self, vertex, UseExisting=0):
5680 return self.QuadrangleParameters(QUAD_STANDARD,vertex,UseExisting)
5683 # Public class: Mesh_Tetrahedron
5684 # ------------------------------
5686 ## Defines a tetrahedron 3D algorithm
5688 # @ingroup l3_algos_basic
5689 class Mesh_Tetrahedron(Mesh_Algorithm):
5694 ## Private constructor.
5695 def __init__(self, mesh, algoType, geom=0):
5696 Mesh_Algorithm.__init__(self)
5698 if algoType == NETGEN:
5700 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
5703 elif algoType == FULL_NETGEN:
5705 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5708 elif algoType == GHS3D:
5710 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
5713 elif algoType == GHS3DPRL:
5714 CheckPlugin(GHS3DPRL)
5715 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
5718 self.algoType = algoType
5720 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
5721 # @param vol for the maximum volume of each tetrahedron
5722 # @param UseExisting if ==true - searches for the existing hypothesis created with
5723 # the same parameters, else (default) - creates a new one
5724 # @ingroup l3_hypos_maxvol
5725 def MaxElementVolume(self, vol, UseExisting=0):
5726 if self.algoType == NETGEN:
5727 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
5728 CompareMethod=self.CompareMaxElementVolume)
5729 hyp.SetMaxElementVolume(vol)
5731 elif self.algoType == FULL_NETGEN:
5732 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
5735 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
5736 def CompareMaxElementVolume(self, hyp, args):
5737 return IsEqual(hyp.GetMaxElementVolume(), args[0])
5739 ## Defines hypothesis having several parameters
5741 # @ingroup l3_hypos_netgen
5742 def Parameters(self, which=SOLE):
5745 if self.algoType == FULL_NETGEN:
5747 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
5748 "libNETGENEngine.so", UseExisting=0)
5750 self.params = self.Hypothesis("NETGEN_Parameters", [],
5751 "libNETGENEngine.so", UseExisting=0)
5753 elif self.algoType == NETGEN:
5754 self.params = self.Hypothesis("NETGEN_Parameters_3D", [],
5755 "libNETGENEngine.so", UseExisting=0)
5757 elif self.algoType == GHS3D:
5758 self.params = self.Hypothesis("GHS3D_Parameters", [],
5759 "libGHS3DEngine.so", UseExisting=0)
5761 elif self.algoType == GHS3DPRL:
5762 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
5763 "libGHS3DPRLEngine.so", UseExisting=0)
5765 print "Warning: %s supports no multi-parameter hypothesis"%self.algo.GetName()
5770 # Parameter of FULL_NETGEN and NETGEN
5771 # @ingroup l3_hypos_netgen
5772 def SetMaxSize(self, theSize):
5773 self.Parameters().SetMaxSize(theSize)
5775 ## Sets SecondOrder flag
5776 # Parameter of FULL_NETGEN
5777 # @ingroup l3_hypos_netgen
5778 def SetSecondOrder(self, theVal):
5779 self.Parameters().SetSecondOrder(theVal)
5781 ## Sets Optimize flag
5782 # Parameter of FULL_NETGEN and NETGEN
5783 # @ingroup l3_hypos_netgen
5784 def SetOptimize(self, theVal):
5785 self.Parameters().SetOptimize(theVal)
5788 # @param theFineness is:
5789 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5790 # Parameter of FULL_NETGEN
5791 # @ingroup l3_hypos_netgen
5792 def SetFineness(self, theFineness):
5793 self.Parameters().SetFineness(theFineness)
5796 # Parameter of FULL_NETGEN
5797 # @ingroup l3_hypos_netgen
5798 def SetGrowthRate(self, theRate):
5799 self.Parameters().SetGrowthRate(theRate)
5801 ## Sets NbSegPerEdge
5802 # Parameter of FULL_NETGEN
5803 # @ingroup l3_hypos_netgen
5804 def SetNbSegPerEdge(self, theVal):
5805 self.Parameters().SetNbSegPerEdge(theVal)
5807 ## Sets NbSegPerRadius
5808 # Parameter of FULL_NETGEN
5809 # @ingroup l3_hypos_netgen
5810 def SetNbSegPerRadius(self, theVal):
5811 self.Parameters().SetNbSegPerRadius(theVal)
5813 ## Sets number of segments overriding value set by SetLocalLength()
5814 # Only for algoType == NETGEN_FULL
5815 # @ingroup l3_hypos_netgen
5816 def SetNumberOfSegments(self, theVal):
5817 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5819 ## Sets number of segments overriding value set by SetNumberOfSegments()
5820 # Only for algoType == NETGEN_FULL
5821 # @ingroup l3_hypos_netgen
5822 def SetLocalLength(self, theVal):
5823 self.Parameters(SIMPLE).SetLocalLength(theVal)
5825 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
5826 # Overrides value set by LengthFromEdges()
5827 # Only for algoType == NETGEN_FULL
5828 # @ingroup l3_hypos_netgen
5829 def MaxElementArea(self, area):
5830 self.Parameters(SIMPLE).SetMaxElementArea(area)
5832 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
5833 # Overrides value set by MaxElementArea()
5834 # Only for algoType == NETGEN_FULL
5835 # @ingroup l3_hypos_netgen
5836 def LengthFromEdges(self):
5837 self.Parameters(SIMPLE).LengthFromEdges()
5839 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
5840 # Overrides value set by MaxElementVolume()
5841 # Only for algoType == NETGEN_FULL
5842 # @ingroup l3_hypos_netgen
5843 def LengthFromFaces(self):
5844 self.Parameters(SIMPLE).LengthFromFaces()
5846 ## To mesh "holes" in a solid or not. Default is to mesh.
5847 # @ingroup l3_hypos_ghs3dh
5848 def SetToMeshHoles(self, toMesh):
5849 # Parameter of GHS3D
5850 if self.Parameters():
5851 self.params.SetToMeshHoles(toMesh)
5853 ## Set Optimization level:
5854 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
5855 # Strong_Optimization.
5856 # Default is Standard_Optimization
5857 # @ingroup l3_hypos_ghs3dh
5858 def SetOptimizationLevel(self, level):
5859 # Parameter of GHS3D
5860 if self.Parameters():
5861 self.params.SetOptimizationLevel(level)
5863 ## Maximal size of memory to be used by the algorithm (in Megabytes).
5864 # @ingroup l3_hypos_ghs3dh
5865 def SetMaximumMemory(self, MB):
5866 # Advanced parameter of GHS3D
5867 if self.Parameters():
5868 self.params.SetMaximumMemory(MB)
5870 ## Initial size of memory to be used by the algorithm (in Megabytes) in
5871 # automatic memory adjustment mode.
5872 # @ingroup l3_hypos_ghs3dh
5873 def SetInitialMemory(self, MB):
5874 # Advanced parameter of GHS3D
5875 if self.Parameters():
5876 self.params.SetInitialMemory(MB)
5878 ## Path to working directory.
5879 # @ingroup l3_hypos_ghs3dh
5880 def SetWorkingDirectory(self, path):
5881 # Advanced parameter of GHS3D
5882 if self.Parameters():
5883 self.params.SetWorkingDirectory(path)
5885 ## To keep working files or remove them. Log file remains in case of errors anyway.
5886 # @ingroup l3_hypos_ghs3dh
5887 def SetKeepFiles(self, toKeep):
5888 # Advanced parameter of GHS3D and GHS3DPRL
5889 if self.Parameters():
5890 self.params.SetKeepFiles(toKeep)
5892 ## To set verbose level [0-10]. <ul>
5893 #<li> 0 - no standard output,
5894 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
5895 # indicates when the final mesh is being saved. In addition the software
5896 # gives indication regarding the CPU time.
5897 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
5898 # histogram of the skin mesh, quality statistics histogram together with
5899 # the characteristics of the final mesh.</ul>
5900 # @ingroup l3_hypos_ghs3dh
5901 def SetVerboseLevel(self, level):
5902 # Advanced parameter of GHS3D
5903 if self.Parameters():
5904 self.params.SetVerboseLevel(level)
5906 ## To create new nodes.
5907 # @ingroup l3_hypos_ghs3dh
5908 def SetToCreateNewNodes(self, toCreate):
5909 # Advanced parameter of GHS3D
5910 if self.Parameters():
5911 self.params.SetToCreateNewNodes(toCreate)
5913 ## To use boundary recovery version which tries to create mesh on a very poor
5914 # quality surface mesh.
5915 # @ingroup l3_hypos_ghs3dh
5916 def SetToUseBoundaryRecoveryVersion(self, toUse):
5917 # Advanced parameter of GHS3D
5918 if self.Parameters():
5919 self.params.SetToUseBoundaryRecoveryVersion(toUse)
5921 ## Applies finite-element correction by replacing overconstrained elements where
5922 # it is possible. The process is cutting first the overconstrained edges and
5923 # second the overconstrained facets. This insure that no edges have two boundary
5924 # vertices and that no facets have three boundary vertices.
5925 # @ingroup l3_hypos_ghs3dh
5926 def SetFEMCorrection(self, toUseFem):
5927 # Advanced parameter of GHS3D
5928 if self.Parameters():
5929 self.params.SetFEMCorrection(toUseFem)
5931 ## To removes initial central point.
5932 # @ingroup l3_hypos_ghs3dh
5933 def SetToRemoveCentralPoint(self, toRemove):
5934 # Advanced parameter of GHS3D
5935 if self.Parameters():
5936 self.params.SetToRemoveCentralPoint(toRemove)
5938 ## To set an enforced vertex.
5939 # @param x : x coordinate
5940 # @param y : y coordinate
5941 # @param z : z coordinate
5942 # @param size : size of 1D element around enforced vertex
5943 # @param vertexName : name of the enforced vertex
5944 # @param groupName : name of the group
5945 # @ingroup l3_hypos_ghs3dh
5946 def SetEnforcedVertex(self, x, y, z, size, vertexName = "", groupName = ""):
5947 # Advanced parameter of GHS3D
5948 if self.Parameters():
5949 if vertexName == "":
5951 return self.params.SetEnforcedVertex(x, y, z, size)
5953 return self.params.SetEnforcedVertexWithGroup(x, y, z, size, groupName)
5956 return self.params.SetEnforcedVertexNamed(x, y, z, size, vertexName)
5958 return self.params.SetEnforcedVertexNamedWithGroup(x, y, z, size, vertexName, groupName)
5960 ## To set an enforced vertex given a GEOM vertex, group or compound.
5961 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
5962 # @param size : size of 1D element around enforced vertex
5963 # @param groupName : name of the group
5964 # @ingroup l3_hypos_ghs3dh
5965 def SetEnforcedVertexGeom(self, theVertex, size, groupName = ""):
5966 AssureGeomPublished( self.mesh, theVertex )
5967 # Advanced parameter of GHS3D
5968 if self.Parameters():
5970 return self.params.SetEnforcedVertexGeom(theVertex, size)
5972 return self.params.SetEnforcedVertexGeomWithGroup(theVertex, size, groupName)
5974 ## To remove an enforced vertex.
5975 # @param x : x coordinate
5976 # @param y : y coordinate
5977 # @param z : z coordinate
5978 # @ingroup l3_hypos_ghs3dh
5979 def RemoveEnforcedVertex(self, x, y, z):
5980 # Advanced parameter of GHS3D
5981 if self.Parameters():
5982 return self.params.RemoveEnforcedVertex(x, y, z)
5984 ## To remove an enforced vertex given a GEOM vertex, group or compound.
5985 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
5986 # @ingroup l3_hypos_ghs3dh
5987 def RemoveEnforcedVertexGeom(self, theVertex):
5988 AssureGeomPublished( self.mesh, theVertex )
5989 # Advanced parameter of GHS3D
5990 if self.Parameters():
5991 return self.params.RemoveEnforcedVertexGeom(theVertex)
5993 ## To set an enforced mesh with given size and add the enforced elements in the group "groupName".
5994 # @param theSource : source mesh which provides constraint elements/nodes
5995 # @param elementType : SMESH.ElementType (NODE, EDGE or FACE)
5996 # @param size : size of elements around enforced elements. Unused if -1.
5997 # @param groupName : group in which enforced elements will be added. Unused if "".
5998 # @ingroup l3_hypos_ghs3dh
5999 def SetEnforcedMesh(self, theSource, elementType, size = -1, groupName = ""):
6000 # Advanced parameter of GHS3D
6001 if self.Parameters():
6004 return self.params.SetEnforcedMesh(theSource, elementType)
6006 return self.params.SetEnforcedMeshWithGroup(theSource, elementType, groupName)
6009 return self.params.SetEnforcedMeshSize(theSource, elementType, size)
6011 return self.params.SetEnforcedMeshSizeWithGroup(theSource, elementType, size, groupName)
6013 ## Sets command line option as text.
6014 # @ingroup l3_hypos_ghs3dh
6015 def SetTextOption(self, option):
6016 # Advanced parameter of GHS3D
6017 if self.Parameters():
6018 self.params.SetTextOption(option)
6020 ## Sets MED files name and path.
6021 def SetMEDName(self, value):
6022 if self.Parameters():
6023 self.params.SetMEDName(value)
6025 ## Sets the number of partition of the initial mesh
6026 def SetNbPart(self, value):
6027 if self.Parameters():
6028 self.params.SetNbPart(value)
6030 ## When big mesh, start tepal in background
6031 def SetBackground(self, value):
6032 if self.Parameters():
6033 self.params.SetBackground(value)
6035 # Public class: Mesh_Hexahedron
6036 # ------------------------------
6038 ## Defines a hexahedron 3D algorithm
6040 # @ingroup l3_algos_basic
6041 class Mesh_Hexahedron(Mesh_Algorithm):
6046 ## Private constructor.
6047 def __init__(self, mesh, algoType=Hexa, geom=0):
6048 Mesh_Algorithm.__init__(self)
6050 self.algoType = algoType
6052 if algoType == Hexa:
6053 self.Create(mesh, geom, "Hexa_3D")
6056 elif algoType == Hexotic:
6057 CheckPlugin(Hexotic)
6058 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
6061 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
6062 # @ingroup l3_hypos_hexotic
6063 def MinMaxQuad(self, min=3, max=8, quad=True):
6064 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
6066 self.params.SetHexesMinLevel(min)
6067 self.params.SetHexesMaxLevel(max)
6068 self.params.SetHexoticQuadrangles(quad)
6071 # Deprecated, only for compatibility!
6072 # Public class: Mesh_Netgen
6073 # ------------------------------
6075 ## Defines a NETGEN-based 2D or 3D algorithm
6076 # that needs no discrete boundary (i.e. independent)
6078 # This class is deprecated, only for compatibility!
6081 # @ingroup l3_algos_basic
6082 class Mesh_Netgen(Mesh_Algorithm):
6086 ## Private constructor.
6087 def __init__(self, mesh, is3D, geom=0):
6088 Mesh_Algorithm.__init__(self)
6094 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
6098 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
6101 ## Defines the hypothesis containing parameters of the algorithm
6102 def Parameters(self):
6104 hyp = self.Hypothesis("NETGEN_Parameters", [],
6105 "libNETGENEngine.so", UseExisting=0)
6107 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
6108 "libNETGENEngine.so", UseExisting=0)
6111 # Public class: Mesh_Projection1D
6112 # ------------------------------
6114 ## Defines a projection 1D algorithm
6115 # @ingroup l3_algos_proj
6117 class Mesh_Projection1D(Mesh_Algorithm):
6119 ## Private constructor.
6120 def __init__(self, mesh, geom=0):
6121 Mesh_Algorithm.__init__(self)
6122 self.Create(mesh, geom, "Projection_1D")
6124 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
6125 # a mesh pattern is taken, and, optionally, the association of vertices
6126 # between the source edge and a target edge (to which a hypothesis is assigned)
6127 # @param edge from which nodes distribution is taken
6128 # @param mesh from which nodes distribution is taken (optional)
6129 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
6130 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
6131 # to associate with \a srcV (optional)
6132 # @param UseExisting if ==true - searches for the existing hypothesis created with
6133 # the same parameters, else (default) - creates a new one
6134 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
6135 AssureGeomPublished( self.mesh, edge )
6136 AssureGeomPublished( self.mesh, srcV )
6137 AssureGeomPublished( self.mesh, tgtV )
6138 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
6140 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
6141 hyp.SetSourceEdge( edge )
6142 if not mesh is None and isinstance(mesh, Mesh):
6143 mesh = mesh.GetMesh()
6144 hyp.SetSourceMesh( mesh )
6145 hyp.SetVertexAssociation( srcV, tgtV )
6148 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
6149 #def CompareSourceEdge(self, hyp, args):
6150 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
6154 # Public class: Mesh_Projection2D
6155 # ------------------------------
6157 ## Defines a projection 2D algorithm
6158 # @ingroup l3_algos_proj
6160 class Mesh_Projection2D(Mesh_Algorithm):
6162 ## Private constructor.
6163 def __init__(self, mesh, geom=0, algoName="Projection_2D"):
6164 Mesh_Algorithm.__init__(self)
6165 self.Create(mesh, geom, algoName)
6167 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
6168 # a mesh pattern is taken, and, optionally, the association of vertices
6169 # between the source face and the target face (to which a hypothesis is assigned)
6170 # @param face from which the mesh pattern is taken
6171 # @param mesh from which the mesh pattern is taken (optional)
6172 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
6173 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
6174 # to associate with \a srcV1 (optional)
6175 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
6176 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
6177 # to associate with \a srcV2 (optional)
6178 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
6179 # the same parameters, else (default) - forces the creation a new one
6181 # Note: all association vertices must belong to one edge of a face
6182 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
6183 srcV2=None, tgtV2=None, UseExisting=0):
6184 for geom in [ face, srcV1, tgtV1, srcV2, tgtV2 ]:
6185 AssureGeomPublished( self.mesh, geom )
6186 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
6188 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
6189 hyp.SetSourceFace( face )
6190 if isinstance(mesh, Mesh):
6191 mesh = mesh.GetMesh()
6192 hyp.SetSourceMesh( mesh )
6193 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
6196 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
6197 #def CompareSourceFace(self, hyp, args):
6198 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
6201 # Public class: Mesh_Projection3D
6202 # ------------------------------
6204 ## Defines a projection 3D algorithm
6205 # @ingroup l3_algos_proj
6207 class Mesh_Projection3D(Mesh_Algorithm):
6209 ## Private constructor.
6210 def __init__(self, mesh, geom=0):
6211 Mesh_Algorithm.__init__(self)
6212 self.Create(mesh, geom, "Projection_3D")
6214 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
6215 # the mesh pattern is taken, and, optionally, the association of vertices
6216 # between the source and the target solid (to which a hipothesis is assigned)
6217 # @param solid from where the mesh pattern is taken
6218 # @param mesh from where the mesh pattern is taken (optional)
6219 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
6220 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
6221 # to associate with \a srcV1 (optional)
6222 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
6223 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
6224 # to associate with \a srcV2 (optional)
6225 # @param UseExisting - if ==true - searches for the existing hypothesis created with
6226 # the same parameters, else (default) - creates a new one
6228 # Note: association vertices must belong to one edge of a solid
6229 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
6230 srcV2=0, tgtV2=0, UseExisting=0):
6231 for geom in [ solid, srcV1, tgtV1, srcV2, tgtV2 ]:
6232 AssureGeomPublished( self.mesh, geom )
6233 hyp = self.Hypothesis("ProjectionSource3D",
6234 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
6236 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
6237 hyp.SetSource3DShape( solid )
6238 if not mesh is None and isinstance(mesh, Mesh):
6239 mesh = mesh.GetMesh()
6240 hyp.SetSourceMesh( mesh )
6241 if srcV1 and srcV2 and tgtV1 and tgtV2:
6242 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
6243 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
6246 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
6247 #def CompareSourceShape3D(self, hyp, args):
6248 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
6252 # Public class: Mesh_Prism
6253 # ------------------------
6255 ## Defines a 3D extrusion algorithm
6256 # @ingroup l3_algos_3dextr
6258 class Mesh_Prism3D(Mesh_Algorithm):
6260 ## Private constructor.
6261 def __init__(self, mesh, geom=0):
6262 Mesh_Algorithm.__init__(self)
6263 self.Create(mesh, geom, "Prism_3D")
6265 # Public class: Mesh_RadialPrism
6266 # -------------------------------
6268 ## Defines a Radial Prism 3D algorithm
6269 # @ingroup l3_algos_radialp
6271 class Mesh_RadialPrism3D(Mesh_Algorithm):
6273 ## Private constructor.
6274 def __init__(self, mesh, geom=0):
6275 Mesh_Algorithm.__init__(self)
6276 self.Create(mesh, geom, "RadialPrism_3D")
6278 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
6279 self.nbLayers = None
6281 ## Return 3D hypothesis holding the 1D one
6282 def Get3DHypothesis(self):
6283 return self.distribHyp
6285 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
6286 # hypothesis. Returns the created hypothesis
6287 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
6288 #print "OwnHypothesis",hypType
6289 if not self.nbLayers is None:
6290 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
6291 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
6292 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
6293 self.mesh.smeshpyD.SetCurrentStudy( None )
6294 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
6295 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
6296 self.distribHyp.SetLayerDistribution( hyp )
6299 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
6300 # prisms to build between the inner and outer shells
6301 # @param n number of layers
6302 # @param UseExisting if ==true - searches for the existing hypothesis created with
6303 # the same parameters, else (default) - creates a new one
6304 def NumberOfLayers(self, n, UseExisting=0):
6305 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
6306 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
6307 CompareMethod=self.CompareNumberOfLayers)
6308 self.nbLayers.SetNumberOfLayers( n )
6309 return self.nbLayers
6311 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
6312 def CompareNumberOfLayers(self, hyp, args):
6313 return IsEqual(hyp.GetNumberOfLayers(), args[0])
6315 ## Defines "LocalLength" hypothesis, specifying the segment length
6316 # to build between the inner and the outer shells
6317 # @param l the length of segments
6318 # @param p the precision of rounding
6319 def LocalLength(self, l, p=1e-07):
6320 hyp = self.OwnHypothesis("LocalLength", [l,p])
6325 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
6326 # prisms to build between the inner and the outer shells.
6327 # @param n the number of layers
6328 # @param s the scale factor (optional)
6329 def NumberOfSegments(self, n, s=[]):
6331 hyp = self.OwnHypothesis("NumberOfSegments", [n])
6333 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
6334 hyp.SetDistrType( 1 )
6335 hyp.SetScaleFactor(s)
6336 hyp.SetNumberOfSegments(n)
6339 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
6340 # to build between the inner and the outer shells with a length that changes in arithmetic progression
6341 # @param start the length of the first segment
6342 # @param end the length of the last segment
6343 def Arithmetic1D(self, start, end ):
6344 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
6345 hyp.SetLength(start, 1)
6346 hyp.SetLength(end , 0)
6349 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
6350 # to build between the inner and the outer shells as geometric length increasing
6351 # @param start for the length of the first segment
6352 # @param end for the length of the last segment
6353 def StartEndLength(self, start, end):
6354 hyp = self.OwnHypothesis("StartEndLength", [start, end])
6355 hyp.SetLength(start, 1)
6356 hyp.SetLength(end , 0)
6359 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
6360 # to build between the inner and outer shells
6361 # @param fineness defines the quality of the mesh within the range [0-1]
6362 def AutomaticLength(self, fineness=0):
6363 hyp = self.OwnHypothesis("AutomaticLength")
6364 hyp.SetFineness( fineness )
6367 # Public class: Mesh_RadialQuadrangle1D2D
6368 # -------------------------------
6370 ## Defines a Radial Quadrangle 1D2D algorithm
6371 # @ingroup l2_algos_radialq
6373 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
6375 ## Private constructor.
6376 def __init__(self, mesh, geom=0):
6377 Mesh_Algorithm.__init__(self)
6378 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
6380 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
6381 self.nbLayers = None
6383 ## Return 2D hypothesis holding the 1D one
6384 def Get2DHypothesis(self):
6385 return self.distribHyp
6387 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
6388 # hypothesis. Returns the created hypothesis
6389 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
6390 #print "OwnHypothesis",hypType
6392 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
6393 if self.distribHyp is None:
6394 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
6396 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
6397 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
6398 self.mesh.smeshpyD.SetCurrentStudy( None )
6399 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
6400 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
6401 self.distribHyp.SetLayerDistribution( hyp )
6404 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
6405 # @param n number of layers
6406 # @param UseExisting if ==true - searches for the existing hypothesis created with
6407 # the same parameters, else (default) - creates a new one
6408 def NumberOfLayers(self, n, UseExisting=0):
6410 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
6411 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
6412 CompareMethod=self.CompareNumberOfLayers)
6413 self.nbLayers.SetNumberOfLayers( n )
6414 return self.nbLayers
6416 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
6417 def CompareNumberOfLayers(self, hyp, args):
6418 return IsEqual(hyp.GetNumberOfLayers(), args[0])
6420 ## Defines "LocalLength" hypothesis, specifying the segment length
6421 # @param l the length of segments
6422 # @param p the precision of rounding
6423 def LocalLength(self, l, p=1e-07):
6424 hyp = self.OwnHypothesis("LocalLength", [l,p])
6429 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
6430 # @param n the number of layers
6431 # @param s the scale factor (optional)
6432 def NumberOfSegments(self, n, s=[]):
6434 hyp = self.OwnHypothesis("NumberOfSegments", [n])
6436 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
6437 hyp.SetDistrType( 1 )
6438 hyp.SetScaleFactor(s)
6439 hyp.SetNumberOfSegments(n)
6442 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
6443 # with a length that changes in arithmetic progression
6444 # @param start the length of the first segment
6445 # @param end the length of the last segment
6446 def Arithmetic1D(self, start, end ):
6447 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
6448 hyp.SetLength(start, 1)
6449 hyp.SetLength(end , 0)
6452 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
6453 # as geometric length increasing
6454 # @param start for the length of the first segment
6455 # @param end for the length of the last segment
6456 def StartEndLength(self, start, end):
6457 hyp = self.OwnHypothesis("StartEndLength", [start, end])
6458 hyp.SetLength(start, 1)
6459 hyp.SetLength(end , 0)
6462 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
6463 # @param fineness defines the quality of the mesh within the range [0-1]
6464 def AutomaticLength(self, fineness=0):
6465 hyp = self.OwnHypothesis("AutomaticLength")
6466 hyp.SetFineness( fineness )
6470 # Public class: Mesh_UseExistingElements
6471 # --------------------------------------
6472 ## Defines a Radial Quadrangle 1D2D algorithm
6473 # @ingroup l3_algos_basic
6475 class Mesh_UseExistingElements(Mesh_Algorithm):
6477 def __init__(self, dim, mesh, geom=0):
6479 self.Create(mesh, geom, "Import_1D")
6481 self.Create(mesh, geom, "Import_1D2D")
6484 ## Defines "Source edges" hypothesis, specifying groups of edges to import
6485 # @param groups list of groups of edges
6486 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
6487 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
6488 # @param UseExisting if ==true - searches for the existing hypothesis created with
6489 # the same parameters, else (default) - creates a new one
6490 def SourceEdges(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
6491 if self.algo.GetName() != "Import_1D":
6492 raise ValueError, "algoritm dimension mismatch"
6493 for group in groups:
6494 AssureGeomPublished( self.mesh, group )
6495 hyp = self.Hypothesis("ImportSource1D", [groups, toCopyMesh, toCopyGroups],
6496 UseExisting=UseExisting, CompareMethod=self._compareHyp)
6497 hyp.SetSourceEdges(groups)
6498 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
6501 ## Defines "Source faces" hypothesis, specifying groups of faces to import
6502 # @param groups list of groups of faces
6503 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
6504 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
6505 # @param UseExisting if ==true - searches for the existing hypothesis created with
6506 # the same parameters, else (default) - creates a new one
6507 def SourceFaces(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
6508 if self.algo.GetName() == "Import_1D":
6509 raise ValueError, "algoritm dimension mismatch"
6510 for group in groups:
6511 AssureGeomPublished( self.mesh, group )
6512 hyp = self.Hypothesis("ImportSource2D", [groups, toCopyMesh, toCopyGroups],
6513 UseExisting=UseExisting, CompareMethod=self._compareHyp)
6514 hyp.SetSourceFaces(groups)
6515 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
6518 def _compareHyp(self,hyp,args):
6519 if hasattr( hyp, "GetSourceEdges"):
6520 entries = hyp.GetSourceEdges()
6522 entries = hyp.GetSourceFaces()
6524 toCopyMesh,toCopyGroups = hyp.GetCopySourceMesh()
6525 if len(entries)==len(groups) and toCopyMesh==args[1] and toCopyGroups==args[2]:
6527 study = self.mesh.smeshpyD.GetCurrentStudy()
6530 ior = salome.orb.object_to_string(g)
6531 sobj = study.FindObjectIOR(ior)
6532 if sobj: entries2.append( sobj.GetID() )
6537 return entries == entries2
6540 # Public class: Mesh_Cartesian_3D
6541 # --------------------------------------
6542 ## Defines a Body Fitting 3D algorithm
6543 # @ingroup l3_algos_basic
6545 class Mesh_Cartesian_3D(Mesh_Algorithm):
6547 def __init__(self, mesh, geom=0):
6548 self.Create(mesh, geom, "Cartesian_3D")
6552 ## Defines "Body Fitting parameters" hypothesis
6553 # @param xGridDef is definition of the grid along the X asix.
6554 # It can be in either of two following forms:
6555 # - Explicit coordinates of nodes, e.g. [-1.5, 0.0, 3.1] or range( -100,200,10)
6556 # - Functions f(t) defining grid spacing at each point on grid axis. If there are
6557 # several functions, they must be accompanied by relative coordinates of
6558 # points dividing the whole shape into ranges where the functions apply; points
6559 # coodrinates should vary within (0.0, 1.0) range. Parameter \a t of the spacing
6560 # function f(t) varies from 0.0 to 1.0 witin a shape range.
6562 # - "10.5" - defines a grid with a constant spacing
6563 # - [["1", "1+10*t", "11"] [0.1, 0.6]] - defines different spacing in 3 ranges.
6564 # @param yGridDef defines the grid along the Y asix the same way as \axGridDef does
6565 # @param zGridDef defines the grid along the Z asix the same way as \axGridDef does
6566 # @param sizeThreshold (> 1.0) defines a minimal size of a polyhedron so that
6567 # a polyhedron of size less than hexSize/sizeThreshold is not created
6568 # @param UseExisting if ==true - searches for the existing hypothesis created with
6569 # the same parameters, else (default) - creates a new one
6570 def SetGrid(self, xGridDef, yGridDef, zGridDef, sizeThreshold=4.0, UseExisting=False):
6572 self.hyp = self.Hypothesis("CartesianParameters3D",
6573 [xGridDef, yGridDef, zGridDef, sizeThreshold],
6574 UseExisting=UseExisting, CompareMethod=self._compareHyp)
6575 if not self.mesh.IsUsedHypothesis( self.hyp, self.geom ):
6576 self.mesh.AddHypothesis( self.hyp, self.geom )
6578 for axis, gridDef in enumerate( [xGridDef, yGridDef, zGridDef]):
6579 if not gridDef: raise ValueError, "Empty grid definition"
6580 if isinstance( gridDef, str ):
6581 self.hyp.SetGridSpacing( [gridDef], [], axis )
6582 elif isinstance( gridDef[0], str ):
6583 self.hyp.SetGridSpacing( gridDef, [], axis )
6584 elif isinstance( gridDef[0], int ) or \
6585 isinstance( gridDef[0], float ):
6586 self.hyp.SetGrid(gridDef, axis )
6588 self.hyp.SetGridSpacing( gridDef[0], gridDef[1], axis )
6589 self.hyp.SetSizeThreshold( sizeThreshold )
6592 def _compareHyp(self,hyp,args):
6593 # not implemented yet
6596 # Public class: Mesh_UseExisting
6597 # -------------------------------
6598 class Mesh_UseExisting(Mesh_Algorithm):
6600 def __init__(self, dim, mesh, geom=0):
6602 self.Create(mesh, geom, "UseExisting_1D")
6604 self.Create(mesh, geom, "UseExisting_2D")
6607 import salome_notebook
6608 notebook = salome_notebook.notebook
6610 ##Return values of the notebook variables
6611 def ParseParameters(last, nbParams,nbParam, value):
6615 listSize = len(last)
6616 for n in range(0,nbParams):
6618 if counter < listSize:
6619 strResult = strResult + last[counter]
6621 strResult = strResult + ""
6623 if isinstance(value, str):
6624 if notebook.isVariable(value):
6625 result = notebook.get(value)
6626 strResult=strResult+value
6628 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
6630 strResult=strResult+str(value)
6632 if nbParams - 1 != counter:
6633 strResult=strResult+var_separator #":"
6635 return result, strResult
6637 #Wrapper class for StdMeshers_LocalLength hypothesis
6638 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
6640 ## Set Length parameter value
6641 # @param length numerical value or name of variable from notebook
6642 def SetLength(self, length):
6643 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
6644 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6645 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
6647 ## Set Precision parameter value
6648 # @param precision numerical value or name of variable from notebook
6649 def SetPrecision(self, precision):
6650 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
6651 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6652 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
6654 #Registering the new proxy for LocalLength
6655 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
6658 #Wrapper class for StdMeshers_LayerDistribution hypothesis
6659 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
6661 def SetLayerDistribution(self, hypo):
6662 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
6663 hypo.ClearParameters();
6664 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
6666 #Registering the new proxy for LayerDistribution
6667 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
6669 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
6670 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
6672 ## Set Length parameter value
6673 # @param length numerical value or name of variable from notebook
6674 def SetLength(self, length):
6675 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
6676 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
6677 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
6679 #Registering the new proxy for SegmentLengthAroundVertex
6680 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
6683 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
6684 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
6686 ## Set Length parameter value
6687 # @param length numerical value or name of variable from notebook
6688 # @param isStart true is length is Start Length, otherwise false
6689 def SetLength(self, length, isStart):
6693 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
6694 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
6695 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
6697 #Registering the new proxy for Arithmetic1D
6698 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
6700 #Wrapper class for StdMeshers_Deflection1D hypothesis
6701 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
6703 ## Set Deflection parameter value
6704 # @param deflection numerical value or name of variable from notebook
6705 def SetDeflection(self, deflection):
6706 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
6707 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
6708 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
6710 #Registering the new proxy for Deflection1D
6711 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
6713 #Wrapper class for StdMeshers_StartEndLength hypothesis
6714 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
6716 ## Set Length parameter value
6717 # @param length numerical value or name of variable from notebook
6718 # @param isStart true is length is Start Length, otherwise false
6719 def SetLength(self, length, isStart):
6723 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
6724 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
6725 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
6727 #Registering the new proxy for StartEndLength
6728 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
6730 #Wrapper class for StdMeshers_MaxElementArea hypothesis
6731 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
6733 ## Set Max Element Area parameter value
6734 # @param area numerical value or name of variable from notebook
6735 def SetMaxElementArea(self, area):
6736 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
6737 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
6738 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
6740 #Registering the new proxy for MaxElementArea
6741 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
6744 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
6745 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
6747 ## Set Max Element Volume parameter value
6748 # @param volume numerical value or name of variable from notebook
6749 def SetMaxElementVolume(self, volume):
6750 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
6751 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
6752 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
6754 #Registering the new proxy for MaxElementVolume
6755 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
6758 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
6759 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
6761 ## Set Number Of Layers parameter value
6762 # @param nbLayers numerical value or name of variable from notebook
6763 def SetNumberOfLayers(self, nbLayers):
6764 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
6765 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
6766 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
6768 #Registering the new proxy for NumberOfLayers
6769 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
6771 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
6772 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
6774 ## Set Number Of Segments parameter value
6775 # @param nbSeg numerical value or name of variable from notebook
6776 def SetNumberOfSegments(self, nbSeg):
6777 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
6778 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
6779 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6780 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
6782 ## Set Scale Factor parameter value
6783 # @param factor numerical value or name of variable from notebook
6784 def SetScaleFactor(self, factor):
6785 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
6786 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6787 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
6789 #Registering the new proxy for NumberOfSegments
6790 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
6792 if not noNETGENPlugin:
6793 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
6794 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
6796 ## Set Max Size parameter value
6797 # @param maxsize numerical value or name of variable from notebook
6798 def SetMaxSize(self, maxsize):
6799 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6800 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
6801 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6802 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
6804 ## Set Growth Rate parameter value
6805 # @param value numerical value or name of variable from notebook
6806 def SetGrowthRate(self, value):
6807 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6808 value, parameters = ParseParameters(lastParameters,4,2,value)
6809 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6810 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
6812 ## Set Number of Segments per Edge parameter value
6813 # @param value numerical value or name of variable from notebook
6814 def SetNbSegPerEdge(self, value):
6815 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6816 value, parameters = ParseParameters(lastParameters,4,3,value)
6817 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6818 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
6820 ## Set Number of Segments per Radius parameter value
6821 # @param value numerical value or name of variable from notebook
6822 def SetNbSegPerRadius(self, value):
6823 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6824 value, parameters = ParseParameters(lastParameters,4,4,value)
6825 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6826 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
6828 #Registering the new proxy for NETGENPlugin_Hypothesis
6829 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
6832 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
6833 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
6836 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
6837 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
6839 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
6840 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
6842 ## Set Number of Segments parameter value
6843 # @param nbSeg numerical value or name of variable from notebook
6844 def SetNumberOfSegments(self, nbSeg):
6845 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6846 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
6847 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6848 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
6850 ## Set Local Length parameter value
6851 # @param length numerical value or name of variable from notebook
6852 def SetLocalLength(self, length):
6853 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6854 length, parameters = ParseParameters(lastParameters,2,1,length)
6855 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6856 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
6858 ## Set Max Element Area parameter value
6859 # @param area numerical value or name of variable from notebook
6860 def SetMaxElementArea(self, area):
6861 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6862 area, parameters = ParseParameters(lastParameters,2,2,area)
6863 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6864 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
6866 def LengthFromEdges(self):
6867 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6869 value, parameters = ParseParameters(lastParameters,2,2,value)
6870 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6871 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
6873 #Registering the new proxy for NETGEN_SimpleParameters_2D
6874 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
6877 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
6878 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
6879 ## Set Max Element Volume parameter value
6880 # @param volume numerical value or name of variable from notebook
6881 def SetMaxElementVolume(self, volume):
6882 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6883 volume, parameters = ParseParameters(lastParameters,3,3,volume)
6884 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6885 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
6887 def LengthFromFaces(self):
6888 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6890 value, parameters = ParseParameters(lastParameters,3,3,value)
6891 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6892 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
6894 #Registering the new proxy for NETGEN_SimpleParameters_3D
6895 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
6897 pass # if not noNETGENPlugin:
6899 class Pattern(SMESH._objref_SMESH_Pattern):
6901 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
6903 if isinstance(theNodeIndexOnKeyPoint1,str):
6905 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
6907 theNodeIndexOnKeyPoint1 -= 1
6908 theMesh.SetParameters(Parameters)
6909 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
6911 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
6914 if isinstance(theNode000Index,str):
6916 if isinstance(theNode001Index,str):
6918 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
6920 theNode000Index -= 1
6922 theNode001Index -= 1
6923 theMesh.SetParameters(Parameters)
6924 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
6926 #Registering the new proxy for Pattern
6927 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)