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 ## Evaluates size of prospective mesh on a shape
1471 # @return a list where i-th element is a number of elements of i-th SMESH.EntityType
1472 # To know predicted number of e.g. edges, inquire it this way
1473 # Evaluate()[ EnumToLong( Entity_Edge )]
1474 def Evaluate(self, geom=0):
1475 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1477 geom = self.mesh.GetShapeToMesh()
1480 return self.smeshpyD.Evaluate(self.mesh, geom)
1483 ## Computes the mesh and returns the status of the computation
1484 # @param geom geomtrical shape on which mesh data should be computed
1485 # @param discardModifs if True and the mesh has been edited since
1486 # a last total re-compute and that may prevent successful partial re-compute,
1487 # then the mesh is cleaned before Compute()
1488 # @return True or False
1489 # @ingroup l2_construct
1490 def Compute(self, geom=0, discardModifs=False):
1491 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1493 geom = self.mesh.GetShapeToMesh()
1498 if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693
1500 ok = self.smeshpyD.Compute(self.mesh, geom)
1501 except SALOME.SALOME_Exception, ex:
1502 print "Mesh computation failed, exception caught:"
1503 print " ", ex.details.text
1506 print "Mesh computation failed, exception caught:"
1507 traceback.print_exc()
1511 # Treat compute errors
1512 computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
1513 for err in computeErrors:
1515 if self.mesh.HasShapeToMesh():
1517 mainIOR = salome.orb.object_to_string(geom)
1518 for sname in salome.myStudyManager.GetOpenStudies():
1519 s = salome.myStudyManager.GetStudyByName(sname)
1521 mainSO = s.FindObjectIOR(mainIOR)
1522 if not mainSO: continue
1523 if err.subShapeID == 1:
1524 shapeText = ' on "%s"' % mainSO.GetName()
1525 subIt = s.NewChildIterator(mainSO)
1527 subSO = subIt.Value()
1529 obj = subSO.GetObject()
1530 if not obj: continue
1531 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
1533 ids = go.GetSubShapeIndices()
1534 if len(ids) == 1 and ids[0] == err.subShapeID:
1535 shapeText = ' on "%s"' % subSO.GetName()
1538 shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
1540 shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID)
1542 shapeText = " on subshape #%s" % (err.subShapeID)
1544 shapeText = " on subshape #%s" % (err.subShapeID)
1546 stdErrors = ["OK", #COMPERR_OK
1547 "Invalid input mesh", #COMPERR_BAD_INPUT_MESH
1548 "std::exception", #COMPERR_STD_EXCEPTION
1549 "OCC exception", #COMPERR_OCC_EXCEPTION
1550 "SALOME exception", #COMPERR_SLM_EXCEPTION
1551 "Unknown exception", #COMPERR_EXCEPTION
1552 "Memory allocation problem", #COMPERR_MEMORY_PB
1553 "Algorithm failed", #COMPERR_ALGO_FAILED
1554 "Unexpected geometry"]#COMPERR_BAD_SHAPE
1556 if err.code < len(stdErrors): errText = stdErrors[err.code]
1558 errText = "code %s" % -err.code
1559 if errText: errText += ". "
1560 errText += err.comment
1561 if allReasons != "":allReasons += "\n"
1562 allReasons += '"%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
1566 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1568 if err.isGlobalAlgo:
1576 reason = '%s %sD algorithm is missing' % (glob, dim)
1577 elif err.state == HYP_MISSING:
1578 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1579 % (glob, dim, name, dim))
1580 elif err.state == HYP_NOTCONFORM:
1581 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1582 elif err.state == HYP_BAD_PARAMETER:
1583 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1584 % ( glob, dim, name ))
1585 elif err.state == HYP_BAD_GEOMETRY:
1586 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1587 'geometry' % ( glob, dim, name ))
1589 reason = "For unknown reason."+\
1590 " Revise Mesh.Compute() implementation in smeshDC.py!"
1592 if allReasons != "":allReasons += "\n"
1593 allReasons += reason
1595 if allReasons != "":
1596 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1600 print '"' + GetName(self.mesh) + '"',"has not been computed."
1603 if salome.sg.hasDesktop():
1604 smeshgui = salome.ImportComponentGUI("SMESH")
1605 smeshgui.Init(self.mesh.GetStudyId())
1606 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1607 salome.sg.updateObjBrowser(1)
1611 ## Return submesh objects list in meshing order
1612 # @return list of list of submesh objects
1613 # @ingroup l2_construct
1614 def GetMeshOrder(self):
1615 return self.mesh.GetMeshOrder()
1617 ## Return submesh objects list in meshing order
1618 # @return list of list of submesh objects
1619 # @ingroup l2_construct
1620 def SetMeshOrder(self, submeshes):
1621 return self.mesh.SetMeshOrder(submeshes)
1623 ## Removes all nodes and elements
1624 # @ingroup l2_construct
1627 if salome.sg.hasDesktop():
1628 smeshgui = salome.ImportComponentGUI("SMESH")
1629 smeshgui.Init(self.mesh.GetStudyId())
1630 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1631 salome.sg.updateObjBrowser(1)
1633 ## Removes all nodes and elements of indicated shape
1634 # @ingroup l2_construct
1635 def ClearSubMesh(self, geomId):
1636 self.mesh.ClearSubMesh(geomId)
1637 if salome.sg.hasDesktop():
1638 smeshgui = salome.ImportComponentGUI("SMESH")
1639 smeshgui.Init(self.mesh.GetStudyId())
1640 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1641 salome.sg.updateObjBrowser(1)
1643 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1644 # @param fineness [0.0,1.0] defines mesh fineness
1645 # @return True or False
1646 # @ingroup l3_algos_basic
1647 def AutomaticTetrahedralization(self, fineness=0):
1648 dim = self.MeshDimension()
1650 self.RemoveGlobalHypotheses()
1651 self.Segment().AutomaticLength(fineness)
1653 self.Triangle().LengthFromEdges()
1656 self.Tetrahedron(NETGEN)
1658 return self.Compute()
1660 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1661 # @param fineness [0.0, 1.0] defines mesh fineness
1662 # @return True or False
1663 # @ingroup l3_algos_basic
1664 def AutomaticHexahedralization(self, fineness=0):
1665 dim = self.MeshDimension()
1666 # assign the hypotheses
1667 self.RemoveGlobalHypotheses()
1668 self.Segment().AutomaticLength(fineness)
1675 return self.Compute()
1677 ## Assigns a hypothesis
1678 # @param hyp a hypothesis to assign
1679 # @param geom a subhape of mesh geometry
1680 # @return SMESH.Hypothesis_Status
1681 # @ingroup l2_hypotheses
1682 def AddHypothesis(self, hyp, geom=0):
1683 if isinstance( hyp, Mesh_Algorithm ):
1684 hyp = hyp.GetAlgorithm()
1689 geom = self.mesh.GetShapeToMesh()
1691 status = self.mesh.AddHypothesis(geom, hyp)
1692 isAlgo = hyp._narrow( SMESH_Algo )
1693 hyp_name = GetName( hyp )
1696 geom_name = GetName( geom )
1697 TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1700 ## Unassigns a hypothesis
1701 # @param hyp a hypothesis to unassign
1702 # @param geom a subshape of mesh geometry
1703 # @return SMESH.Hypothesis_Status
1704 # @ingroup l2_hypotheses
1705 def RemoveHypothesis(self, hyp, geom=0):
1706 if isinstance( hyp, Mesh_Algorithm ):
1707 hyp = hyp.GetAlgorithm()
1712 status = self.mesh.RemoveHypothesis(geom, hyp)
1715 ## Gets the list of hypotheses added on a geometry
1716 # @param geom a subshape of mesh geometry
1717 # @return the sequence of SMESH_Hypothesis
1718 # @ingroup l2_hypotheses
1719 def GetHypothesisList(self, geom):
1720 return self.mesh.GetHypothesisList( geom )
1722 ## Removes all global hypotheses
1723 # @ingroup l2_hypotheses
1724 def RemoveGlobalHypotheses(self):
1725 current_hyps = self.mesh.GetHypothesisList( self.geom )
1726 for hyp in current_hyps:
1727 self.mesh.RemoveHypothesis( self.geom, hyp )
1731 ## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead.
1732 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1733 ## allowing to overwrite the file if it exists or add the exported data to its contents
1734 # @param f the file name
1735 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1736 # @param opt boolean parameter for creating/not creating
1737 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1738 # @param overwrite boolean parameter for overwriting/not overwriting the file
1739 # @ingroup l2_impexp
1740 def ExportToMED(self, f, version, opt=0, overwrite=1):
1741 self.mesh.ExportToMEDX(f, opt, version, overwrite)
1743 ## Exports the mesh in a file in MED format and chooses the \a version of MED format
1744 ## allowing to overwrite the file if it exists or add the exported data to its contents
1745 # @param f is the file name
1746 # @param auto_groups boolean parameter for creating/not creating
1747 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1748 # the typical use is auto_groups=false.
1749 # @param version MED format version(MED_V2_1 or MED_V2_2)
1750 # @param overwrite boolean parameter for overwriting/not overwriting the file
1751 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1752 # @ingroup l2_impexp
1753 def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1, meshPart=None):
1755 if isinstance( meshPart, list ):
1756 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1757 self.mesh.ExportPartToMED( meshPart, f, auto_groups, version, overwrite )
1759 self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
1761 ## Exports the mesh in a file in SAUV format
1762 # @param f is the file name
1763 # @param auto_groups boolean parameter for creating/not creating
1764 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1765 # the typical use is auto_groups=false.
1766 # @ingroup l2_impexp
1767 def ExportSAUV(self, f, auto_groups=0):
1768 self.mesh.ExportSAUV(f, auto_groups)
1770 ## Exports the mesh in a file in DAT format
1771 # @param f the file name
1772 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1773 # @ingroup l2_impexp
1774 def ExportDAT(self, f, meshPart=None):
1776 if isinstance( meshPart, list ):
1777 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1778 self.mesh.ExportPartToDAT( meshPart, f )
1780 self.mesh.ExportDAT(f)
1782 ## Exports the mesh in a file in UNV format
1783 # @param f the file name
1784 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1785 # @ingroup l2_impexp
1786 def ExportUNV(self, f, meshPart=None):
1788 if isinstance( meshPart, list ):
1789 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1790 self.mesh.ExportPartToUNV( meshPart, f )
1792 self.mesh.ExportUNV(f)
1794 ## Export the mesh in a file in STL format
1795 # @param f the file name
1796 # @param ascii defines the file encoding
1797 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1798 # @ingroup l2_impexp
1799 def ExportSTL(self, f, ascii=1, meshPart=None):
1801 if isinstance( meshPart, list ):
1802 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1803 self.mesh.ExportPartToSTL( meshPart, f, ascii )
1805 self.mesh.ExportSTL(f, ascii)
1807 ## Exports the mesh in a file in CGNS format
1808 # @param f is the file name
1809 # @param overwrite boolean parameter for overwriting/not overwriting the file
1810 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1811 # @ingroup l2_impexp
1812 def ExportCGNS(self, f, overwrite=1, meshPart=None):
1813 if isinstance( meshPart, list ):
1814 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1815 if isinstance( meshPart, Mesh ):
1816 meshPart = meshPart.mesh
1818 meshPart = self.mesh
1819 self.mesh.ExportCGNS(meshPart, f, overwrite)
1821 # Operations with groups:
1822 # ----------------------
1824 ## Creates an empty mesh group
1825 # @param elementType the type of elements in the group
1826 # @param name the name of the mesh group
1827 # @return SMESH_Group
1828 # @ingroup l2_grps_create
1829 def CreateEmptyGroup(self, elementType, name):
1830 return self.mesh.CreateGroup(elementType, name)
1832 ## Creates a mesh group based on the geometric object \a grp
1833 # and gives a \a name, \n if this parameter is not defined
1834 # the name is the same as the geometric group name \n
1835 # Note: Works like GroupOnGeom().
1836 # @param grp a geometric group, a vertex, an edge, a face or a solid
1837 # @param name the name of the mesh group
1838 # @return SMESH_GroupOnGeom
1839 # @ingroup l2_grps_create
1840 def Group(self, grp, name=""):
1841 return self.GroupOnGeom(grp, name)
1843 ## Creates a mesh group based on the geometrical object \a grp
1844 # and gives a \a name, \n if this parameter is not defined
1845 # the name is the same as the geometrical group name
1846 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1847 # @param name the name of the mesh group
1848 # @param typ the type of elements in the group. If not set, it is
1849 # automatically detected by the type of the geometry
1850 # @return SMESH_GroupOnGeom
1851 # @ingroup l2_grps_create
1852 def GroupOnGeom(self, grp, name="", typ=None):
1853 AssureGeomPublished( self, grp, name )
1855 name = grp.GetName()
1857 typ = self._groupTypeFromShape( grp )
1858 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1860 ## Pivate method to get a type of group on geometry
1861 def _groupTypeFromShape( self, shape ):
1862 tgeo = str(shape.GetShapeType())
1863 if tgeo == "VERTEX":
1865 elif tgeo == "EDGE":
1867 elif tgeo == "FACE" or tgeo == "SHELL":
1869 elif tgeo == "SOLID" or tgeo == "COMPSOLID":
1871 elif tgeo == "COMPOUND":
1872 sub = self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHAPE"])
1874 raise ValueError,"_groupTypeFromShape(): empty geometric group or compound '%s'" % GetName(shape)
1875 return self._groupTypeFromShape( sub[0] )
1878 "_groupTypeFromShape(): invalid geometry '%s'" % GetName(shape)
1881 ## Creates a mesh group with given \a name based on the \a filter which
1882 ## is a special type of group dynamically updating it's contents during
1883 ## mesh modification
1884 # @param typ the type of elements in the group
1885 # @param name the name of the mesh group
1886 # @param filter the filter defining group contents
1887 # @return SMESH_GroupOnFilter
1888 # @ingroup l2_grps_create
1889 def GroupOnFilter(self, typ, name, filter):
1890 return self.mesh.CreateGroupFromFilter(typ, name, filter)
1892 ## Creates a mesh group by the given ids of elements
1893 # @param groupName the name of the mesh group
1894 # @param elementType the type of elements in the group
1895 # @param elemIDs the list of ids
1896 # @return SMESH_Group
1897 # @ingroup l2_grps_create
1898 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1899 group = self.mesh.CreateGroup(elementType, groupName)
1903 ## Creates a mesh group by the given conditions
1904 # @param groupName the name of the mesh group
1905 # @param elementType the type of elements in the group
1906 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1907 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1908 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1909 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1910 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
1911 # FT_LyingOnGeom, FT_CoplanarFaces criteria
1912 # @return SMESH_Group
1913 # @ingroup l2_grps_create
1917 CritType=FT_Undefined,
1920 UnaryOp=FT_Undefined,
1922 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined,Tolerance)
1923 group = self.MakeGroupByCriterion(groupName, aCriterion)
1926 ## Creates a mesh group by the given criterion
1927 # @param groupName the name of the mesh group
1928 # @param Criterion the instance of Criterion class
1929 # @return SMESH_Group
1930 # @ingroup l2_grps_create
1931 def MakeGroupByCriterion(self, groupName, Criterion):
1932 aFilterMgr = self.smeshpyD.CreateFilterManager()
1933 aFilter = aFilterMgr.CreateFilter()
1935 aCriteria.append(Criterion)
1936 aFilter.SetCriteria(aCriteria)
1937 group = self.MakeGroupByFilter(groupName, aFilter)
1938 aFilterMgr.UnRegister()
1941 ## Creates a mesh group by the given criteria (list of criteria)
1942 # @param groupName the name of the mesh group
1943 # @param theCriteria the list of criteria
1944 # @return SMESH_Group
1945 # @ingroup l2_grps_create
1946 def MakeGroupByCriteria(self, groupName, theCriteria):
1947 aFilterMgr = self.smeshpyD.CreateFilterManager()
1948 aFilter = aFilterMgr.CreateFilter()
1949 aFilter.SetCriteria(theCriteria)
1950 group = self.MakeGroupByFilter(groupName, aFilter)
1951 aFilterMgr.UnRegister()
1954 ## Creates a mesh group by the given filter
1955 # @param groupName the name of the mesh group
1956 # @param theFilter the instance of Filter class
1957 # @return SMESH_Group
1958 # @ingroup l2_grps_create
1959 def MakeGroupByFilter(self, groupName, theFilter):
1960 group = self.CreateEmptyGroup(theFilter.GetElementType(), groupName)
1961 theFilter.SetMesh( self.mesh )
1962 group.AddFrom( theFilter )
1965 ## Passes mesh elements through the given filter and return IDs of fitting elements
1966 # @param theFilter SMESH_Filter
1967 # @return a list of ids
1968 # @ingroup l1_controls
1969 def GetIdsFromFilter(self, theFilter):
1970 theFilter.SetMesh( self.mesh )
1971 return theFilter.GetIDs()
1973 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1974 # Returns a list of special structures (borders).
1975 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1976 # @ingroup l1_controls
1977 def GetFreeBorders(self):
1978 aFilterMgr = self.smeshpyD.CreateFilterManager()
1979 aPredicate = aFilterMgr.CreateFreeEdges()
1980 aPredicate.SetMesh(self.mesh)
1981 aBorders = aPredicate.GetBorders()
1982 aFilterMgr.UnRegister()
1986 # @ingroup l2_grps_delete
1987 def RemoveGroup(self, group):
1988 self.mesh.RemoveGroup(group)
1990 ## Removes a group with its contents
1991 # @ingroup l2_grps_delete
1992 def RemoveGroupWithContents(self, group):
1993 self.mesh.RemoveGroupWithContents(group)
1995 ## Gets the list of groups existing in the mesh
1996 # @return a sequence of SMESH_GroupBase
1997 # @ingroup l2_grps_create
1998 def GetGroups(self):
1999 return self.mesh.GetGroups()
2001 ## Gets the number of groups existing in the mesh
2002 # @return the quantity of groups as an integer value
2003 # @ingroup l2_grps_create
2005 return self.mesh.NbGroups()
2007 ## Gets the list of names of groups existing in the mesh
2008 # @return list of strings
2009 # @ingroup l2_grps_create
2010 def GetGroupNames(self):
2011 groups = self.GetGroups()
2013 for group in groups:
2014 names.append(group.GetName())
2017 ## Produces a union of two groups
2018 # A new group is created. All mesh elements that are
2019 # present in the initial groups are added to the new one
2020 # @return an instance of SMESH_Group
2021 # @ingroup l2_grps_operon
2022 def UnionGroups(self, group1, group2, name):
2023 return self.mesh.UnionGroups(group1, group2, name)
2025 ## Produces a union list of groups
2026 # New group is created. All mesh elements that are present in
2027 # initial groups are added to the new one
2028 # @return an instance of SMESH_Group
2029 # @ingroup l2_grps_operon
2030 def UnionListOfGroups(self, groups, name):
2031 return self.mesh.UnionListOfGroups(groups, name)
2033 ## Prodices an intersection of two groups
2034 # A new group is created. All mesh elements that are common
2035 # for the two initial groups are added to the new one.
2036 # @return an instance of SMESH_Group
2037 # @ingroup l2_grps_operon
2038 def IntersectGroups(self, group1, group2, name):
2039 return self.mesh.IntersectGroups(group1, group2, name)
2041 ## Produces an intersection of groups
2042 # New group is created. All mesh elements that are present in all
2043 # initial groups simultaneously are added to the new one
2044 # @return an instance of SMESH_Group
2045 # @ingroup l2_grps_operon
2046 def IntersectListOfGroups(self, groups, name):
2047 return self.mesh.IntersectListOfGroups(groups, name)
2049 ## Produces a cut of two groups
2050 # A new group is created. All mesh elements that are present in
2051 # the main group but are not present in the tool group are added to the new one
2052 # @return an instance of SMESH_Group
2053 # @ingroup l2_grps_operon
2054 def CutGroups(self, main_group, tool_group, name):
2055 return self.mesh.CutGroups(main_group, tool_group, name)
2057 ## Produces a cut of groups
2058 # A new group is created. All mesh elements that are present in main groups
2059 # but do not present in tool groups are added to the new one
2060 # @return an instance of SMESH_Group
2061 # @ingroup l2_grps_operon
2062 def CutListOfGroups(self, main_groups, tool_groups, name):
2063 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
2065 ## Produces a group of elements of specified type using list of existing groups
2066 # A new group is created. System
2067 # 1) extracts all nodes on which groups elements are built
2068 # 2) combines all elements of specified dimension laying on these nodes
2069 # @return an instance of SMESH_Group
2070 # @ingroup l2_grps_operon
2071 def CreateDimGroup(self, groups, elem_type, name):
2072 return self.mesh.CreateDimGroup(groups, elem_type, name)
2075 ## Convert group on geom into standalone group
2076 # @ingroup l2_grps_delete
2077 def ConvertToStandalone(self, group):
2078 return self.mesh.ConvertToStandalone(group)
2080 # Get some info about mesh:
2081 # ------------------------
2083 ## Returns the log of nodes and elements added or removed
2084 # since the previous clear of the log.
2085 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
2086 # @return list of log_block structures:
2091 # @ingroup l1_auxiliary
2092 def GetLog(self, clearAfterGet):
2093 return self.mesh.GetLog(clearAfterGet)
2095 ## Clears the log of nodes and elements added or removed since the previous
2096 # clear. Must be used immediately after GetLog if clearAfterGet is false.
2097 # @ingroup l1_auxiliary
2099 self.mesh.ClearLog()
2101 ## Toggles auto color mode on the object.
2102 # @param theAutoColor the flag which toggles auto color mode.
2103 # @ingroup l1_auxiliary
2104 def SetAutoColor(self, theAutoColor):
2105 self.mesh.SetAutoColor(theAutoColor)
2107 ## Gets flag of object auto color mode.
2108 # @return True or False
2109 # @ingroup l1_auxiliary
2110 def GetAutoColor(self):
2111 return self.mesh.GetAutoColor()
2113 ## Gets the internal ID
2114 # @return integer value, which is the internal Id of the mesh
2115 # @ingroup l1_auxiliary
2117 return self.mesh.GetId()
2120 # @return integer value, which is the study Id of the mesh
2121 # @ingroup l1_auxiliary
2122 def GetStudyId(self):
2123 return self.mesh.GetStudyId()
2125 ## Checks the group names for duplications.
2126 # Consider the maximum group name length stored in MED file.
2127 # @return True or False
2128 # @ingroup l1_auxiliary
2129 def HasDuplicatedGroupNamesMED(self):
2130 return self.mesh.HasDuplicatedGroupNamesMED()
2132 ## Obtains the mesh editor tool
2133 # @return an instance of SMESH_MeshEditor
2134 # @ingroup l1_modifying
2135 def GetMeshEditor(self):
2136 return self.mesh.GetMeshEditor()
2138 ## Wrap a list of IDs of elements or nodes into SMESH_IDSource which
2139 # can be passed as argument to accepting mesh, group or sub-mesh
2140 # @return an instance of SMESH_IDSource
2141 # @ingroup l1_auxiliary
2142 def GetIDSource(self, ids, elemType):
2143 return self.GetMeshEditor().MakeIDSource(ids, elemType)
2146 # @return an instance of SALOME_MED::MESH
2147 # @ingroup l1_auxiliary
2148 def GetMEDMesh(self):
2149 return self.mesh.GetMEDMesh()
2152 # Get informations about mesh contents:
2153 # ------------------------------------
2155 ## Gets the mesh stattistic
2156 # @return dictionary type element - count of elements
2157 # @ingroup l1_meshinfo
2158 def GetMeshInfo(self, obj = None):
2159 if not obj: obj = self.mesh
2160 return self.smeshpyD.GetMeshInfo(obj)
2162 ## Returns the number of nodes in the mesh
2163 # @return an integer value
2164 # @ingroup l1_meshinfo
2166 return self.mesh.NbNodes()
2168 ## Returns the number of elements in the mesh
2169 # @return an integer value
2170 # @ingroup l1_meshinfo
2171 def NbElements(self):
2172 return self.mesh.NbElements()
2174 ## Returns the number of 0d elements in the mesh
2175 # @return an integer value
2176 # @ingroup l1_meshinfo
2177 def Nb0DElements(self):
2178 return self.mesh.Nb0DElements()
2180 ## Returns the number of edges in the mesh
2181 # @return an integer value
2182 # @ingroup l1_meshinfo
2184 return self.mesh.NbEdges()
2186 ## Returns the number of edges with the given order in the mesh
2187 # @param elementOrder the order of elements:
2188 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2189 # @return an integer value
2190 # @ingroup l1_meshinfo
2191 def NbEdgesOfOrder(self, elementOrder):
2192 return self.mesh.NbEdgesOfOrder(elementOrder)
2194 ## Returns the number of faces in the mesh
2195 # @return an integer value
2196 # @ingroup l1_meshinfo
2198 return self.mesh.NbFaces()
2200 ## Returns the number of faces with the given order in the mesh
2201 # @param elementOrder the order of elements:
2202 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2203 # @return an integer value
2204 # @ingroup l1_meshinfo
2205 def NbFacesOfOrder(self, elementOrder):
2206 return self.mesh.NbFacesOfOrder(elementOrder)
2208 ## Returns the number of triangles in the mesh
2209 # @return an integer value
2210 # @ingroup l1_meshinfo
2211 def NbTriangles(self):
2212 return self.mesh.NbTriangles()
2214 ## Returns the number of triangles with the given order in the mesh
2215 # @param elementOrder is the order of elements:
2216 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2217 # @return an integer value
2218 # @ingroup l1_meshinfo
2219 def NbTrianglesOfOrder(self, elementOrder):
2220 return self.mesh.NbTrianglesOfOrder(elementOrder)
2222 ## Returns the number of quadrangles in the mesh
2223 # @return an integer value
2224 # @ingroup l1_meshinfo
2225 def NbQuadrangles(self):
2226 return self.mesh.NbQuadrangles()
2228 ## Returns the number of quadrangles with the given order in the mesh
2229 # @param elementOrder the order of elements:
2230 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2231 # @return an integer value
2232 # @ingroup l1_meshinfo
2233 def NbQuadranglesOfOrder(self, elementOrder):
2234 return self.mesh.NbQuadranglesOfOrder(elementOrder)
2236 ## Returns the number of polygons in the mesh
2237 # @return an integer value
2238 # @ingroup l1_meshinfo
2239 def NbPolygons(self):
2240 return self.mesh.NbPolygons()
2242 ## Returns the number of volumes in the mesh
2243 # @return an integer value
2244 # @ingroup l1_meshinfo
2245 def NbVolumes(self):
2246 return self.mesh.NbVolumes()
2248 ## Returns the number of volumes with the given order in the mesh
2249 # @param elementOrder the order of elements:
2250 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2251 # @return an integer value
2252 # @ingroup l1_meshinfo
2253 def NbVolumesOfOrder(self, elementOrder):
2254 return self.mesh.NbVolumesOfOrder(elementOrder)
2256 ## Returns the number of tetrahedrons in the mesh
2257 # @return an integer value
2258 # @ingroup l1_meshinfo
2260 return self.mesh.NbTetras()
2262 ## Returns the number of tetrahedrons with the given order in the mesh
2263 # @param elementOrder the order of elements:
2264 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2265 # @return an integer value
2266 # @ingroup l1_meshinfo
2267 def NbTetrasOfOrder(self, elementOrder):
2268 return self.mesh.NbTetrasOfOrder(elementOrder)
2270 ## Returns the number of hexahedrons in the mesh
2271 # @return an integer value
2272 # @ingroup l1_meshinfo
2274 return self.mesh.NbHexas()
2276 ## Returns the number of hexahedrons with the given order in the mesh
2277 # @param elementOrder the order of elements:
2278 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2279 # @return an integer value
2280 # @ingroup l1_meshinfo
2281 def NbHexasOfOrder(self, elementOrder):
2282 return self.mesh.NbHexasOfOrder(elementOrder)
2284 ## Returns the number of pyramids in the mesh
2285 # @return an integer value
2286 # @ingroup l1_meshinfo
2287 def NbPyramids(self):
2288 return self.mesh.NbPyramids()
2290 ## Returns the number of pyramids with the given order in the mesh
2291 # @param elementOrder the order of elements:
2292 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2293 # @return an integer value
2294 # @ingroup l1_meshinfo
2295 def NbPyramidsOfOrder(self, elementOrder):
2296 return self.mesh.NbPyramidsOfOrder(elementOrder)
2298 ## Returns the number of prisms in the mesh
2299 # @return an integer value
2300 # @ingroup l1_meshinfo
2302 return self.mesh.NbPrisms()
2304 ## Returns the number of prisms with the given order in the mesh
2305 # @param elementOrder the order of elements:
2306 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2307 # @return an integer value
2308 # @ingroup l1_meshinfo
2309 def NbPrismsOfOrder(self, elementOrder):
2310 return self.mesh.NbPrismsOfOrder(elementOrder)
2312 ## Returns the number of polyhedrons in the mesh
2313 # @return an integer value
2314 # @ingroup l1_meshinfo
2315 def NbPolyhedrons(self):
2316 return self.mesh.NbPolyhedrons()
2318 ## Returns the number of submeshes in the mesh
2319 # @return an integer value
2320 # @ingroup l1_meshinfo
2321 def NbSubMesh(self):
2322 return self.mesh.NbSubMesh()
2324 ## Returns the list of mesh elements IDs
2325 # @return the list of integer values
2326 # @ingroup l1_meshinfo
2327 def GetElementsId(self):
2328 return self.mesh.GetElementsId()
2330 ## Returns the list of IDs of mesh elements with the given type
2331 # @param elementType the required type of elements (SMESH.NODE, SMESH.EDGE, SMESH.FACE or SMESH.VOLUME)
2332 # @return list of integer values
2333 # @ingroup l1_meshinfo
2334 def GetElementsByType(self, elementType):
2335 return self.mesh.GetElementsByType(elementType)
2337 ## Returns the list of mesh nodes IDs
2338 # @return the list of integer values
2339 # @ingroup l1_meshinfo
2340 def GetNodesId(self):
2341 return self.mesh.GetNodesId()
2343 # Get the information about mesh elements:
2344 # ------------------------------------
2346 ## Returns the type of mesh element
2347 # @return the value from SMESH::ElementType enumeration
2348 # @ingroup l1_meshinfo
2349 def GetElementType(self, id, iselem):
2350 return self.mesh.GetElementType(id, iselem)
2352 ## Returns the geometric type of mesh element
2353 # @return the value from SMESH::EntityType enumeration
2354 # @ingroup l1_meshinfo
2355 def GetElementGeomType(self, id):
2356 return self.mesh.GetElementGeomType(id)
2358 ## Returns the list of submesh elements IDs
2359 # @param Shape a geom object(subshape) IOR
2360 # Shape must be the subshape of a ShapeToMesh()
2361 # @return the list of integer values
2362 # @ingroup l1_meshinfo
2363 def GetSubMeshElementsId(self, Shape):
2364 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2365 ShapeID = Shape.GetSubShapeIndices()[0]
2368 return self.mesh.GetSubMeshElementsId(ShapeID)
2370 ## Returns the list of submesh nodes IDs
2371 # @param Shape a geom object(subshape) IOR
2372 # Shape must be the subshape of a ShapeToMesh()
2373 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
2374 # @return the list of integer values
2375 # @ingroup l1_meshinfo
2376 def GetSubMeshNodesId(self, Shape, all):
2377 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2378 ShapeID = Shape.GetSubShapeIndices()[0]
2381 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2383 ## Returns type of elements on given shape
2384 # @param Shape a geom object(subshape) IOR
2385 # Shape must be a subshape of a ShapeToMesh()
2386 # @return element type
2387 # @ingroup l1_meshinfo
2388 def GetSubMeshElementType(self, Shape):
2389 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2390 ShapeID = Shape.GetSubShapeIndices()[0]
2393 return self.mesh.GetSubMeshElementType(ShapeID)
2395 ## Gets the mesh description
2396 # @return string value
2397 # @ingroup l1_meshinfo
2399 return self.mesh.Dump()
2402 # Get the information about nodes and elements of a mesh by its IDs:
2403 # -----------------------------------------------------------
2405 ## Gets XYZ coordinates of a node
2406 # \n If there is no nodes for the given ID - returns an empty list
2407 # @return a list of double precision values
2408 # @ingroup l1_meshinfo
2409 def GetNodeXYZ(self, id):
2410 return self.mesh.GetNodeXYZ(id)
2412 ## Returns list of IDs of inverse elements for the given node
2413 # \n If there is no node for the given ID - returns an empty list
2414 # @return a list of integer values
2415 # @ingroup l1_meshinfo
2416 def GetNodeInverseElements(self, id):
2417 return self.mesh.GetNodeInverseElements(id)
2419 ## @brief Returns the position of a node on the shape
2420 # @return SMESH::NodePosition
2421 # @ingroup l1_meshinfo
2422 def GetNodePosition(self,NodeID):
2423 return self.mesh.GetNodePosition(NodeID)
2425 ## If the given element is a node, returns the ID of shape
2426 # \n If there is no node for the given ID - returns -1
2427 # @return an integer value
2428 # @ingroup l1_meshinfo
2429 def GetShapeID(self, id):
2430 return self.mesh.GetShapeID(id)
2432 ## Returns the ID of the result shape after
2433 # FindShape() from SMESH_MeshEditor for the given element
2434 # \n If there is no element for the given ID - returns -1
2435 # @return an integer value
2436 # @ingroup l1_meshinfo
2437 def GetShapeIDForElem(self,id):
2438 return self.mesh.GetShapeIDForElem(id)
2440 ## Returns the number of nodes for the given element
2441 # \n If there is no element for the given ID - returns -1
2442 # @return an integer value
2443 # @ingroup l1_meshinfo
2444 def GetElemNbNodes(self, id):
2445 return self.mesh.GetElemNbNodes(id)
2447 ## Returns the node ID the given index for the given element
2448 # \n If there is no element for the given ID - returns -1
2449 # \n If there is no node for the given index - returns -2
2450 # @return an integer value
2451 # @ingroup l1_meshinfo
2452 def GetElemNode(self, id, index):
2453 return self.mesh.GetElemNode(id, index)
2455 ## Returns the IDs of nodes of the given element
2456 # @return a list of integer values
2457 # @ingroup l1_meshinfo
2458 def GetElemNodes(self, id):
2459 return self.mesh.GetElemNodes(id)
2461 ## Returns true if the given node is the medium node in the given quadratic element
2462 # @ingroup l1_meshinfo
2463 def IsMediumNode(self, elementID, nodeID):
2464 return self.mesh.IsMediumNode(elementID, nodeID)
2466 ## Returns true if the given node is the medium node in one of quadratic elements
2467 # @ingroup l1_meshinfo
2468 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2469 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2471 ## Returns the number of edges for the given element
2472 # @ingroup l1_meshinfo
2473 def ElemNbEdges(self, id):
2474 return self.mesh.ElemNbEdges(id)
2476 ## Returns the number of faces for the given element
2477 # @ingroup l1_meshinfo
2478 def ElemNbFaces(self, id):
2479 return self.mesh.ElemNbFaces(id)
2481 ## Returns nodes of given face (counted from zero) for given volumic element.
2482 # @ingroup l1_meshinfo
2483 def GetElemFaceNodes(self,elemId, faceIndex):
2484 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2486 ## Returns an element based on all given nodes.
2487 # @ingroup l1_meshinfo
2488 def FindElementByNodes(self,nodes):
2489 return self.mesh.FindElementByNodes(nodes)
2491 ## Returns true if the given element is a polygon
2492 # @ingroup l1_meshinfo
2493 def IsPoly(self, id):
2494 return self.mesh.IsPoly(id)
2496 ## Returns true if the given element is quadratic
2497 # @ingroup l1_meshinfo
2498 def IsQuadratic(self, id):
2499 return self.mesh.IsQuadratic(id)
2501 ## Returns XYZ coordinates of the barycenter of the given element
2502 # \n If there is no element for the given ID - returns an empty list
2503 # @return a list of three double values
2504 # @ingroup l1_meshinfo
2505 def BaryCenter(self, id):
2506 return self.mesh.BaryCenter(id)
2509 # Get mesh measurements information:
2510 # ------------------------------------
2512 ## Get minimum distance between two nodes, elements or distance to the origin
2513 # @param id1 first node/element id
2514 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2515 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2516 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2517 # @return minimum distance value
2518 # @sa GetMinDistance()
2519 def MinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2520 aMeasure = self.GetMinDistance(id1, id2, isElem1, isElem2)
2521 return aMeasure.value
2523 ## Get measure structure specifying minimum distance data between two objects
2524 # @param id1 first node/element id
2525 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2526 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2527 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2528 # @return Measure structure
2530 def GetMinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2532 id1 = self.editor.MakeIDSource([id1], SMESH.FACE)
2534 id1 = self.editor.MakeIDSource([id1], SMESH.NODE)
2537 id2 = self.editor.MakeIDSource([id2], SMESH.FACE)
2539 id2 = self.editor.MakeIDSource([id2], SMESH.NODE)
2544 aMeasurements = self.smeshpyD.CreateMeasurements()
2545 aMeasure = aMeasurements.MinDistance(id1, id2)
2546 aMeasurements.UnRegister()
2549 ## Get bounding box of the specified object(s)
2550 # @param objects single source object or list of source objects or list of nodes/elements IDs
2551 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2552 # @c False specifies that @a objects are nodes
2553 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
2554 # @sa GetBoundingBox()
2555 def BoundingBox(self, objects=None, isElem=False):
2556 result = self.GetBoundingBox(objects, isElem)
2560 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
2563 ## Get measure structure specifying bounding box data of the specified object(s)
2564 # @param IDs single source object or list of source objects or list of nodes/elements IDs
2565 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2566 # @c False specifies that @a objects are nodes
2567 # @return Measure structure
2569 def GetBoundingBox(self, IDs=None, isElem=False):
2572 elif isinstance(IDs, tuple):
2574 if not isinstance(IDs, list):
2576 if len(IDs) > 0 and isinstance(IDs[0], int):
2580 if isinstance(o, Mesh):
2581 srclist.append(o.mesh)
2582 elif hasattr(o, "_narrow"):
2583 src = o._narrow(SMESH.SMESH_IDSource)
2584 if src: srclist.append(src)
2586 elif isinstance(o, list):
2588 srclist.append(self.editor.MakeIDSource(o, SMESH.FACE))
2590 srclist.append(self.editor.MakeIDSource(o, SMESH.NODE))
2593 aMeasurements = self.smeshpyD.CreateMeasurements()
2594 aMeasure = aMeasurements.BoundingBox(srclist)
2595 aMeasurements.UnRegister()
2598 # Mesh edition (SMESH_MeshEditor functionality):
2599 # ---------------------------------------------
2601 ## Removes the elements from the mesh by ids
2602 # @param IDsOfElements is a list of ids of elements to remove
2603 # @return True or False
2604 # @ingroup l2_modif_del
2605 def RemoveElements(self, IDsOfElements):
2606 return self.editor.RemoveElements(IDsOfElements)
2608 ## Removes nodes from mesh by ids
2609 # @param IDsOfNodes is a list of ids of nodes to remove
2610 # @return True or False
2611 # @ingroup l2_modif_del
2612 def RemoveNodes(self, IDsOfNodes):
2613 return self.editor.RemoveNodes(IDsOfNodes)
2615 ## Removes all orphan (free) nodes from mesh
2616 # @return number of the removed nodes
2617 # @ingroup l2_modif_del
2618 def RemoveOrphanNodes(self):
2619 return self.editor.RemoveOrphanNodes()
2621 ## Add a node to the mesh by coordinates
2622 # @return Id of the new node
2623 # @ingroup l2_modif_add
2624 def AddNode(self, x, y, z):
2625 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2626 self.mesh.SetParameters(Parameters)
2627 return self.editor.AddNode( x, y, z)
2629 ## Creates a 0D element on a node with given number.
2630 # @param IDOfNode the ID of node for creation of the element.
2631 # @return the Id of the new 0D element
2632 # @ingroup l2_modif_add
2633 def Add0DElement(self, IDOfNode):
2634 return self.editor.Add0DElement(IDOfNode)
2636 ## Creates a linear or quadratic edge (this is determined
2637 # by the number of given nodes).
2638 # @param IDsOfNodes the list of node IDs for creation of the element.
2639 # The order of nodes in this list should correspond to the description
2640 # of MED. \n This description is located by the following link:
2641 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2642 # @return the Id of the new edge
2643 # @ingroup l2_modif_add
2644 def AddEdge(self, IDsOfNodes):
2645 return self.editor.AddEdge(IDsOfNodes)
2647 ## Creates a linear or quadratic face (this is determined
2648 # by the number of given nodes).
2649 # @param IDsOfNodes the list of node IDs for creation of the element.
2650 # The order of nodes in this list should correspond to the description
2651 # of MED. \n This description is located by the following link:
2652 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2653 # @return the Id of the new face
2654 # @ingroup l2_modif_add
2655 def AddFace(self, IDsOfNodes):
2656 return self.editor.AddFace(IDsOfNodes)
2658 ## Adds a polygonal face to the mesh by the list of node IDs
2659 # @param IdsOfNodes the list of node IDs for creation of the element.
2660 # @return the Id of the new face
2661 # @ingroup l2_modif_add
2662 def AddPolygonalFace(self, IdsOfNodes):
2663 return self.editor.AddPolygonalFace(IdsOfNodes)
2665 ## Creates both simple and quadratic volume (this is determined
2666 # by the number of given nodes).
2667 # @param IDsOfNodes the list of node IDs for creation of the element.
2668 # The order of nodes in this list should correspond to the description
2669 # of MED. \n This description is located by the following link:
2670 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2671 # @return the Id of the new volumic element
2672 # @ingroup l2_modif_add
2673 def AddVolume(self, IDsOfNodes):
2674 return self.editor.AddVolume(IDsOfNodes)
2676 ## Creates a volume of many faces, giving nodes for each face.
2677 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2678 # @param Quantities the list of integer values, Quantities[i]
2679 # gives the quantity of nodes in face number i.
2680 # @return the Id of the new volumic element
2681 # @ingroup l2_modif_add
2682 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2683 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2685 ## Creates a volume of many faces, giving the IDs of the existing faces.
2686 # @param IdsOfFaces the list of face IDs for volume creation.
2688 # Note: The created volume will refer only to the nodes
2689 # of the given faces, not to the faces themselves.
2690 # @return the Id of the new volumic element
2691 # @ingroup l2_modif_add
2692 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2693 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2696 ## @brief Binds a node to a vertex
2697 # @param NodeID a node ID
2698 # @param Vertex a vertex or vertex ID
2699 # @return True if succeed else raises an exception
2700 # @ingroup l2_modif_add
2701 def SetNodeOnVertex(self, NodeID, Vertex):
2702 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2703 VertexID = Vertex.GetSubShapeIndices()[0]
2707 self.editor.SetNodeOnVertex(NodeID, VertexID)
2708 except SALOME.SALOME_Exception, inst:
2709 raise ValueError, inst.details.text
2713 ## @brief Stores the node position on an edge
2714 # @param NodeID a node ID
2715 # @param Edge an edge or edge ID
2716 # @param paramOnEdge a parameter on the edge where the node is located
2717 # @return True if succeed else raises an exception
2718 # @ingroup l2_modif_add
2719 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2720 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2721 EdgeID = Edge.GetSubShapeIndices()[0]
2725 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2726 except SALOME.SALOME_Exception, inst:
2727 raise ValueError, inst.details.text
2730 ## @brief Stores node position on a face
2731 # @param NodeID a node ID
2732 # @param Face a face or face ID
2733 # @param u U parameter on the face where the node is located
2734 # @param v V parameter on the face where the node is located
2735 # @return True if succeed else raises an exception
2736 # @ingroup l2_modif_add
2737 def SetNodeOnFace(self, NodeID, Face, u, v):
2738 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2739 FaceID = Face.GetSubShapeIndices()[0]
2743 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2744 except SALOME.SALOME_Exception, inst:
2745 raise ValueError, inst.details.text
2748 ## @brief Binds a node to a solid
2749 # @param NodeID a node ID
2750 # @param Solid a solid or solid ID
2751 # @return True if succeed else raises an exception
2752 # @ingroup l2_modif_add
2753 def SetNodeInVolume(self, NodeID, Solid):
2754 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2755 SolidID = Solid.GetSubShapeIndices()[0]
2759 self.editor.SetNodeInVolume(NodeID, SolidID)
2760 except SALOME.SALOME_Exception, inst:
2761 raise ValueError, inst.details.text
2764 ## @brief Bind an element to a shape
2765 # @param ElementID an element ID
2766 # @param Shape a shape or shape ID
2767 # @return True if succeed else raises an exception
2768 # @ingroup l2_modif_add
2769 def SetMeshElementOnShape(self, ElementID, Shape):
2770 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2771 ShapeID = Shape.GetSubShapeIndices()[0]
2775 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2776 except SALOME.SALOME_Exception, inst:
2777 raise ValueError, inst.details.text
2781 ## Moves the node with the given id
2782 # @param NodeID the id of the node
2783 # @param x a new X coordinate
2784 # @param y a new Y coordinate
2785 # @param z a new Z coordinate
2786 # @return True if succeed else False
2787 # @ingroup l2_modif_movenode
2788 def MoveNode(self, NodeID, x, y, z):
2789 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2790 self.mesh.SetParameters(Parameters)
2791 return self.editor.MoveNode(NodeID, x, y, z)
2793 ## Finds the node closest to a point and moves it to a point location
2794 # @param x the X coordinate of a point
2795 # @param y the Y coordinate of a point
2796 # @param z the Z coordinate of a point
2797 # @param NodeID if specified (>0), the node with this ID is moved,
2798 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2799 # @return the ID of a node
2800 # @ingroup l2_modif_throughp
2801 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2802 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2803 self.mesh.SetParameters(Parameters)
2804 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2806 ## Finds the node closest to a point
2807 # @param x the X coordinate of a point
2808 # @param y the Y coordinate of a point
2809 # @param z the Z coordinate of a point
2810 # @return the ID of a node
2811 # @ingroup l2_modif_throughp
2812 def FindNodeClosestTo(self, x, y, z):
2813 #preview = self.mesh.GetMeshEditPreviewer()
2814 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2815 return self.editor.FindNodeClosestTo(x, y, z)
2817 ## Finds the elements where a point lays IN or ON
2818 # @param x the X coordinate of a point
2819 # @param y the Y coordinate of a point
2820 # @param z the Z coordinate of a point
2821 # @param elementType type of elements to find (SMESH.ALL type
2822 # means elements of any type excluding nodes and 0D elements)
2823 # @param meshPart a part of mesh (group, sub-mesh) to search within
2824 # @return list of IDs of found elements
2825 # @ingroup l2_modif_throughp
2826 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL, meshPart=None):
2828 return self.editor.FindAmongElementsByPoint( meshPart, x, y, z, elementType );
2830 return self.editor.FindElementsByPoint(x, y, z, elementType)
2832 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2833 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2835 def GetPointState(self, x, y, z):
2836 return self.editor.GetPointState(x, y, z)
2838 ## Finds the node closest to a point and moves it to a point location
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 moved node
2843 # @ingroup l2_modif_throughp
2844 def MeshToPassThroughAPoint(self, x, y, z):
2845 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2847 ## Replaces two neighbour triangles sharing Node1-Node2 link
2848 # with the triangles built on the same 4 nodes but having other common link.
2849 # @param NodeID1 the ID of the first node
2850 # @param NodeID2 the ID of the second node
2851 # @return false if proper faces were not found
2852 # @ingroup l2_modif_invdiag
2853 def InverseDiag(self, NodeID1, NodeID2):
2854 return self.editor.InverseDiag(NodeID1, NodeID2)
2856 ## Replaces two neighbour triangles sharing Node1-Node2 link
2857 # with a quadrangle built on the same 4 nodes.
2858 # @param NodeID1 the ID of the first node
2859 # @param NodeID2 the ID of the second node
2860 # @return false if proper faces were not found
2861 # @ingroup l2_modif_unitetri
2862 def DeleteDiag(self, NodeID1, NodeID2):
2863 return self.editor.DeleteDiag(NodeID1, NodeID2)
2865 ## Reorients elements by ids
2866 # @param IDsOfElements if undefined reorients all mesh elements
2867 # @return True if succeed else False
2868 # @ingroup l2_modif_changori
2869 def Reorient(self, IDsOfElements=None):
2870 if IDsOfElements == None:
2871 IDsOfElements = self.GetElementsId()
2872 return self.editor.Reorient(IDsOfElements)
2874 ## Reorients all elements of the object
2875 # @param theObject mesh, submesh or group
2876 # @return True if succeed else False
2877 # @ingroup l2_modif_changori
2878 def ReorientObject(self, theObject):
2879 if ( isinstance( theObject, Mesh )):
2880 theObject = theObject.GetMesh()
2881 return self.editor.ReorientObject(theObject)
2883 ## Fuses the neighbouring triangles into quadrangles.
2884 # @param IDsOfElements The triangles to be fused,
2885 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2886 # @param MaxAngle is the maximum angle between element normals at which the fusion
2887 # is still performed; theMaxAngle is mesured in radians.
2888 # Also it could be a name of variable which defines angle in degrees.
2889 # @return TRUE in case of success, FALSE otherwise.
2890 # @ingroup l2_modif_unitetri
2891 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2893 if isinstance(MaxAngle,str):
2895 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2897 MaxAngle = DegreesToRadians(MaxAngle)
2898 if IDsOfElements == []:
2899 IDsOfElements = self.GetElementsId()
2900 self.mesh.SetParameters(Parameters)
2902 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2903 Functor = theCriterion
2905 Functor = self.smeshpyD.GetFunctor(theCriterion)
2906 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2908 ## Fuses the neighbouring triangles of the object into quadrangles
2909 # @param theObject is mesh, submesh or group
2910 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2911 # @param MaxAngle a max angle between element normals at which the fusion
2912 # is still performed; theMaxAngle is mesured in radians.
2913 # @return TRUE in case of success, FALSE otherwise.
2914 # @ingroup l2_modif_unitetri
2915 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2916 if ( isinstance( theObject, Mesh )):
2917 theObject = theObject.GetMesh()
2918 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2920 ## Splits quadrangles into triangles.
2921 # @param IDsOfElements the faces to be splitted.
2922 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2923 # @return TRUE in case of success, FALSE otherwise.
2924 # @ingroup l2_modif_cutquadr
2925 def QuadToTri (self, IDsOfElements, theCriterion):
2926 if IDsOfElements == []:
2927 IDsOfElements = self.GetElementsId()
2928 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2930 ## Splits quadrangles into triangles.
2931 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2932 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2933 # @return TRUE in case of success, FALSE otherwise.
2934 # @ingroup l2_modif_cutquadr
2935 def QuadToTriObject (self, theObject, theCriterion):
2936 if ( isinstance( theObject, Mesh )):
2937 theObject = theObject.GetMesh()
2938 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2940 ## Splits quadrangles into triangles.
2941 # @param IDsOfElements the faces to be splitted
2942 # @param Diag13 is used to choose a diagonal for splitting.
2943 # @return TRUE in case of success, FALSE otherwise.
2944 # @ingroup l2_modif_cutquadr
2945 def SplitQuad (self, IDsOfElements, Diag13):
2946 if IDsOfElements == []:
2947 IDsOfElements = self.GetElementsId()
2948 return self.editor.SplitQuad(IDsOfElements, Diag13)
2950 ## Splits quadrangles into triangles.
2951 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2952 # @param Diag13 is used to choose a diagonal for splitting.
2953 # @return TRUE in case of success, FALSE otherwise.
2954 # @ingroup l2_modif_cutquadr
2955 def SplitQuadObject (self, theObject, Diag13):
2956 if ( isinstance( theObject, Mesh )):
2957 theObject = theObject.GetMesh()
2958 return self.editor.SplitQuadObject(theObject, Diag13)
2960 ## Finds a better splitting of the given quadrangle.
2961 # @param IDOfQuad the ID of the quadrangle to be splitted.
2962 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2963 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2964 # diagonal is better, 0 if error occurs.
2965 # @ingroup l2_modif_cutquadr
2966 def BestSplit (self, IDOfQuad, theCriterion):
2967 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2969 ## Splits volumic elements into tetrahedrons
2970 # @param elemIDs either list of elements or mesh or group or submesh
2971 # @param method flags passing splitting method: Hex_5Tet, Hex_6Tet, Hex_24Tet
2972 # Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc
2973 # @ingroup l2_modif_cutquadr
2974 def SplitVolumesIntoTetra(self, elemIDs, method=Hex_5Tet ):
2975 if isinstance( elemIDs, Mesh ):
2976 elemIDs = elemIDs.GetMesh()
2977 if ( isinstance( elemIDs, list )):
2978 elemIDs = self.editor.MakeIDSource(elemIDs, SMESH.VOLUME)
2979 self.editor.SplitVolumesIntoTetra(elemIDs, method)
2981 ## Splits quadrangle faces near triangular facets of volumes
2983 # @ingroup l1_auxiliary
2984 def SplitQuadsNearTriangularFacets(self):
2985 faces_array = self.GetElementsByType(SMESH.FACE)
2986 for face_id in faces_array:
2987 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2988 quad_nodes = self.mesh.GetElemNodes(face_id)
2989 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2990 isVolumeFound = False
2991 for node1_elem in node1_elems:
2992 if not isVolumeFound:
2993 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2994 nb_nodes = self.GetElemNbNodes(node1_elem)
2995 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2996 volume_elem = node1_elem
2997 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2998 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2999 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
3000 isVolumeFound = True
3001 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
3002 self.SplitQuad([face_id], False) # diagonal 2-4
3003 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
3004 isVolumeFound = True
3005 self.SplitQuad([face_id], True) # diagonal 1-3
3006 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
3007 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
3008 isVolumeFound = True
3009 self.SplitQuad([face_id], True) # diagonal 1-3
3011 ## @brief Splits hexahedrons into tetrahedrons.
3013 # This operation uses pattern mapping functionality for splitting.
3014 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
3015 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
3016 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
3017 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
3018 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
3019 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
3020 # @return TRUE in case of success, FALSE otherwise.
3021 # @ingroup l1_auxiliary
3022 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
3023 # Pattern: 5.---------.6
3028 # (0,0,1) 4.---------.7 * |
3035 # (0,0,0) 0.---------.3
3036 pattern_tetra = "!!! Nb of points: \n 8 \n\
3046 !!! Indices of points of 6 tetras: \n\
3054 pattern = self.smeshpyD.GetPattern()
3055 isDone = pattern.LoadFromFile(pattern_tetra)
3057 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
3060 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
3061 isDone = pattern.MakeMesh(self.mesh, False, False)
3062 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
3064 # split quafrangle faces near triangular facets of volumes
3065 self.SplitQuadsNearTriangularFacets()
3069 ## @brief Split hexahedrons into prisms.
3071 # Uses the pattern mapping functionality for splitting.
3072 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
3073 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
3074 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
3075 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
3076 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
3077 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
3078 # @return TRUE in case of success, FALSE otherwise.
3079 # @ingroup l1_auxiliary
3080 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
3081 # Pattern: 5.---------.6
3086 # (0,0,1) 4.---------.7 |
3093 # (0,0,0) 0.---------.3
3094 pattern_prism = "!!! Nb of points: \n 8 \n\
3104 !!! Indices of points of 2 prisms: \n\
3108 pattern = self.smeshpyD.GetPattern()
3109 isDone = pattern.LoadFromFile(pattern_prism)
3111 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
3114 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
3115 isDone = pattern.MakeMesh(self.mesh, False, False)
3116 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
3118 # Splits quafrangle faces near triangular facets of volumes
3119 self.SplitQuadsNearTriangularFacets()
3123 ## Smoothes elements
3124 # @param IDsOfElements the list if ids of elements to smooth
3125 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3126 # Note that nodes built on edges and boundary nodes are always fixed.
3127 # @param MaxNbOfIterations the maximum number of iterations
3128 # @param MaxAspectRatio varies in range [1.0, inf]
3129 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3130 # @return TRUE in case of success, FALSE otherwise.
3131 # @ingroup l2_modif_smooth
3132 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
3133 MaxNbOfIterations, MaxAspectRatio, Method):
3134 if IDsOfElements == []:
3135 IDsOfElements = self.GetElementsId()
3136 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
3137 self.mesh.SetParameters(Parameters)
3138 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
3139 MaxNbOfIterations, MaxAspectRatio, Method)
3141 ## Smoothes elements which belong to the given object
3142 # @param theObject the object to smooth
3143 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3144 # Note that nodes built on edges and boundary nodes are always fixed.
3145 # @param MaxNbOfIterations the maximum number of iterations
3146 # @param MaxAspectRatio varies in range [1.0, inf]
3147 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3148 # @return TRUE in case of success, FALSE otherwise.
3149 # @ingroup l2_modif_smooth
3150 def SmoothObject(self, theObject, IDsOfFixedNodes,
3151 MaxNbOfIterations, MaxAspectRatio, Method):
3152 if ( isinstance( theObject, Mesh )):
3153 theObject = theObject.GetMesh()
3154 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
3155 MaxNbOfIterations, MaxAspectRatio, Method)
3157 ## Parametrically smoothes the given elements
3158 # @param IDsOfElements the list if ids of elements to smooth
3159 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3160 # Note that nodes built on edges and boundary nodes are always fixed.
3161 # @param MaxNbOfIterations the maximum number of iterations
3162 # @param MaxAspectRatio varies in range [1.0, inf]
3163 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3164 # @return TRUE in case of success, FALSE otherwise.
3165 # @ingroup l2_modif_smooth
3166 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
3167 MaxNbOfIterations, MaxAspectRatio, Method):
3168 if IDsOfElements == []:
3169 IDsOfElements = self.GetElementsId()
3170 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
3171 self.mesh.SetParameters(Parameters)
3172 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
3173 MaxNbOfIterations, MaxAspectRatio, Method)
3175 ## Parametrically smoothes the elements which belong to the given object
3176 # @param theObject the object to smooth
3177 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3178 # Note that nodes built on edges and boundary nodes are always fixed.
3179 # @param MaxNbOfIterations the maximum number of iterations
3180 # @param MaxAspectRatio varies in range [1.0, inf]
3181 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3182 # @return TRUE in case of success, FALSE otherwise.
3183 # @ingroup l2_modif_smooth
3184 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
3185 MaxNbOfIterations, MaxAspectRatio, Method):
3186 if ( isinstance( theObject, Mesh )):
3187 theObject = theObject.GetMesh()
3188 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
3189 MaxNbOfIterations, MaxAspectRatio, Method)
3191 ## Converts the mesh to quadratic, deletes old elements, replacing
3192 # them with quadratic with the same id.
3193 # @param theForce3d new node creation method:
3194 # 0 - the medium node lies at the geometrical entity from which the mesh element is built
3195 # 1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element
3196 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
3197 # @ingroup l2_modif_tofromqu
3198 def ConvertToQuadratic(self, theForce3d, theSubMesh=None):
3200 self.editor.ConvertToQuadraticObject(theForce3d,theSubMesh)
3202 self.editor.ConvertToQuadratic(theForce3d)
3204 ## Converts the mesh from quadratic to ordinary,
3205 # deletes old quadratic elements, \n replacing
3206 # them with ordinary mesh elements with the same id.
3207 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
3208 # @ingroup l2_modif_tofromqu
3209 def ConvertFromQuadratic(self, theSubMesh=None):
3211 self.editor.ConvertFromQuadraticObject(theSubMesh)
3213 return self.editor.ConvertFromQuadratic()
3215 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
3216 # @return TRUE if operation has been completed successfully, FALSE otherwise
3217 # @ingroup l2_modif_edit
3218 def Make2DMeshFrom3D(self):
3219 return self.editor. Make2DMeshFrom3D()
3221 ## Creates missing boundary elements
3222 # @param elements - elements whose boundary is to be checked:
3223 # mesh, group, sub-mesh or list of elements
3224 # if elements is mesh, it must be the mesh whose MakeBoundaryMesh() is called
3225 # @param dimension - defines type of boundary elements to create:
3226 # SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D
3227 # SMESH.BND_1DFROM3D creates mesh edges on all borders of free facets of 3D cells
3228 # @param groupName - a name of group to store created boundary elements in,
3229 # "" means not to create the group
3230 # @param meshName - a name of new mesh to store created boundary elements in,
3231 # "" means not to create the new mesh
3232 # @param toCopyElements - if true, the checked elements will be copied into
3233 # the new mesh else only boundary elements will be copied into the new mesh
3234 # @param toCopyExistingBondary - if true, not only new but also pre-existing
3235 # boundary elements will be copied into the new mesh
3236 # @return tuple (mesh, group) where bondary elements were added to
3237 # @ingroup l2_modif_edit
3238 def MakeBoundaryMesh(self, elements, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3239 toCopyElements=False, toCopyExistingBondary=False):
3240 if isinstance( elements, Mesh ):
3241 elements = elements.GetMesh()
3242 if ( isinstance( elements, list )):
3243 elemType = SMESH.ALL
3244 if elements: elemType = self.GetElementType( elements[0], iselem=True)
3245 elements = self.editor.MakeIDSource(elements, elemType)
3246 mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName,
3247 toCopyElements,toCopyExistingBondary)
3248 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3252 # @brief Creates missing boundary elements around either the whole mesh or
3253 # groups of 2D elements
3254 # @param dimension - defines type of boundary elements to create
3255 # @param groupName - a name of group to store all boundary elements in,
3256 # "" means not to create the group
3257 # @param meshName - a name of a new mesh, which is a copy of the initial
3258 # mesh + created boundary elements; "" means not to create the new mesh
3259 # @param toCopyAll - if true, the whole initial mesh will be copied into
3260 # the new mesh else only boundary elements will be copied into the new mesh
3261 # @param groups - groups of 2D elements to make boundary around
3262 # @retval tuple( long, mesh, groups )
3263 # long - number of added boundary elements
3264 # mesh - the mesh where elements were added to
3265 # group - the group of boundary elements or None
3267 def MakeBoundaryElements(self, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3268 toCopyAll=False, groups=[]):
3269 nb, mesh, group = self.editor.MakeBoundaryElements(dimension,groupName,meshName,
3271 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3272 return nb, mesh, group
3274 ## Renumber mesh nodes
3275 # @ingroup l2_modif_renumber
3276 def RenumberNodes(self):
3277 self.editor.RenumberNodes()
3279 ## Renumber mesh elements
3280 # @ingroup l2_modif_renumber
3281 def RenumberElements(self):
3282 self.editor.RenumberElements()
3284 ## Generates new elements by rotation of the elements around the axis
3285 # @param IDsOfElements the list of ids of elements to sweep
3286 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3287 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
3288 # @param NbOfSteps the number of steps
3289 # @param Tolerance tolerance
3290 # @param MakeGroups forces the generation of new groups from existing ones
3291 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3292 # of all steps, else - size of each step
3293 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3294 # @ingroup l2_modif_extrurev
3295 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
3296 MakeGroups=False, TotalAngle=False):
3298 if isinstance(AngleInRadians,str):
3300 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3302 AngleInRadians = DegreesToRadians(AngleInRadians)
3303 if IDsOfElements == []:
3304 IDsOfElements = self.GetElementsId()
3305 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3306 Axis = self.smeshpyD.GetAxisStruct(Axis)
3307 Axis,AxisParameters = ParseAxisStruct(Axis)
3308 if TotalAngle and NbOfSteps:
3309 AngleInRadians /= NbOfSteps
3310 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3311 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3312 self.mesh.SetParameters(Parameters)
3314 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
3315 AngleInRadians, NbOfSteps, Tolerance)
3316 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
3319 ## Generates new elements by rotation of the elements of object around the axis
3320 # @param theObject object which elements should be sweeped.
3321 # It can be a mesh, a sub mesh or a group.
3322 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3323 # @param AngleInRadians the angle of Rotation
3324 # @param NbOfSteps number of steps
3325 # @param Tolerance tolerance
3326 # @param MakeGroups forces the generation of new groups from existing ones
3327 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3328 # of all steps, else - size of each step
3329 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3330 # @ingroup l2_modif_extrurev
3331 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3332 MakeGroups=False, TotalAngle=False):
3334 if isinstance(AngleInRadians,str):
3336 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3338 AngleInRadians = DegreesToRadians(AngleInRadians)
3339 if ( isinstance( theObject, Mesh )):
3340 theObject = theObject.GetMesh()
3341 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3342 Axis = self.smeshpyD.GetAxisStruct(Axis)
3343 Axis,AxisParameters = ParseAxisStruct(Axis)
3344 if TotalAngle and NbOfSteps:
3345 AngleInRadians /= NbOfSteps
3346 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3347 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3348 self.mesh.SetParameters(Parameters)
3350 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
3351 NbOfSteps, Tolerance)
3352 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3355 ## Generates new elements by rotation of the elements of object around the axis
3356 # @param theObject object which elements should be sweeped.
3357 # It can be a mesh, a sub mesh or a group.
3358 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3359 # @param AngleInRadians the angle of Rotation
3360 # @param NbOfSteps number of steps
3361 # @param Tolerance tolerance
3362 # @param MakeGroups forces the generation of new groups from existing ones
3363 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3364 # of all steps, else - size of each step
3365 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3366 # @ingroup l2_modif_extrurev
3367 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3368 MakeGroups=False, TotalAngle=False):
3370 if isinstance(AngleInRadians,str):
3372 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3374 AngleInRadians = DegreesToRadians(AngleInRadians)
3375 if ( isinstance( theObject, Mesh )):
3376 theObject = theObject.GetMesh()
3377 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3378 Axis = self.smeshpyD.GetAxisStruct(Axis)
3379 Axis,AxisParameters = ParseAxisStruct(Axis)
3380 if TotalAngle and NbOfSteps:
3381 AngleInRadians /= NbOfSteps
3382 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3383 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3384 self.mesh.SetParameters(Parameters)
3386 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
3387 NbOfSteps, Tolerance)
3388 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3391 ## Generates new elements by rotation of the elements of object around the axis
3392 # @param theObject object which elements should be sweeped.
3393 # It can be a mesh, a sub mesh or a group.
3394 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3395 # @param AngleInRadians the angle of Rotation
3396 # @param NbOfSteps number of steps
3397 # @param Tolerance tolerance
3398 # @param MakeGroups forces the generation of new groups from existing ones
3399 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3400 # of all steps, else - size of each step
3401 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3402 # @ingroup l2_modif_extrurev
3403 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3404 MakeGroups=False, TotalAngle=False):
3406 if isinstance(AngleInRadians,str):
3408 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3410 AngleInRadians = DegreesToRadians(AngleInRadians)
3411 if ( isinstance( theObject, Mesh )):
3412 theObject = theObject.GetMesh()
3413 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3414 Axis = self.smeshpyD.GetAxisStruct(Axis)
3415 Axis,AxisParameters = ParseAxisStruct(Axis)
3416 if TotalAngle and NbOfSteps:
3417 AngleInRadians /= NbOfSteps
3418 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3419 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3420 self.mesh.SetParameters(Parameters)
3422 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
3423 NbOfSteps, Tolerance)
3424 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3427 ## Generates new elements by extrusion of the elements with given ids
3428 # @param IDsOfElements the list of elements ids for extrusion
3429 # @param StepVector vector or DirStruct, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3430 # @param NbOfSteps the number of steps
3431 # @param MakeGroups forces the generation of new groups from existing ones
3432 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3433 # @ingroup l2_modif_extrurev
3434 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
3435 if IDsOfElements == []:
3436 IDsOfElements = self.GetElementsId()
3437 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3438 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3439 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3440 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3441 Parameters = StepVectorParameters + var_separator + Parameters
3442 self.mesh.SetParameters(Parameters)
3444 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
3445 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
3448 ## Generates new elements by extrusion of the elements with given ids
3449 # @param IDsOfElements is ids of elements
3450 # @param StepVector vector, defining the direction and value of extrusion
3451 # @param NbOfSteps the number of steps
3452 # @param ExtrFlags sets flags for extrusion
3453 # @param SewTolerance uses for comparing locations of nodes if flag
3454 # EXTRUSION_FLAG_SEW is set
3455 # @param MakeGroups forces the generation of new groups from existing ones
3456 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3457 # @ingroup l2_modif_extrurev
3458 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
3459 ExtrFlags, SewTolerance, MakeGroups=False):
3460 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3461 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3463 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
3464 ExtrFlags, SewTolerance)
3465 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
3466 ExtrFlags, SewTolerance)
3469 ## Generates new elements by extrusion of the elements which belong to the object
3470 # @param theObject the object which elements should be processed.
3471 # It can be a mesh, a sub mesh or a group.
3472 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3473 # @param NbOfSteps the number of steps
3474 # @param MakeGroups forces the generation of new groups from existing ones
3475 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3476 # @ingroup l2_modif_extrurev
3477 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3478 if ( isinstance( theObject, Mesh )):
3479 theObject = theObject.GetMesh()
3480 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3481 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3482 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3483 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3484 Parameters = StepVectorParameters + var_separator + Parameters
3485 self.mesh.SetParameters(Parameters)
3487 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3488 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
3491 ## Generates new elements by extrusion of the elements which belong to the object
3492 # @param theObject object which elements should be processed.
3493 # It can be a mesh, a sub mesh or a group.
3494 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3495 # @param NbOfSteps the number of steps
3496 # @param MakeGroups to generate new groups from existing ones
3497 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3498 # @ingroup l2_modif_extrurev
3499 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3500 if ( isinstance( theObject, Mesh )):
3501 theObject = theObject.GetMesh()
3502 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3503 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3504 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3505 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3506 Parameters = StepVectorParameters + var_separator + Parameters
3507 self.mesh.SetParameters(Parameters)
3509 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3510 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3513 ## Generates new elements by extrusion of the elements which belong to the object
3514 # @param theObject object which elements should be processed.
3515 # It can be a mesh, a sub mesh or a group.
3516 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3517 # @param NbOfSteps the number of steps
3518 # @param MakeGroups forces the generation of new groups from existing ones
3519 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3520 # @ingroup l2_modif_extrurev
3521 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3522 if ( isinstance( theObject, Mesh )):
3523 theObject = theObject.GetMesh()
3524 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3525 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3526 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3527 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3528 Parameters = StepVectorParameters + var_separator + Parameters
3529 self.mesh.SetParameters(Parameters)
3531 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3532 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3537 ## Generates new elements by extrusion of the given elements
3538 # The path of extrusion must be a meshed edge.
3539 # @param Base mesh or group, or submesh, or list of ids of elements for extrusion
3540 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3541 # @param NodeStart the start node from Path. Defines the direction of extrusion
3542 # @param HasAngles allows the shape to be rotated around the path
3543 # to get the resulting mesh in a helical fashion
3544 # @param Angles list of angles in radians
3545 # @param LinearVariation forces the computation of rotation angles as linear
3546 # variation of the given Angles along path steps
3547 # @param HasRefPoint allows using the reference point
3548 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3549 # The User can specify any point as the Reference Point.
3550 # @param MakeGroups forces the generation of new groups from existing ones
3551 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3552 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3553 # only SMESH::Extrusion_Error otherwise
3554 # @ingroup l2_modif_extrurev
3555 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3556 HasAngles, Angles, LinearVariation,
3557 HasRefPoint, RefPoint, MakeGroups, ElemType):
3558 Angles,AnglesParameters = ParseAngles(Angles)
3559 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3560 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3561 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3563 Parameters = AnglesParameters + var_separator + RefPointParameters
3564 self.mesh.SetParameters(Parameters)
3566 if (isinstance(Path, Mesh)): Path = Path.GetMesh()
3568 if isinstance(Base, list):
3570 if Base == []: IDsOfElements = self.GetElementsId()
3571 else: IDsOfElements = Base
3572 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3573 HasAngles, Angles, LinearVariation,
3574 HasRefPoint, RefPoint, MakeGroups, ElemType)
3576 if isinstance(Base, Mesh): Base = Base.GetMesh()
3577 if isinstance(Base, SMESH._objref_SMESH_Mesh) or isinstance(Base, SMESH._objref_SMESH_Group) or isinstance(Base, SMESH._objref_SMESH_subMesh):
3578 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3579 HasAngles, Angles, LinearVariation,
3580 HasRefPoint, RefPoint, MakeGroups, ElemType)
3582 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3585 ## Generates new elements by extrusion of the given elements
3586 # The path of extrusion must be a meshed edge.
3587 # @param IDsOfElements ids of elements
3588 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3589 # @param PathShape shape(edge) defines the sub-mesh for the path
3590 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3591 # @param HasAngles allows the shape to be rotated around the path
3592 # to get the resulting mesh in a helical fashion
3593 # @param Angles list of angles in radians
3594 # @param HasRefPoint allows using the reference point
3595 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3596 # The User can specify any point as the Reference Point.
3597 # @param MakeGroups forces the generation of new groups from existing ones
3598 # @param LinearVariation forces the computation of rotation angles as linear
3599 # variation of the given Angles along path steps
3600 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3601 # only SMESH::Extrusion_Error otherwise
3602 # @ingroup l2_modif_extrurev
3603 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3604 HasAngles, Angles, HasRefPoint, RefPoint,
3605 MakeGroups=False, LinearVariation=False):
3606 Angles,AnglesParameters = ParseAngles(Angles)
3607 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3608 if IDsOfElements == []:
3609 IDsOfElements = self.GetElementsId()
3610 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3611 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3613 if ( isinstance( PathMesh, Mesh )):
3614 PathMesh = PathMesh.GetMesh()
3615 if HasAngles and Angles and LinearVariation:
3616 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3618 Parameters = AnglesParameters + var_separator + RefPointParameters
3619 self.mesh.SetParameters(Parameters)
3621 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3622 PathShape, NodeStart, HasAngles,
3623 Angles, HasRefPoint, RefPoint)
3624 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3625 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3627 ## Generates new elements by extrusion of the elements which belong to the object
3628 # The path of extrusion must be a meshed edge.
3629 # @param theObject the object which elements should be processed.
3630 # It can be a mesh, a sub mesh or a group.
3631 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3632 # @param PathShape shape(edge) defines the sub-mesh for the path
3633 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3634 # @param HasAngles allows the shape to be rotated around the path
3635 # to get the resulting mesh in a helical fashion
3636 # @param Angles list of angles
3637 # @param HasRefPoint allows using the reference point
3638 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3639 # The User can specify any point as the Reference Point.
3640 # @param MakeGroups forces the generation of new groups from existing ones
3641 # @param LinearVariation forces the computation of rotation angles as linear
3642 # variation of the given Angles along path steps
3643 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3644 # only SMESH::Extrusion_Error otherwise
3645 # @ingroup l2_modif_extrurev
3646 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3647 HasAngles, Angles, HasRefPoint, RefPoint,
3648 MakeGroups=False, LinearVariation=False):
3649 Angles,AnglesParameters = ParseAngles(Angles)
3650 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3651 if ( isinstance( theObject, Mesh )):
3652 theObject = theObject.GetMesh()
3653 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3654 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3655 if ( isinstance( PathMesh, Mesh )):
3656 PathMesh = PathMesh.GetMesh()
3657 if HasAngles and Angles and LinearVariation:
3658 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3660 Parameters = AnglesParameters + var_separator + RefPointParameters
3661 self.mesh.SetParameters(Parameters)
3663 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3664 PathShape, NodeStart, HasAngles,
3665 Angles, HasRefPoint, RefPoint)
3666 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3667 NodeStart, HasAngles, Angles, HasRefPoint,
3670 ## Generates new elements by extrusion of the elements which belong to the object
3671 # The path of extrusion must be a meshed edge.
3672 # @param theObject the object which elements should be processed.
3673 # It can be a mesh, a sub mesh or a group.
3674 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3675 # @param PathShape shape(edge) defines the sub-mesh for the path
3676 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3677 # @param HasAngles allows the shape to be rotated around the path
3678 # to get the resulting mesh in a helical fashion
3679 # @param Angles list of angles
3680 # @param HasRefPoint allows using the reference point
3681 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3682 # The User can specify any point as the Reference Point.
3683 # @param MakeGroups forces the generation of new groups from existing ones
3684 # @param LinearVariation forces the computation of rotation angles as linear
3685 # variation of the given Angles along path steps
3686 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3687 # only SMESH::Extrusion_Error otherwise
3688 # @ingroup l2_modif_extrurev
3689 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3690 HasAngles, Angles, HasRefPoint, RefPoint,
3691 MakeGroups=False, LinearVariation=False):
3692 Angles,AnglesParameters = ParseAngles(Angles)
3693 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3694 if ( isinstance( theObject, Mesh )):
3695 theObject = theObject.GetMesh()
3696 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3697 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3698 if ( isinstance( PathMesh, Mesh )):
3699 PathMesh = PathMesh.GetMesh()
3700 if HasAngles and Angles and LinearVariation:
3701 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3703 Parameters = AnglesParameters + var_separator + RefPointParameters
3704 self.mesh.SetParameters(Parameters)
3706 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3707 PathShape, NodeStart, HasAngles,
3708 Angles, HasRefPoint, RefPoint)
3709 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3710 NodeStart, HasAngles, Angles, HasRefPoint,
3713 ## Generates new elements by extrusion of the elements which belong to the object
3714 # The path of extrusion must be a meshed edge.
3715 # @param theObject the object which elements should be processed.
3716 # It can be a mesh, a sub mesh or a group.
3717 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3718 # @param PathShape shape(edge) defines the sub-mesh for the path
3719 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3720 # @param HasAngles allows the shape to be rotated around the path
3721 # to get the resulting mesh in a helical fashion
3722 # @param Angles list of angles
3723 # @param HasRefPoint allows using the reference point
3724 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3725 # The User can specify any point as the Reference Point.
3726 # @param MakeGroups forces the generation of new groups from existing ones
3727 # @param LinearVariation forces the computation of rotation angles as linear
3728 # variation of the given Angles along path steps
3729 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3730 # only SMESH::Extrusion_Error otherwise
3731 # @ingroup l2_modif_extrurev
3732 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3733 HasAngles, Angles, HasRefPoint, RefPoint,
3734 MakeGroups=False, LinearVariation=False):
3735 Angles,AnglesParameters = ParseAngles(Angles)
3736 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3737 if ( isinstance( theObject, Mesh )):
3738 theObject = theObject.GetMesh()
3739 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3740 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3741 if ( isinstance( PathMesh, Mesh )):
3742 PathMesh = PathMesh.GetMesh()
3743 if HasAngles and Angles and LinearVariation:
3744 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3746 Parameters = AnglesParameters + var_separator + RefPointParameters
3747 self.mesh.SetParameters(Parameters)
3749 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3750 PathShape, NodeStart, HasAngles,
3751 Angles, HasRefPoint, RefPoint)
3752 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3753 NodeStart, HasAngles, Angles, HasRefPoint,
3756 ## Creates a symmetrical copy of mesh elements
3757 # @param IDsOfElements list of elements ids
3758 # @param Mirror is AxisStruct or geom object(point, line, plane)
3759 # @param theMirrorType is POINT, AXIS or PLANE
3760 # If the Mirror is a geom object this parameter is unnecessary
3761 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3762 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3763 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3764 # @ingroup l2_modif_trsf
3765 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3766 if IDsOfElements == []:
3767 IDsOfElements = self.GetElementsId()
3768 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3769 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3770 Mirror,Parameters = ParseAxisStruct(Mirror)
3771 self.mesh.SetParameters(Parameters)
3772 if Copy and MakeGroups:
3773 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3774 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3777 ## Creates a new mesh by a symmetrical copy of mesh elements
3778 # @param IDsOfElements the list of elements ids
3779 # @param Mirror is AxisStruct or geom object (point, line, plane)
3780 # @param theMirrorType is POINT, AXIS or PLANE
3781 # If the Mirror is a geom object this parameter is unnecessary
3782 # @param MakeGroups to generate new groups from existing ones
3783 # @param NewMeshName a name of the new mesh to create
3784 # @return instance of Mesh class
3785 # @ingroup l2_modif_trsf
3786 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3787 if IDsOfElements == []:
3788 IDsOfElements = self.GetElementsId()
3789 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3790 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3791 Mirror,Parameters = ParseAxisStruct(Mirror)
3792 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3793 MakeGroups, NewMeshName)
3794 mesh.SetParameters(Parameters)
3795 return Mesh(self.smeshpyD,self.geompyD,mesh)
3797 ## Creates a symmetrical copy of the object
3798 # @param theObject mesh, submesh or group
3799 # @param Mirror AxisStruct or geom object (point, line, plane)
3800 # @param theMirrorType is POINT, AXIS or PLANE
3801 # If the Mirror is a geom object this parameter is unnecessary
3802 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3803 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3804 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3805 # @ingroup l2_modif_trsf
3806 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3807 if ( isinstance( theObject, Mesh )):
3808 theObject = theObject.GetMesh()
3809 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3810 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3811 Mirror,Parameters = ParseAxisStruct(Mirror)
3812 self.mesh.SetParameters(Parameters)
3813 if Copy and MakeGroups:
3814 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3815 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3818 ## Creates a new mesh by a symmetrical copy of the object
3819 # @param theObject mesh, submesh or group
3820 # @param Mirror AxisStruct or geom object (point, line, plane)
3821 # @param theMirrorType POINT, AXIS or PLANE
3822 # If the Mirror is a geom object this parameter is unnecessary
3823 # @param MakeGroups forces the generation of new groups from existing ones
3824 # @param NewMeshName the name of the new mesh to create
3825 # @return instance of Mesh class
3826 # @ingroup l2_modif_trsf
3827 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3828 if ( isinstance( theObject, Mesh )):
3829 theObject = theObject.GetMesh()
3830 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3831 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3832 Mirror,Parameters = ParseAxisStruct(Mirror)
3833 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3834 MakeGroups, NewMeshName)
3835 mesh.SetParameters(Parameters)
3836 return Mesh( self.smeshpyD,self.geompyD,mesh )
3838 ## Translates the elements
3839 # @param IDsOfElements list of elements ids
3840 # @param Vector the direction of translation (DirStruct or vector)
3841 # @param Copy allows copying the translated elements
3842 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3843 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3844 # @ingroup l2_modif_trsf
3845 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3846 if IDsOfElements == []:
3847 IDsOfElements = self.GetElementsId()
3848 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3849 Vector = self.smeshpyD.GetDirStruct(Vector)
3850 Vector,Parameters = ParseDirStruct(Vector)
3851 self.mesh.SetParameters(Parameters)
3852 if Copy and MakeGroups:
3853 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3854 self.editor.Translate(IDsOfElements, Vector, Copy)
3857 ## Creates a new mesh of translated elements
3858 # @param IDsOfElements list of elements ids
3859 # @param Vector the direction of translation (DirStruct or vector)
3860 # @param MakeGroups forces the generation of new groups from existing ones
3861 # @param NewMeshName the name of the newly created mesh
3862 # @return instance of Mesh class
3863 # @ingroup l2_modif_trsf
3864 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3865 if IDsOfElements == []:
3866 IDsOfElements = self.GetElementsId()
3867 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3868 Vector = self.smeshpyD.GetDirStruct(Vector)
3869 Vector,Parameters = ParseDirStruct(Vector)
3870 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3871 mesh.SetParameters(Parameters)
3872 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3874 ## Translates the object
3875 # @param theObject the object to translate (mesh, submesh, or group)
3876 # @param Vector direction of translation (DirStruct or geom vector)
3877 # @param Copy allows copying the translated elements
3878 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3879 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3880 # @ingroup l2_modif_trsf
3881 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3882 if ( isinstance( theObject, Mesh )):
3883 theObject = theObject.GetMesh()
3884 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3885 Vector = self.smeshpyD.GetDirStruct(Vector)
3886 Vector,Parameters = ParseDirStruct(Vector)
3887 self.mesh.SetParameters(Parameters)
3888 if Copy and MakeGroups:
3889 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3890 self.editor.TranslateObject(theObject, Vector, Copy)
3893 ## Creates a new mesh from the translated object
3894 # @param theObject the object to translate (mesh, submesh, or group)
3895 # @param Vector the direction of translation (DirStruct or geom vector)
3896 # @param MakeGroups forces the generation of new groups from existing ones
3897 # @param NewMeshName the name of the newly created mesh
3898 # @return instance of Mesh class
3899 # @ingroup l2_modif_trsf
3900 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3901 if (isinstance(theObject, Mesh)):
3902 theObject = theObject.GetMesh()
3903 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3904 Vector = self.smeshpyD.GetDirStruct(Vector)
3905 Vector,Parameters = ParseDirStruct(Vector)
3906 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3907 mesh.SetParameters(Parameters)
3908 return Mesh( self.smeshpyD, self.geompyD, mesh )
3912 ## Scales the object
3913 # @param theObject - the object to translate (mesh, submesh, or group)
3914 # @param thePoint - base point for scale
3915 # @param theScaleFact - list of 1-3 scale factors for axises
3916 # @param Copy - allows copying the translated elements
3917 # @param MakeGroups - forces the generation of new groups from existing
3919 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3920 # empty list otherwise
3921 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3922 if ( isinstance( theObject, Mesh )):
3923 theObject = theObject.GetMesh()
3924 if ( isinstance( theObject, list )):
3925 theObject = self.GetIDSource(theObject, SMESH.ALL)
3927 thePoint, Parameters = ParsePointStruct(thePoint)
3928 self.mesh.SetParameters(Parameters)
3930 if Copy and MakeGroups:
3931 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3932 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3935 ## Creates a new mesh from the translated object
3936 # @param theObject - the object to translate (mesh, submesh, or group)
3937 # @param thePoint - base point for scale
3938 # @param theScaleFact - list of 1-3 scale factors for axises
3939 # @param MakeGroups - forces the generation of new groups from existing ones
3940 # @param NewMeshName - the name of the newly created mesh
3941 # @return instance of Mesh class
3942 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3943 if (isinstance(theObject, Mesh)):
3944 theObject = theObject.GetMesh()
3945 if ( isinstance( theObject, list )):
3946 theObject = self.GetIDSource(theObject,SMESH.ALL)
3948 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3949 MakeGroups, NewMeshName)
3950 #mesh.SetParameters(Parameters)
3951 return Mesh( self.smeshpyD, self.geompyD, mesh )
3955 ## Rotates the elements
3956 # @param IDsOfElements list of elements ids
3957 # @param Axis the axis of rotation (AxisStruct or geom line)
3958 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3959 # @param Copy allows copying the rotated elements
3960 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3961 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3962 # @ingroup l2_modif_trsf
3963 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3965 if isinstance(AngleInRadians,str):
3967 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3969 AngleInRadians = DegreesToRadians(AngleInRadians)
3970 if IDsOfElements == []:
3971 IDsOfElements = self.GetElementsId()
3972 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3973 Axis = self.smeshpyD.GetAxisStruct(Axis)
3974 Axis,AxisParameters = ParseAxisStruct(Axis)
3975 Parameters = AxisParameters + var_separator + Parameters
3976 self.mesh.SetParameters(Parameters)
3977 if Copy and MakeGroups:
3978 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3979 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3982 ## Creates a new mesh of rotated elements
3983 # @param IDsOfElements list of element ids
3984 # @param Axis the axis of rotation (AxisStruct or geom line)
3985 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3986 # @param MakeGroups forces the generation of new groups from existing ones
3987 # @param NewMeshName the name of the newly created mesh
3988 # @return instance of Mesh class
3989 # @ingroup l2_modif_trsf
3990 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3992 if isinstance(AngleInRadians,str):
3994 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3996 AngleInRadians = DegreesToRadians(AngleInRadians)
3997 if IDsOfElements == []:
3998 IDsOfElements = self.GetElementsId()
3999 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
4000 Axis = self.smeshpyD.GetAxisStruct(Axis)
4001 Axis,AxisParameters = ParseAxisStruct(Axis)
4002 Parameters = AxisParameters + var_separator + Parameters
4003 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
4004 MakeGroups, NewMeshName)
4005 mesh.SetParameters(Parameters)
4006 return Mesh( self.smeshpyD, self.geompyD, mesh )
4008 ## Rotates the object
4009 # @param theObject the object to rotate( mesh, submesh, or group)
4010 # @param Axis the axis of rotation (AxisStruct or geom line)
4011 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
4012 # @param Copy allows copying the rotated elements
4013 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
4014 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
4015 # @ingroup l2_modif_trsf
4016 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
4018 if isinstance(AngleInRadians,str):
4020 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
4022 AngleInRadians = DegreesToRadians(AngleInRadians)
4023 if (isinstance(theObject, Mesh)):
4024 theObject = theObject.GetMesh()
4025 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
4026 Axis = self.smeshpyD.GetAxisStruct(Axis)
4027 Axis,AxisParameters = ParseAxisStruct(Axis)
4028 Parameters = AxisParameters + ":" + Parameters
4029 self.mesh.SetParameters(Parameters)
4030 if Copy and MakeGroups:
4031 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
4032 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
4035 ## Creates a new mesh from the rotated object
4036 # @param theObject the object to rotate (mesh, submesh, or group)
4037 # @param Axis the axis of rotation (AxisStruct or geom line)
4038 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
4039 # @param MakeGroups forces the generation of new groups from existing ones
4040 # @param NewMeshName the name of the newly created mesh
4041 # @return instance of Mesh class
4042 # @ingroup l2_modif_trsf
4043 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
4045 if isinstance(AngleInRadians,str):
4047 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
4049 AngleInRadians = DegreesToRadians(AngleInRadians)
4050 if (isinstance( theObject, Mesh )):
4051 theObject = theObject.GetMesh()
4052 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
4053 Axis = self.smeshpyD.GetAxisStruct(Axis)
4054 Axis,AxisParameters = ParseAxisStruct(Axis)
4055 Parameters = AxisParameters + ":" + Parameters
4056 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
4057 MakeGroups, NewMeshName)
4058 mesh.SetParameters(Parameters)
4059 return Mesh( self.smeshpyD, self.geompyD, mesh )
4061 ## Finds groups of ajacent nodes within Tolerance.
4062 # @param Tolerance the value of tolerance
4063 # @return the list of groups of nodes
4064 # @ingroup l2_modif_trsf
4065 def FindCoincidentNodes (self, Tolerance):
4066 return self.editor.FindCoincidentNodes(Tolerance)
4068 ## Finds groups of ajacent nodes within Tolerance.
4069 # @param Tolerance the value of tolerance
4070 # @param SubMeshOrGroup SubMesh or Group
4071 # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
4072 # @return the list of groups of nodes
4073 # @ingroup l2_modif_trsf
4074 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
4075 if (isinstance( SubMeshOrGroup, Mesh )):
4076 SubMeshOrGroup = SubMeshOrGroup.GetMesh()
4077 if not isinstance( exceptNodes, list):
4078 exceptNodes = [ exceptNodes ]
4079 if exceptNodes and isinstance( exceptNodes[0], int):
4080 exceptNodes = [ self.GetIDSource( exceptNodes, SMESH.NODE)]
4081 return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes)
4084 # @param GroupsOfNodes the list of groups of nodes
4085 # @ingroup l2_modif_trsf
4086 def MergeNodes (self, GroupsOfNodes):
4087 self.editor.MergeNodes(GroupsOfNodes)
4089 ## Finds the elements built on the same nodes.
4090 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
4091 # @return a list of groups of equal elements
4092 # @ingroup l2_modif_trsf
4093 def FindEqualElements (self, MeshOrSubMeshOrGroup):
4094 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
4095 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
4096 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
4098 ## Merges elements in each given group.
4099 # @param GroupsOfElementsID groups of elements for merging
4100 # @ingroup l2_modif_trsf
4101 def MergeElements(self, GroupsOfElementsID):
4102 self.editor.MergeElements(GroupsOfElementsID)
4104 ## Leaves one element and removes all other elements built on the same nodes.
4105 # @ingroup l2_modif_trsf
4106 def MergeEqualElements(self):
4107 self.editor.MergeEqualElements()
4109 ## Sews free borders
4110 # @return SMESH::Sew_Error
4111 # @ingroup l2_modif_trsf
4112 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
4113 FirstNodeID2, SecondNodeID2, LastNodeID2,
4114 CreatePolygons, CreatePolyedrs):
4115 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
4116 FirstNodeID2, SecondNodeID2, LastNodeID2,
4117 CreatePolygons, CreatePolyedrs)
4119 ## Sews conform free borders
4120 # @return SMESH::Sew_Error
4121 # @ingroup l2_modif_trsf
4122 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
4123 FirstNodeID2, SecondNodeID2):
4124 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
4125 FirstNodeID2, SecondNodeID2)
4127 ## Sews border to side
4128 # @return SMESH::Sew_Error
4129 # @ingroup l2_modif_trsf
4130 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
4131 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
4132 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
4133 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
4135 ## Sews two sides of a mesh. The nodes belonging to Side1 are
4136 # merged with the nodes of elements of Side2.
4137 # The number of elements in theSide1 and in theSide2 must be
4138 # equal and they should have similar nodal connectivity.
4139 # The nodes to merge should belong to side borders and
4140 # the first node should be linked to the second.
4141 # @return SMESH::Sew_Error
4142 # @ingroup l2_modif_trsf
4143 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
4144 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
4145 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
4146 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
4147 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
4148 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
4150 ## Sets new nodes for the given element.
4151 # @param ide the element id
4152 # @param newIDs nodes ids
4153 # @return If the number of nodes does not correspond to the type of element - returns false
4154 # @ingroup l2_modif_edit
4155 def ChangeElemNodes(self, ide, newIDs):
4156 return self.editor.ChangeElemNodes(ide, newIDs)
4158 ## If during the last operation of MeshEditor some nodes were
4159 # created, this method returns the list of their IDs, \n
4160 # if new nodes were not created - returns empty list
4161 # @return the list of integer values (can be empty)
4162 # @ingroup l1_auxiliary
4163 def GetLastCreatedNodes(self):
4164 return self.editor.GetLastCreatedNodes()
4166 ## If during the last operation of MeshEditor some elements were
4167 # created this method returns the list of their IDs, \n
4168 # if new elements were not created - returns empty list
4169 # @return the list of integer values (can be empty)
4170 # @ingroup l1_auxiliary
4171 def GetLastCreatedElems(self):
4172 return self.editor.GetLastCreatedElems()
4174 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4175 # @param theNodes identifiers of nodes to be doubled
4176 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
4177 # nodes. If list of element identifiers is empty then nodes are doubled but
4178 # they not assigned to elements
4179 # @return TRUE if operation has been completed successfully, FALSE otherwise
4180 # @ingroup l2_modif_edit
4181 def DoubleNodes(self, theNodes, theModifiedElems):
4182 return self.editor.DoubleNodes(theNodes, theModifiedElems)
4184 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4185 # This method provided for convenience works as DoubleNodes() described above.
4186 # @param theNodeId identifiers of node to be doubled
4187 # @param theModifiedElems identifiers of elements to be updated
4188 # @return TRUE if operation has been completed successfully, FALSE otherwise
4189 # @ingroup l2_modif_edit
4190 def DoubleNode(self, theNodeId, theModifiedElems):
4191 return self.editor.DoubleNode(theNodeId, theModifiedElems)
4193 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4194 # This method provided for convenience works as DoubleNodes() described above.
4195 # @param theNodes group of nodes to be doubled
4196 # @param theModifiedElems group of elements to be updated.
4197 # @param theMakeGroup forces the generation of a group containing new nodes.
4198 # @return TRUE or a created group if operation has been completed successfully,
4199 # FALSE or None otherwise
4200 # @ingroup l2_modif_edit
4201 def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
4203 return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
4204 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
4206 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4207 # This method provided for convenience works as DoubleNodes() described above.
4208 # @param theNodes list of groups of nodes to be doubled
4209 # @param theModifiedElems list of groups of elements to be updated.
4210 # @param theMakeGroup forces the generation of a group containing new nodes.
4211 # @return TRUE if operation has been completed successfully, FALSE otherwise
4212 # @ingroup l2_modif_edit
4213 def DoubleNodeGroups(self, theNodes, theModifiedElems, theMakeGroup=False):
4215 return self.editor.DoubleNodeGroupsNew(theNodes, theModifiedElems)
4216 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
4218 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4219 # @param theElems - the list of elements (edges or faces) to be replicated
4220 # The nodes for duplication could be found from these elements
4221 # @param theNodesNot - list of nodes to NOT replicate
4222 # @param theAffectedElems - the list of elements (cells and edges) to which the
4223 # replicated nodes should be associated to.
4224 # @return TRUE if operation has been completed successfully, FALSE otherwise
4225 # @ingroup l2_modif_edit
4226 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
4227 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
4229 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4230 # @param theElems - the list of elements (edges or faces) to be replicated
4231 # The nodes for duplication could be found from these elements
4232 # @param theNodesNot - list of nodes to NOT replicate
4233 # @param theShape - shape to detect affected elements (element which geometric center
4234 # located on or inside shape).
4235 # The replicated nodes should be associated to affected elements.
4236 # @return TRUE if operation has been completed successfully, FALSE otherwise
4237 # @ingroup l2_modif_edit
4238 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
4239 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
4241 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4242 # This method provided for convenience works as DoubleNodes() described above.
4243 # @param theElems - group of of elements (edges or faces) to be replicated
4244 # @param theNodesNot - group of nodes not to replicated
4245 # @param theAffectedElems - group of elements to which the replicated nodes
4246 # should be associated to.
4247 # @param theMakeGroup forces the generation of a group containing new elements.
4248 # @return TRUE or a created group if operation has been completed successfully,
4249 # FALSE or None otherwise
4250 # @ingroup l2_modif_edit
4251 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4253 return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
4254 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
4256 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4257 # This method provided for convenience works as DoubleNodes() described above.
4258 # @param theElems - group of of elements (edges or faces) to be replicated
4259 # @param theNodesNot - group of nodes not to replicated
4260 # @param theShape - shape to detect affected elements (element which geometric center
4261 # located on or inside shape).
4262 # The replicated nodes should be associated to affected elements.
4263 # @ingroup l2_modif_edit
4264 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
4265 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
4267 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4268 # This method provided for convenience works as DoubleNodes() described above.
4269 # @param theElems - list of groups of elements (edges or faces) to be replicated
4270 # @param theNodesNot - list of groups of nodes not to replicated
4271 # @param theAffectedElems - group of elements to which the replicated nodes
4272 # should be associated to.
4273 # @param theMakeGroup forces the generation of a group containing new elements.
4274 # @return TRUE or a created group if operation has been completed successfully,
4275 # FALSE or None otherwise
4276 # @ingroup l2_modif_edit
4277 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4279 return self.editor.DoubleNodeElemGroupsNew(theElems, theNodesNot, theAffectedElems)
4280 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
4282 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4283 # This method provided for convenience works as DoubleNodes() described above.
4284 # @param theElems - list of groups of elements (edges or faces) to be replicated
4285 # @param theNodesNot - list of groups of nodes not to replicated
4286 # @param theShape - shape to detect affected elements (element which geometric center
4287 # located on or inside shape).
4288 # The replicated nodes should be associated to affected elements.
4289 # @return TRUE if operation has been completed successfully, FALSE otherwise
4290 # @ingroup l2_modif_edit
4291 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
4292 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
4294 ## Double nodes on shared faces between groups of volumes and create flat elements on demand.
4295 # The list of groups must describe a partition of the mesh volumes.
4296 # The nodes of the internal faces at the boundaries of the groups are doubled.
4297 # In option, the internal faces are replaced by flat elements.
4298 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4299 # @param theDomains - list of groups of volumes
4300 # @param createJointElems - if TRUE, create the elements
4301 # @return TRUE if operation has been completed successfully, FALSE otherwise
4302 def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems ):
4303 return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems )
4305 ## Double nodes on some external faces and create flat elements.
4306 # Flat elements are mainly used by some types of mechanic calculations.
4308 # Each group of the list must be constituted of faces.
4309 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4310 # @param theGroupsOfFaces - list of groups of faces
4311 # @return TRUE if operation has been completed successfully, FALSE otherwise
4312 def CreateFlatElementsOnFacesGroups(self, theGroupsOfFaces ):
4313 return self.editor.CreateFlatElementsOnFacesGroups( theGroupsOfFaces )
4315 def _valueFromFunctor(self, funcType, elemId):
4316 fn = self.smeshpyD.GetFunctor(funcType)
4317 fn.SetMesh(self.mesh)
4318 if fn.GetElementType() == self.GetElementType(elemId, True):
4319 val = fn.GetValue(elemId)
4324 ## Get length of 1D element.
4325 # @param elemId mesh element ID
4326 # @return element's length value
4327 # @ingroup l1_measurements
4328 def GetLength(self, elemId):
4329 return self._valueFromFunctor(SMESH.FT_Length, elemId)
4331 ## Get area of 2D element.
4332 # @param elemId mesh element ID
4333 # @return element's area value
4334 # @ingroup l1_measurements
4335 def GetArea(self, elemId):
4336 return self._valueFromFunctor(SMESH.FT_Area, elemId)
4338 ## Get volume of 3D element.
4339 # @param elemId mesh element ID
4340 # @return element's volume value
4341 # @ingroup l1_measurements
4342 def GetVolume(self, elemId):
4343 return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
4345 ## Get maximum element length.
4346 # @param elemId mesh element ID
4347 # @return element's maximum length value
4348 # @ingroup l1_measurements
4349 def GetMaxElementLength(self, elemId):
4350 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4351 ftype = SMESH.FT_MaxElementLength3D
4353 ftype = SMESH.FT_MaxElementLength2D
4354 return self._valueFromFunctor(ftype, elemId)
4356 ## Get aspect ratio of 2D or 3D element.
4357 # @param elemId mesh element ID
4358 # @return element's aspect ratio value
4359 # @ingroup l1_measurements
4360 def GetAspectRatio(self, elemId):
4361 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4362 ftype = SMESH.FT_AspectRatio3D
4364 ftype = SMESH.FT_AspectRatio
4365 return self._valueFromFunctor(ftype, elemId)
4367 ## Get warping angle of 2D element.
4368 # @param elemId mesh element ID
4369 # @return element's warping angle value
4370 # @ingroup l1_measurements
4371 def GetWarping(self, elemId):
4372 return self._valueFromFunctor(SMESH.FT_Warping, elemId)
4374 ## Get minimum angle of 2D element.
4375 # @param elemId mesh element ID
4376 # @return element's minimum angle value
4377 # @ingroup l1_measurements
4378 def GetMinimumAngle(self, elemId):
4379 return self._valueFromFunctor(SMESH.FT_MinimumAngle, elemId)
4381 ## Get taper of 2D element.
4382 # @param elemId mesh element ID
4383 # @return element's taper value
4384 # @ingroup l1_measurements
4385 def GetTaper(self, elemId):
4386 return self._valueFromFunctor(SMESH.FT_Taper, elemId)
4388 ## Get skew of 2D element.
4389 # @param elemId mesh element ID
4390 # @return element's skew value
4391 # @ingroup l1_measurements
4392 def GetSkew(self, elemId):
4393 return self._valueFromFunctor(SMESH.FT_Skew, elemId)
4395 ## The mother class to define algorithm, it is not recommended to use it directly.
4398 # @ingroup l2_algorithms
4399 class Mesh_Algorithm:
4400 # @class Mesh_Algorithm
4401 # @brief Class Mesh_Algorithm
4403 #def __init__(self,smesh):
4411 ## Finds a hypothesis in the study by its type name and parameters.
4412 # Finds only the hypotheses created in smeshpyD engine.
4413 # @return SMESH.SMESH_Hypothesis
4414 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
4415 study = smeshpyD.GetCurrentStudy()
4416 #to do: find component by smeshpyD object, not by its data type
4417 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4418 if scomp is not None:
4419 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
4420 # Check if the root label of the hypotheses exists
4421 if res and hypRoot is not None:
4422 iter = study.NewChildIterator(hypRoot)
4423 # Check all published hypotheses
4425 hypo_so_i = iter.Value()
4426 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
4427 if attr is not None:
4428 anIOR = attr.Value()
4429 hypo_o_i = salome.orb.string_to_object(anIOR)
4430 if hypo_o_i is not None:
4431 # Check if this is a hypothesis
4432 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
4433 if hypo_i is not None:
4434 # Check if the hypothesis belongs to current engine
4435 if smeshpyD.GetObjectId(hypo_i) > 0:
4436 # Check if this is the required hypothesis
4437 if hypo_i.GetName() == hypname:
4439 if CompareMethod(hypo_i, args):
4453 ## Finds the algorithm in the study by its type name.
4454 # Finds only the algorithms, which have been created in smeshpyD engine.
4455 # @return SMESH.SMESH_Algo
4456 def FindAlgorithm (self, algoname, smeshpyD):
4457 study = smeshpyD.GetCurrentStudy()
4458 #to do: find component by smeshpyD object, not by its data type
4459 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4460 if scomp is not None:
4461 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
4462 # Check if the root label of the algorithms exists
4463 if res and hypRoot is not None:
4464 iter = study.NewChildIterator(hypRoot)
4465 # Check all published algorithms
4467 algo_so_i = iter.Value()
4468 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
4469 if attr is not None:
4470 anIOR = attr.Value()
4471 algo_o_i = salome.orb.string_to_object(anIOR)
4472 if algo_o_i is not None:
4473 # Check if this is an algorithm
4474 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
4475 if algo_i is not None:
4476 # Checks if the algorithm belongs to the current engine
4477 if smeshpyD.GetObjectId(algo_i) > 0:
4478 # Check if this is the required algorithm
4479 if algo_i.GetName() == algoname:
4492 ## If the algorithm is global, returns 0; \n
4493 # else returns the submesh associated to this algorithm.
4494 def GetSubMesh(self):
4497 ## Returns the wrapped mesher.
4498 def GetAlgorithm(self):
4501 ## Gets the list of hypothesis that can be used with this algorithm
4502 def GetCompatibleHypothesis(self):
4505 mylist = self.algo.GetCompatibleHypothesis()
4508 ## Gets the name of the algorithm
4512 ## Sets the name to the algorithm
4513 def SetName(self, name):
4514 self.mesh.smeshpyD.SetName(self.algo, name)
4516 ## Gets the id of the algorithm
4518 return self.algo.GetId()
4521 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
4523 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
4524 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
4526 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
4528 self.Assign(algo, mesh, geom)
4532 def Assign(self, algo, mesh, geom):
4534 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
4538 self.geom = mesh.geom
4541 AssureGeomPublished( mesh, geom )
4543 name = GetName(geom)
4547 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
4549 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
4550 TreatHypoStatus( status, algo.GetName(), name, True )
4553 def CompareHyp (self, hyp, args):
4554 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
4557 def CompareEqualHyp (self, hyp, args):
4561 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
4562 UseExisting=0, CompareMethod=""):
4565 if CompareMethod == "": CompareMethod = self.CompareHyp
4566 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
4569 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
4575 a = a + s + str(args[i])
4579 self.mesh.smeshpyD.SetName(hypo, hyp + a)
4583 geomName = GetName(self.geom)
4584 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
4585 TreatHypoStatus( status, GetName(hypo), geomName, 0 )
4588 ## Returns entry of the shape to mesh in the study
4589 def MainShapeEntry(self):
4591 if not self.mesh or not self.mesh.GetMesh(): return entry
4592 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
4593 study = self.mesh.smeshpyD.GetCurrentStudy()
4594 ior = salome.orb.object_to_string( self.mesh.GetShape() )
4595 sobj = study.FindObjectIOR(ior)
4596 if sobj: entry = sobj.GetID()
4597 if not entry: return ""
4600 ## Defines "ViscousLayers" hypothesis to give parameters of layers of prisms to build
4601 # near mesh boundary. This hypothesis can be used by several 3D algorithms:
4602 # NETGEN 3D, GHS3D, Hexahedron(i,j,k)
4603 # @param thickness total thickness of layers of prisms
4604 # @param numberOfLayers number of layers of prisms
4605 # @param stretchFactor factor (>1.0) of growth of layer thickness towards inside of mesh
4606 # @param ignoreFaces list of geometrical faces (or their ids) not to generate layers on
4607 # @ingroup l3_hypos_additi
4608 def ViscousLayers(self, thickness, numberOfLayers, stretchFactor, ignoreFaces=[]):
4609 if not isinstance(self.algo, SMESH._objref_SMESH_3D_Algo):
4610 raise TypeError, "ViscousLayers are supported by 3D algorithms only"
4611 if not "ViscousLayers" in self.GetCompatibleHypothesis():
4612 raise TypeError, "ViscousLayers are not supported by %s"%self.algo.GetName()
4613 if ignoreFaces and isinstance( ignoreFaces[0], geompyDC.GEOM._objref_GEOM_Object ):
4614 ignoreFaces = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, f) for f in ignoreFaces ]
4615 hyp = self.Hypothesis("ViscousLayers",
4616 [thickness, numberOfLayers, stretchFactor, ignoreFaces])
4617 hyp.SetTotalThickness(thickness)
4618 hyp.SetNumberLayers(numberOfLayers)
4619 hyp.SetStretchFactor(stretchFactor)
4620 hyp.SetIgnoreFaces(ignoreFaces)
4623 ## Transform a list of ether edges or tuples (edge 1st_vertex_of_edge)
4624 # into a list acceptable to SetReversedEdges() of some 1D hypotheses
4625 # @ingroupl3_hypos_1dhyps
4626 def ReversedEdgeIndices(self, reverseList):
4628 geompy = self.mesh.geompyD
4629 for i in reverseList:
4630 if isinstance( i, int ):
4631 s = geompy.SubShapes(self.mesh.geom, [i])[0]
4632 if s.GetShapeType() != geompyDC.GEOM.EDGE:
4633 raise TypeError, "Not EDGE index given"
4635 elif isinstance( i, geompyDC.GEOM._objref_GEOM_Object ):
4636 if i.GetShapeType() != geompyDC.GEOM.EDGE:
4637 raise TypeError, "Not an EDGE given"
4638 resList.append( geompy.GetSubShapeID(self.mesh.geom, i ))
4642 if not isinstance( e, geompyDC.GEOM._objref_GEOM_Object ) or \
4643 not isinstance( v, geompyDC.GEOM._objref_GEOM_Object ):
4644 raise TypeError, "A list item must be a tuple (edge 1st_vertex_of_edge)"
4645 if v.GetShapeType() == geompyDC.GEOM.EDGE and \
4646 e.GetShapeType() == geompyDC.GEOM.VERTEX:
4648 if e.GetShapeType() != geompyDC.GEOM.EDGE or \
4649 v.GetShapeType() != geompyDC.GEOM.VERTEX:
4650 raise TypeError, "A list item must be a tuple (edge 1st_vertex_of_edge)"
4651 vFirst = FirstVertexOnCurve( e )
4652 tol = geompy.Tolerance( vFirst )[-1]
4653 if geompy.MinDistance( v, vFirst ) > 1.5*tol:
4654 resList.append( geompy.GetSubShapeID(self.mesh.geom, e ))
4656 raise TypeError, "Item must be either an edge or tuple (edge 1st_vertex_of_edge)"
4659 # Public class: Mesh_Segment
4660 # --------------------------
4662 ## Class to define a segment 1D algorithm for discretization
4665 # @ingroup l3_algos_basic
4666 class Mesh_Segment(Mesh_Algorithm):
4668 ## Private constructor.
4669 def __init__(self, mesh, geom=0):
4670 Mesh_Algorithm.__init__(self)
4671 self.Create(mesh, geom, "Regular_1D")
4673 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
4674 # @param l for the length of segments that cut an edge
4675 # @param UseExisting if ==true - searches for an existing hypothesis created with
4676 # the same parameters, else (default) - creates a new one
4677 # @param p precision, used for calculation of the number of segments.
4678 # The precision should be a positive, meaningful value within the range [0,1].
4679 # In general, the number of segments is calculated with the formula:
4680 # nb = ceil((edge_length / l) - p)
4681 # Function ceil rounds its argument to the higher integer.
4682 # So, p=0 means rounding of (edge_length / l) to the higher integer,
4683 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
4684 # p=1 means rounding of (edge_length / l) to the lower integer.
4685 # Default value is 1e-07.
4686 # @return an instance of StdMeshers_LocalLength hypothesis
4687 # @ingroup l3_hypos_1dhyps
4688 def LocalLength(self, l, UseExisting=0, p=1e-07):
4689 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
4690 CompareMethod=self.CompareLocalLength)
4696 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
4697 def CompareLocalLength(self, hyp, args):
4698 if IsEqual(hyp.GetLength(), args[0]):
4699 return IsEqual(hyp.GetPrecision(), args[1])
4702 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
4703 # @param length is optional maximal allowed length of segment, if it is omitted
4704 # the preestimated length is used that depends on geometry size
4705 # @param UseExisting if ==true - searches for an existing hypothesis created with
4706 # the same parameters, else (default) - create a new one
4707 # @return an instance of StdMeshers_MaxLength hypothesis
4708 # @ingroup l3_hypos_1dhyps
4709 def MaxSize(self, length=0.0, UseExisting=0):
4710 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
4713 hyp.SetLength(length)
4715 # set preestimated length
4716 gen = self.mesh.smeshpyD
4717 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
4718 self.mesh.GetMesh(), self.mesh.GetShape(),
4720 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
4722 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
4725 hyp.SetUsePreestimatedLength( length == 0.0 )
4728 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
4729 # @param n for the number of segments that cut an edge
4730 # @param s for the scale factor (optional)
4731 # @param reversedEdges is a list of edges to mesh using reversed orientation.
4732 # A list item can also be a tuple (edge 1st_vertex_of_edge)
4733 # @param UseExisting if ==true - searches for an existing hypothesis created with
4734 # the same parameters, else (default) - create a new one
4735 # @return an instance of StdMeshers_NumberOfSegments hypothesis
4736 # @ingroup l3_hypos_1dhyps
4737 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4738 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4739 reversedEdges, UseExisting = [], reversedEdges
4740 entry = self.MainShapeEntry()
4741 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
4743 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdgeInd, entry],
4744 UseExisting=UseExisting,
4745 CompareMethod=self.CompareNumberOfSegments)
4747 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdgeInd, entry],
4748 UseExisting=UseExisting,
4749 CompareMethod=self.CompareNumberOfSegments)
4750 hyp.SetDistrType( 1 )
4751 hyp.SetScaleFactor(s)
4752 hyp.SetNumberOfSegments(n)
4753 hyp.SetReversedEdges( reversedEdgeInd )
4754 hyp.SetObjectEntry( entry )
4758 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4759 def CompareNumberOfSegments(self, hyp, args):
4760 if hyp.GetNumberOfSegments() == args[0]:
4762 if hyp.GetReversedEdges() == args[1]:
4763 if not args[1] or hyp.GetObjectEntry() == args[2]:
4766 if hyp.GetReversedEdges() == args[2]:
4767 if not args[2] or hyp.GetObjectEntry() == args[3]:
4768 if hyp.GetDistrType() == 1:
4769 if IsEqual(hyp.GetScaleFactor(), args[1]):
4773 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4774 # @param start defines the length of the first segment
4775 # @param end defines the length of the last segment
4776 # @param reversedEdges is a list of edges to mesh using reversed orientation.
4777 # A list item can also be a tuple (edge 1st_vertex_of_edge)
4778 # @param UseExisting if ==true - searches for an existing hypothesis created with
4779 # the same parameters, else (default) - creates a new one
4780 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4781 # @ingroup l3_hypos_1dhyps
4782 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4783 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4784 reversedEdges, UseExisting = [], reversedEdges
4785 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
4786 entry = self.MainShapeEntry()
4787 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdgeInd, entry],
4788 UseExisting=UseExisting,
4789 CompareMethod=self.CompareArithmetic1D)
4790 hyp.SetStartLength(start)
4791 hyp.SetEndLength(end)
4792 hyp.SetReversedEdges( reversedEdgeInd )
4793 hyp.SetObjectEntry( entry )
4797 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4798 def CompareArithmetic1D(self, hyp, args):
4799 if IsEqual(hyp.GetLength(1), args[0]):
4800 if IsEqual(hyp.GetLength(0), args[1]):
4801 if hyp.GetReversedEdges() == args[2]:
4802 if not args[2] or hyp.GetObjectEntry() == args[3]:
4807 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4808 # on curve from 0 to 1 (additionally it is neecessary to check
4809 # orientation of edges and create list of reversed edges if it is
4810 # needed) and sets numbers of segments between given points (default
4811 # values are equals 1
4812 # @param points defines the list of parameters on curve
4813 # @param nbSegs defines the list of numbers of segments
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 FixedPoints1D(self, points, nbSegs=[1], 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("FixedPoints1D", [points, nbSegs, reversedEdgeInd, entry],
4826 UseExisting=UseExisting,
4827 CompareMethod=self.CompareFixedPoints1D)
4828 hyp.SetPoints(points)
4829 hyp.SetNbSegments(nbSegs)
4830 hyp.SetReversedEdges(reversedEdgeInd)
4831 hyp.SetObjectEntry(entry)
4835 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4836 ## as the given arguments
4837 def CompareFixedPoints1D(self, hyp, args):
4838 if hyp.GetPoints() == args[0]:
4839 if hyp.GetNbSegments() == args[1]:
4840 if hyp.GetReversedEdges() == args[2]:
4841 if not args[2] or hyp.GetObjectEntry() == args[3]:
4847 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4848 # @param start defines the length of the first segment
4849 # @param end defines the length of the last segment
4850 # @param reversedEdges is a list of edges to mesh using reversed orientation.
4851 # A list item can also be a tuple (edge 1st_vertex_of_edge)
4852 # @param UseExisting if ==true - searches for an existing hypothesis created with
4853 # the same parameters, else (default) - creates a new one
4854 # @return an instance of StdMeshers_StartEndLength hypothesis
4855 # @ingroup l3_hypos_1dhyps
4856 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4857 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4858 reversedEdges, UseExisting = [], reversedEdges
4859 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
4860 entry = self.MainShapeEntry()
4861 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdgeInd, entry],
4862 UseExisting=UseExisting,
4863 CompareMethod=self.CompareStartEndLength)
4864 hyp.SetStartLength(start)
4865 hyp.SetEndLength(end)
4866 hyp.SetReversedEdges( reversedEdgeInd )
4867 hyp.SetObjectEntry( entry )
4870 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4871 def CompareStartEndLength(self, hyp, args):
4872 if IsEqual(hyp.GetLength(1), args[0]):
4873 if IsEqual(hyp.GetLength(0), args[1]):
4874 if hyp.GetReversedEdges() == args[2]:
4875 if not args[2] or hyp.GetObjectEntry() == args[3]:
4879 ## Defines "Deflection1D" hypothesis
4880 # @param d for the deflection
4881 # @param UseExisting if ==true - searches for an existing hypothesis created with
4882 # the same parameters, else (default) - create a new one
4883 # @ingroup l3_hypos_1dhyps
4884 def Deflection1D(self, d, UseExisting=0):
4885 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4886 CompareMethod=self.CompareDeflection1D)
4887 hyp.SetDeflection(d)
4890 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4891 def CompareDeflection1D(self, hyp, args):
4892 return IsEqual(hyp.GetDeflection(), args[0])
4894 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4895 # the opposite side in case of quadrangular faces
4896 # @ingroup l3_hypos_additi
4897 def Propagation(self):
4898 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4900 ## Defines "AutomaticLength" hypothesis
4901 # @param fineness for the fineness [0-1]
4902 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4903 # same parameters, else (default) - create a new one
4904 # @ingroup l3_hypos_1dhyps
4905 def AutomaticLength(self, fineness=0, UseExisting=0):
4906 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4907 CompareMethod=self.CompareAutomaticLength)
4908 hyp.SetFineness( fineness )
4911 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4912 def CompareAutomaticLength(self, hyp, args):
4913 return IsEqual(hyp.GetFineness(), args[0])
4915 ## Defines "SegmentLengthAroundVertex" hypothesis
4916 # @param length for the segment length
4917 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4918 # Any other integer value means that the hypothesis will be set on the
4919 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4920 # @param UseExisting if ==true - searches for an existing hypothesis created with
4921 # the same parameters, else (default) - creates a new one
4922 # @ingroup l3_algos_segmarv
4923 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4925 store_geom = self.geom
4926 if type(vertex) is types.IntType:
4927 if vertex == 0 or vertex == 1:
4928 vertex = self.mesh.geompyD.ExtractShapes(self.geom, geompyDC.ShapeType["VERTEX"],True)[vertex]
4936 if self.geom is None:
4937 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4938 AssureGeomPublished( self.mesh, self.geom )
4939 name = GetName(self.geom)
4941 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4943 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4945 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4946 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4948 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4949 CompareMethod=self.CompareLengthNearVertex)
4950 self.geom = store_geom
4951 hyp.SetLength( length )
4954 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4955 # @ingroup l3_algos_segmarv
4956 def CompareLengthNearVertex(self, hyp, args):
4957 return IsEqual(hyp.GetLength(), args[0])
4959 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4960 # If the 2D mesher sees that all boundary edges are quadratic,
4961 # it generates quadratic faces, else it generates linear faces using
4962 # medium nodes as if they are vertices.
4963 # The 3D mesher generates quadratic volumes only if all boundary faces
4964 # are quadratic, else it fails.
4966 # @ingroup l3_hypos_additi
4967 def QuadraticMesh(self):
4968 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4971 # Public class: Mesh_CompositeSegment
4972 # --------------------------
4974 ## Defines a segment 1D algorithm for discretization
4976 # @ingroup l3_algos_basic
4977 class Mesh_CompositeSegment(Mesh_Segment):
4979 ## Private constructor.
4980 def __init__(self, mesh, geom=0):
4981 self.Create(mesh, geom, "CompositeSegment_1D")
4984 # Public class: Mesh_Segment_Python
4985 # ---------------------------------
4987 ## Defines a segment 1D algorithm for discretization with python function
4989 # @ingroup l3_algos_basic
4990 class Mesh_Segment_Python(Mesh_Segment):
4992 ## Private constructor.
4993 def __init__(self, mesh, geom=0):
4994 import Python1dPlugin
4995 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4997 ## Defines "PythonSplit1D" hypothesis
4998 # @param n for the number of segments that cut an edge
4999 # @param func for the python function that calculates the length of all segments
5000 # @param UseExisting if ==true - searches for the existing hypothesis created with
5001 # the same parameters, else (default) - creates a new one
5002 # @ingroup l3_hypos_1dhyps
5003 def PythonSplit1D(self, n, func, UseExisting=0):
5004 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
5005 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
5006 hyp.SetNumberOfSegments(n)
5007 hyp.SetPythonLog10RatioFunction(func)
5010 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
5011 def ComparePythonSplit1D(self, hyp, args):
5012 #if hyp.GetNumberOfSegments() == args[0]:
5013 # if hyp.GetPythonLog10RatioFunction() == args[1]:
5017 # Public class: Mesh_Triangle
5018 # ---------------------------
5020 ## Defines a triangle 2D algorithm
5022 # @ingroup l3_algos_basic
5023 class Mesh_Triangle(Mesh_Algorithm):
5032 ## Private constructor.
5033 def __init__(self, mesh, algoType, geom=0):
5034 Mesh_Algorithm.__init__(self)
5036 if algoType == MEFISTO:
5037 self.Create(mesh, geom, "MEFISTO_2D")
5039 elif algoType == BLSURF:
5041 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
5042 #self.SetPhysicalMesh() - PAL19680
5043 elif algoType == NETGEN:
5045 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
5047 elif algoType == NETGEN_2D:
5049 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
5052 self.algoType = algoType
5054 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
5055 # @param area for the maximum area of each triangle
5056 # @param UseExisting if ==true - searches for an existing hypothesis created with the
5057 # same parameters, else (default) - creates a new one
5059 # Only for algoType == MEFISTO || NETGEN_2D
5060 # @ingroup l3_hypos_2dhyps
5061 def MaxElementArea(self, area, UseExisting=0):
5062 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
5063 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
5064 CompareMethod=self.CompareMaxElementArea)
5065 elif self.algoType == NETGEN:
5066 hyp = self.Parameters(SIMPLE)
5067 hyp.SetMaxElementArea(area)
5070 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
5071 def CompareMaxElementArea(self, hyp, args):
5072 return IsEqual(hyp.GetMaxElementArea(), args[0])
5074 ## Defines "LengthFromEdges" hypothesis to build triangles
5075 # based on the length of the edges taken from the wire
5077 # Only for algoType == MEFISTO || NETGEN_2D
5078 # @ingroup l3_hypos_2dhyps
5079 def LengthFromEdges(self):
5080 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
5081 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
5083 elif self.algoType == NETGEN:
5084 hyp = self.Parameters(SIMPLE)
5085 hyp.LengthFromEdges()
5088 ## Sets a way to define size of mesh elements to generate.
5089 # @param thePhysicalMesh is: DefaultSize, BLSURF_Custom or SizeMap.
5090 # @ingroup l3_hypos_blsurf
5091 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
5092 if self.Parameters():
5093 # Parameter of BLSURF algo
5094 self.params.SetPhysicalMesh(thePhysicalMesh)
5096 ## Sets size of mesh elements to generate.
5097 # @ingroup l3_hypos_blsurf
5098 def SetPhySize(self, theVal):
5099 if self.Parameters():
5100 # Parameter of BLSURF algo
5101 self.params.SetPhySize(theVal)
5103 ## Sets lower boundary of mesh element size (PhySize).
5104 # @ingroup l3_hypos_blsurf
5105 def SetPhyMin(self, theVal=-1):
5106 if self.Parameters():
5107 # Parameter of BLSURF algo
5108 self.params.SetPhyMin(theVal)
5110 ## Sets upper boundary of mesh element size (PhySize).
5111 # @ingroup l3_hypos_blsurf
5112 def SetPhyMax(self, theVal=-1):
5113 if self.Parameters():
5114 # Parameter of BLSURF algo
5115 self.params.SetPhyMax(theVal)
5117 ## Sets a way to define maximum angular deflection of mesh from CAD model.
5118 # @param theGeometricMesh is: 0 (None) or 1 (Custom)
5119 # @ingroup l3_hypos_blsurf
5120 def SetGeometricMesh(self, theGeometricMesh=0):
5121 if self.Parameters():
5122 # Parameter of BLSURF algo
5123 if self.params.GetPhysicalMesh() == 0: theGeometricMesh = 1
5124 self.params.SetGeometricMesh(theGeometricMesh)
5126 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
5127 # @ingroup l3_hypos_blsurf
5128 def SetAngleMeshS(self, theVal=_angleMeshS):
5129 if self.Parameters():
5130 # Parameter of BLSURF algo
5131 if self.params.GetGeometricMesh() == 0: theVal = self._angleMeshS
5132 self.params.SetAngleMeshS(theVal)
5134 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
5135 # @ingroup l3_hypos_blsurf
5136 def SetAngleMeshC(self, theVal=_angleMeshS):
5137 if self.Parameters():
5138 # Parameter of BLSURF algo
5139 if self.params.GetGeometricMesh() == 0: theVal = self._angleMeshS
5140 self.params.SetAngleMeshC(theVal)
5142 ## Sets lower boundary of mesh element size computed to respect angular deflection.
5143 # @ingroup l3_hypos_blsurf
5144 def SetGeoMin(self, theVal=-1):
5145 if self.Parameters():
5146 # Parameter of BLSURF algo
5147 self.params.SetGeoMin(theVal)
5149 ## Sets upper boundary of mesh element size computed to respect angular deflection.
5150 # @ingroup l3_hypos_blsurf
5151 def SetGeoMax(self, theVal=-1):
5152 if self.Parameters():
5153 # Parameter of BLSURF algo
5154 self.params.SetGeoMax(theVal)
5156 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
5157 # @ingroup l3_hypos_blsurf
5158 def SetGradation(self, theVal=_gradation):
5159 if self.Parameters():
5160 # Parameter of BLSURF algo
5161 if self.params.GetGeometricMesh() == 0: theVal = self._gradation
5162 self.params.SetGradation(theVal)
5164 ## Sets topology usage way.
5165 # @param way defines how mesh conformity is assured <ul>
5166 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
5167 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
5168 # <li>PreCAD - by pre-processing with PreCAD a CAD model</li></ul>
5169 # @ingroup l3_hypos_blsurf
5170 def SetTopology(self, way):
5171 if self.Parameters():
5172 # Parameter of BLSURF algo
5173 self.params.SetTopology(way)
5175 ## To respect geometrical edges or not.
5176 # @ingroup l3_hypos_blsurf
5177 def SetDecimesh(self, toIgnoreEdges=False):
5178 if self.Parameters():
5179 # Parameter of BLSURF algo
5180 self.params.SetDecimesh(toIgnoreEdges)
5182 ## Sets verbosity level in the range 0 to 100.
5183 # @ingroup l3_hypos_blsurf
5184 def SetVerbosity(self, level):
5185 if self.Parameters():
5186 # Parameter of BLSURF algo
5187 self.params.SetVerbosity(level)
5189 ## To optimize merges edges.
5190 # @ingroup l3_hypos_blsurf
5191 def SetPreCADMergeEdges(self, toMergeEdges=False):
5192 if self.Parameters():
5193 # Parameter of BLSURF algo
5194 self.params.SetPreCADMergeEdges(toMergeEdges)
5196 ## To remove nano edges.
5197 # @ingroup l3_hypos_blsurf
5198 def SetPreCADRemoveNanoEdges(self, toRemoveNanoEdges=False):
5199 if self.Parameters():
5200 # Parameter of BLSURF algo
5201 self.params.SetPreCADRemoveNanoEdges(toRemoveNanoEdges)
5203 ## To compute topology from scratch
5204 # @ingroup l3_hypos_blsurf
5205 def SetPreCADDiscardInput(self, toDiscardInput=False):
5206 if self.Parameters():
5207 # Parameter of BLSURF algo
5208 self.params.SetPreCADDiscardInput(toDiscardInput)
5210 ## Sets the length below which an edge is considered as nano
5211 # for the topology processing.
5212 # @ingroup l3_hypos_blsurf
5213 def SetPreCADEpsNano(self, epsNano):
5214 if self.Parameters():
5215 # Parameter of BLSURF algo
5216 self.params.SetPreCADEpsNano(epsNano)
5218 ## Sets advanced option value.
5219 # @ingroup l3_hypos_blsurf
5220 def SetOptionValue(self, optionName, level):
5221 if self.Parameters():
5222 # Parameter of BLSURF algo
5223 self.params.SetOptionValue(optionName,level)
5225 ## Sets advanced PreCAD option value.
5226 # Keyword arguments:
5227 # optionName: name of the option
5228 # optionValue: value of the option
5229 # @ingroup l3_hypos_blsurf
5230 def SetPreCADOptionValue(self, optionName, optionValue):
5231 if self.Parameters():
5232 # Parameter of BLSURF algo
5233 self.params.SetPreCADOptionValue(optionName,optionValue)
5235 ## Sets GMF file for export at computation
5236 # @ingroup l3_hypos_blsurf
5237 def SetGMFFile(self, fileName):
5238 if self.Parameters():
5239 # Parameter of BLSURF algo
5240 self.params.SetGMFFile(fileName)
5242 ## Enforced vertices (BLSURF)
5244 ## To get all the enforced vertices
5245 # @ingroup l3_hypos_blsurf
5246 def GetAllEnforcedVertices(self):
5247 if self.Parameters():
5248 # Parameter of BLSURF algo
5249 return self.params.GetAllEnforcedVertices()
5251 ## To get all the enforced vertices sorted by face (or group, compound)
5252 # @ingroup l3_hypos_blsurf
5253 def GetAllEnforcedVerticesByFace(self):
5254 if self.Parameters():
5255 # Parameter of BLSURF algo
5256 return self.params.GetAllEnforcedVerticesByFace()
5258 ## To get all the enforced vertices sorted by coords of input vertices
5259 # @ingroup l3_hypos_blsurf
5260 def GetAllEnforcedVerticesByCoords(self):
5261 if self.Parameters():
5262 # Parameter of BLSURF algo
5263 return self.params.GetAllEnforcedVerticesByCoords()
5265 ## To get all the coords of input vertices sorted by face (or group, compound)
5266 # @ingroup l3_hypos_blsurf
5267 def GetAllCoordsByFace(self):
5268 if self.Parameters():
5269 # Parameter of BLSURF algo
5270 return self.params.GetAllCoordsByFace()
5272 ## To get all the enforced vertices on a face (or group, compound)
5273 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
5274 # @ingroup l3_hypos_blsurf
5275 def GetEnforcedVertices(self, theFace):
5276 if self.Parameters():
5277 # Parameter of BLSURF algo
5278 AssureGeomPublished( self.mesh, theFace )
5279 return self.params.GetEnforcedVertices(theFace)
5281 ## To clear all the enforced vertices
5282 # @ingroup l3_hypos_blsurf
5283 def ClearAllEnforcedVertices(self):
5284 if self.Parameters():
5285 # Parameter of BLSURF algo
5286 return self.params.ClearAllEnforcedVertices()
5288 ## 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.
5289 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
5290 # @param x : x coordinate
5291 # @param y : y coordinate
5292 # @param z : z coordinate
5293 # @param vertexName : name of the enforced vertex
5294 # @param groupName : name of the group
5295 # @ingroup l3_hypos_blsurf
5296 def SetEnforcedVertex(self, theFace, x, y, z, vertexName = "", groupName = ""):
5297 if self.Parameters():
5298 # Parameter of BLSURF algo
5299 AssureGeomPublished( self.mesh, theFace )
5300 if vertexName == "":
5302 return self.params.SetEnforcedVertex(theFace, x, y, z)
5304 return self.params.SetEnforcedVertexWithGroup(theFace, x, y, z, groupName)
5307 return self.params.SetEnforcedVertexNamed(theFace, x, y, z, vertexName)
5309 return self.params.SetEnforcedVertexNamedWithGroup(theFace, x, y, z, vertexName, groupName)
5311 ## To set an enforced vertex on a face (or group, compound) given a GEOM vertex, group or compound.
5312 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
5313 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
5314 # @param groupName : name of the group
5315 # @ingroup l3_hypos_blsurf
5316 def SetEnforcedVertexGeom(self, theFace, theVertex, groupName = ""):
5317 if self.Parameters():
5318 # Parameter of BLSURF algo
5319 AssureGeomPublished( self.mesh, theFace )
5320 AssureGeomPublished( self.mesh, theVertex )
5322 return self.params.SetEnforcedVertexGeom(theFace, theVertex)
5324 return self.params.SetEnforcedVertexGeomWithGroup(theFace, theVertex,groupName)
5326 ## To remove an enforced vertex on a given GEOM face (or group, compound) given the coordinates.
5327 # @param theFace : GEOM face (or group, compound) on which to remove the enforced vertex
5328 # @param x : x coordinate
5329 # @param y : y coordinate
5330 # @param z : z coordinate
5331 # @ingroup l3_hypos_blsurf
5332 def UnsetEnforcedVertex(self, theFace, x, y, z):
5333 if self.Parameters():
5334 # Parameter of BLSURF algo
5335 AssureGeomPublished( self.mesh, theFace )
5336 return self.params.UnsetEnforcedVertex(theFace, x, y, z)
5338 ## To remove an enforced vertex on a given GEOM face (or group, compound) given a GEOM vertex, group or compound.
5339 # @param theFace : GEOM face (or group, compound) on which to remove the enforced vertex
5340 # @param theVertex : GEOM vertex (or group, compound) to remove.
5341 # @ingroup l3_hypos_blsurf
5342 def UnsetEnforcedVertexGeom(self, theFace, theVertex):
5343 if self.Parameters():
5344 # Parameter of BLSURF algo
5345 AssureGeomPublished( self.mesh, theFace )
5346 AssureGeomPublished( self.mesh, theVertex )
5347 return self.params.UnsetEnforcedVertexGeom(theFace, theVertex)
5349 ## To remove all enforced vertices on a given face.
5350 # @param theFace : face (or group/compound of faces) on which to remove all enforced vertices
5351 # @ingroup l3_hypos_blsurf
5352 def UnsetEnforcedVertices(self, theFace):
5353 if self.Parameters():
5354 # Parameter of BLSURF algo
5355 AssureGeomPublished( self.mesh, theFace )
5356 return self.params.UnsetEnforcedVertices(theFace)
5358 ## Attractors (BLSURF)
5360 ## 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 ]
5361 # @param theFace : face on which the attractor will be defined
5362 # @param theAttractor : geometrical object from which the mesh size "h" decreases exponentially
5363 # @param theStartSize : mesh size on theAttractor
5364 # @param theEndSize : maximum size that will be reached on theFace
5365 # @param theInfluenceDistance : influence of the attractor ( the size grow slower on theFace if it's high)
5366 # @param theConstantSizeDistance : distance until which the mesh size will be kept constant on theFace
5367 # @ingroup l3_hypos_blsurf
5368 def SetAttractorGeom(self, theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance):
5369 if self.Parameters():
5370 # Parameter of BLSURF algo
5371 AssureGeomPublished( self.mesh, theFace )
5372 AssureGeomPublished( self.mesh, theAttractor )
5373 self.params.SetAttractorGeom(theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance)
5375 ## Unsets an attractor on the chosen face.
5376 # @param theFace : face on which the attractor has to be removed
5377 # @ingroup l3_hypos_blsurf
5378 def UnsetAttractorGeom(self, theFace):
5379 if self.Parameters():
5380 # Parameter of BLSURF algo
5381 AssureGeomPublished( self.mesh, theFace )
5382 self.params.SetAttractorGeom(theFace)
5384 ## Size maps (BLSURF)
5386 ## To set a size map on a face, edge or vertex (or group, compound) given Python function.
5387 # If theObject is a face, the function can be: def f(u,v): return u+v
5388 # If theObject is an edge, the function can be: def f(t): return t/2
5389 # If theObject is a vertex, the function can be: def f(): return 10
5390 # @param theObject : GEOM face, edge or vertex (or group, compound) on which to define a size map
5391 # @param theSizeMap : Size map defined as a string
5392 # @ingroup l3_hypos_blsurf
5393 def SetSizeMap(self, theObject, theSizeMap):
5394 if self.Parameters():
5395 # Parameter of BLSURF algo
5396 AssureGeomPublished( self.mesh, theObject )
5397 return self.params.SetSizeMap(theObject, theSizeMap)
5399 ## To remove a size map defined on a face, edge or vertex (or group, compound)
5400 # @param theObject : GEOM face, edge or vertex (or group, compound) on which to define a size map
5401 # @ingroup l3_hypos_blsurf
5402 def UnsetSizeMap(self, theObject):
5403 if self.Parameters():
5404 # Parameter of BLSURF algo
5405 AssureGeomPublished( self.mesh, theObject )
5406 return self.params.UnsetSizeMap(theObject)
5408 ## To remove all the size maps
5409 # @ingroup l3_hypos_blsurf
5410 def ClearSizeMaps(self):
5411 if self.Parameters():
5412 # Parameter of BLSURF algo
5413 return self.params.ClearSizeMaps()
5416 ## Sets QuadAllowed flag.
5417 # Only for algoType == NETGEN(NETGEN_1D2D) || NETGEN_2D || BLSURF
5418 # @ingroup l3_hypos_netgen l3_hypos_blsurf
5419 def SetQuadAllowed(self, toAllow=True):
5420 if self.algoType == NETGEN_2D:
5423 hasSimpleHyps = False
5424 simpleHyps = ["QuadranglePreference","LengthFromEdges","MaxElementArea"]
5425 for hyp in self.mesh.GetHypothesisList( self.geom ):
5426 if hyp.GetName() in simpleHyps:
5427 hasSimpleHyps = True
5428 if hyp.GetName() == "QuadranglePreference":
5429 if not toAllow: # remove QuadranglePreference
5430 self.mesh.RemoveHypothesis( self.geom, hyp )
5436 if toAllow: # add QuadranglePreference
5437 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
5442 if self.Parameters():
5443 self.params.SetQuadAllowed(toAllow)
5446 ## Defines hypothesis having several parameters
5448 # @ingroup l3_hypos_netgen
5449 def Parameters(self, which=SOLE):
5451 if self.algoType == NETGEN:
5453 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
5454 "libNETGENEngine.so", UseExisting=0)
5456 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
5457 "libNETGENEngine.so", UseExisting=0)
5458 elif self.algoType == MEFISTO:
5459 print "Mefisto algo support no multi-parameter hypothesis"
5460 elif self.algoType == NETGEN_2D:
5461 self.params = self.Hypothesis("NETGEN_Parameters_2D_ONLY", [],
5462 "libNETGENEngine.so", UseExisting=0)
5463 elif self.algoType == BLSURF:
5464 self.params = self.Hypothesis("BLSURF_Parameters", [],
5465 "libBLSURFEngine.so", UseExisting=0)
5467 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
5472 # Only for algoType == NETGEN
5473 # @ingroup l3_hypos_netgen
5474 def SetMaxSize(self, theSize):
5475 if self.Parameters():
5476 self.params.SetMaxSize(theSize)
5478 ## Sets SecondOrder flag
5480 # Only for algoType == NETGEN
5481 # @ingroup l3_hypos_netgen
5482 def SetSecondOrder(self, theVal):
5483 if self.Parameters():
5484 self.params.SetSecondOrder(theVal)
5486 ## Sets Optimize flag
5488 # Only for algoType == NETGEN
5489 # @ingroup l3_hypos_netgen
5490 def SetOptimize(self, theVal):
5491 if self.Parameters():
5492 self.params.SetOptimize(theVal)
5495 # @param theFineness is:
5496 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5498 # Only for algoType == NETGEN
5499 # @ingroup l3_hypos_netgen
5500 def SetFineness(self, theFineness):
5501 if self.Parameters():
5502 self.params.SetFineness(theFineness)
5506 # Only for algoType == NETGEN
5507 # @ingroup l3_hypos_netgen
5508 def SetGrowthRate(self, theRate):
5509 if self.Parameters():
5510 self.params.SetGrowthRate(theRate)
5512 ## Sets NbSegPerEdge
5514 # Only for algoType == NETGEN
5515 # @ingroup l3_hypos_netgen
5516 def SetNbSegPerEdge(self, theVal):
5517 if self.Parameters():
5518 self.params.SetNbSegPerEdge(theVal)
5520 ## Sets NbSegPerRadius
5522 # Only for algoType == NETGEN
5523 # @ingroup l3_hypos_netgen
5524 def SetNbSegPerRadius(self, theVal):
5525 if self.Parameters():
5526 self.params.SetNbSegPerRadius(theVal)
5528 ## Sets number of segments overriding value set by SetLocalLength()
5530 # Only for algoType == NETGEN
5531 # @ingroup l3_hypos_netgen
5532 def SetNumberOfSegments(self, theVal):
5533 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5535 ## Sets number of segments overriding value set by SetNumberOfSegments()
5537 # Only for algoType == NETGEN
5538 # @ingroup l3_hypos_netgen
5539 def SetLocalLength(self, theVal):
5540 self.Parameters(SIMPLE).SetLocalLength(theVal)
5545 # Public class: Mesh_Quadrangle
5546 # -----------------------------
5548 ## Defines a quadrangle 2D algorithm
5550 # @ingroup l3_algos_basic
5551 class Mesh_Quadrangle(Mesh_Algorithm):
5555 ## Private constructor.
5556 def __init__(self, mesh, geom=0):
5557 Mesh_Algorithm.__init__(self)
5558 self.Create(mesh, geom, "Quadrangle_2D")
5561 ## Defines "QuadrangleParameters" hypothesis
5562 # @param quadType defines the algorithm of transition between differently descretized
5563 # sides of a geometrical face:
5564 # - QUAD_STANDARD - both triangles and quadrangles are possible in the transition
5565 # area along the finer meshed sides.
5566 # - QUAD_TRIANGLE_PREF - only triangles are built in the transition area along the
5567 # finer meshed sides.
5568 # - QUAD_QUADRANGLE_PREF - only quadrangles are built in the transition area along
5569 # the finer meshed sides, iff the total quantity of segments on
5570 # all four sides of the face is even (divisible by 2).
5571 # - QUAD_QUADRANGLE_PREF_REVERSED - same as QUAD_QUADRANGLE_PREF but the transition
5572 # area is located along the coarser meshed sides.
5573 # - QUAD_REDUCED - only quadrangles are built and the transition between the sides
5574 # is made gradually, layer by layer. This type has a limitation on
5575 # the number of segments: one pair of opposite sides must have the
5576 # same number of segments, the other pair must have an even difference
5577 # between the numbers of segments on the sides.
5578 # @param triangleVertex: vertex of a trilateral geometrical face, around which triangles
5579 # will be created while other elements will be quadrangles.
5580 # Vertex can be either a GEOM_Object or a vertex ID within the
5582 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5583 # the same parameters, else (default) - creates a new one
5584 # @ingroup l3_hypos_quad
5585 def QuadrangleParameters(self, quadType=StdMeshers.QUAD_STANDARD, triangleVertex=0, UseExisting=0):
5586 vertexID = triangleVertex
5587 if isinstance( triangleVertex, geompyDC.GEOM._objref_GEOM_Object ):
5588 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, triangleVertex )
5590 compFun = lambda hyp,args: \
5591 hyp.GetQuadType() == args[0] and \
5592 ( hyp.GetTriaVertex()==args[1] or ( hyp.GetTriaVertex()<1 and args[1]<1))
5593 self.params = self.Hypothesis("QuadrangleParams", [quadType,vertexID],
5594 UseExisting = UseExisting, CompareMethod=compFun)
5596 if self.params.GetQuadType() != quadType:
5597 self.params.SetQuadType(quadType)
5599 self.params.SetTriaVertex( vertexID )
5602 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5603 # quadrangles are built in the transition area along the finer meshed sides,
5604 # iff the total quantity of segments on all four sides of the face is even.
5605 # @param reversed if True, transition area is located along the coarser meshed sides.
5606 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5607 # the same parameters, else (default) - creates a new one
5608 # @ingroup l3_hypos_quad
5609 def QuadranglePreference(self, reversed=False, UseExisting=0):
5611 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF_REVERSED,UseExisting=UseExisting)
5612 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF,UseExisting=UseExisting)
5614 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5615 # triangles are built in the transition area along the finer meshed sides.
5616 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5617 # the same parameters, else (default) - creates a new one
5618 # @ingroup l3_hypos_quad
5619 def TrianglePreference(self, UseExisting=0):
5620 return self.QuadrangleParameters(QUAD_TRIANGLE_PREF,UseExisting=UseExisting)
5622 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5623 # quadrangles are built and the transition between the sides is made gradually,
5624 # layer by layer. This type has a limitation on the number of segments: one pair
5625 # of opposite sides must have the same number of segments, the other pair must
5626 # have an even difference between the numbers of segments on the sides.
5627 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5628 # the same parameters, else (default) - creates a new one
5629 # @ingroup l3_hypos_quad
5630 def Reduced(self, UseExisting=0):
5631 return self.QuadrangleParameters(QUAD_REDUCED,UseExisting=UseExisting)
5633 ## Defines "QuadrangleParams" hypothesis with QUAD_STANDARD type of quadrangulation
5634 # @param vertex: vertex of a trilateral geometrical face, around which triangles
5635 # will be created while other elements will be quadrangles.
5636 # Vertex can be either a GEOM_Object or a vertex ID within the
5638 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5639 # the same parameters, else (default) - creates a new one
5640 # @ingroup l3_hypos_quad
5641 def TriangleVertex(self, vertex, UseExisting=0):
5642 return self.QuadrangleParameters(QUAD_STANDARD,vertex,UseExisting)
5645 # Public class: Mesh_Tetrahedron
5646 # ------------------------------
5648 ## Defines a tetrahedron 3D algorithm
5650 # @ingroup l3_algos_basic
5651 class Mesh_Tetrahedron(Mesh_Algorithm):
5656 ## Private constructor.
5657 def __init__(self, mesh, algoType, geom=0):
5658 Mesh_Algorithm.__init__(self)
5660 if algoType == NETGEN:
5662 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
5665 elif algoType == FULL_NETGEN:
5667 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5670 elif algoType == GHS3D:
5672 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
5675 elif algoType == GHS3DPRL:
5676 CheckPlugin(GHS3DPRL)
5677 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
5680 self.algoType = algoType
5682 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
5683 # @param vol for the maximum volume of each tetrahedron
5684 # @param UseExisting if ==true - searches for the existing hypothesis created with
5685 # the same parameters, else (default) - creates a new one
5686 # @ingroup l3_hypos_maxvol
5687 def MaxElementVolume(self, vol, UseExisting=0):
5688 if self.algoType == NETGEN:
5689 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
5690 CompareMethod=self.CompareMaxElementVolume)
5691 hyp.SetMaxElementVolume(vol)
5693 elif self.algoType == FULL_NETGEN:
5694 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
5697 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
5698 def CompareMaxElementVolume(self, hyp, args):
5699 return IsEqual(hyp.GetMaxElementVolume(), args[0])
5701 ## Defines hypothesis having several parameters
5703 # @ingroup l3_hypos_netgen
5704 def Parameters(self, which=SOLE):
5707 if self.algoType == FULL_NETGEN:
5709 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
5710 "libNETGENEngine.so", UseExisting=0)
5712 self.params = self.Hypothesis("NETGEN_Parameters", [],
5713 "libNETGENEngine.so", UseExisting=0)
5715 elif self.algoType == NETGEN:
5716 self.params = self.Hypothesis("NETGEN_Parameters_3D", [],
5717 "libNETGENEngine.so", UseExisting=0)
5719 elif self.algoType == GHS3D:
5720 self.params = self.Hypothesis("GHS3D_Parameters", [],
5721 "libGHS3DEngine.so", UseExisting=0)
5723 elif self.algoType == GHS3DPRL:
5724 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
5725 "libGHS3DPRLEngine.so", UseExisting=0)
5727 print "Warning: %s supports no multi-parameter hypothesis"%self.algo.GetName()
5732 # Parameter of FULL_NETGEN and NETGEN
5733 # @ingroup l3_hypos_netgen
5734 def SetMaxSize(self, theSize):
5735 self.Parameters().SetMaxSize(theSize)
5737 ## Sets SecondOrder flag
5738 # Parameter of FULL_NETGEN
5739 # @ingroup l3_hypos_netgen
5740 def SetSecondOrder(self, theVal):
5741 self.Parameters().SetSecondOrder(theVal)
5743 ## Sets Optimize flag
5744 # Parameter of FULL_NETGEN and NETGEN
5745 # @ingroup l3_hypos_netgen
5746 def SetOptimize(self, theVal):
5747 self.Parameters().SetOptimize(theVal)
5750 # @param theFineness is:
5751 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5752 # Parameter of FULL_NETGEN
5753 # @ingroup l3_hypos_netgen
5754 def SetFineness(self, theFineness):
5755 self.Parameters().SetFineness(theFineness)
5758 # Parameter of FULL_NETGEN
5759 # @ingroup l3_hypos_netgen
5760 def SetGrowthRate(self, theRate):
5761 self.Parameters().SetGrowthRate(theRate)
5763 ## Sets NbSegPerEdge
5764 # Parameter of FULL_NETGEN
5765 # @ingroup l3_hypos_netgen
5766 def SetNbSegPerEdge(self, theVal):
5767 self.Parameters().SetNbSegPerEdge(theVal)
5769 ## Sets NbSegPerRadius
5770 # Parameter of FULL_NETGEN
5771 # @ingroup l3_hypos_netgen
5772 def SetNbSegPerRadius(self, theVal):
5773 self.Parameters().SetNbSegPerRadius(theVal)
5775 ## Sets number of segments overriding value set by SetLocalLength()
5776 # Only for algoType == NETGEN_FULL
5777 # @ingroup l3_hypos_netgen
5778 def SetNumberOfSegments(self, theVal):
5779 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5781 ## Sets number of segments overriding value set by SetNumberOfSegments()
5782 # Only for algoType == NETGEN_FULL
5783 # @ingroup l3_hypos_netgen
5784 def SetLocalLength(self, theVal):
5785 self.Parameters(SIMPLE).SetLocalLength(theVal)
5787 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
5788 # Overrides value set by LengthFromEdges()
5789 # Only for algoType == NETGEN_FULL
5790 # @ingroup l3_hypos_netgen
5791 def MaxElementArea(self, area):
5792 self.Parameters(SIMPLE).SetMaxElementArea(area)
5794 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
5795 # Overrides value set by MaxElementArea()
5796 # Only for algoType == NETGEN_FULL
5797 # @ingroup l3_hypos_netgen
5798 def LengthFromEdges(self):
5799 self.Parameters(SIMPLE).LengthFromEdges()
5801 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
5802 # Overrides value set by MaxElementVolume()
5803 # Only for algoType == NETGEN_FULL
5804 # @ingroup l3_hypos_netgen
5805 def LengthFromFaces(self):
5806 self.Parameters(SIMPLE).LengthFromFaces()
5808 ## To mesh "holes" in a solid or not. Default is to mesh.
5809 # @ingroup l3_hypos_ghs3dh
5810 def SetToMeshHoles(self, toMesh):
5811 # Parameter of GHS3D
5812 if self.Parameters():
5813 self.params.SetToMeshHoles(toMesh)
5815 ## Set Optimization level:
5816 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
5817 # Strong_Optimization.
5818 # Default is Standard_Optimization
5819 # @ingroup l3_hypos_ghs3dh
5820 def SetOptimizationLevel(self, level):
5821 # Parameter of GHS3D
5822 if self.Parameters():
5823 self.params.SetOptimizationLevel(level)
5825 ## Maximal size of memory to be used by the algorithm (in Megabytes).
5826 # @ingroup l3_hypos_ghs3dh
5827 def SetMaximumMemory(self, MB):
5828 # Advanced parameter of GHS3D
5829 if self.Parameters():
5830 self.params.SetMaximumMemory(MB)
5832 ## Initial size of memory to be used by the algorithm (in Megabytes) in
5833 # automatic memory adjustment mode.
5834 # @ingroup l3_hypos_ghs3dh
5835 def SetInitialMemory(self, MB):
5836 # Advanced parameter of GHS3D
5837 if self.Parameters():
5838 self.params.SetInitialMemory(MB)
5840 ## Path to working directory.
5841 # @ingroup l3_hypos_ghs3dh
5842 def SetWorkingDirectory(self, path):
5843 # Advanced parameter of GHS3D
5844 if self.Parameters():
5845 self.params.SetWorkingDirectory(path)
5847 ## To keep working files or remove them. Log file remains in case of errors anyway.
5848 # @ingroup l3_hypos_ghs3dh
5849 def SetKeepFiles(self, toKeep):
5850 # Advanced parameter of GHS3D and GHS3DPRL
5851 if self.Parameters():
5852 self.params.SetKeepFiles(toKeep)
5854 ## To set verbose level [0-10]. <ul>
5855 #<li> 0 - no standard output,
5856 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
5857 # indicates when the final mesh is being saved. In addition the software
5858 # gives indication regarding the CPU time.
5859 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
5860 # histogram of the skin mesh, quality statistics histogram together with
5861 # the characteristics of the final mesh.</ul>
5862 # @ingroup l3_hypos_ghs3dh
5863 def SetVerboseLevel(self, level):
5864 # Advanced parameter of GHS3D
5865 if self.Parameters():
5866 self.params.SetVerboseLevel(level)
5868 ## To create new nodes.
5869 # @ingroup l3_hypos_ghs3dh
5870 def SetToCreateNewNodes(self, toCreate):
5871 # Advanced parameter of GHS3D
5872 if self.Parameters():
5873 self.params.SetToCreateNewNodes(toCreate)
5875 ## To use boundary recovery version which tries to create mesh on a very poor
5876 # quality surface mesh.
5877 # @ingroup l3_hypos_ghs3dh
5878 def SetToUseBoundaryRecoveryVersion(self, toUse):
5879 # Advanced parameter of GHS3D
5880 if self.Parameters():
5881 self.params.SetToUseBoundaryRecoveryVersion(toUse)
5883 ## Applies finite-element correction by replacing overconstrained elements where
5884 # it is possible. The process is cutting first the overconstrained edges and
5885 # second the overconstrained facets. This insure that no edges have two boundary
5886 # vertices and that no facets have three boundary vertices.
5887 # @ingroup l3_hypos_ghs3dh
5888 def SetFEMCorrection(self, toUseFem):
5889 # Advanced parameter of GHS3D
5890 if self.Parameters():
5891 self.params.SetFEMCorrection(toUseFem)
5893 ## To removes initial central point.
5894 # @ingroup l3_hypos_ghs3dh
5895 def SetToRemoveCentralPoint(self, toRemove):
5896 # Advanced parameter of GHS3D
5897 if self.Parameters():
5898 self.params.SetToRemoveCentralPoint(toRemove)
5900 ## To set an enforced vertex.
5901 # @param x : x coordinate
5902 # @param y : y coordinate
5903 # @param z : z coordinate
5904 # @param size : size of 1D element around enforced vertex
5905 # @param vertexName : name of the enforced vertex
5906 # @param groupName : name of the group
5907 # @ingroup l3_hypos_ghs3dh
5908 def SetEnforcedVertex(self, x, y, z, size, vertexName = "", groupName = ""):
5909 # Advanced parameter of GHS3D
5910 if self.Parameters():
5911 if vertexName == "":
5913 return self.params.SetEnforcedVertex(x, y, z, size)
5915 return self.params.SetEnforcedVertexWithGroup(x, y, z, size, groupName)
5918 return self.params.SetEnforcedVertexNamed(x, y, z, size, vertexName)
5920 return self.params.SetEnforcedVertexNamedWithGroup(x, y, z, size, vertexName, groupName)
5922 ## To set an enforced vertex given a GEOM vertex, group or compound.
5923 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
5924 # @param size : size of 1D element around enforced vertex
5925 # @param groupName : name of the group
5926 # @ingroup l3_hypos_ghs3dh
5927 def SetEnforcedVertexGeom(self, theVertex, size, groupName = ""):
5928 AssureGeomPublished( self.mesh, theVertex )
5929 # Advanced parameter of GHS3D
5930 if self.Parameters():
5932 return self.params.SetEnforcedVertexGeom(theVertex, size)
5934 return self.params.SetEnforcedVertexGeomWithGroup(theVertex, size, groupName)
5936 ## To remove an enforced vertex.
5937 # @param x : x coordinate
5938 # @param y : y coordinate
5939 # @param z : z coordinate
5940 # @ingroup l3_hypos_ghs3dh
5941 def RemoveEnforcedVertex(self, x, y, z):
5942 # Advanced parameter of GHS3D
5943 if self.Parameters():
5944 return self.params.RemoveEnforcedVertex(x, y, z)
5946 ## To remove an enforced vertex given a GEOM vertex, group or compound.
5947 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
5948 # @ingroup l3_hypos_ghs3dh
5949 def RemoveEnforcedVertexGeom(self, theVertex):
5950 AssureGeomPublished( self.mesh, theVertex )
5951 # Advanced parameter of GHS3D
5952 if self.Parameters():
5953 return self.params.RemoveEnforcedVertexGeom(theVertex)
5955 ## To set an enforced mesh with given size and add the enforced elements in the group "groupName".
5956 # @param theSource : source mesh which provides constraint elements/nodes
5957 # @param elementType : SMESH.ElementType (NODE, EDGE or FACE)
5958 # @param size : size of elements around enforced elements. Unused if -1.
5959 # @param groupName : group in which enforced elements will be added. Unused if "".
5960 # @ingroup l3_hypos_ghs3dh
5961 def SetEnforcedMesh(self, theSource, elementType, size = -1, groupName = ""):
5962 # Advanced parameter of GHS3D
5963 if self.Parameters():
5966 return self.params.SetEnforcedMesh(theSource, elementType)
5968 return self.params.SetEnforcedMeshWithGroup(theSource, elementType, groupName)
5971 return self.params.SetEnforcedMeshSize(theSource, elementType, size)
5973 return self.params.SetEnforcedMeshSizeWithGroup(theSource, elementType, size, groupName)
5975 ## Sets command line option as text.
5976 # @ingroup l3_hypos_ghs3dh
5977 def SetTextOption(self, option):
5978 # Advanced parameter of GHS3D
5979 if self.Parameters():
5980 self.params.SetTextOption(option)
5982 ## Sets MED files name and path.
5983 def SetMEDName(self, value):
5984 if self.Parameters():
5985 self.params.SetMEDName(value)
5987 ## Sets the number of partition of the initial mesh
5988 def SetNbPart(self, value):
5989 if self.Parameters():
5990 self.params.SetNbPart(value)
5992 ## When big mesh, start tepal in background
5993 def SetBackground(self, value):
5994 if self.Parameters():
5995 self.params.SetBackground(value)
5997 # Public class: Mesh_Hexahedron
5998 # ------------------------------
6000 ## Defines a hexahedron 3D algorithm
6002 # @ingroup l3_algos_basic
6003 class Mesh_Hexahedron(Mesh_Algorithm):
6008 ## Private constructor.
6009 def __init__(self, mesh, algoType=Hexa, geom=0):
6010 Mesh_Algorithm.__init__(self)
6012 self.algoType = algoType
6014 if algoType == Hexa:
6015 self.Create(mesh, geom, "Hexa_3D")
6018 elif algoType == Hexotic:
6019 CheckPlugin(Hexotic)
6020 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
6023 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
6024 # @ingroup l3_hypos_hexotic
6025 def MinMaxQuad(self, min=3, max=8, quad=True):
6026 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
6028 self.params.SetHexesMinLevel(min)
6029 self.params.SetHexesMaxLevel(max)
6030 self.params.SetHexoticQuadrangles(quad)
6033 # Deprecated, only for compatibility!
6034 # Public class: Mesh_Netgen
6035 # ------------------------------
6037 ## Defines a NETGEN-based 2D or 3D algorithm
6038 # that needs no discrete boundary (i.e. independent)
6040 # This class is deprecated, only for compatibility!
6043 # @ingroup l3_algos_basic
6044 class Mesh_Netgen(Mesh_Algorithm):
6048 ## Private constructor.
6049 def __init__(self, mesh, is3D, geom=0):
6050 Mesh_Algorithm.__init__(self)
6056 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
6060 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
6063 ## Defines the hypothesis containing parameters of the algorithm
6064 def Parameters(self):
6066 hyp = self.Hypothesis("NETGEN_Parameters", [],
6067 "libNETGENEngine.so", UseExisting=0)
6069 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
6070 "libNETGENEngine.so", UseExisting=0)
6073 # Public class: Mesh_Projection1D
6074 # ------------------------------
6076 ## Defines a projection 1D algorithm
6077 # @ingroup l3_algos_proj
6079 class Mesh_Projection1D(Mesh_Algorithm):
6081 ## Private constructor.
6082 def __init__(self, mesh, geom=0):
6083 Mesh_Algorithm.__init__(self)
6084 self.Create(mesh, geom, "Projection_1D")
6086 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
6087 # a mesh pattern is taken, and, optionally, the association of vertices
6088 # between the source edge and a target edge (to which a hypothesis is assigned)
6089 # @param edge from which nodes distribution is taken
6090 # @param mesh from which nodes distribution is taken (optional)
6091 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
6092 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
6093 # to associate with \a srcV (optional)
6094 # @param UseExisting if ==true - searches for the existing hypothesis created with
6095 # the same parameters, else (default) - creates a new one
6096 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
6097 AssureGeomPublished( self.mesh, edge )
6098 AssureGeomPublished( self.mesh, srcV )
6099 AssureGeomPublished( self.mesh, tgtV )
6100 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
6102 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
6103 hyp.SetSourceEdge( edge )
6104 if not mesh is None and isinstance(mesh, Mesh):
6105 mesh = mesh.GetMesh()
6106 hyp.SetSourceMesh( mesh )
6107 hyp.SetVertexAssociation( srcV, tgtV )
6110 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
6111 #def CompareSourceEdge(self, hyp, args):
6112 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
6116 # Public class: Mesh_Projection2D
6117 # ------------------------------
6119 ## Defines a projection 2D algorithm
6120 # @ingroup l3_algos_proj
6122 class Mesh_Projection2D(Mesh_Algorithm):
6124 ## Private constructor.
6125 def __init__(self, mesh, geom=0, algoName="Projection_2D"):
6126 Mesh_Algorithm.__init__(self)
6127 self.Create(mesh, geom, algoName)
6129 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
6130 # a mesh pattern is taken, and, optionally, the association of vertices
6131 # between the source face and the target face (to which a hypothesis is assigned)
6132 # @param face from which the mesh pattern is taken
6133 # @param mesh from which the mesh pattern is taken (optional)
6134 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
6135 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
6136 # to associate with \a srcV1 (optional)
6137 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
6138 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
6139 # to associate with \a srcV2 (optional)
6140 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
6141 # the same parameters, else (default) - forces the creation a new one
6143 # Note: all association vertices must belong to one edge of a face
6144 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
6145 srcV2=None, tgtV2=None, UseExisting=0):
6146 for geom in [ face, srcV1, tgtV1, srcV2, tgtV2 ]:
6147 AssureGeomPublished( self.mesh, geom )
6148 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
6150 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
6151 hyp.SetSourceFace( face )
6152 if isinstance(mesh, Mesh):
6153 mesh = mesh.GetMesh()
6154 hyp.SetSourceMesh( mesh )
6155 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
6158 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
6159 #def CompareSourceFace(self, hyp, args):
6160 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
6163 # Public class: Mesh_Projection3D
6164 # ------------------------------
6166 ## Defines a projection 3D algorithm
6167 # @ingroup l3_algos_proj
6169 class Mesh_Projection3D(Mesh_Algorithm):
6171 ## Private constructor.
6172 def __init__(self, mesh, geom=0):
6173 Mesh_Algorithm.__init__(self)
6174 self.Create(mesh, geom, "Projection_3D")
6176 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
6177 # the mesh pattern is taken, and, optionally, the association of vertices
6178 # between the source and the target solid (to which a hipothesis is assigned)
6179 # @param solid from where the mesh pattern is taken
6180 # @param mesh from where the mesh pattern is taken (optional)
6181 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
6182 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
6183 # to associate with \a srcV1 (optional)
6184 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
6185 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
6186 # to associate with \a srcV2 (optional)
6187 # @param UseExisting - if ==true - searches for the existing hypothesis created with
6188 # the same parameters, else (default) - creates a new one
6190 # Note: association vertices must belong to one edge of a solid
6191 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
6192 srcV2=0, tgtV2=0, UseExisting=0):
6193 for geom in [ solid, srcV1, tgtV1, srcV2, tgtV2 ]:
6194 AssureGeomPublished( self.mesh, geom )
6195 hyp = self.Hypothesis("ProjectionSource3D",
6196 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
6198 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
6199 hyp.SetSource3DShape( solid )
6200 if not mesh is None and isinstance(mesh, Mesh):
6201 mesh = mesh.GetMesh()
6202 hyp.SetSourceMesh( mesh )
6203 if srcV1 and srcV2 and tgtV1 and tgtV2:
6204 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
6205 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
6208 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
6209 #def CompareSourceShape3D(self, hyp, args):
6210 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
6214 # Public class: Mesh_Prism
6215 # ------------------------
6217 ## Defines a 3D extrusion algorithm
6218 # @ingroup l3_algos_3dextr
6220 class Mesh_Prism3D(Mesh_Algorithm):
6222 ## Private constructor.
6223 def __init__(self, mesh, geom=0):
6224 Mesh_Algorithm.__init__(self)
6225 self.Create(mesh, geom, "Prism_3D")
6227 # Public class: Mesh_RadialPrism
6228 # -------------------------------
6230 ## Defines a Radial Prism 3D algorithm
6231 # @ingroup l3_algos_radialp
6233 class Mesh_RadialPrism3D(Mesh_Algorithm):
6235 ## Private constructor.
6236 def __init__(self, mesh, geom=0):
6237 Mesh_Algorithm.__init__(self)
6238 self.Create(mesh, geom, "RadialPrism_3D")
6240 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
6241 self.nbLayers = None
6243 ## Return 3D hypothesis holding the 1D one
6244 def Get3DHypothesis(self):
6245 return self.distribHyp
6247 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
6248 # hypothesis. Returns the created hypothesis
6249 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
6250 #print "OwnHypothesis",hypType
6251 if not self.nbLayers is None:
6252 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
6253 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
6254 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
6255 self.mesh.smeshpyD.SetCurrentStudy( None )
6256 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
6257 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
6258 self.distribHyp.SetLayerDistribution( hyp )
6261 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
6262 # prisms to build between the inner and outer shells
6263 # @param n number of layers
6264 # @param UseExisting if ==true - searches for the existing hypothesis created with
6265 # the same parameters, else (default) - creates a new one
6266 def NumberOfLayers(self, n, UseExisting=0):
6267 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
6268 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
6269 CompareMethod=self.CompareNumberOfLayers)
6270 self.nbLayers.SetNumberOfLayers( n )
6271 return self.nbLayers
6273 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
6274 def CompareNumberOfLayers(self, hyp, args):
6275 return IsEqual(hyp.GetNumberOfLayers(), args[0])
6277 ## Defines "LocalLength" hypothesis, specifying the segment length
6278 # to build between the inner and the outer shells
6279 # @param l the length of segments
6280 # @param p the precision of rounding
6281 def LocalLength(self, l, p=1e-07):
6282 hyp = self.OwnHypothesis("LocalLength", [l,p])
6287 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
6288 # prisms to build between the inner and the outer shells.
6289 # @param n the number of layers
6290 # @param s the scale factor (optional)
6291 def NumberOfSegments(self, n, s=[]):
6293 hyp = self.OwnHypothesis("NumberOfSegments", [n])
6295 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
6296 hyp.SetDistrType( 1 )
6297 hyp.SetScaleFactor(s)
6298 hyp.SetNumberOfSegments(n)
6301 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
6302 # to build between the inner and the outer shells with a length that changes in arithmetic progression
6303 # @param start the length of the first segment
6304 # @param end the length of the last segment
6305 def Arithmetic1D(self, start, end ):
6306 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
6307 hyp.SetLength(start, 1)
6308 hyp.SetLength(end , 0)
6311 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
6312 # to build between the inner and the outer shells as geometric length increasing
6313 # @param start for the length of the first segment
6314 # @param end for the length of the last segment
6315 def StartEndLength(self, start, end):
6316 hyp = self.OwnHypothesis("StartEndLength", [start, end])
6317 hyp.SetLength(start, 1)
6318 hyp.SetLength(end , 0)
6321 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
6322 # to build between the inner and outer shells
6323 # @param fineness defines the quality of the mesh within the range [0-1]
6324 def AutomaticLength(self, fineness=0):
6325 hyp = self.OwnHypothesis("AutomaticLength")
6326 hyp.SetFineness( fineness )
6329 # Public class: Mesh_RadialQuadrangle1D2D
6330 # -------------------------------
6332 ## Defines a Radial Quadrangle 1D2D algorithm
6333 # @ingroup l2_algos_radialq
6335 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
6337 ## Private constructor.
6338 def __init__(self, mesh, geom=0):
6339 Mesh_Algorithm.__init__(self)
6340 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
6342 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
6343 self.nbLayers = None
6345 ## Return 2D hypothesis holding the 1D one
6346 def Get2DHypothesis(self):
6347 return self.distribHyp
6349 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
6350 # hypothesis. Returns the created hypothesis
6351 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
6352 #print "OwnHypothesis",hypType
6354 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
6355 if self.distribHyp is None:
6356 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
6358 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
6359 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
6360 self.mesh.smeshpyD.SetCurrentStudy( None )
6361 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
6362 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
6363 self.distribHyp.SetLayerDistribution( hyp )
6366 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
6367 # @param n number of layers
6368 # @param UseExisting if ==true - searches for the existing hypothesis created with
6369 # the same parameters, else (default) - creates a new one
6370 def NumberOfLayers(self, n, UseExisting=0):
6372 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
6373 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
6374 CompareMethod=self.CompareNumberOfLayers)
6375 self.nbLayers.SetNumberOfLayers( n )
6376 return self.nbLayers
6378 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
6379 def CompareNumberOfLayers(self, hyp, args):
6380 return IsEqual(hyp.GetNumberOfLayers(), args[0])
6382 ## Defines "LocalLength" hypothesis, specifying the segment length
6383 # @param l the length of segments
6384 # @param p the precision of rounding
6385 def LocalLength(self, l, p=1e-07):
6386 hyp = self.OwnHypothesis("LocalLength", [l,p])
6391 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
6392 # @param n the number of layers
6393 # @param s the scale factor (optional)
6394 def NumberOfSegments(self, n, s=[]):
6396 hyp = self.OwnHypothesis("NumberOfSegments", [n])
6398 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
6399 hyp.SetDistrType( 1 )
6400 hyp.SetScaleFactor(s)
6401 hyp.SetNumberOfSegments(n)
6404 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
6405 # with a length that changes in arithmetic progression
6406 # @param start the length of the first segment
6407 # @param end the length of the last segment
6408 def Arithmetic1D(self, start, end ):
6409 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
6410 hyp.SetLength(start, 1)
6411 hyp.SetLength(end , 0)
6414 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
6415 # as geometric length increasing
6416 # @param start for the length of the first segment
6417 # @param end for the length of the last segment
6418 def StartEndLength(self, start, end):
6419 hyp = self.OwnHypothesis("StartEndLength", [start, end])
6420 hyp.SetLength(start, 1)
6421 hyp.SetLength(end , 0)
6424 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
6425 # @param fineness defines the quality of the mesh within the range [0-1]
6426 def AutomaticLength(self, fineness=0):
6427 hyp = self.OwnHypothesis("AutomaticLength")
6428 hyp.SetFineness( fineness )
6432 # Public class: Mesh_UseExistingElements
6433 # --------------------------------------
6434 ## Defines a Radial Quadrangle 1D2D algorithm
6435 # @ingroup l3_algos_basic
6437 class Mesh_UseExistingElements(Mesh_Algorithm):
6439 def __init__(self, dim, mesh, geom=0):
6441 self.Create(mesh, geom, "Import_1D")
6443 self.Create(mesh, geom, "Import_1D2D")
6446 ## Defines "Source edges" hypothesis, specifying groups of edges to import
6447 # @param groups list of groups of edges
6448 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
6449 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
6450 # @param UseExisting if ==true - searches for the existing hypothesis created with
6451 # the same parameters, else (default) - creates a new one
6452 def SourceEdges(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
6453 if self.algo.GetName() != "Import_1D":
6454 raise ValueError, "algoritm dimension mismatch"
6455 for group in groups:
6456 AssureGeomPublished( self.mesh, group )
6457 hyp = self.Hypothesis("ImportSource1D", [groups, toCopyMesh, toCopyGroups],
6458 UseExisting=UseExisting, CompareMethod=self._compareHyp)
6459 hyp.SetSourceEdges(groups)
6460 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
6463 ## Defines "Source faces" hypothesis, specifying groups of faces to import
6464 # @param groups list of groups of faces
6465 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
6466 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
6467 # @param UseExisting if ==true - searches for the existing hypothesis created with
6468 # the same parameters, else (default) - creates a new one
6469 def SourceFaces(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
6470 if self.algo.GetName() == "Import_1D":
6471 raise ValueError, "algoritm dimension mismatch"
6472 for group in groups:
6473 AssureGeomPublished( self.mesh, group )
6474 hyp = self.Hypothesis("ImportSource2D", [groups, toCopyMesh, toCopyGroups],
6475 UseExisting=UseExisting, CompareMethod=self._compareHyp)
6476 hyp.SetSourceFaces(groups)
6477 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
6480 def _compareHyp(self,hyp,args):
6481 if hasattr( hyp, "GetSourceEdges"):
6482 entries = hyp.GetSourceEdges()
6484 entries = hyp.GetSourceFaces()
6486 toCopyMesh,toCopyGroups = hyp.GetCopySourceMesh()
6487 if len(entries)==len(groups) and toCopyMesh==args[1] and toCopyGroups==args[2]:
6489 study = self.mesh.smeshpyD.GetCurrentStudy()
6492 ior = salome.orb.object_to_string(g)
6493 sobj = study.FindObjectIOR(ior)
6494 if sobj: entries2.append( sobj.GetID() )
6499 return entries == entries2
6503 # Private class: Mesh_UseExisting
6504 # -------------------------------
6505 class Mesh_UseExisting(Mesh_Algorithm):
6507 def __init__(self, dim, mesh, geom=0):
6509 self.Create(mesh, geom, "UseExisting_1D")
6511 self.Create(mesh, geom, "UseExisting_2D")
6514 import salome_notebook
6515 notebook = salome_notebook.notebook
6517 ##Return values of the notebook variables
6518 def ParseParameters(last, nbParams,nbParam, value):
6522 listSize = len(last)
6523 for n in range(0,nbParams):
6525 if counter < listSize:
6526 strResult = strResult + last[counter]
6528 strResult = strResult + ""
6530 if isinstance(value, str):
6531 if notebook.isVariable(value):
6532 result = notebook.get(value)
6533 strResult=strResult+value
6535 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
6537 strResult=strResult+str(value)
6539 if nbParams - 1 != counter:
6540 strResult=strResult+var_separator #":"
6542 return result, strResult
6544 #Wrapper class for StdMeshers_LocalLength hypothesis
6545 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
6547 ## Set Length parameter value
6548 # @param length numerical value or name of variable from notebook
6549 def SetLength(self, length):
6550 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
6551 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6552 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
6554 ## Set Precision parameter value
6555 # @param precision numerical value or name of variable from notebook
6556 def SetPrecision(self, precision):
6557 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
6558 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6559 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
6561 #Registering the new proxy for LocalLength
6562 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
6565 #Wrapper class for StdMeshers_LayerDistribution hypothesis
6566 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
6568 def SetLayerDistribution(self, hypo):
6569 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
6570 hypo.ClearParameters();
6571 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
6573 #Registering the new proxy for LayerDistribution
6574 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
6576 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
6577 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
6579 ## Set Length parameter value
6580 # @param length numerical value or name of variable from notebook
6581 def SetLength(self, length):
6582 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
6583 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
6584 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
6586 #Registering the new proxy for SegmentLengthAroundVertex
6587 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
6590 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
6591 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
6593 ## Set Length parameter value
6594 # @param length numerical value or name of variable from notebook
6595 # @param isStart true is length is Start Length, otherwise false
6596 def SetLength(self, length, isStart):
6600 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
6601 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
6602 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
6604 #Registering the new proxy for Arithmetic1D
6605 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
6607 #Wrapper class for StdMeshers_Deflection1D hypothesis
6608 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
6610 ## Set Deflection parameter value
6611 # @param deflection numerical value or name of variable from notebook
6612 def SetDeflection(self, deflection):
6613 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
6614 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
6615 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
6617 #Registering the new proxy for Deflection1D
6618 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
6620 #Wrapper class for StdMeshers_StartEndLength hypothesis
6621 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
6623 ## Set Length parameter value
6624 # @param length numerical value or name of variable from notebook
6625 # @param isStart true is length is Start Length, otherwise false
6626 def SetLength(self, length, isStart):
6630 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
6631 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
6632 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
6634 #Registering the new proxy for StartEndLength
6635 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
6637 #Wrapper class for StdMeshers_MaxElementArea hypothesis
6638 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
6640 ## Set Max Element Area parameter value
6641 # @param area numerical value or name of variable from notebook
6642 def SetMaxElementArea(self, area):
6643 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
6644 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
6645 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
6647 #Registering the new proxy for MaxElementArea
6648 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
6651 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
6652 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
6654 ## Set Max Element Volume parameter value
6655 # @param volume numerical value or name of variable from notebook
6656 def SetMaxElementVolume(self, volume):
6657 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
6658 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
6659 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
6661 #Registering the new proxy for MaxElementVolume
6662 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
6665 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
6666 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
6668 ## Set Number Of Layers parameter value
6669 # @param nbLayers numerical value or name of variable from notebook
6670 def SetNumberOfLayers(self, nbLayers):
6671 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
6672 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
6673 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
6675 #Registering the new proxy for NumberOfLayers
6676 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
6678 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
6679 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
6681 ## Set Number Of Segments parameter value
6682 # @param nbSeg numerical value or name of variable from notebook
6683 def SetNumberOfSegments(self, nbSeg):
6684 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
6685 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
6686 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6687 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
6689 ## Set Scale Factor parameter value
6690 # @param factor numerical value or name of variable from notebook
6691 def SetScaleFactor(self, factor):
6692 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
6693 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6694 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
6696 #Registering the new proxy for NumberOfSegments
6697 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
6699 if not noNETGENPlugin:
6700 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
6701 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
6703 ## Set Max Size parameter value
6704 # @param maxsize numerical value or name of variable from notebook
6705 def SetMaxSize(self, maxsize):
6706 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6707 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
6708 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6709 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
6711 ## Set Growth Rate parameter value
6712 # @param value numerical value or name of variable from notebook
6713 def SetGrowthRate(self, value):
6714 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6715 value, parameters = ParseParameters(lastParameters,4,2,value)
6716 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6717 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
6719 ## Set Number of Segments per Edge parameter value
6720 # @param value numerical value or name of variable from notebook
6721 def SetNbSegPerEdge(self, value):
6722 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6723 value, parameters = ParseParameters(lastParameters,4,3,value)
6724 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6725 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
6727 ## Set Number of Segments per Radius parameter value
6728 # @param value numerical value or name of variable from notebook
6729 def SetNbSegPerRadius(self, value):
6730 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6731 value, parameters = ParseParameters(lastParameters,4,4,value)
6732 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6733 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
6735 #Registering the new proxy for NETGENPlugin_Hypothesis
6736 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
6739 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
6740 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
6743 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
6744 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
6746 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
6747 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
6749 ## Set Number of Segments parameter value
6750 # @param nbSeg numerical value or name of variable from notebook
6751 def SetNumberOfSegments(self, nbSeg):
6752 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6753 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
6754 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6755 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
6757 ## Set Local Length parameter value
6758 # @param length numerical value or name of variable from notebook
6759 def SetLocalLength(self, length):
6760 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6761 length, parameters = ParseParameters(lastParameters,2,1,length)
6762 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6763 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
6765 ## Set Max Element Area parameter value
6766 # @param area numerical value or name of variable from notebook
6767 def SetMaxElementArea(self, area):
6768 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6769 area, parameters = ParseParameters(lastParameters,2,2,area)
6770 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6771 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
6773 def LengthFromEdges(self):
6774 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6776 value, parameters = ParseParameters(lastParameters,2,2,value)
6777 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6778 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
6780 #Registering the new proxy for NETGEN_SimpleParameters_2D
6781 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
6784 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
6785 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
6786 ## Set Max Element Volume parameter value
6787 # @param volume numerical value or name of variable from notebook
6788 def SetMaxElementVolume(self, volume):
6789 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6790 volume, parameters = ParseParameters(lastParameters,3,3,volume)
6791 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6792 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
6794 def LengthFromFaces(self):
6795 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6797 value, parameters = ParseParameters(lastParameters,3,3,value)
6798 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6799 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
6801 #Registering the new proxy for NETGEN_SimpleParameters_3D
6802 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
6804 pass # if not noNETGENPlugin:
6806 class Pattern(SMESH._objref_SMESH_Pattern):
6808 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
6810 if isinstance(theNodeIndexOnKeyPoint1,str):
6812 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
6814 theNodeIndexOnKeyPoint1 -= 1
6815 theMesh.SetParameters(Parameters)
6816 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
6818 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
6821 if isinstance(theNode000Index,str):
6823 if isinstance(theNode001Index,str):
6825 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
6827 theNode000Index -= 1
6829 theNode001Index -= 1
6830 theMesh.SetParameters(Parameters)
6831 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
6833 #Registering the new proxy for Pattern
6834 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)