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 = 0,1,2
193 # Element size flag of BLSURF
194 DefaultSize, DefaultGeom, Custom = 0,0,1
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 # end of l1_auxiliary
515 # All methods of this class are accessible directly from the smesh.py package.
516 class smeshDC(SMESH._objref_SMESH_Gen):
518 ## Dump component to the Python script
519 # This method overrides IDL function to allow default values for the parameters.
520 def DumpPython(self, theStudy, theIsPublished=True, theIsMultiFile=True):
521 return SMESH._objref_SMESH_Gen.DumpPython(self, theStudy, theIsPublished, theIsMultiFile)
523 ## Sets the current study and Geometry component
524 # @ingroup l1_auxiliary
525 def init_smesh(self,theStudy,geompyD):
526 self.SetCurrentStudy(theStudy,geompyD)
528 ## Creates an empty Mesh. This mesh can have an underlying geometry.
529 # @param obj the Geometrical object on which the mesh is built. If not defined,
530 # the mesh will have no underlying geometry.
531 # @param name the name for the new mesh.
532 # @return an instance of Mesh class.
533 # @ingroup l2_construct
534 def Mesh(self, obj=0, name=0):
535 if isinstance(obj,str):
537 return Mesh(self,self.geompyD,obj,name)
539 ## Returns a long value from enumeration
540 # Should be used for SMESH.FunctorType enumeration
541 # @ingroup l1_controls
542 def EnumToLong(self,theItem):
545 ## Returns a string representation of the color.
546 # To be used with filters.
547 # @param c color value (SALOMEDS.Color)
548 # @ingroup l1_controls
549 def ColorToString(self,c):
551 if isinstance(c, SALOMEDS.Color):
552 val = "%s;%s;%s" % (c.R, c.G, c.B)
553 elif isinstance(c, str):
556 raise ValueError, "Color value should be of string or SALOMEDS.Color type"
559 ## Gets PointStruct from vertex
560 # @param theVertex a GEOM object(vertex)
561 # @return SMESH.PointStruct
562 # @ingroup l1_auxiliary
563 def GetPointStruct(self,theVertex):
564 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
565 return PointStruct(x,y,z)
567 ## Gets DirStruct from vector
568 # @param theVector a GEOM object(vector)
569 # @return SMESH.DirStruct
570 # @ingroup l1_auxiliary
571 def GetDirStruct(self,theVector):
572 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
573 if(len(vertices) != 2):
574 print "Error: vector object is incorrect."
576 p1 = self.geompyD.PointCoordinates(vertices[0])
577 p2 = self.geompyD.PointCoordinates(vertices[1])
578 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
579 dirst = DirStruct(pnt)
582 ## Makes DirStruct from a triplet
583 # @param x,y,z vector components
584 # @return SMESH.DirStruct
585 # @ingroup l1_auxiliary
586 def MakeDirStruct(self,x,y,z):
587 pnt = PointStruct(x,y,z)
588 return DirStruct(pnt)
590 ## Get AxisStruct from object
591 # @param theObj a GEOM object (line or plane)
592 # @return SMESH.AxisStruct
593 # @ingroup l1_auxiliary
594 def GetAxisStruct(self,theObj):
595 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
597 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
598 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
599 vertex1 = self.geompyD.PointCoordinates(vertex1)
600 vertex2 = self.geompyD.PointCoordinates(vertex2)
601 vertex3 = self.geompyD.PointCoordinates(vertex3)
602 vertex4 = self.geompyD.PointCoordinates(vertex4)
603 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
604 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
605 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] ]
606 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
608 elif len(edges) == 1:
609 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
610 p1 = self.geompyD.PointCoordinates( vertex1 )
611 p2 = self.geompyD.PointCoordinates( vertex2 )
612 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
616 # From SMESH_Gen interface:
617 # ------------------------
619 ## Sets the given name to the object
620 # @param obj the object to rename
621 # @param name a new object name
622 # @ingroup l1_auxiliary
623 def SetName(self, obj, name):
624 if isinstance( obj, Mesh ):
626 elif isinstance( obj, Mesh_Algorithm ):
627 obj = obj.GetAlgorithm()
628 ior = salome.orb.object_to_string(obj)
629 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
631 ## Sets the current mode
632 # @ingroup l1_auxiliary
633 def SetEmbeddedMode( self,theMode ):
634 #self.SetEmbeddedMode(theMode)
635 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
637 ## Gets the current mode
638 # @ingroup l1_auxiliary
639 def IsEmbeddedMode(self):
640 #return self.IsEmbeddedMode()
641 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
643 ## Sets the current study
644 # @ingroup l1_auxiliary
645 def SetCurrentStudy( self, theStudy, geompyD = None ):
646 #self.SetCurrentStudy(theStudy)
649 geompyD = geompy.geom
652 self.SetGeomEngine(geompyD)
653 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
655 ## Gets the current study
656 # @ingroup l1_auxiliary
657 def GetCurrentStudy(self):
658 #return self.GetCurrentStudy()
659 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
661 ## Creates a Mesh object importing data from the given UNV file
662 # @return an instance of Mesh class
664 def CreateMeshesFromUNV( self,theFileName ):
665 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
666 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
669 ## Creates a Mesh object(s) importing data from the given MED file
670 # @return a list of Mesh class instances
672 def CreateMeshesFromMED( self,theFileName ):
673 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
675 for iMesh in range(len(aSmeshMeshes)) :
676 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
677 aMeshes.append(aMesh)
678 return aMeshes, aStatus
680 ## Creates a Mesh object importing data from the given STL file
681 # @return an instance of Mesh class
683 def CreateMeshesFromSTL( self, theFileName ):
684 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
685 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
688 ## Concatenate the given meshes into one mesh.
689 # @return an instance of Mesh class
690 # @param meshes the meshes to combine into one mesh
691 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
692 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
693 # @param mergeTolerance tolerance for merging nodes
694 # @param allGroups forces creation of groups of all elements
695 def Concatenate( self, meshes, uniteIdenticalGroups,
696 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
697 mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
698 for i,m in enumerate(meshes):
699 if isinstance(m, Mesh):
700 meshes[i] = m.GetMesh()
702 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
703 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
705 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
706 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
707 aSmeshMesh.SetParameters(Parameters)
708 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
711 ## Create a mesh by copying a part of another mesh.
712 # @param meshPart a part of mesh to copy, either a Mesh, a sub-mesh or a group;
713 # to copy nodes or elements not contained in any mesh object,
714 # pass result of Mesh.GetIDSource( list_of_ids, type ) as meshPart
715 # @param meshName a name of the new mesh
716 # @param toCopyGroups to create in the new mesh groups the copied elements belongs to
717 # @param toKeepIDs to preserve IDs of the copied elements or not
718 # @return an instance of Mesh class
719 def CopyMesh( self, meshPart, meshName, toCopyGroups=False, toKeepIDs=False):
720 if (isinstance( meshPart, Mesh )):
721 meshPart = meshPart.GetMesh()
722 mesh = SMESH._objref_SMESH_Gen.CopyMesh( self,meshPart,meshName,toCopyGroups,toKeepIDs )
723 return Mesh(self, self.geompyD, mesh)
725 ## From SMESH_Gen interface
726 # @return the list of integer values
727 # @ingroup l1_auxiliary
728 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
729 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
731 ## From SMESH_Gen interface. Creates a pattern
732 # @return an instance of SMESH_Pattern
734 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
735 # @ingroup l2_modif_patterns
736 def GetPattern(self):
737 return SMESH._objref_SMESH_Gen.GetPattern(self)
739 ## Sets number of segments per diagonal of boundary box of geometry by which
740 # default segment length of appropriate 1D hypotheses is defined.
741 # Default value is 10
742 # @ingroup l1_auxiliary
743 def SetBoundaryBoxSegmentation(self, nbSegments):
744 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
746 # Filtering. Auxiliary functions:
747 # ------------------------------
749 ## Creates an empty criterion
750 # @return SMESH.Filter.Criterion
751 # @ingroup l1_controls
752 def GetEmptyCriterion(self):
753 Type = self.EnumToLong(FT_Undefined)
754 Compare = self.EnumToLong(FT_Undefined)
758 UnaryOp = self.EnumToLong(FT_Undefined)
759 BinaryOp = self.EnumToLong(FT_Undefined)
762 Precision = -1 ##@1e-07
763 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
764 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
766 ## Creates a criterion by the given parameters
767 # \n Criterion structures allow to define complex filters by combining them with logical operations (AND / OR) (see example below)
768 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
769 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
770 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
771 # @param Treshold the threshold value (range of ids as string, shape, numeric)
772 # @param UnaryOp FT_LogicalNOT or FT_Undefined
773 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
774 # FT_Undefined (must be for the last criterion of all criteria)
775 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
776 # FT_LyingOnGeom, FT_CoplanarFaces criteria
777 # @return SMESH.Filter.Criterion
779 # <a href="../tui_filters_page.html#combining_filters">Example of Criteria usage</a>
780 # @ingroup l1_controls
781 def GetCriterion(self,elementType,
783 Compare = FT_EqualTo,
785 UnaryOp=FT_Undefined,
786 BinaryOp=FT_Undefined,
788 aCriterion = self.GetEmptyCriterion()
789 aCriterion.TypeOfElement = elementType
790 aCriterion.Type = self.EnumToLong(CritType)
791 aCriterion.Tolerance = Tolerance
795 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
796 aCriterion.Compare = self.EnumToLong(Compare)
797 elif Compare == "=" or Compare == "==":
798 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
800 aCriterion.Compare = self.EnumToLong(FT_LessThan)
802 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
804 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
807 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
808 FT_BelongToCylinder, FT_LyingOnGeom]:
809 # Checks the treshold
810 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
811 aCriterion.ThresholdStr = GetName(aTreshold)
812 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
814 print "Error: The treshold should be a shape."
816 if isinstance(UnaryOp,float):
817 aCriterion.Tolerance = UnaryOp
818 UnaryOp = FT_Undefined
820 elif CritType == FT_RangeOfIds:
821 # Checks the treshold
822 if isinstance(aTreshold, str):
823 aCriterion.ThresholdStr = aTreshold
825 print "Error: The treshold should be a string."
827 elif CritType == FT_CoplanarFaces:
828 # Checks the treshold
829 if isinstance(aTreshold, int):
830 aCriterion.ThresholdID = "%s"%aTreshold
831 elif isinstance(aTreshold, str):
834 raise ValueError, "Invalid ID of mesh face: '%s'"%aTreshold
835 aCriterion.ThresholdID = aTreshold
838 "The treshold should be an ID of mesh face and not '%s'"%aTreshold
839 elif CritType == FT_ElemGeomType:
840 # Checks the treshold
842 aCriterion.Threshold = self.EnumToLong(aTreshold)
844 if isinstance(aTreshold, int):
845 aCriterion.Threshold = aTreshold
847 print "Error: The treshold should be an integer or SMESH.GeometryType."
851 elif CritType == FT_GroupColor:
852 # Checks the treshold
854 aCriterion.ThresholdStr = self.ColorToString(aTreshold)
856 print "Error: The threshold value should be of SALOMEDS.Color type"
859 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
860 FT_FreeFaces, FT_LinearOrQuadratic,
861 FT_BareBorderFace, FT_BareBorderVolume,
862 FT_OverConstrainedFace, FT_OverConstrainedVolume]:
863 # At this point the treshold is unnecessary
864 if aTreshold == FT_LogicalNOT:
865 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
866 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
867 aCriterion.BinaryOp = aTreshold
871 aTreshold = float(aTreshold)
872 aCriterion.Threshold = aTreshold
874 print "Error: The treshold should be a number."
877 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
878 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
880 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
881 aCriterion.BinaryOp = self.EnumToLong(Treshold)
883 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
884 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
886 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
887 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
891 ## Creates a filter with the given parameters
892 # @param elementType the type of elements in the group
893 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
894 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
895 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
896 # @param UnaryOp FT_LogicalNOT or FT_Undefined
897 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
898 # FT_LyingOnGeom, FT_CoplanarFaces criteria
899 # @return SMESH_Filter
901 # <a href="../tui_filters_page.html#tui_filters">Example of Filters usage</a>
902 # @ingroup l1_controls
903 def GetFilter(self,elementType,
904 CritType=FT_Undefined,
907 UnaryOp=FT_Undefined,
909 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined,Tolerance)
910 aFilterMgr = self.CreateFilterManager()
911 aFilter = aFilterMgr.CreateFilter()
913 aCriteria.append(aCriterion)
914 aFilter.SetCriteria(aCriteria)
915 aFilterMgr.UnRegister()
918 ## Creates a numerical functor by its type
919 # @param theCriterion FT_...; functor type
920 # @return SMESH_NumericalFunctor
921 # @ingroup l1_controls
922 def GetFunctor(self,theCriterion):
923 aFilterMgr = self.CreateFilterManager()
924 if theCriterion == FT_AspectRatio:
925 return aFilterMgr.CreateAspectRatio()
926 elif theCriterion == FT_AspectRatio3D:
927 return aFilterMgr.CreateAspectRatio3D()
928 elif theCriterion == FT_Warping:
929 return aFilterMgr.CreateWarping()
930 elif theCriterion == FT_MinimumAngle:
931 return aFilterMgr.CreateMinimumAngle()
932 elif theCriterion == FT_Taper:
933 return aFilterMgr.CreateTaper()
934 elif theCriterion == FT_Skew:
935 return aFilterMgr.CreateSkew()
936 elif theCriterion == FT_Area:
937 return aFilterMgr.CreateArea()
938 elif theCriterion == FT_Volume3D:
939 return aFilterMgr.CreateVolume3D()
940 elif theCriterion == FT_MaxElementLength2D:
941 return aFilterMgr.CreateMaxElementLength2D()
942 elif theCriterion == FT_MaxElementLength3D:
943 return aFilterMgr.CreateMaxElementLength3D()
944 elif theCriterion == FT_MultiConnection:
945 return aFilterMgr.CreateMultiConnection()
946 elif theCriterion == FT_MultiConnection2D:
947 return aFilterMgr.CreateMultiConnection2D()
948 elif theCriterion == FT_Length:
949 return aFilterMgr.CreateLength()
950 elif theCriterion == FT_Length2D:
951 return aFilterMgr.CreateLength2D()
953 print "Error: given parameter is not numerucal functor type."
955 ## Creates hypothesis
956 # @param theHType mesh hypothesis type (string)
957 # @param theLibName mesh plug-in library name
958 # @return created hypothesis instance
959 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
960 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
962 ## Gets the mesh stattistic
963 # @return dictionary type element - count of elements
964 # @ingroup l1_meshinfo
965 def GetMeshInfo(self, obj):
966 if isinstance( obj, Mesh ):
969 if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource):
970 values = obj.GetMeshInfo()
971 for i in range(SMESH.Entity_Last._v):
972 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
976 ## Get minimum distance between two objects
978 # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
979 # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
981 # @param src1 first source object
982 # @param src2 second source object
983 # @param id1 node/element id from the first source
984 # @param id2 node/element id from the second (or first) source
985 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
986 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
987 # @return minimum distance value
988 # @sa GetMinDistance()
989 # @ingroup l1_measurements
990 def MinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
991 result = self.GetMinDistance(src1, src2, id1, id2, isElem1, isElem2)
995 result = result.value
998 ## Get measure structure specifying minimum distance data between two objects
1000 # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
1001 # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
1003 # @param src1 first source object
1004 # @param src2 second source object
1005 # @param id1 node/element id from the first source
1006 # @param id2 node/element id from the second (or first) source
1007 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
1008 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
1009 # @return Measure structure or None if input data is invalid
1011 # @ingroup l1_measurements
1012 def GetMinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
1013 if isinstance(src1, Mesh): src1 = src1.mesh
1014 if isinstance(src2, Mesh): src2 = src2.mesh
1015 if src2 is None and id2 != 0: src2 = src1
1016 if not hasattr(src1, "_narrow"): return None
1017 src1 = src1._narrow(SMESH.SMESH_IDSource)
1018 if not src1: return None
1021 e = m.GetMeshEditor()
1023 src1 = e.MakeIDSource([id1], SMESH.FACE)
1025 src1 = e.MakeIDSource([id1], SMESH.NODE)
1027 if hasattr(src2, "_narrow"):
1028 src2 = src2._narrow(SMESH.SMESH_IDSource)
1029 if src2 and id2 != 0:
1031 e = m.GetMeshEditor()
1033 src2 = e.MakeIDSource([id2], SMESH.FACE)
1035 src2 = e.MakeIDSource([id2], SMESH.NODE)
1038 aMeasurements = self.CreateMeasurements()
1039 result = aMeasurements.MinDistance(src1, src2)
1040 aMeasurements.UnRegister()
1043 ## Get bounding box of the specified object(s)
1044 # @param objects single source object or list of source objects
1045 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
1046 # @sa GetBoundingBox()
1047 # @ingroup l1_measurements
1048 def BoundingBox(self, objects):
1049 result = self.GetBoundingBox(objects)
1053 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
1056 ## Get measure structure specifying bounding box data of the specified object(s)
1057 # @param objects single source object or list of source objects
1058 # @return Measure structure
1060 # @ingroup l1_measurements
1061 def GetBoundingBox(self, objects):
1062 if isinstance(objects, tuple):
1063 objects = list(objects)
1064 if not isinstance(objects, list):
1068 if isinstance(o, Mesh):
1069 srclist.append(o.mesh)
1070 elif hasattr(o, "_narrow"):
1071 src = o._narrow(SMESH.SMESH_IDSource)
1072 if src: srclist.append(src)
1075 aMeasurements = self.CreateMeasurements()
1076 result = aMeasurements.BoundingBox(srclist)
1077 aMeasurements.UnRegister()
1081 #Registering the new proxy for SMESH_Gen
1082 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
1085 # Public class: Mesh
1086 # ==================
1088 ## This class allows defining and managing a mesh.
1089 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
1090 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
1091 # new nodes and elements and by changing the existing entities), to get information
1092 # about a mesh and to export a mesh into different formats.
1101 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
1102 # sets the GUI name of this mesh to \a name.
1103 # @param smeshpyD an instance of smeshDC class
1104 # @param geompyD an instance of geompyDC class
1105 # @param obj Shape to be meshed or SMESH_Mesh object
1106 # @param name Study name of the mesh
1107 # @ingroup l2_construct
1108 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
1109 self.smeshpyD=smeshpyD
1110 self.geompyD=geompyD
1114 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
1116 # publish geom of mesh (issue 0021122)
1117 if not self.geom.GetStudyEntry():
1118 studyID = smeshpyD.GetCurrentStudy()._get_StudyId()
1119 if studyID != geompyD.myStudyId:
1120 geompyD.init_geom( smeshpyD.GetCurrentStudy())
1122 geo_name = "%s_%s"%(self.geom.GetShapeType(), id(self.geom)%100)
1123 geompyD.addToStudy( self.geom, geo_name )
1124 self.mesh = self.smeshpyD.CreateMesh(self.geom)
1126 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
1129 self.mesh = self.smeshpyD.CreateEmptyMesh()
1131 self.smeshpyD.SetName(self.mesh, name)
1133 self.smeshpyD.SetName(self.mesh, GetName(obj))
1136 self.geom = self.mesh.GetShapeToMesh()
1138 self.editor = self.mesh.GetMeshEditor()
1140 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
1141 # @param theMesh a SMESH_Mesh object
1142 # @ingroup l2_construct
1143 def SetMesh(self, theMesh):
1145 self.geom = self.mesh.GetShapeToMesh()
1147 ## Returns the mesh, that is an instance of SMESH_Mesh interface
1148 # @return a SMESH_Mesh object
1149 # @ingroup l2_construct
1153 ## Gets the name of the mesh
1154 # @return the name of the mesh as a string
1155 # @ingroup l2_construct
1157 name = GetName(self.GetMesh())
1160 ## Sets a name to the mesh
1161 # @param name a new name of the mesh
1162 # @ingroup l2_construct
1163 def SetName(self, name):
1164 self.smeshpyD.SetName(self.GetMesh(), name)
1166 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
1167 # The subMesh object gives access to the IDs of nodes and elements.
1168 # @param geom a geometrical object (shape)
1169 # @param name a name for the submesh
1170 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
1171 # @ingroup l2_submeshes
1172 def GetSubMesh(self, geom, name):
1173 AssureGeomPublished( self, geom, name )
1174 submesh = self.mesh.GetSubMesh( geom, name )
1177 ## Returns the shape associated to the mesh
1178 # @return a GEOM_Object
1179 # @ingroup l2_construct
1183 ## Associates the given shape to the mesh (entails the recreation of the mesh)
1184 # @param geom the shape to be meshed (GEOM_Object)
1185 # @ingroup l2_construct
1186 def SetShape(self, geom):
1187 self.mesh = self.smeshpyD.CreateMesh(geom)
1189 ## Returns true if the hypotheses are defined well
1190 # @param theSubObject a subshape of a mesh shape
1191 # @return True or False
1192 # @ingroup l2_construct
1193 def IsReadyToCompute(self, theSubObject):
1194 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
1196 ## Returns errors of hypotheses definition.
1197 # The list of errors is empty if everything is OK.
1198 # @param theSubObject a subshape of a mesh shape
1199 # @return a list of errors
1200 # @ingroup l2_construct
1201 def GetAlgoState(self, theSubObject):
1202 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
1204 ## Returns a geometrical object on which the given element was built.
1205 # The returned geometrical object, if not nil, is either found in the
1206 # study or published by this method with the given name
1207 # @param theElementID the id of the mesh element
1208 # @param theGeomName the user-defined name of the geometrical object
1209 # @return GEOM::GEOM_Object instance
1210 # @ingroup l2_construct
1211 def GetGeometryByMeshElement(self, theElementID, theGeomName):
1212 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
1214 ## Returns the mesh dimension depending on the dimension of the underlying shape
1215 # @return mesh dimension as an integer value [0,3]
1216 # @ingroup l1_auxiliary
1217 def MeshDimension(self):
1218 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
1219 if len( shells ) > 0 :
1221 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
1223 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
1229 ## Creates a segment discretization 1D algorithm.
1230 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
1231 # \n If the optional \a geom parameter is not set, this algorithm is global.
1232 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1233 # @param algo the type of the required algorithm. Possible values are:
1235 # - smesh.PYTHON for discretization via a python function,
1236 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
1237 # @param geom If defined is the subshape to be meshed
1238 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
1239 # @ingroup l3_algos_basic
1240 def Segment(self, algo=REGULAR, geom=0):
1241 ## if Segment(geom) is called by mistake
1242 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
1243 algo, geom = geom, algo
1244 if not algo: algo = REGULAR
1247 return Mesh_Segment(self, geom)
1248 elif algo == PYTHON:
1249 return Mesh_Segment_Python(self, geom)
1250 elif algo == COMPOSITE:
1251 return Mesh_CompositeSegment(self, geom)
1253 return Mesh_Segment(self, geom)
1255 ## Creates 1D algorithm importing segments conatined in groups of other mesh.
1256 # If the optional \a geom parameter is not set, this algorithm is global.
1257 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1258 # @param geom If defined the subshape is to be meshed
1259 # @return an instance of Mesh_UseExistingElements class
1260 # @ingroup l3_algos_basic
1261 def UseExisting1DElements(self, geom=0):
1262 return Mesh_UseExistingElements(1,self, geom)
1264 ## Creates 2D algorithm importing faces conatined in groups of other mesh.
1265 # If the optional \a geom parameter is not set, this algorithm is global.
1266 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1267 # @param geom If defined the subshape is to be meshed
1268 # @return an instance of Mesh_UseExistingElements class
1269 # @ingroup l3_algos_basic
1270 def UseExisting2DElements(self, geom=0):
1271 return Mesh_UseExistingElements(2,self, geom)
1273 ## Enables creation of nodes and segments usable by 2D algoritms.
1274 # The added nodes and segments must be bound to edges and vertices by
1275 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
1276 # If the optional \a geom parameter is not set, this algorithm is global.
1277 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1278 # @param geom the subshape to be manually meshed
1279 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
1280 # @ingroup l3_algos_basic
1281 def UseExistingSegments(self, geom=0):
1282 algo = Mesh_UseExisting(1,self,geom)
1283 return algo.GetAlgorithm()
1285 ## Enables creation of nodes and faces usable by 3D algoritms.
1286 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
1287 # and SetMeshElementOnShape()
1288 # If the optional \a geom parameter is not set, this algorithm is global.
1289 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1290 # @param geom the subshape to be manually meshed
1291 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1292 # @ingroup l3_algos_basic
1293 def UseExistingFaces(self, geom=0):
1294 algo = Mesh_UseExisting(2,self,geom)
1295 return algo.GetAlgorithm()
1297 ## Creates a triangle 2D algorithm for faces.
1298 # If the optional \a geom parameter is not set, this algorithm is global.
1299 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1300 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1301 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1302 # @return an instance of Mesh_Triangle algorithm
1303 # @ingroup l3_algos_basic
1304 def Triangle(self, algo=MEFISTO, geom=0):
1305 ## if Triangle(geom) is called by mistake
1306 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1309 return Mesh_Triangle(self, algo, geom)
1311 ## Creates a quadrangle 2D algorithm for faces.
1312 # If the optional \a geom parameter is not set, this algorithm is global.
1313 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1314 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1315 # @param algo values are: smesh.QUADRANGLE || smesh.RADIAL_QUAD
1316 # @return an instance of Mesh_Quadrangle algorithm
1317 # @ingroup l3_algos_basic
1318 def Quadrangle(self, geom=0, algo=QUADRANGLE):
1319 if algo==RADIAL_QUAD:
1320 return Mesh_RadialQuadrangle1D2D(self,geom)
1322 return Mesh_Quadrangle(self, geom)
1324 ## Creates a tetrahedron 3D algorithm for solids.
1325 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1326 # If the optional \a geom parameter is not set, this algorithm is global.
1327 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1328 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1329 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1330 # @return an instance of Mesh_Tetrahedron algorithm
1331 # @ingroup l3_algos_basic
1332 def Tetrahedron(self, algo=NETGEN, geom=0):
1333 ## if Tetrahedron(geom) is called by mistake
1334 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1335 algo, geom = geom, algo
1336 if not algo: algo = NETGEN
1338 return Mesh_Tetrahedron(self, algo, geom)
1340 ## Creates a hexahedron 3D algorithm for solids.
1341 # If the optional \a geom parameter is not set, this algorithm is global.
1342 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1343 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1344 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1345 # @return an instance of Mesh_Hexahedron algorithm
1346 # @ingroup l3_algos_basic
1347 def Hexahedron(self, algo=Hexa, geom=0):
1348 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1349 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1350 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1351 elif geom == 0: algo, geom = Hexa, algo
1352 return Mesh_Hexahedron(self, algo, geom)
1354 ## Deprecated, used only for compatibility!
1355 # @return an instance of Mesh_Netgen algorithm
1356 # @ingroup l3_algos_basic
1357 def Netgen(self, is3D, geom=0):
1358 return Mesh_Netgen(self, is3D, geom)
1360 ## Creates a projection 1D algorithm for edges.
1361 # If the optional \a geom parameter is not set, this algorithm is global.
1362 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1363 # @param geom If defined, the subshape to be meshed
1364 # @return an instance of Mesh_Projection1D algorithm
1365 # @ingroup l3_algos_proj
1366 def Projection1D(self, geom=0):
1367 return Mesh_Projection1D(self, geom)
1369 ## Creates a projection 2D algorithm for faces.
1370 # If the optional \a geom parameter is not set, this algorithm is global.
1371 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1372 # @param geom If defined, the subshape to be meshed
1373 # @return an instance of Mesh_Projection2D algorithm
1374 # @ingroup l3_algos_proj
1375 def Projection2D(self, geom=0):
1376 return Mesh_Projection2D(self, geom)
1378 ## Creates a projection 3D algorithm for solids.
1379 # If the optional \a geom parameter is not set, this algorithm is global.
1380 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1381 # @param geom If defined, the subshape to be meshed
1382 # @return an instance of Mesh_Projection3D algorithm
1383 # @ingroup l3_algos_proj
1384 def Projection3D(self, geom=0):
1385 return Mesh_Projection3D(self, geom)
1387 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1388 # If the optional \a geom parameter is not set, this algorithm is global.
1389 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1390 # @param geom If defined, the subshape to be meshed
1391 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1392 # @ingroup l3_algos_radialp l3_algos_3dextr
1393 def Prism(self, geom=0):
1397 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1398 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1399 if nbSolids == 0 or nbSolids == nbShells:
1400 return Mesh_Prism3D(self, geom)
1401 return Mesh_RadialPrism3D(self, geom)
1403 ## Evaluates size of prospective mesh on a shape
1404 # @return a list where i-th element is a number of elements of i-th SMESH.EntityType
1405 # To know predicted number of e.g. edges, inquire it this way
1406 # Evaluate()[ EnumToLong( Entity_Edge )]
1407 def Evaluate(self, geom=0):
1408 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1410 geom = self.mesh.GetShapeToMesh()
1413 return self.smeshpyD.Evaluate(self.mesh, geom)
1416 ## Computes the mesh and returns the status of the computation
1417 # @param geom geomtrical shape on which mesh data should be computed
1418 # @param discardModifs if True and the mesh has been edited since
1419 # a last total re-compute and that may prevent successful partial re-compute,
1420 # then the mesh is cleaned before Compute()
1421 # @return True or False
1422 # @ingroup l2_construct
1423 def Compute(self, geom=0, discardModifs=False):
1424 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1426 geom = self.mesh.GetShapeToMesh()
1431 if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693
1433 ok = self.smeshpyD.Compute(self.mesh, geom)
1434 except SALOME.SALOME_Exception, ex:
1435 print "Mesh computation failed, exception caught:"
1436 print " ", ex.details.text
1439 print "Mesh computation failed, exception caught:"
1440 traceback.print_exc()
1444 # Treat compute errors
1445 computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
1446 for err in computeErrors:
1448 if self.mesh.HasShapeToMesh():
1450 mainIOR = salome.orb.object_to_string(geom)
1451 for sname in salome.myStudyManager.GetOpenStudies():
1452 s = salome.myStudyManager.GetStudyByName(sname)
1454 mainSO = s.FindObjectIOR(mainIOR)
1455 if not mainSO: continue
1456 if err.subShapeID == 1:
1457 shapeText = ' on "%s"' % mainSO.GetName()
1458 subIt = s.NewChildIterator(mainSO)
1460 subSO = subIt.Value()
1462 obj = subSO.GetObject()
1463 if not obj: continue
1464 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
1466 ids = go.GetSubShapeIndices()
1467 if len(ids) == 1 and ids[0] == err.subShapeID:
1468 shapeText = ' on "%s"' % subSO.GetName()
1471 shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
1473 shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID)
1475 shapeText = " on subshape #%s" % (err.subShapeID)
1477 shapeText = " on subshape #%s" % (err.subShapeID)
1479 stdErrors = ["OK", #COMPERR_OK
1480 "Invalid input mesh", #COMPERR_BAD_INPUT_MESH
1481 "std::exception", #COMPERR_STD_EXCEPTION
1482 "OCC exception", #COMPERR_OCC_EXCEPTION
1483 "SALOME exception", #COMPERR_SLM_EXCEPTION
1484 "Unknown exception", #COMPERR_EXCEPTION
1485 "Memory allocation problem", #COMPERR_MEMORY_PB
1486 "Algorithm failed", #COMPERR_ALGO_FAILED
1487 "Unexpected geometry"]#COMPERR_BAD_SHAPE
1489 if err.code < len(stdErrors): errText = stdErrors[err.code]
1491 errText = "code %s" % -err.code
1492 if errText: errText += ". "
1493 errText += err.comment
1494 if allReasons != "":allReasons += "\n"
1495 allReasons += '"%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
1499 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1501 if err.isGlobalAlgo:
1509 reason = '%s %sD algorithm is missing' % (glob, dim)
1510 elif err.state == HYP_MISSING:
1511 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1512 % (glob, dim, name, dim))
1513 elif err.state == HYP_NOTCONFORM:
1514 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1515 elif err.state == HYP_BAD_PARAMETER:
1516 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1517 % ( glob, dim, name ))
1518 elif err.state == HYP_BAD_GEOMETRY:
1519 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1520 'geometry' % ( glob, dim, name ))
1522 reason = "For unknown reason."+\
1523 " Revise Mesh.Compute() implementation in smeshDC.py!"
1525 if allReasons != "":allReasons += "\n"
1526 allReasons += reason
1528 if allReasons != "":
1529 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1533 print '"' + GetName(self.mesh) + '"',"has not been computed."
1536 if salome.sg.hasDesktop():
1537 smeshgui = salome.ImportComponentGUI("SMESH")
1538 smeshgui.Init(self.mesh.GetStudyId())
1539 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1540 salome.sg.updateObjBrowser(1)
1544 ## Return submesh objects list in meshing order
1545 # @return list of list of submesh objects
1546 # @ingroup l2_construct
1547 def GetMeshOrder(self):
1548 return self.mesh.GetMeshOrder()
1550 ## Return submesh objects list in meshing order
1551 # @return list of list of submesh objects
1552 # @ingroup l2_construct
1553 def SetMeshOrder(self, submeshes):
1554 return self.mesh.SetMeshOrder(submeshes)
1556 ## Removes all nodes and elements
1557 # @ingroup l2_construct
1560 if salome.sg.hasDesktop():
1561 smeshgui = salome.ImportComponentGUI("SMESH")
1562 smeshgui.Init(self.mesh.GetStudyId())
1563 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1564 salome.sg.updateObjBrowser(1)
1566 ## Removes all nodes and elements of indicated shape
1567 # @ingroup l2_construct
1568 def ClearSubMesh(self, geomId):
1569 self.mesh.ClearSubMesh(geomId)
1570 if salome.sg.hasDesktop():
1571 smeshgui = salome.ImportComponentGUI("SMESH")
1572 smeshgui.Init(self.mesh.GetStudyId())
1573 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1574 salome.sg.updateObjBrowser(1)
1576 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1577 # @param fineness [0.0,1.0] defines mesh fineness
1578 # @return True or False
1579 # @ingroup l3_algos_basic
1580 def AutomaticTetrahedralization(self, fineness=0):
1581 dim = self.MeshDimension()
1583 self.RemoveGlobalHypotheses()
1584 self.Segment().AutomaticLength(fineness)
1586 self.Triangle().LengthFromEdges()
1589 self.Tetrahedron(NETGEN)
1591 return self.Compute()
1593 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1594 # @param fineness [0.0, 1.0] defines mesh fineness
1595 # @return True or False
1596 # @ingroup l3_algos_basic
1597 def AutomaticHexahedralization(self, fineness=0):
1598 dim = self.MeshDimension()
1599 # assign the hypotheses
1600 self.RemoveGlobalHypotheses()
1601 self.Segment().AutomaticLength(fineness)
1608 return self.Compute()
1610 ## Assigns a hypothesis
1611 # @param hyp a hypothesis to assign
1612 # @param geom a subhape of mesh geometry
1613 # @return SMESH.Hypothesis_Status
1614 # @ingroup l2_hypotheses
1615 def AddHypothesis(self, hyp, geom=0):
1616 if isinstance( hyp, Mesh_Algorithm ):
1617 hyp = hyp.GetAlgorithm()
1622 geom = self.mesh.GetShapeToMesh()
1624 status = self.mesh.AddHypothesis(geom, hyp)
1625 isAlgo = hyp._narrow( SMESH_Algo )
1626 hyp_name = GetName( hyp )
1629 geom_name = GetName( geom )
1630 TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1633 ## Unassigns a hypothesis
1634 # @param hyp a hypothesis to unassign
1635 # @param geom a subshape of mesh geometry
1636 # @return SMESH.Hypothesis_Status
1637 # @ingroup l2_hypotheses
1638 def RemoveHypothesis(self, hyp, geom=0):
1639 if isinstance( hyp, Mesh_Algorithm ):
1640 hyp = hyp.GetAlgorithm()
1645 status = self.mesh.RemoveHypothesis(geom, hyp)
1648 ## Gets the list of hypotheses added on a geometry
1649 # @param geom a subshape of mesh geometry
1650 # @return the sequence of SMESH_Hypothesis
1651 # @ingroup l2_hypotheses
1652 def GetHypothesisList(self, geom):
1653 return self.mesh.GetHypothesisList( geom )
1655 ## Removes all global hypotheses
1656 # @ingroup l2_hypotheses
1657 def RemoveGlobalHypotheses(self):
1658 current_hyps = self.mesh.GetHypothesisList( self.geom )
1659 for hyp in current_hyps:
1660 self.mesh.RemoveHypothesis( self.geom, hyp )
1664 ## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead.
1665 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1666 ## allowing to overwrite the file if it exists or add the exported data to its contents
1667 # @param f the file name
1668 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1669 # @param opt boolean parameter for creating/not creating
1670 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1671 # @param overwrite boolean parameter for overwriting/not overwriting the file
1672 # @ingroup l2_impexp
1673 def ExportToMED(self, f, version, opt=0, overwrite=1):
1674 self.mesh.ExportToMEDX(f, opt, version, overwrite)
1676 ## Exports the mesh in a file in MED format and chooses the \a version of MED format
1677 ## allowing to overwrite the file if it exists or add the exported data to its contents
1678 # @param f is the file name
1679 # @param auto_groups boolean parameter for creating/not creating
1680 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1681 # the typical use is auto_groups=false.
1682 # @param version MED format version(MED_V2_1 or MED_V2_2)
1683 # @param overwrite boolean parameter for overwriting/not overwriting the file
1684 # @ingroup l2_impexp
1685 def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1):
1686 self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
1688 ## Exports the mesh in a file in DAT format
1689 # @param f the file name
1690 # @ingroup l2_impexp
1691 def ExportDAT(self, f):
1692 self.mesh.ExportDAT(f)
1694 ## Exports the mesh in a file in UNV format
1695 # @param f the file name
1696 # @ingroup l2_impexp
1697 def ExportUNV(self, f):
1698 self.mesh.ExportUNV(f)
1700 ## Export the mesh in a file in STL format
1701 # @param f the file name
1702 # @param ascii defines the file encoding
1703 # @ingroup l2_impexp
1704 def ExportSTL(self, f, ascii=1):
1705 self.mesh.ExportSTL(f, ascii)
1708 # Operations with groups:
1709 # ----------------------
1711 ## Creates an empty mesh group
1712 # @param elementType the type of elements in the group
1713 # @param name the name of the mesh group
1714 # @return SMESH_Group
1715 # @ingroup l2_grps_create
1716 def CreateEmptyGroup(self, elementType, name):
1717 return self.mesh.CreateGroup(elementType, name)
1719 ## Creates a mesh group based on the geometric object \a grp
1720 # and gives a \a name, \n if this parameter is not defined
1721 # the name is the same as the geometric group name \n
1722 # Note: Works like GroupOnGeom().
1723 # @param grp a geometric group, a vertex, an edge, a face or a solid
1724 # @param name the name of the mesh group
1725 # @return SMESH_GroupOnGeom
1726 # @ingroup l2_grps_create
1727 def Group(self, grp, name=""):
1728 return self.GroupOnGeom(grp, name)
1730 ## Creates a mesh group based on the geometrical object \a grp
1731 # and gives a \a name, \n if this parameter is not defined
1732 # the name is the same as the geometrical group name
1733 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1734 # @param name the name of the mesh group
1735 # @param typ the type of elements in the group. If not set, it is
1736 # automatically detected by the type of the geometry
1737 # @return SMESH_GroupOnGeom
1738 # @ingroup l2_grps_create
1739 def GroupOnGeom(self, grp, name="", typ=None):
1740 AssureGeomPublished( self, grp, name )
1742 name = grp.GetName()
1744 typ = self._groupTypeFromShape( grp )
1745 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1747 ## Pivate method to get a type of group on geometry
1748 def _groupTypeFromShape( self, shape ):
1749 tgeo = str(shape.GetShapeType())
1750 if tgeo == "VERTEX":
1752 elif tgeo == "EDGE":
1754 elif tgeo == "FACE" or tgeo == "SHELL":
1756 elif tgeo == "SOLID" or tgeo == "COMPSOLID":
1758 elif tgeo == "COMPOUND":
1759 sub = self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHAPE"])
1761 raise ValueError,"_groupTypeFromShape(): empty geometric group or compound '%s'" % GetName(shape)
1762 return self._groupTypeFromShape( sub[0] )
1765 "_groupTypeFromShape(): invalid geometry '%s'" % GetName(shape)
1768 ## Creates a mesh group by the given ids of elements
1769 # @param groupName the name of the mesh group
1770 # @param elementType the type of elements in the group
1771 # @param elemIDs the list of ids
1772 # @return SMESH_Group
1773 # @ingroup l2_grps_create
1774 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1775 group = self.mesh.CreateGroup(elementType, groupName)
1779 ## Creates a mesh group by the given conditions
1780 # @param groupName the name of the mesh group
1781 # @param elementType the type of elements in the group
1782 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1783 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1784 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1785 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1786 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
1787 # FT_LyingOnGeom, FT_CoplanarFaces criteria
1788 # @return SMESH_Group
1789 # @ingroup l2_grps_create
1793 CritType=FT_Undefined,
1796 UnaryOp=FT_Undefined,
1798 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined,Tolerance)
1799 group = self.MakeGroupByCriterion(groupName, aCriterion)
1802 ## Creates a mesh group by the given criterion
1803 # @param groupName the name of the mesh group
1804 # @param Criterion the instance of Criterion class
1805 # @return SMESH_Group
1806 # @ingroup l2_grps_create
1807 def MakeGroupByCriterion(self, groupName, Criterion):
1808 aFilterMgr = self.smeshpyD.CreateFilterManager()
1809 aFilter = aFilterMgr.CreateFilter()
1811 aCriteria.append(Criterion)
1812 aFilter.SetCriteria(aCriteria)
1813 group = self.MakeGroupByFilter(groupName, aFilter)
1814 aFilterMgr.UnRegister()
1817 ## Creates a mesh group by the given criteria (list of criteria)
1818 # @param groupName the name of the mesh group
1819 # @param theCriteria the list of criteria
1820 # @return SMESH_Group
1821 # @ingroup l2_grps_create
1822 def MakeGroupByCriteria(self, groupName, theCriteria):
1823 aFilterMgr = self.smeshpyD.CreateFilterManager()
1824 aFilter = aFilterMgr.CreateFilter()
1825 aFilter.SetCriteria(theCriteria)
1826 group = self.MakeGroupByFilter(groupName, aFilter)
1827 aFilterMgr.UnRegister()
1830 ## Creates a mesh group by the given filter
1831 # @param groupName the name of the mesh group
1832 # @param theFilter the instance of Filter class
1833 # @return SMESH_Group
1834 # @ingroup l2_grps_create
1835 def MakeGroupByFilter(self, groupName, theFilter):
1836 group = self.CreateEmptyGroup(theFilter.GetElementType(), groupName)
1837 theFilter.SetMesh( self.mesh )
1838 group.AddFrom( theFilter )
1841 ## Passes mesh elements through the given filter and return IDs of fitting elements
1842 # @param theFilter SMESH_Filter
1843 # @return a list of ids
1844 # @ingroup l1_controls
1845 def GetIdsFromFilter(self, theFilter):
1846 theFilter.SetMesh( self.mesh )
1847 return theFilter.GetIDs()
1849 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1850 # Returns a list of special structures (borders).
1851 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1852 # @ingroup l1_controls
1853 def GetFreeBorders(self):
1854 aFilterMgr = self.smeshpyD.CreateFilterManager()
1855 aPredicate = aFilterMgr.CreateFreeEdges()
1856 aPredicate.SetMesh(self.mesh)
1857 aBorders = aPredicate.GetBorders()
1858 aFilterMgr.UnRegister()
1862 # @ingroup l2_grps_delete
1863 def RemoveGroup(self, group):
1864 self.mesh.RemoveGroup(group)
1866 ## Removes a group with its contents
1867 # @ingroup l2_grps_delete
1868 def RemoveGroupWithContents(self, group):
1869 self.mesh.RemoveGroupWithContents(group)
1871 ## Gets the list of groups existing in the mesh
1872 # @return a sequence of SMESH_GroupBase
1873 # @ingroup l2_grps_create
1874 def GetGroups(self):
1875 return self.mesh.GetGroups()
1877 ## Gets the number of groups existing in the mesh
1878 # @return the quantity of groups as an integer value
1879 # @ingroup l2_grps_create
1881 return self.mesh.NbGroups()
1883 ## Gets the list of names of groups existing in the mesh
1884 # @return list of strings
1885 # @ingroup l2_grps_create
1886 def GetGroupNames(self):
1887 groups = self.GetGroups()
1889 for group in groups:
1890 names.append(group.GetName())
1893 ## Produces a union of two groups
1894 # A new group is created. All mesh elements that are
1895 # present in the initial groups are added to the new one
1896 # @return an instance of SMESH_Group
1897 # @ingroup l2_grps_operon
1898 def UnionGroups(self, group1, group2, name):
1899 return self.mesh.UnionGroups(group1, group2, name)
1901 ## Produces a union list of groups
1902 # New group is created. All mesh elements that are present in
1903 # initial groups are added to the new one
1904 # @return an instance of SMESH_Group
1905 # @ingroup l2_grps_operon
1906 def UnionListOfGroups(self, groups, name):
1907 return self.mesh.UnionListOfGroups(groups, name)
1909 ## Prodices an intersection of two groups
1910 # A new group is created. All mesh elements that are common
1911 # for the two initial groups are added to the new one.
1912 # @return an instance of SMESH_Group
1913 # @ingroup l2_grps_operon
1914 def IntersectGroups(self, group1, group2, name):
1915 return self.mesh.IntersectGroups(group1, group2, name)
1917 ## Produces an intersection of groups
1918 # New group is created. All mesh elements that are present in all
1919 # initial groups simultaneously are added to the new one
1920 # @return an instance of SMESH_Group
1921 # @ingroup l2_grps_operon
1922 def IntersectListOfGroups(self, groups, name):
1923 return self.mesh.IntersectListOfGroups(groups, name)
1925 ## Produces a cut of two groups
1926 # A new group is created. All mesh elements that are present in
1927 # the main group but are not present in the tool group are added to the new one
1928 # @return an instance of SMESH_Group
1929 # @ingroup l2_grps_operon
1930 def CutGroups(self, main_group, tool_group, name):
1931 return self.mesh.CutGroups(main_group, tool_group, name)
1933 ## Produces a cut of groups
1934 # A new group is created. All mesh elements that are present in main groups
1935 # but do not present in tool groups are added to the new one
1936 # @return an instance of SMESH_Group
1937 # @ingroup l2_grps_operon
1938 def CutListOfGroups(self, main_groups, tool_groups, name):
1939 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1941 ## Produces a group of elements of specified type using list of existing groups
1942 # A new group is created. System
1943 # 1) extracts all nodes on which groups elements are built
1944 # 2) combines all elements of specified dimension laying on these nodes
1945 # @return an instance of SMESH_Group
1946 # @ingroup l2_grps_operon
1947 def CreateDimGroup(self, groups, elem_type, name):
1948 return self.mesh.CreateDimGroup(groups, elem_type, name)
1951 ## Convert group on geom into standalone group
1952 # @ingroup l2_grps_delete
1953 def ConvertToStandalone(self, group):
1954 return self.mesh.ConvertToStandalone(group)
1956 # Get some info about mesh:
1957 # ------------------------
1959 ## Returns the log of nodes and elements added or removed
1960 # since the previous clear of the log.
1961 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1962 # @return list of log_block structures:
1967 # @ingroup l1_auxiliary
1968 def GetLog(self, clearAfterGet):
1969 return self.mesh.GetLog(clearAfterGet)
1971 ## Clears the log of nodes and elements added or removed since the previous
1972 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1973 # @ingroup l1_auxiliary
1975 self.mesh.ClearLog()
1977 ## Toggles auto color mode on the object.
1978 # @param theAutoColor the flag which toggles auto color mode.
1979 # @ingroup l1_auxiliary
1980 def SetAutoColor(self, theAutoColor):
1981 self.mesh.SetAutoColor(theAutoColor)
1983 ## Gets flag of object auto color mode.
1984 # @return True or False
1985 # @ingroup l1_auxiliary
1986 def GetAutoColor(self):
1987 return self.mesh.GetAutoColor()
1989 ## Gets the internal ID
1990 # @return integer value, which is the internal Id of the mesh
1991 # @ingroup l1_auxiliary
1993 return self.mesh.GetId()
1996 # @return integer value, which is the study Id of the mesh
1997 # @ingroup l1_auxiliary
1998 def GetStudyId(self):
1999 return self.mesh.GetStudyId()
2001 ## Checks the group names for duplications.
2002 # Consider the maximum group name length stored in MED file.
2003 # @return True or False
2004 # @ingroup l1_auxiliary
2005 def HasDuplicatedGroupNamesMED(self):
2006 return self.mesh.HasDuplicatedGroupNamesMED()
2008 ## Obtains the mesh editor tool
2009 # @return an instance of SMESH_MeshEditor
2010 # @ingroup l1_modifying
2011 def GetMeshEditor(self):
2012 return self.mesh.GetMeshEditor()
2014 ## Wrap a list of IDs of elements or nodes into SMESH_IDSource which
2015 # can be passed as argument to accepting mesh, group or sub-mesh
2016 # @return an instance of SMESH_IDSource
2017 # @ingroup l1_auxiliary
2018 def GetIDSource(self, ids, elemType):
2019 return self.GetMeshEditor().MakeIDSource(ids, elemType)
2022 # @return an instance of SALOME_MED::MESH
2023 # @ingroup l1_auxiliary
2024 def GetMEDMesh(self):
2025 return self.mesh.GetMEDMesh()
2028 # Get informations about mesh contents:
2029 # ------------------------------------
2031 ## Gets the mesh stattistic
2032 # @return dictionary type element - count of elements
2033 # @ingroup l1_meshinfo
2034 def GetMeshInfo(self, obj = None):
2035 if not obj: obj = self.mesh
2036 return self.smeshpyD.GetMeshInfo(obj)
2038 ## Returns the number of nodes in the mesh
2039 # @return an integer value
2040 # @ingroup l1_meshinfo
2042 return self.mesh.NbNodes()
2044 ## Returns the number of elements in the mesh
2045 # @return an integer value
2046 # @ingroup l1_meshinfo
2047 def NbElements(self):
2048 return self.mesh.NbElements()
2050 ## Returns the number of 0d elements in the mesh
2051 # @return an integer value
2052 # @ingroup l1_meshinfo
2053 def Nb0DElements(self):
2054 return self.mesh.Nb0DElements()
2056 ## Returns the number of edges in the mesh
2057 # @return an integer value
2058 # @ingroup l1_meshinfo
2060 return self.mesh.NbEdges()
2062 ## Returns the number of edges with the given order in the mesh
2063 # @param elementOrder the order of elements:
2064 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2065 # @return an integer value
2066 # @ingroup l1_meshinfo
2067 def NbEdgesOfOrder(self, elementOrder):
2068 return self.mesh.NbEdgesOfOrder(elementOrder)
2070 ## Returns the number of faces in the mesh
2071 # @return an integer value
2072 # @ingroup l1_meshinfo
2074 return self.mesh.NbFaces()
2076 ## Returns the number of faces with the given order in the mesh
2077 # @param elementOrder the order of elements:
2078 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2079 # @return an integer value
2080 # @ingroup l1_meshinfo
2081 def NbFacesOfOrder(self, elementOrder):
2082 return self.mesh.NbFacesOfOrder(elementOrder)
2084 ## Returns the number of triangles in the mesh
2085 # @return an integer value
2086 # @ingroup l1_meshinfo
2087 def NbTriangles(self):
2088 return self.mesh.NbTriangles()
2090 ## Returns the number of triangles with the given order in the mesh
2091 # @param elementOrder is the order of elements:
2092 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2093 # @return an integer value
2094 # @ingroup l1_meshinfo
2095 def NbTrianglesOfOrder(self, elementOrder):
2096 return self.mesh.NbTrianglesOfOrder(elementOrder)
2098 ## Returns the number of quadrangles in the mesh
2099 # @return an integer value
2100 # @ingroup l1_meshinfo
2101 def NbQuadrangles(self):
2102 return self.mesh.NbQuadrangles()
2104 ## Returns the number of quadrangles with the given order in the mesh
2105 # @param elementOrder the order of elements:
2106 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2107 # @return an integer value
2108 # @ingroup l1_meshinfo
2109 def NbQuadranglesOfOrder(self, elementOrder):
2110 return self.mesh.NbQuadranglesOfOrder(elementOrder)
2112 ## Returns the number of polygons in the mesh
2113 # @return an integer value
2114 # @ingroup l1_meshinfo
2115 def NbPolygons(self):
2116 return self.mesh.NbPolygons()
2118 ## Returns the number of volumes in the mesh
2119 # @return an integer value
2120 # @ingroup l1_meshinfo
2121 def NbVolumes(self):
2122 return self.mesh.NbVolumes()
2124 ## Returns the number of volumes with the given order in the mesh
2125 # @param elementOrder the order of elements:
2126 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2127 # @return an integer value
2128 # @ingroup l1_meshinfo
2129 def NbVolumesOfOrder(self, elementOrder):
2130 return self.mesh.NbVolumesOfOrder(elementOrder)
2132 ## Returns the number of tetrahedrons in the mesh
2133 # @return an integer value
2134 # @ingroup l1_meshinfo
2136 return self.mesh.NbTetras()
2138 ## Returns the number of tetrahedrons with the given order in the mesh
2139 # @param elementOrder the order of elements:
2140 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2141 # @return an integer value
2142 # @ingroup l1_meshinfo
2143 def NbTetrasOfOrder(self, elementOrder):
2144 return self.mesh.NbTetrasOfOrder(elementOrder)
2146 ## Returns the number of hexahedrons in the mesh
2147 # @return an integer value
2148 # @ingroup l1_meshinfo
2150 return self.mesh.NbHexas()
2152 ## Returns the number of hexahedrons with the given order in the mesh
2153 # @param elementOrder the order of elements:
2154 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2155 # @return an integer value
2156 # @ingroup l1_meshinfo
2157 def NbHexasOfOrder(self, elementOrder):
2158 return self.mesh.NbHexasOfOrder(elementOrder)
2160 ## Returns the number of pyramids in the mesh
2161 # @return an integer value
2162 # @ingroup l1_meshinfo
2163 def NbPyramids(self):
2164 return self.mesh.NbPyramids()
2166 ## Returns the number of pyramids with the given order in the mesh
2167 # @param elementOrder the order of elements:
2168 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2169 # @return an integer value
2170 # @ingroup l1_meshinfo
2171 def NbPyramidsOfOrder(self, elementOrder):
2172 return self.mesh.NbPyramidsOfOrder(elementOrder)
2174 ## Returns the number of prisms in the mesh
2175 # @return an integer value
2176 # @ingroup l1_meshinfo
2178 return self.mesh.NbPrisms()
2180 ## Returns the number of prisms with the given order in the mesh
2181 # @param elementOrder the order of elements:
2182 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2183 # @return an integer value
2184 # @ingroup l1_meshinfo
2185 def NbPrismsOfOrder(self, elementOrder):
2186 return self.mesh.NbPrismsOfOrder(elementOrder)
2188 ## Returns the number of polyhedrons in the mesh
2189 # @return an integer value
2190 # @ingroup l1_meshinfo
2191 def NbPolyhedrons(self):
2192 return self.mesh.NbPolyhedrons()
2194 ## Returns the number of submeshes in the mesh
2195 # @return an integer value
2196 # @ingroup l1_meshinfo
2197 def NbSubMesh(self):
2198 return self.mesh.NbSubMesh()
2200 ## Returns the list of mesh elements IDs
2201 # @return the list of integer values
2202 # @ingroup l1_meshinfo
2203 def GetElementsId(self):
2204 return self.mesh.GetElementsId()
2206 ## Returns the list of IDs of mesh elements with the given type
2207 # @param elementType the required type of elements (SMESH.NODE, SMESH.EDGE, SMESH.FACE or SMESH.VOLUME)
2208 # @return list of integer values
2209 # @ingroup l1_meshinfo
2210 def GetElementsByType(self, elementType):
2211 return self.mesh.GetElementsByType(elementType)
2213 ## Returns the list of mesh nodes IDs
2214 # @return the list of integer values
2215 # @ingroup l1_meshinfo
2216 def GetNodesId(self):
2217 return self.mesh.GetNodesId()
2219 # Get the information about mesh elements:
2220 # ------------------------------------
2222 ## Returns the type of mesh element
2223 # @return the value from SMESH::ElementType enumeration
2224 # @ingroup l1_meshinfo
2225 def GetElementType(self, id, iselem):
2226 return self.mesh.GetElementType(id, iselem)
2228 ## Returns the geometric type of mesh element
2229 # @return the value from SMESH::EntityType enumeration
2230 # @ingroup l1_meshinfo
2231 def GetElementGeomType(self, id):
2232 return self.mesh.GetElementGeomType(id)
2234 ## Returns the list of submesh elements IDs
2235 # @param Shape a geom object(subshape) IOR
2236 # Shape must be the subshape of a ShapeToMesh()
2237 # @return the list of integer values
2238 # @ingroup l1_meshinfo
2239 def GetSubMeshElementsId(self, Shape):
2240 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2241 ShapeID = Shape.GetSubShapeIndices()[0]
2244 return self.mesh.GetSubMeshElementsId(ShapeID)
2246 ## Returns the list of submesh nodes IDs
2247 # @param Shape a geom object(subshape) IOR
2248 # Shape must be the subshape of a ShapeToMesh()
2249 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
2250 # @return the list of integer values
2251 # @ingroup l1_meshinfo
2252 def GetSubMeshNodesId(self, Shape, all):
2253 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2254 ShapeID = Shape.GetSubShapeIndices()[0]
2257 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2259 ## Returns type of elements on given shape
2260 # @param Shape a geom object(subshape) IOR
2261 # Shape must be a subshape of a ShapeToMesh()
2262 # @return element type
2263 # @ingroup l1_meshinfo
2264 def GetSubMeshElementType(self, Shape):
2265 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2266 ShapeID = Shape.GetSubShapeIndices()[0]
2269 return self.mesh.GetSubMeshElementType(ShapeID)
2271 ## Gets the mesh description
2272 # @return string value
2273 # @ingroup l1_meshinfo
2275 return self.mesh.Dump()
2278 # Get the information about nodes and elements of a mesh by its IDs:
2279 # -----------------------------------------------------------
2281 ## Gets XYZ coordinates of a node
2282 # \n If there is no nodes for the given ID - returns an empty list
2283 # @return a list of double precision values
2284 # @ingroup l1_meshinfo
2285 def GetNodeXYZ(self, id):
2286 return self.mesh.GetNodeXYZ(id)
2288 ## Returns list of IDs of inverse elements for the given node
2289 # \n If there is no node for the given ID - returns an empty list
2290 # @return a list of integer values
2291 # @ingroup l1_meshinfo
2292 def GetNodeInverseElements(self, id):
2293 return self.mesh.GetNodeInverseElements(id)
2295 ## @brief Returns the position of a node on the shape
2296 # @return SMESH::NodePosition
2297 # @ingroup l1_meshinfo
2298 def GetNodePosition(self,NodeID):
2299 return self.mesh.GetNodePosition(NodeID)
2301 ## If the given element is a node, returns the ID of shape
2302 # \n If there is no node for the given ID - returns -1
2303 # @return an integer value
2304 # @ingroup l1_meshinfo
2305 def GetShapeID(self, id):
2306 return self.mesh.GetShapeID(id)
2308 ## Returns the ID of the result shape after
2309 # FindShape() from SMESH_MeshEditor for the given element
2310 # \n If there is no element for the given ID - returns -1
2311 # @return an integer value
2312 # @ingroup l1_meshinfo
2313 def GetShapeIDForElem(self,id):
2314 return self.mesh.GetShapeIDForElem(id)
2316 ## Returns the number of nodes for the given element
2317 # \n If there is no element for the given ID - returns -1
2318 # @return an integer value
2319 # @ingroup l1_meshinfo
2320 def GetElemNbNodes(self, id):
2321 return self.mesh.GetElemNbNodes(id)
2323 ## Returns the node ID the given index for the given element
2324 # \n If there is no element for the given ID - returns -1
2325 # \n If there is no node for the given index - returns -2
2326 # @return an integer value
2327 # @ingroup l1_meshinfo
2328 def GetElemNode(self, id, index):
2329 return self.mesh.GetElemNode(id, index)
2331 ## Returns the IDs of nodes of the given element
2332 # @return a list of integer values
2333 # @ingroup l1_meshinfo
2334 def GetElemNodes(self, id):
2335 return self.mesh.GetElemNodes(id)
2337 ## Returns true if the given node is the medium node in the given quadratic element
2338 # @ingroup l1_meshinfo
2339 def IsMediumNode(self, elementID, nodeID):
2340 return self.mesh.IsMediumNode(elementID, nodeID)
2342 ## Returns true if the given node is the medium node in one of quadratic elements
2343 # @ingroup l1_meshinfo
2344 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2345 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2347 ## Returns the number of edges for the given element
2348 # @ingroup l1_meshinfo
2349 def ElemNbEdges(self, id):
2350 return self.mesh.ElemNbEdges(id)
2352 ## Returns the number of faces for the given element
2353 # @ingroup l1_meshinfo
2354 def ElemNbFaces(self, id):
2355 return self.mesh.ElemNbFaces(id)
2357 ## Returns nodes of given face (counted from zero) for given volumic element.
2358 # @ingroup l1_meshinfo
2359 def GetElemFaceNodes(self,elemId, faceIndex):
2360 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2362 ## Returns an element based on all given nodes.
2363 # @ingroup l1_meshinfo
2364 def FindElementByNodes(self,nodes):
2365 return self.mesh.FindElementByNodes(nodes)
2367 ## Returns true if the given element is a polygon
2368 # @ingroup l1_meshinfo
2369 def IsPoly(self, id):
2370 return self.mesh.IsPoly(id)
2372 ## Returns true if the given element is quadratic
2373 # @ingroup l1_meshinfo
2374 def IsQuadratic(self, id):
2375 return self.mesh.IsQuadratic(id)
2377 ## Returns XYZ coordinates of the barycenter of the given element
2378 # \n If there is no element for the given ID - returns an empty list
2379 # @return a list of three double values
2380 # @ingroup l1_meshinfo
2381 def BaryCenter(self, id):
2382 return self.mesh.BaryCenter(id)
2385 # Get mesh measurements information:
2386 # ------------------------------------
2388 ## Get minimum distance between two nodes, elements or distance to the origin
2389 # @param id1 first node/element id
2390 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2391 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2392 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2393 # @return minimum distance value
2394 # @sa GetMinDistance()
2395 def MinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2396 aMeasure = self.GetMinDistance(id1, id2, isElem1, isElem2)
2397 return aMeasure.value
2399 ## Get measure structure specifying minimum distance data between two objects
2400 # @param id1 first node/element id
2401 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2402 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2403 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2404 # @return Measure structure
2406 def GetMinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2408 id1 = self.editor.MakeIDSource([id1], SMESH.FACE)
2410 id1 = self.editor.MakeIDSource([id1], SMESH.NODE)
2413 id2 = self.editor.MakeIDSource([id2], SMESH.FACE)
2415 id2 = self.editor.MakeIDSource([id2], SMESH.NODE)
2420 aMeasurements = self.smeshpyD.CreateMeasurements()
2421 aMeasure = aMeasurements.MinDistance(id1, id2)
2422 aMeasurements.UnRegister()
2425 ## Get bounding box of the specified object(s)
2426 # @param objects single source object or list of source objects or list of nodes/elements IDs
2427 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2428 # @c False specifies that @a objects are nodes
2429 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
2430 # @sa GetBoundingBox()
2431 def BoundingBox(self, objects=None, isElem=False):
2432 result = self.GetBoundingBox(objects, isElem)
2436 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
2439 ## Get measure structure specifying bounding box data of the specified object(s)
2440 # @param objects single source object or list of source objects or list of nodes/elements IDs
2441 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2442 # @c False specifies that @a objects are nodes
2443 # @return Measure structure
2445 def GetBoundingBox(self, IDs=None, isElem=False):
2448 elif isinstance(IDs, tuple):
2450 if not isinstance(IDs, list):
2452 if len(IDs) > 0 and isinstance(IDs[0], int):
2456 if isinstance(o, Mesh):
2457 srclist.append(o.mesh)
2458 elif hasattr(o, "_narrow"):
2459 src = o._narrow(SMESH.SMESH_IDSource)
2460 if src: srclist.append(src)
2462 elif isinstance(o, list):
2464 srclist.append(self.editor.MakeIDSource(o, SMESH.FACE))
2466 srclist.append(self.editor.MakeIDSource(o, SMESH.NODE))
2469 aMeasurements = self.smeshpyD.CreateMeasurements()
2470 aMeasure = aMeasurements.BoundingBox(srclist)
2471 aMeasurements.UnRegister()
2474 # Mesh edition (SMESH_MeshEditor functionality):
2475 # ---------------------------------------------
2477 ## Removes the elements from the mesh by ids
2478 # @param IDsOfElements is a list of ids of elements to remove
2479 # @return True or False
2480 # @ingroup l2_modif_del
2481 def RemoveElements(self, IDsOfElements):
2482 return self.editor.RemoveElements(IDsOfElements)
2484 ## Removes nodes from mesh by ids
2485 # @param IDsOfNodes is a list of ids of nodes to remove
2486 # @return True or False
2487 # @ingroup l2_modif_del
2488 def RemoveNodes(self, IDsOfNodes):
2489 return self.editor.RemoveNodes(IDsOfNodes)
2491 ## Removes all orphan (free) nodes from mesh
2492 # @return number of the removed nodes
2493 # @ingroup l2_modif_del
2494 def RemoveOrphanNodes(self):
2495 return self.editor.RemoveOrphanNodes()
2497 ## Add a node to the mesh by coordinates
2498 # @return Id of the new node
2499 # @ingroup l2_modif_add
2500 def AddNode(self, x, y, z):
2501 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2502 self.mesh.SetParameters(Parameters)
2503 return self.editor.AddNode( x, y, z)
2505 ## Creates a 0D element on a node with given number.
2506 # @param IDOfNode the ID of node for creation of the element.
2507 # @return the Id of the new 0D element
2508 # @ingroup l2_modif_add
2509 def Add0DElement(self, IDOfNode):
2510 return self.editor.Add0DElement(IDOfNode)
2512 ## Creates a linear or quadratic edge (this is determined
2513 # by the number of given nodes).
2514 # @param IDsOfNodes the list of node IDs for creation of the element.
2515 # The order of nodes in this list should correspond to the description
2516 # of MED. \n This description is located by the following link:
2517 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2518 # @return the Id of the new edge
2519 # @ingroup l2_modif_add
2520 def AddEdge(self, IDsOfNodes):
2521 return self.editor.AddEdge(IDsOfNodes)
2523 ## Creates a linear or quadratic face (this is determined
2524 # by the number of given nodes).
2525 # @param IDsOfNodes the list of node IDs for creation of the element.
2526 # The order of nodes in this list should correspond to the description
2527 # of MED. \n This description is located by the following link:
2528 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2529 # @return the Id of the new face
2530 # @ingroup l2_modif_add
2531 def AddFace(self, IDsOfNodes):
2532 return self.editor.AddFace(IDsOfNodes)
2534 ## Adds a polygonal face to the mesh by the list of node IDs
2535 # @param IdsOfNodes the list of node IDs for creation of the element.
2536 # @return the Id of the new face
2537 # @ingroup l2_modif_add
2538 def AddPolygonalFace(self, IdsOfNodes):
2539 return self.editor.AddPolygonalFace(IdsOfNodes)
2541 ## Creates both simple and quadratic volume (this is determined
2542 # by the number of given nodes).
2543 # @param IDsOfNodes the list of node IDs for creation of the element.
2544 # The order of nodes in this list should correspond to the description
2545 # of MED. \n This description is located by the following link:
2546 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2547 # @return the Id of the new volumic element
2548 # @ingroup l2_modif_add
2549 def AddVolume(self, IDsOfNodes):
2550 return self.editor.AddVolume(IDsOfNodes)
2552 ## Creates a volume of many faces, giving nodes for each face.
2553 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2554 # @param Quantities the list of integer values, Quantities[i]
2555 # gives the quantity of nodes in face number i.
2556 # @return the Id of the new volumic element
2557 # @ingroup l2_modif_add
2558 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2559 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2561 ## Creates a volume of many faces, giving the IDs of the existing faces.
2562 # @param IdsOfFaces the list of face IDs for volume creation.
2564 # Note: The created volume will refer only to the nodes
2565 # of the given faces, not to the faces themselves.
2566 # @return the Id of the new volumic element
2567 # @ingroup l2_modif_add
2568 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2569 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2572 ## @brief Binds a node to a vertex
2573 # @param NodeID a node ID
2574 # @param Vertex a vertex or vertex ID
2575 # @return True if succeed else raises an exception
2576 # @ingroup l2_modif_add
2577 def SetNodeOnVertex(self, NodeID, Vertex):
2578 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2579 VertexID = Vertex.GetSubShapeIndices()[0]
2583 self.editor.SetNodeOnVertex(NodeID, VertexID)
2584 except SALOME.SALOME_Exception, inst:
2585 raise ValueError, inst.details.text
2589 ## @brief Stores the node position on an edge
2590 # @param NodeID a node ID
2591 # @param Edge an edge or edge ID
2592 # @param paramOnEdge a parameter on the edge where the node is located
2593 # @return True if succeed else raises an exception
2594 # @ingroup l2_modif_add
2595 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2596 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2597 EdgeID = Edge.GetSubShapeIndices()[0]
2601 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2602 except SALOME.SALOME_Exception, inst:
2603 raise ValueError, inst.details.text
2606 ## @brief Stores node position on a face
2607 # @param NodeID a node ID
2608 # @param Face a face or face ID
2609 # @param u U parameter on the face where the node is located
2610 # @param v V parameter on the face where the node is located
2611 # @return True if succeed else raises an exception
2612 # @ingroup l2_modif_add
2613 def SetNodeOnFace(self, NodeID, Face, u, v):
2614 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2615 FaceID = Face.GetSubShapeIndices()[0]
2619 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2620 except SALOME.SALOME_Exception, inst:
2621 raise ValueError, inst.details.text
2624 ## @brief Binds a node to a solid
2625 # @param NodeID a node ID
2626 # @param Solid a solid or solid ID
2627 # @return True if succeed else raises an exception
2628 # @ingroup l2_modif_add
2629 def SetNodeInVolume(self, NodeID, Solid):
2630 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2631 SolidID = Solid.GetSubShapeIndices()[0]
2635 self.editor.SetNodeInVolume(NodeID, SolidID)
2636 except SALOME.SALOME_Exception, inst:
2637 raise ValueError, inst.details.text
2640 ## @brief Bind an element to a shape
2641 # @param ElementID an element ID
2642 # @param Shape a shape or shape ID
2643 # @return True if succeed else raises an exception
2644 # @ingroup l2_modif_add
2645 def SetMeshElementOnShape(self, ElementID, Shape):
2646 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2647 ShapeID = Shape.GetSubShapeIndices()[0]
2651 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2652 except SALOME.SALOME_Exception, inst:
2653 raise ValueError, inst.details.text
2657 ## Moves the node with the given id
2658 # @param NodeID the id of the node
2659 # @param x a new X coordinate
2660 # @param y a new Y coordinate
2661 # @param z a new Z coordinate
2662 # @return True if succeed else False
2663 # @ingroup l2_modif_movenode
2664 def MoveNode(self, NodeID, x, y, z):
2665 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2666 self.mesh.SetParameters(Parameters)
2667 return self.editor.MoveNode(NodeID, x, y, z)
2669 ## Finds the node closest to a point and moves it to a point location
2670 # @param x the X coordinate of a point
2671 # @param y the Y coordinate of a point
2672 # @param z the Z coordinate of a point
2673 # @param NodeID if specified (>0), the node with this ID is moved,
2674 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2675 # @return the ID of a node
2676 # @ingroup l2_modif_throughp
2677 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2678 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2679 self.mesh.SetParameters(Parameters)
2680 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2682 ## Finds the node closest to a point
2683 # @param x the X coordinate of a point
2684 # @param y the Y coordinate of a point
2685 # @param z the Z coordinate of a point
2686 # @return the ID of a node
2687 # @ingroup l2_modif_throughp
2688 def FindNodeClosestTo(self, x, y, z):
2689 #preview = self.mesh.GetMeshEditPreviewer()
2690 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2691 return self.editor.FindNodeClosestTo(x, y, z)
2693 ## Finds the elements where a point lays IN or ON
2694 # @param x the X coordinate of a point
2695 # @param y the Y coordinate of a point
2696 # @param z the Z coordinate of a point
2697 # @param elementType type of elements to find (SMESH.ALL type
2698 # means elements of any type excluding nodes and 0D elements)
2699 # @return list of IDs of found elements
2700 # @ingroup l2_modif_throughp
2701 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2702 return self.editor.FindElementsByPoint(x, y, z, elementType)
2704 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2705 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2707 def GetPointState(self, x, y, z):
2708 return self.editor.GetPointState(x, y, z)
2710 ## Finds the node closest to a point and moves it to a point location
2711 # @param x the X coordinate of a point
2712 # @param y the Y coordinate of a point
2713 # @param z the Z coordinate of a point
2714 # @return the ID of a moved node
2715 # @ingroup l2_modif_throughp
2716 def MeshToPassThroughAPoint(self, x, y, z):
2717 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2719 ## Replaces two neighbour triangles sharing Node1-Node2 link
2720 # with the triangles built on the same 4 nodes but having other common link.
2721 # @param NodeID1 the ID of the first node
2722 # @param NodeID2 the ID of the second node
2723 # @return false if proper faces were not found
2724 # @ingroup l2_modif_invdiag
2725 def InverseDiag(self, NodeID1, NodeID2):
2726 return self.editor.InverseDiag(NodeID1, NodeID2)
2728 ## Replaces two neighbour triangles sharing Node1-Node2 link
2729 # with a quadrangle built on the same 4 nodes.
2730 # @param NodeID1 the ID of the first node
2731 # @param NodeID2 the ID of the second node
2732 # @return false if proper faces were not found
2733 # @ingroup l2_modif_unitetri
2734 def DeleteDiag(self, NodeID1, NodeID2):
2735 return self.editor.DeleteDiag(NodeID1, NodeID2)
2737 ## Reorients elements by ids
2738 # @param IDsOfElements if undefined reorients all mesh elements
2739 # @return True if succeed else False
2740 # @ingroup l2_modif_changori
2741 def Reorient(self, IDsOfElements=None):
2742 if IDsOfElements == None:
2743 IDsOfElements = self.GetElementsId()
2744 return self.editor.Reorient(IDsOfElements)
2746 ## Reorients all elements of the object
2747 # @param theObject mesh, submesh or group
2748 # @return True if succeed else False
2749 # @ingroup l2_modif_changori
2750 def ReorientObject(self, theObject):
2751 if ( isinstance( theObject, Mesh )):
2752 theObject = theObject.GetMesh()
2753 return self.editor.ReorientObject(theObject)
2755 ## Fuses the neighbouring triangles into quadrangles.
2756 # @param IDsOfElements The triangles to be fused,
2757 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2758 # @param MaxAngle is the maximum angle between element normals at which the fusion
2759 # is still performed; theMaxAngle is mesured in radians.
2760 # Also it could be a name of variable which defines angle in degrees.
2761 # @return TRUE in case of success, FALSE otherwise.
2762 # @ingroup l2_modif_unitetri
2763 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2765 if isinstance(MaxAngle,str):
2767 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2769 MaxAngle = DegreesToRadians(MaxAngle)
2770 if IDsOfElements == []:
2771 IDsOfElements = self.GetElementsId()
2772 self.mesh.SetParameters(Parameters)
2774 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2775 Functor = theCriterion
2777 Functor = self.smeshpyD.GetFunctor(theCriterion)
2778 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2780 ## Fuses the neighbouring triangles of the object into quadrangles
2781 # @param theObject is mesh, submesh or group
2782 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2783 # @param MaxAngle a max angle between element normals at which the fusion
2784 # is still performed; theMaxAngle is mesured in radians.
2785 # @return TRUE in case of success, FALSE otherwise.
2786 # @ingroup l2_modif_unitetri
2787 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2788 if ( isinstance( theObject, Mesh )):
2789 theObject = theObject.GetMesh()
2790 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2792 ## Splits quadrangles into triangles.
2793 # @param IDsOfElements the faces to be splitted.
2794 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2795 # @return TRUE in case of success, FALSE otherwise.
2796 # @ingroup l2_modif_cutquadr
2797 def QuadToTri (self, IDsOfElements, theCriterion):
2798 if IDsOfElements == []:
2799 IDsOfElements = self.GetElementsId()
2800 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2802 ## Splits quadrangles into triangles.
2803 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2804 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2805 # @return TRUE in case of success, FALSE otherwise.
2806 # @ingroup l2_modif_cutquadr
2807 def QuadToTriObject (self, theObject, theCriterion):
2808 if ( isinstance( theObject, Mesh )):
2809 theObject = theObject.GetMesh()
2810 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2812 ## Splits quadrangles into triangles.
2813 # @param IDsOfElements the faces to be splitted
2814 # @param Diag13 is used to choose a diagonal for splitting.
2815 # @return TRUE in case of success, FALSE otherwise.
2816 # @ingroup l2_modif_cutquadr
2817 def SplitQuad (self, IDsOfElements, Diag13):
2818 if IDsOfElements == []:
2819 IDsOfElements = self.GetElementsId()
2820 return self.editor.SplitQuad(IDsOfElements, Diag13)
2822 ## Splits quadrangles into triangles.
2823 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2824 # @param Diag13 is used to choose a diagonal for splitting.
2825 # @return TRUE in case of success, FALSE otherwise.
2826 # @ingroup l2_modif_cutquadr
2827 def SplitQuadObject (self, theObject, Diag13):
2828 if ( isinstance( theObject, Mesh )):
2829 theObject = theObject.GetMesh()
2830 return self.editor.SplitQuadObject(theObject, Diag13)
2832 ## Finds a better splitting of the given quadrangle.
2833 # @param IDOfQuad the ID of the quadrangle to be splitted.
2834 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2835 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2836 # diagonal is better, 0 if error occurs.
2837 # @ingroup l2_modif_cutquadr
2838 def BestSplit (self, IDOfQuad, theCriterion):
2839 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2841 ## Splits volumic elements into tetrahedrons
2842 # @param elemIDs either list of elements or mesh or group or submesh
2843 # @param method flags passing splitting method: Hex_5Tet, Hex_6Tet, Hex_24Tet
2844 # Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc
2845 # @ingroup l2_modif_cutquadr
2846 def SplitVolumesIntoTetra(self, elemIDs, method=Hex_5Tet ):
2847 if isinstance( elemIDs, Mesh ):
2848 elemIDs = elemIDs.GetMesh()
2849 if ( isinstance( elemIDs, list )):
2850 elemIDs = self.editor.MakeIDSource(elemIDs, SMESH.VOLUME)
2851 self.editor.SplitVolumesIntoTetra(elemIDs, method)
2853 ## Splits quadrangle faces near triangular facets of volumes
2855 # @ingroup l1_auxiliary
2856 def SplitQuadsNearTriangularFacets(self):
2857 faces_array = self.GetElementsByType(SMESH.FACE)
2858 for face_id in faces_array:
2859 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2860 quad_nodes = self.mesh.GetElemNodes(face_id)
2861 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2862 isVolumeFound = False
2863 for node1_elem in node1_elems:
2864 if not isVolumeFound:
2865 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2866 nb_nodes = self.GetElemNbNodes(node1_elem)
2867 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2868 volume_elem = node1_elem
2869 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2870 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2871 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2872 isVolumeFound = True
2873 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2874 self.SplitQuad([face_id], False) # diagonal 2-4
2875 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2876 isVolumeFound = True
2877 self.SplitQuad([face_id], True) # diagonal 1-3
2878 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2879 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2880 isVolumeFound = True
2881 self.SplitQuad([face_id], True) # diagonal 1-3
2883 ## @brief Splits hexahedrons into tetrahedrons.
2885 # This operation uses pattern mapping functionality for splitting.
2886 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2887 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2888 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2889 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2890 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2891 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2892 # @return TRUE in case of success, FALSE otherwise.
2893 # @ingroup l1_auxiliary
2894 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2895 # Pattern: 5.---------.6
2900 # (0,0,1) 4.---------.7 * |
2907 # (0,0,0) 0.---------.3
2908 pattern_tetra = "!!! Nb of points: \n 8 \n\
2918 !!! Indices of points of 6 tetras: \n\
2926 pattern = self.smeshpyD.GetPattern()
2927 isDone = pattern.LoadFromFile(pattern_tetra)
2929 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2932 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2933 isDone = pattern.MakeMesh(self.mesh, False, False)
2934 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2936 # split quafrangle faces near triangular facets of volumes
2937 self.SplitQuadsNearTriangularFacets()
2941 ## @brief Split hexahedrons into prisms.
2943 # Uses the pattern mapping functionality for splitting.
2944 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2945 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2946 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2947 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2948 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2949 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2950 # @return TRUE in case of success, FALSE otherwise.
2951 # @ingroup l1_auxiliary
2952 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2953 # Pattern: 5.---------.6
2958 # (0,0,1) 4.---------.7 |
2965 # (0,0,0) 0.---------.3
2966 pattern_prism = "!!! Nb of points: \n 8 \n\
2976 !!! Indices of points of 2 prisms: \n\
2980 pattern = self.smeshpyD.GetPattern()
2981 isDone = pattern.LoadFromFile(pattern_prism)
2983 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2986 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2987 isDone = pattern.MakeMesh(self.mesh, False, False)
2988 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2990 # Splits quafrangle faces near triangular facets of volumes
2991 self.SplitQuadsNearTriangularFacets()
2995 ## Smoothes elements
2996 # @param IDsOfElements the list if ids of elements to smooth
2997 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2998 # Note that nodes built on edges and boundary nodes are always fixed.
2999 # @param MaxNbOfIterations the maximum number of iterations
3000 # @param MaxAspectRatio varies in range [1.0, inf]
3001 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3002 # @return TRUE in case of success, FALSE otherwise.
3003 # @ingroup l2_modif_smooth
3004 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
3005 MaxNbOfIterations, MaxAspectRatio, Method):
3006 if IDsOfElements == []:
3007 IDsOfElements = self.GetElementsId()
3008 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
3009 self.mesh.SetParameters(Parameters)
3010 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
3011 MaxNbOfIterations, MaxAspectRatio, Method)
3013 ## Smoothes elements which belong to the given object
3014 # @param theObject the object to smooth
3015 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3016 # Note that nodes built on edges and boundary nodes are always fixed.
3017 # @param MaxNbOfIterations the maximum number of iterations
3018 # @param MaxAspectRatio varies in range [1.0, inf]
3019 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3020 # @return TRUE in case of success, FALSE otherwise.
3021 # @ingroup l2_modif_smooth
3022 def SmoothObject(self, theObject, IDsOfFixedNodes,
3023 MaxNbOfIterations, MaxAspectRatio, Method):
3024 if ( isinstance( theObject, Mesh )):
3025 theObject = theObject.GetMesh()
3026 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
3027 MaxNbOfIterations, MaxAspectRatio, Method)
3029 ## Parametrically smoothes the given elements
3030 # @param IDsOfElements the list if ids of elements to smooth
3031 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3032 # Note that nodes built on edges and boundary nodes are always fixed.
3033 # @param MaxNbOfIterations the maximum number of iterations
3034 # @param MaxAspectRatio varies in range [1.0, inf]
3035 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3036 # @return TRUE in case of success, FALSE otherwise.
3037 # @ingroup l2_modif_smooth
3038 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
3039 MaxNbOfIterations, MaxAspectRatio, Method):
3040 if IDsOfElements == []:
3041 IDsOfElements = self.GetElementsId()
3042 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
3043 self.mesh.SetParameters(Parameters)
3044 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
3045 MaxNbOfIterations, MaxAspectRatio, Method)
3047 ## Parametrically smoothes the elements which belong to the given object
3048 # @param theObject the object to smooth
3049 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3050 # Note that nodes built on edges and boundary nodes are always fixed.
3051 # @param MaxNbOfIterations the maximum number of iterations
3052 # @param MaxAspectRatio varies in range [1.0, inf]
3053 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3054 # @return TRUE in case of success, FALSE otherwise.
3055 # @ingroup l2_modif_smooth
3056 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
3057 MaxNbOfIterations, MaxAspectRatio, Method):
3058 if ( isinstance( theObject, Mesh )):
3059 theObject = theObject.GetMesh()
3060 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
3061 MaxNbOfIterations, MaxAspectRatio, Method)
3063 ## Converts the mesh to quadratic, deletes old elements, replacing
3064 # them with quadratic with the same id.
3065 # @param theForce3d new node creation method:
3066 # 0 - the medium node lies at the geometrical entity from which the mesh element is built
3067 # 1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element
3068 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
3069 # @ingroup l2_modif_tofromqu
3070 def ConvertToQuadratic(self, theForce3d, theSubMesh=None):
3072 self.editor.ConvertToQuadraticObject(theForce3d,theSubMesh)
3074 self.editor.ConvertToQuadratic(theForce3d)
3076 ## Converts the mesh from quadratic to ordinary,
3077 # deletes old quadratic elements, \n replacing
3078 # them with ordinary mesh elements with the same id.
3079 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
3080 # @ingroup l2_modif_tofromqu
3081 def ConvertFromQuadratic(self, theSubMesh=None):
3083 self.editor.ConvertFromQuadraticObject(theSubMesh)
3085 return self.editor.ConvertFromQuadratic()
3087 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
3088 # @return TRUE if operation has been completed successfully, FALSE otherwise
3089 # @ingroup l2_modif_edit
3090 def Make2DMeshFrom3D(self):
3091 return self.editor. Make2DMeshFrom3D()
3093 ## Creates missing boundary elements
3094 # @param elements - elements whose boundary is to be checked:
3095 # mesh, group, sub-mesh or list of elements
3096 # if elements is mesh, it must be the mesh whose MakeBoundaryMesh() is called
3097 # @param dimension - defines type of boundary elements to create:
3098 # SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D
3099 # SMESH.BND_1DFROM3D creates mesh edges on all borders of free facets of 3D cells
3100 # @param groupName - a name of group to store created boundary elements in,
3101 # "" means not to create the group
3102 # @param meshName - a name of new mesh to store created boundary elements in,
3103 # "" means not to create the new mesh
3104 # @param toCopyElements - if true, the checked elements will be copied into
3105 # the new mesh else only boundary elements will be copied into the new mesh
3106 # @param toCopyExistingBondary - if true, not only new but also pre-existing
3107 # boundary elements will be copied into the new mesh
3108 # @return tuple (mesh, group) where bondary elements were added to
3109 # @ingroup l2_modif_edit
3110 def MakeBoundaryMesh(self, elements, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3111 toCopyElements=False, toCopyExistingBondary=False):
3112 if isinstance( elements, Mesh ):
3113 elements = elements.GetMesh()
3114 if ( isinstance( elements, list )):
3115 elemType = SMESH.ALL
3116 if elements: elemType = self.GetElementType( elements[0], iselem=True)
3117 elements = self.editor.MakeIDSource(elements, elemType)
3118 mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName,
3119 toCopyElements,toCopyExistingBondary)
3120 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3124 # @brief Creates missing boundary elements around either the whole mesh or
3125 # groups of 2D elements
3126 # @param dimension - defines type of boundary elements to create
3127 # @param groupName - a name of group to store all boundary elements in,
3128 # "" means not to create the group
3129 # @param meshName - a name of a new mesh, which is a copy of the initial
3130 # mesh + created boundary elements; "" means not to create the new mesh
3131 # @param toCopyAll - if true, the whole initial mesh will be copied into
3132 # the new mesh else only boundary elements will be copied into the new mesh
3133 # @param groups - groups of 2D elements to make boundary around
3134 # @retval tuple( long, mesh, groups )
3135 # long - number of added boundary elements
3136 # mesh - the mesh where elements were added to
3137 # group - the group of boundary elements or None
3139 def MakeBoundaryElements(self, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3140 toCopyAll=False, groups=[]):
3141 nb, mesh, group = self.editor.MakeBoundaryElements(dimension,groupName,meshName,
3143 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3144 return nb, mesh, group
3146 ## Renumber mesh nodes
3147 # @ingroup l2_modif_renumber
3148 def RenumberNodes(self):
3149 self.editor.RenumberNodes()
3151 ## Renumber mesh elements
3152 # @ingroup l2_modif_renumber
3153 def RenumberElements(self):
3154 self.editor.RenumberElements()
3156 ## Generates new elements by rotation of the elements around the axis
3157 # @param IDsOfElements the list of ids of elements to sweep
3158 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3159 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
3160 # @param NbOfSteps the number of steps
3161 # @param Tolerance tolerance
3162 # @param MakeGroups forces the generation of new groups from existing ones
3163 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3164 # of all steps, else - size of each step
3165 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3166 # @ingroup l2_modif_extrurev
3167 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
3168 MakeGroups=False, TotalAngle=False):
3170 if isinstance(AngleInRadians,str):
3172 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3174 AngleInRadians = DegreesToRadians(AngleInRadians)
3175 if IDsOfElements == []:
3176 IDsOfElements = self.GetElementsId()
3177 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3178 Axis = self.smeshpyD.GetAxisStruct(Axis)
3179 Axis,AxisParameters = ParseAxisStruct(Axis)
3180 if TotalAngle and NbOfSteps:
3181 AngleInRadians /= NbOfSteps
3182 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3183 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3184 self.mesh.SetParameters(Parameters)
3186 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
3187 AngleInRadians, NbOfSteps, Tolerance)
3188 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
3191 ## Generates new elements by rotation of the elements of object around the axis
3192 # @param theObject object which elements should be sweeped.
3193 # It can be a mesh, a sub mesh or a group.
3194 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3195 # @param AngleInRadians the angle of Rotation
3196 # @param NbOfSteps number of steps
3197 # @param Tolerance tolerance
3198 # @param MakeGroups forces the generation of new groups from existing ones
3199 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3200 # of all steps, else - size of each step
3201 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3202 # @ingroup l2_modif_extrurev
3203 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3204 MakeGroups=False, TotalAngle=False):
3206 if isinstance(AngleInRadians,str):
3208 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3210 AngleInRadians = DegreesToRadians(AngleInRadians)
3211 if ( isinstance( theObject, Mesh )):
3212 theObject = theObject.GetMesh()
3213 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3214 Axis = self.smeshpyD.GetAxisStruct(Axis)
3215 Axis,AxisParameters = ParseAxisStruct(Axis)
3216 if TotalAngle and NbOfSteps:
3217 AngleInRadians /= NbOfSteps
3218 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3219 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3220 self.mesh.SetParameters(Parameters)
3222 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
3223 NbOfSteps, Tolerance)
3224 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3227 ## Generates new elements by rotation of the elements of object around the axis
3228 # @param theObject object which elements should be sweeped.
3229 # It can be a mesh, a sub mesh or a group.
3230 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3231 # @param AngleInRadians the angle of Rotation
3232 # @param NbOfSteps number of steps
3233 # @param Tolerance tolerance
3234 # @param MakeGroups forces the generation of new groups from existing ones
3235 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3236 # of all steps, else - size of each step
3237 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3238 # @ingroup l2_modif_extrurev
3239 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3240 MakeGroups=False, TotalAngle=False):
3242 if isinstance(AngleInRadians,str):
3244 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3246 AngleInRadians = DegreesToRadians(AngleInRadians)
3247 if ( isinstance( theObject, Mesh )):
3248 theObject = theObject.GetMesh()
3249 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3250 Axis = self.smeshpyD.GetAxisStruct(Axis)
3251 Axis,AxisParameters = ParseAxisStruct(Axis)
3252 if TotalAngle and NbOfSteps:
3253 AngleInRadians /= NbOfSteps
3254 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3255 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3256 self.mesh.SetParameters(Parameters)
3258 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
3259 NbOfSteps, Tolerance)
3260 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3263 ## Generates new elements by rotation of the elements of object around the axis
3264 # @param theObject object which elements should be sweeped.
3265 # It can be a mesh, a sub mesh or a group.
3266 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3267 # @param AngleInRadians the angle of Rotation
3268 # @param NbOfSteps number of steps
3269 # @param Tolerance tolerance
3270 # @param MakeGroups forces the generation of new groups from existing ones
3271 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3272 # of all steps, else - size of each step
3273 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3274 # @ingroup l2_modif_extrurev
3275 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3276 MakeGroups=False, TotalAngle=False):
3278 if isinstance(AngleInRadians,str):
3280 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3282 AngleInRadians = DegreesToRadians(AngleInRadians)
3283 if ( isinstance( theObject, Mesh )):
3284 theObject = theObject.GetMesh()
3285 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3286 Axis = self.smeshpyD.GetAxisStruct(Axis)
3287 Axis,AxisParameters = ParseAxisStruct(Axis)
3288 if TotalAngle and NbOfSteps:
3289 AngleInRadians /= NbOfSteps
3290 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3291 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3292 self.mesh.SetParameters(Parameters)
3294 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
3295 NbOfSteps, Tolerance)
3296 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3299 ## Generates new elements by extrusion of the elements with given ids
3300 # @param IDsOfElements the list of elements ids for extrusion
3301 # @param StepVector vector or DirStruct, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3302 # @param NbOfSteps the number of steps
3303 # @param MakeGroups forces the generation of new groups from existing ones
3304 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3305 # @ingroup l2_modif_extrurev
3306 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
3307 if IDsOfElements == []:
3308 IDsOfElements = self.GetElementsId()
3309 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3310 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3311 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3312 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3313 Parameters = StepVectorParameters + var_separator + Parameters
3314 self.mesh.SetParameters(Parameters)
3316 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
3317 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
3320 ## Generates new elements by extrusion of the elements with given ids
3321 # @param IDsOfElements is ids of elements
3322 # @param StepVector vector, defining the direction and value of extrusion
3323 # @param NbOfSteps the number of steps
3324 # @param ExtrFlags sets flags for extrusion
3325 # @param SewTolerance uses for comparing locations of nodes if flag
3326 # EXTRUSION_FLAG_SEW is set
3327 # @param MakeGroups forces the generation of new groups from existing ones
3328 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3329 # @ingroup l2_modif_extrurev
3330 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
3331 ExtrFlags, SewTolerance, MakeGroups=False):
3332 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3333 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3335 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
3336 ExtrFlags, SewTolerance)
3337 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
3338 ExtrFlags, SewTolerance)
3341 ## Generates new elements by extrusion of the elements which belong to the object
3342 # @param theObject the object which elements should be processed.
3343 # It can be a mesh, a sub mesh or a group.
3344 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3345 # @param NbOfSteps the number of steps
3346 # @param MakeGroups forces the generation of new groups from existing ones
3347 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3348 # @ingroup l2_modif_extrurev
3349 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3350 if ( isinstance( theObject, Mesh )):
3351 theObject = theObject.GetMesh()
3352 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3353 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3354 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3355 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3356 Parameters = StepVectorParameters + var_separator + Parameters
3357 self.mesh.SetParameters(Parameters)
3359 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3360 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
3363 ## Generates new elements by extrusion of the elements which belong to the object
3364 # @param theObject object which elements should be processed.
3365 # It can be a mesh, a sub mesh or a group.
3366 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3367 # @param NbOfSteps the number of steps
3368 # @param MakeGroups to generate new groups from existing ones
3369 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3370 # @ingroup l2_modif_extrurev
3371 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3372 if ( isinstance( theObject, Mesh )):
3373 theObject = theObject.GetMesh()
3374 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3375 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3376 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3377 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3378 Parameters = StepVectorParameters + var_separator + Parameters
3379 self.mesh.SetParameters(Parameters)
3381 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3382 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3385 ## Generates new elements by extrusion of the elements which belong to the object
3386 # @param theObject object which elements should be processed.
3387 # It can be a mesh, a sub mesh or a group.
3388 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3389 # @param NbOfSteps the number of steps
3390 # @param MakeGroups forces the generation of new groups from existing ones
3391 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3392 # @ingroup l2_modif_extrurev
3393 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3394 if ( isinstance( theObject, Mesh )):
3395 theObject = theObject.GetMesh()
3396 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3397 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3398 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3399 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3400 Parameters = StepVectorParameters + var_separator + Parameters
3401 self.mesh.SetParameters(Parameters)
3403 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3404 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3409 ## Generates new elements by extrusion of the given elements
3410 # The path of extrusion must be a meshed edge.
3411 # @param Base mesh or group, or submesh, or list of ids of elements for extrusion
3412 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3413 # @param NodeStart the start node from Path. Defines the direction of extrusion
3414 # @param HasAngles allows the shape to be rotated around the path
3415 # to get the resulting mesh in a helical fashion
3416 # @param Angles list of angles in radians
3417 # @param LinearVariation forces the computation of rotation angles as linear
3418 # variation of the given Angles along path steps
3419 # @param HasRefPoint allows using the reference point
3420 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3421 # The User can specify any point as the Reference Point.
3422 # @param MakeGroups forces the generation of new groups from existing ones
3423 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3424 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3425 # only SMESH::Extrusion_Error otherwise
3426 # @ingroup l2_modif_extrurev
3427 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3428 HasAngles, Angles, LinearVariation,
3429 HasRefPoint, RefPoint, MakeGroups, ElemType):
3430 Angles,AnglesParameters = ParseAngles(Angles)
3431 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3432 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3433 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3435 Parameters = AnglesParameters + var_separator + RefPointParameters
3436 self.mesh.SetParameters(Parameters)
3438 if (isinstance(Path, Mesh)): Path = Path.GetMesh()
3440 if isinstance(Base, list):
3442 if Base == []: IDsOfElements = self.GetElementsId()
3443 else: IDsOfElements = Base
3444 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3445 HasAngles, Angles, LinearVariation,
3446 HasRefPoint, RefPoint, MakeGroups, ElemType)
3448 if isinstance(Base, Mesh): Base = Base.GetMesh()
3449 if isinstance(Base, SMESH._objref_SMESH_Mesh) or isinstance(Base, SMESH._objref_SMESH_Group) or isinstance(Base, SMESH._objref_SMESH_subMesh):
3450 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3451 HasAngles, Angles, LinearVariation,
3452 HasRefPoint, RefPoint, MakeGroups, ElemType)
3454 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3457 ## Generates new elements by extrusion of the given elements
3458 # The path of extrusion must be a meshed edge.
3459 # @param IDsOfElements ids of elements
3460 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3461 # @param PathShape shape(edge) defines the sub-mesh for the path
3462 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3463 # @param HasAngles allows the shape to be rotated around the path
3464 # to get the resulting mesh in a helical fashion
3465 # @param Angles list of angles in radians
3466 # @param HasRefPoint allows using the reference point
3467 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3468 # The User can specify any point as the Reference Point.
3469 # @param MakeGroups forces the generation of new groups from existing ones
3470 # @param LinearVariation forces the computation of rotation angles as linear
3471 # variation of the given Angles along path steps
3472 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3473 # only SMESH::Extrusion_Error otherwise
3474 # @ingroup l2_modif_extrurev
3475 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3476 HasAngles, Angles, HasRefPoint, RefPoint,
3477 MakeGroups=False, LinearVariation=False):
3478 Angles,AnglesParameters = ParseAngles(Angles)
3479 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3480 if IDsOfElements == []:
3481 IDsOfElements = self.GetElementsId()
3482 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3483 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3485 if ( isinstance( PathMesh, Mesh )):
3486 PathMesh = PathMesh.GetMesh()
3487 if HasAngles and Angles and LinearVariation:
3488 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3490 Parameters = AnglesParameters + var_separator + RefPointParameters
3491 self.mesh.SetParameters(Parameters)
3493 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3494 PathShape, NodeStart, HasAngles,
3495 Angles, HasRefPoint, RefPoint)
3496 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3497 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3499 ## Generates new elements by extrusion of the elements which belong to the object
3500 # The path of extrusion must be a meshed edge.
3501 # @param theObject the object which elements should be processed.
3502 # It can be a mesh, a sub mesh or a group.
3503 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3504 # @param PathShape shape(edge) defines the sub-mesh for the path
3505 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3506 # @param HasAngles allows the shape to be rotated around the path
3507 # to get the resulting mesh in a helical fashion
3508 # @param Angles list of angles
3509 # @param HasRefPoint allows using the reference point
3510 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3511 # The User can specify any point as the Reference Point.
3512 # @param MakeGroups forces the generation of new groups from existing ones
3513 # @param LinearVariation forces the computation of rotation angles as linear
3514 # variation of the given Angles along path steps
3515 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3516 # only SMESH::Extrusion_Error otherwise
3517 # @ingroup l2_modif_extrurev
3518 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3519 HasAngles, Angles, HasRefPoint, RefPoint,
3520 MakeGroups=False, LinearVariation=False):
3521 Angles,AnglesParameters = ParseAngles(Angles)
3522 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3523 if ( isinstance( theObject, Mesh )):
3524 theObject = theObject.GetMesh()
3525 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3526 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3527 if ( isinstance( PathMesh, Mesh )):
3528 PathMesh = PathMesh.GetMesh()
3529 if HasAngles and Angles and LinearVariation:
3530 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3532 Parameters = AnglesParameters + var_separator + RefPointParameters
3533 self.mesh.SetParameters(Parameters)
3535 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3536 PathShape, NodeStart, HasAngles,
3537 Angles, HasRefPoint, RefPoint)
3538 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3539 NodeStart, HasAngles, Angles, HasRefPoint,
3542 ## Generates new elements by extrusion of the elements which belong to the object
3543 # The path of extrusion must be a meshed edge.
3544 # @param theObject the object which elements should be processed.
3545 # It can be a mesh, a sub mesh or a group.
3546 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3547 # @param PathShape shape(edge) defines the sub-mesh for the path
3548 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3549 # @param HasAngles allows the shape to be rotated around the path
3550 # to get the resulting mesh in a helical fashion
3551 # @param Angles list of angles
3552 # @param HasRefPoint allows using the reference point
3553 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3554 # The User can specify any point as the Reference Point.
3555 # @param MakeGroups forces the generation of new groups from existing ones
3556 # @param LinearVariation forces the computation of rotation angles as linear
3557 # variation of the given Angles along path steps
3558 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3559 # only SMESH::Extrusion_Error otherwise
3560 # @ingroup l2_modif_extrurev
3561 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3562 HasAngles, Angles, HasRefPoint, RefPoint,
3563 MakeGroups=False, LinearVariation=False):
3564 Angles,AnglesParameters = ParseAngles(Angles)
3565 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3566 if ( isinstance( theObject, Mesh )):
3567 theObject = theObject.GetMesh()
3568 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3569 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3570 if ( isinstance( PathMesh, Mesh )):
3571 PathMesh = PathMesh.GetMesh()
3572 if HasAngles and Angles and LinearVariation:
3573 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3575 Parameters = AnglesParameters + var_separator + RefPointParameters
3576 self.mesh.SetParameters(Parameters)
3578 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3579 PathShape, NodeStart, HasAngles,
3580 Angles, HasRefPoint, RefPoint)
3581 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3582 NodeStart, HasAngles, Angles, HasRefPoint,
3585 ## Generates new elements by extrusion of the elements which belong to the object
3586 # The path of extrusion must be a meshed edge.
3587 # @param theObject the object which elements should be processed.
3588 # It can be a mesh, a sub mesh or a group.
3589 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3590 # @param PathShape shape(edge) defines the sub-mesh for the path
3591 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3592 # @param HasAngles allows the shape to be rotated around the path
3593 # to get the resulting mesh in a helical fashion
3594 # @param Angles list of angles
3595 # @param HasRefPoint allows using the reference point
3596 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3597 # The User can specify any point as the Reference Point.
3598 # @param MakeGroups forces the generation of new groups from existing ones
3599 # @param LinearVariation forces the computation of rotation angles as linear
3600 # variation of the given Angles along path steps
3601 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3602 # only SMESH::Extrusion_Error otherwise
3603 # @ingroup l2_modif_extrurev
3604 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3605 HasAngles, Angles, HasRefPoint, RefPoint,
3606 MakeGroups=False, LinearVariation=False):
3607 Angles,AnglesParameters = ParseAngles(Angles)
3608 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3609 if ( isinstance( theObject, Mesh )):
3610 theObject = theObject.GetMesh()
3611 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3612 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.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3622 PathShape, NodeStart, HasAngles,
3623 Angles, HasRefPoint, RefPoint)
3624 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3625 NodeStart, HasAngles, Angles, HasRefPoint,
3628 ## Creates a symmetrical copy of mesh elements
3629 # @param IDsOfElements list of elements ids
3630 # @param Mirror is AxisStruct or geom object(point, line, plane)
3631 # @param theMirrorType is POINT, AXIS or PLANE
3632 # If the Mirror is a geom object this parameter is unnecessary
3633 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3634 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3635 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3636 # @ingroup l2_modif_trsf
3637 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3638 if IDsOfElements == []:
3639 IDsOfElements = self.GetElementsId()
3640 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3641 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3642 Mirror,Parameters = ParseAxisStruct(Mirror)
3643 self.mesh.SetParameters(Parameters)
3644 if Copy and MakeGroups:
3645 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3646 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3649 ## Creates a new mesh by a symmetrical copy of mesh elements
3650 # @param IDsOfElements the list of elements ids
3651 # @param Mirror is AxisStruct or geom object (point, line, plane)
3652 # @param theMirrorType is POINT, AXIS or PLANE
3653 # If the Mirror is a geom object this parameter is unnecessary
3654 # @param MakeGroups to generate new groups from existing ones
3655 # @param NewMeshName a name of the new mesh to create
3656 # @return instance of Mesh class
3657 # @ingroup l2_modif_trsf
3658 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3659 if IDsOfElements == []:
3660 IDsOfElements = self.GetElementsId()
3661 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3662 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3663 Mirror,Parameters = ParseAxisStruct(Mirror)
3664 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3665 MakeGroups, NewMeshName)
3666 mesh.SetParameters(Parameters)
3667 return Mesh(self.smeshpyD,self.geompyD,mesh)
3669 ## Creates a symmetrical copy of the object
3670 # @param theObject mesh, submesh or group
3671 # @param Mirror AxisStruct or geom object (point, line, plane)
3672 # @param theMirrorType is POINT, AXIS or PLANE
3673 # If the Mirror is a geom object this parameter is unnecessary
3674 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3675 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3676 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3677 # @ingroup l2_modif_trsf
3678 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3679 if ( isinstance( theObject, Mesh )):
3680 theObject = theObject.GetMesh()
3681 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3682 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3683 Mirror,Parameters = ParseAxisStruct(Mirror)
3684 self.mesh.SetParameters(Parameters)
3685 if Copy and MakeGroups:
3686 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3687 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3690 ## Creates a new mesh by a symmetrical copy of the object
3691 # @param theObject mesh, submesh or group
3692 # @param Mirror AxisStruct or geom object (point, line, plane)
3693 # @param theMirrorType POINT, AXIS or PLANE
3694 # If the Mirror is a geom object this parameter is unnecessary
3695 # @param MakeGroups forces the generation of new groups from existing ones
3696 # @param NewMeshName the name of the new mesh to create
3697 # @return instance of Mesh class
3698 # @ingroup l2_modif_trsf
3699 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3700 if ( isinstance( theObject, Mesh )):
3701 theObject = theObject.GetMesh()
3702 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3703 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3704 Mirror,Parameters = ParseAxisStruct(Mirror)
3705 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3706 MakeGroups, NewMeshName)
3707 mesh.SetParameters(Parameters)
3708 return Mesh( self.smeshpyD,self.geompyD,mesh )
3710 ## Translates the elements
3711 # @param IDsOfElements list of elements ids
3712 # @param Vector the direction of translation (DirStruct or vector)
3713 # @param Copy allows copying the translated elements
3714 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3715 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3716 # @ingroup l2_modif_trsf
3717 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3718 if IDsOfElements == []:
3719 IDsOfElements = self.GetElementsId()
3720 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3721 Vector = self.smeshpyD.GetDirStruct(Vector)
3722 Vector,Parameters = ParseDirStruct(Vector)
3723 self.mesh.SetParameters(Parameters)
3724 if Copy and MakeGroups:
3725 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3726 self.editor.Translate(IDsOfElements, Vector, Copy)
3729 ## Creates a new mesh of translated elements
3730 # @param IDsOfElements list of elements ids
3731 # @param Vector the direction of translation (DirStruct or vector)
3732 # @param MakeGroups forces the generation of new groups from existing ones
3733 # @param NewMeshName the name of the newly created mesh
3734 # @return instance of Mesh class
3735 # @ingroup l2_modif_trsf
3736 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3737 if IDsOfElements == []:
3738 IDsOfElements = self.GetElementsId()
3739 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3740 Vector = self.smeshpyD.GetDirStruct(Vector)
3741 Vector,Parameters = ParseDirStruct(Vector)
3742 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3743 mesh.SetParameters(Parameters)
3744 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3746 ## Translates the object
3747 # @param theObject the object to translate (mesh, submesh, or group)
3748 # @param Vector direction of translation (DirStruct or geom vector)
3749 # @param Copy allows copying the translated elements
3750 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3751 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3752 # @ingroup l2_modif_trsf
3753 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3754 if ( isinstance( theObject, Mesh )):
3755 theObject = theObject.GetMesh()
3756 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3757 Vector = self.smeshpyD.GetDirStruct(Vector)
3758 Vector,Parameters = ParseDirStruct(Vector)
3759 self.mesh.SetParameters(Parameters)
3760 if Copy and MakeGroups:
3761 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3762 self.editor.TranslateObject(theObject, Vector, Copy)
3765 ## Creates a new mesh from the translated object
3766 # @param theObject the object to translate (mesh, submesh, or group)
3767 # @param Vector the direction of translation (DirStruct or geom vector)
3768 # @param MakeGroups forces the generation of new groups from existing ones
3769 # @param NewMeshName the name of the newly created mesh
3770 # @return instance of Mesh class
3771 # @ingroup l2_modif_trsf
3772 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3773 if (isinstance(theObject, Mesh)):
3774 theObject = theObject.GetMesh()
3775 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3776 Vector = self.smeshpyD.GetDirStruct(Vector)
3777 Vector,Parameters = ParseDirStruct(Vector)
3778 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3779 mesh.SetParameters(Parameters)
3780 return Mesh( self.smeshpyD, self.geompyD, mesh )
3784 ## Scales the object
3785 # @param theObject - the object to translate (mesh, submesh, or group)
3786 # @param thePoint - base point for scale
3787 # @param theScaleFact - list of 1-3 scale factors for axises
3788 # @param Copy - allows copying the translated elements
3789 # @param MakeGroups - forces the generation of new groups from existing
3791 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3792 # empty list otherwise
3793 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3794 if ( isinstance( theObject, Mesh )):
3795 theObject = theObject.GetMesh()
3796 if ( isinstance( theObject, list )):
3797 theObject = self.GetIDSource(theObject, SMESH.ALL)
3799 thePoint, Parameters = ParsePointStruct(thePoint)
3800 self.mesh.SetParameters(Parameters)
3802 if Copy and MakeGroups:
3803 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3804 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3807 ## Creates a new mesh from the translated object
3808 # @param theObject - the object to translate (mesh, submesh, or group)
3809 # @param thePoint - base point for scale
3810 # @param theScaleFact - list of 1-3 scale factors for axises
3811 # @param MakeGroups - forces the generation of new groups from existing ones
3812 # @param NewMeshName - the name of the newly created mesh
3813 # @return instance of Mesh class
3814 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3815 if (isinstance(theObject, Mesh)):
3816 theObject = theObject.GetMesh()
3817 if ( isinstance( theObject, list )):
3818 theObject = self.GetIDSource(theObject,SMESH.ALL)
3820 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3821 MakeGroups, NewMeshName)
3822 #mesh.SetParameters(Parameters)
3823 return Mesh( self.smeshpyD, self.geompyD, mesh )
3827 ## Rotates the elements
3828 # @param IDsOfElements list of elements ids
3829 # @param Axis the axis of rotation (AxisStruct or geom line)
3830 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3831 # @param Copy allows copying the rotated elements
3832 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3833 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3834 # @ingroup l2_modif_trsf
3835 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3837 if isinstance(AngleInRadians,str):
3839 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3841 AngleInRadians = DegreesToRadians(AngleInRadians)
3842 if IDsOfElements == []:
3843 IDsOfElements = self.GetElementsId()
3844 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3845 Axis = self.smeshpyD.GetAxisStruct(Axis)
3846 Axis,AxisParameters = ParseAxisStruct(Axis)
3847 Parameters = AxisParameters + var_separator + Parameters
3848 self.mesh.SetParameters(Parameters)
3849 if Copy and MakeGroups:
3850 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3851 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3854 ## Creates a new mesh of rotated elements
3855 # @param IDsOfElements list of element ids
3856 # @param Axis the axis of rotation (AxisStruct or geom line)
3857 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3858 # @param MakeGroups forces the generation of new groups from existing ones
3859 # @param NewMeshName the name of the newly created mesh
3860 # @return instance of Mesh class
3861 # @ingroup l2_modif_trsf
3862 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3864 if isinstance(AngleInRadians,str):
3866 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3868 AngleInRadians = DegreesToRadians(AngleInRadians)
3869 if IDsOfElements == []:
3870 IDsOfElements = self.GetElementsId()
3871 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3872 Axis = self.smeshpyD.GetAxisStruct(Axis)
3873 Axis,AxisParameters = ParseAxisStruct(Axis)
3874 Parameters = AxisParameters + var_separator + Parameters
3875 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3876 MakeGroups, NewMeshName)
3877 mesh.SetParameters(Parameters)
3878 return Mesh( self.smeshpyD, self.geompyD, mesh )
3880 ## Rotates the object
3881 # @param theObject the object to rotate( mesh, submesh, or group)
3882 # @param Axis the axis of rotation (AxisStruct or geom line)
3883 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3884 # @param Copy allows copying the rotated elements
3885 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3886 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3887 # @ingroup l2_modif_trsf
3888 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3890 if isinstance(AngleInRadians,str):
3892 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3894 AngleInRadians = DegreesToRadians(AngleInRadians)
3895 if (isinstance(theObject, Mesh)):
3896 theObject = theObject.GetMesh()
3897 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3898 Axis = self.smeshpyD.GetAxisStruct(Axis)
3899 Axis,AxisParameters = ParseAxisStruct(Axis)
3900 Parameters = AxisParameters + ":" + Parameters
3901 self.mesh.SetParameters(Parameters)
3902 if Copy and MakeGroups:
3903 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3904 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3907 ## Creates a new mesh from the rotated object
3908 # @param theObject the object to rotate (mesh, submesh, or group)
3909 # @param Axis the axis of rotation (AxisStruct or geom line)
3910 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3911 # @param MakeGroups forces the generation of new groups from existing ones
3912 # @param NewMeshName the name of the newly created mesh
3913 # @return instance of Mesh class
3914 # @ingroup l2_modif_trsf
3915 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3917 if isinstance(AngleInRadians,str):
3919 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3921 AngleInRadians = DegreesToRadians(AngleInRadians)
3922 if (isinstance( theObject, Mesh )):
3923 theObject = theObject.GetMesh()
3924 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3925 Axis = self.smeshpyD.GetAxisStruct(Axis)
3926 Axis,AxisParameters = ParseAxisStruct(Axis)
3927 Parameters = AxisParameters + ":" + Parameters
3928 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3929 MakeGroups, NewMeshName)
3930 mesh.SetParameters(Parameters)
3931 return Mesh( self.smeshpyD, self.geompyD, mesh )
3933 ## Finds groups of ajacent nodes within Tolerance.
3934 # @param Tolerance the value of tolerance
3935 # @return the list of groups of nodes
3936 # @ingroup l2_modif_trsf
3937 def FindCoincidentNodes (self, Tolerance):
3938 return self.editor.FindCoincidentNodes(Tolerance)
3940 ## Finds groups of ajacent nodes within Tolerance.
3941 # @param Tolerance the value of tolerance
3942 # @param SubMeshOrGroup SubMesh or Group
3943 # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
3944 # @return the list of groups of nodes
3945 # @ingroup l2_modif_trsf
3946 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
3947 if (isinstance( SubMeshOrGroup, Mesh )):
3948 SubMeshOrGroup = SubMeshOrGroup.GetMesh()
3949 if not isinstance( exceptNodes, list):
3950 exceptNodes = [ exceptNodes ]
3951 if exceptNodes and isinstance( exceptNodes[0], int):
3952 exceptNodes = [ self.GetIDSource( exceptNodes, SMESH.NODE)]
3953 return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes)
3956 # @param GroupsOfNodes the list of groups of nodes
3957 # @ingroup l2_modif_trsf
3958 def MergeNodes (self, GroupsOfNodes):
3959 self.editor.MergeNodes(GroupsOfNodes)
3961 ## Finds the elements built on the same nodes.
3962 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3963 # @return a list of groups of equal elements
3964 # @ingroup l2_modif_trsf
3965 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3966 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3967 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3968 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3970 ## Merges elements in each given group.
3971 # @param GroupsOfElementsID groups of elements for merging
3972 # @ingroup l2_modif_trsf
3973 def MergeElements(self, GroupsOfElementsID):
3974 self.editor.MergeElements(GroupsOfElementsID)
3976 ## Leaves one element and removes all other elements built on the same nodes.
3977 # @ingroup l2_modif_trsf
3978 def MergeEqualElements(self):
3979 self.editor.MergeEqualElements()
3981 ## Sews free borders
3982 # @return SMESH::Sew_Error
3983 # @ingroup l2_modif_trsf
3984 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3985 FirstNodeID2, SecondNodeID2, LastNodeID2,
3986 CreatePolygons, CreatePolyedrs):
3987 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3988 FirstNodeID2, SecondNodeID2, LastNodeID2,
3989 CreatePolygons, CreatePolyedrs)
3991 ## Sews conform free borders
3992 # @return SMESH::Sew_Error
3993 # @ingroup l2_modif_trsf
3994 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3995 FirstNodeID2, SecondNodeID2):
3996 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3997 FirstNodeID2, SecondNodeID2)
3999 ## Sews border to side
4000 # @return SMESH::Sew_Error
4001 # @ingroup l2_modif_trsf
4002 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
4003 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
4004 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
4005 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
4007 ## Sews two sides of a mesh. The nodes belonging to Side1 are
4008 # merged with the nodes of elements of Side2.
4009 # The number of elements in theSide1 and in theSide2 must be
4010 # equal and they should have similar nodal connectivity.
4011 # The nodes to merge should belong to side borders and
4012 # the first node should be linked to the second.
4013 # @return SMESH::Sew_Error
4014 # @ingroup l2_modif_trsf
4015 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
4016 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
4017 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
4018 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
4019 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
4020 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
4022 ## Sets new nodes for the given element.
4023 # @param ide the element id
4024 # @param newIDs nodes ids
4025 # @return If the number of nodes does not correspond to the type of element - returns false
4026 # @ingroup l2_modif_edit
4027 def ChangeElemNodes(self, ide, newIDs):
4028 return self.editor.ChangeElemNodes(ide, newIDs)
4030 ## If during the last operation of MeshEditor some nodes were
4031 # created, this method returns the list of their IDs, \n
4032 # if new nodes were not created - returns empty list
4033 # @return the list of integer values (can be empty)
4034 # @ingroup l1_auxiliary
4035 def GetLastCreatedNodes(self):
4036 return self.editor.GetLastCreatedNodes()
4038 ## If during the last operation of MeshEditor some elements were
4039 # created this method returns the list of their IDs, \n
4040 # if new elements were not created - returns empty list
4041 # @return the list of integer values (can be empty)
4042 # @ingroup l1_auxiliary
4043 def GetLastCreatedElems(self):
4044 return self.editor.GetLastCreatedElems()
4046 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4047 # @param theNodes identifiers of nodes to be doubled
4048 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
4049 # nodes. If list of element identifiers is empty then nodes are doubled but
4050 # they not assigned to elements
4051 # @return TRUE if operation has been completed successfully, FALSE otherwise
4052 # @ingroup l2_modif_edit
4053 def DoubleNodes(self, theNodes, theModifiedElems):
4054 return self.editor.DoubleNodes(theNodes, theModifiedElems)
4056 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4057 # This method provided for convenience works as DoubleNodes() described above.
4058 # @param theNodeId identifiers of node to be doubled
4059 # @param theModifiedElems identifiers of elements to be updated
4060 # @return TRUE if operation has been completed successfully, FALSE otherwise
4061 # @ingroup l2_modif_edit
4062 def DoubleNode(self, theNodeId, theModifiedElems):
4063 return self.editor.DoubleNode(theNodeId, theModifiedElems)
4065 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4066 # This method provided for convenience works as DoubleNodes() described above.
4067 # @param theNodes group of nodes to be doubled
4068 # @param theModifiedElems group of elements to be updated.
4069 # @param theMakeGroup forces the generation of a group containing new nodes.
4070 # @return TRUE or a created group if operation has been completed successfully,
4071 # FALSE or None otherwise
4072 # @ingroup l2_modif_edit
4073 def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
4075 return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
4076 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
4078 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4079 # This method provided for convenience works as DoubleNodes() described above.
4080 # @param theNodes list of groups of nodes to be doubled
4081 # @param theModifiedElems list of groups of elements to be updated.
4082 # @return TRUE if operation has been completed successfully, FALSE otherwise
4083 # @ingroup l2_modif_edit
4084 def DoubleNodeGroups(self, theNodes, theModifiedElems, theMakeGroup=False):
4086 return self.editor.DoubleNodeGroupsNew(theNodes, theModifiedElems)
4087 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
4089 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4090 # @param theElems - the list of elements (edges or faces) to be replicated
4091 # The nodes for duplication could be found from these elements
4092 # @param theNodesNot - list of nodes to NOT replicate
4093 # @param theAffectedElems - the list of elements (cells and edges) to which the
4094 # replicated nodes should be associated to.
4095 # @return TRUE if operation has been completed successfully, FALSE otherwise
4096 # @ingroup l2_modif_edit
4097 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
4098 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
4100 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4101 # @param theElems - the list of elements (edges or faces) to be replicated
4102 # The nodes for duplication could be found from these elements
4103 # @param theNodesNot - list of nodes to NOT replicate
4104 # @param theShape - shape to detect affected elements (element which geometric center
4105 # located on or inside shape).
4106 # The replicated nodes should be associated to affected elements.
4107 # @return TRUE if operation has been completed successfully, FALSE otherwise
4108 # @ingroup l2_modif_edit
4109 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
4110 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
4112 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4113 # This method provided for convenience works as DoubleNodes() described above.
4114 # @param theElems - group of of elements (edges or faces) to be replicated
4115 # @param theNodesNot - group of nodes not to replicated
4116 # @param theAffectedElems - group of elements to which the replicated nodes
4117 # should be associated to.
4118 # @param theMakeGroup forces the generation of a group containing new elements.
4119 # @return TRUE or a created group if operation has been completed successfully,
4120 # FALSE or None otherwise
4121 # @ingroup l2_modif_edit
4122 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4124 return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
4125 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
4127 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4128 # This method provided for convenience works as DoubleNodes() described above.
4129 # @param theElems - group of of elements (edges or faces) to be replicated
4130 # @param theNodesNot - group of nodes not to replicated
4131 # @param theShape - shape to detect affected elements (element which geometric center
4132 # located on or inside shape).
4133 # The replicated nodes should be associated to affected elements.
4134 # @ingroup l2_modif_edit
4135 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
4136 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
4138 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4139 # This method provided for convenience works as DoubleNodes() described above.
4140 # @param theElems - list of groups of elements (edges or faces) to be replicated
4141 # @param theNodesNot - list of groups of nodes not to replicated
4142 # @param theAffectedElems - group of elements to which the replicated nodes
4143 # should be associated to.
4144 # @param theMakeGroup forces the generation of a group containing new elements.
4145 # @return TRUE or a created group if operation has been completed successfully,
4146 # FALSE or None otherwise
4147 # @ingroup l2_modif_edit
4148 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4150 return self.editor.DoubleNodeElemGroupsNew(theElems, theNodesNot, theAffectedElems)
4151 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
4153 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4154 # This method provided for convenience works as DoubleNodes() described above.
4155 # @param theElems - list of groups of elements (edges or faces) to be replicated
4156 # @param theNodesNot - list of groups of nodes not to replicated
4157 # @param theShape - shape to detect affected elements (element which geometric center
4158 # located on or inside shape).
4159 # The replicated nodes should be associated to affected elements.
4160 # @return TRUE if operation has been completed successfully, FALSE otherwise
4161 # @ingroup l2_modif_edit
4162 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
4163 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
4165 ## Double nodes on shared faces between groups of volumes and create flat elements on demand.
4166 # The list of groups must describe a partition of the mesh volumes.
4167 # The nodes of the internal faces at the boundaries of the groups are doubled.
4168 # In option, the internal faces are replaced by flat elements.
4169 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4170 # @param theDomains - list of groups of volumes
4171 # @param createJointElems - if TRUE, create the elements
4172 # @return TRUE if operation has been completed successfully, FALSE otherwise
4173 def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems ):
4174 return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems )
4176 ## Double nodes on some external faces and create flat elements.
4177 # Flat elements are mainly used by some types of mechanic calculations.
4179 # Each group of the list must be constituted of faces.
4180 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4181 # @param theGroupsOfFaces - list of groups of faces
4182 # @return TRUE if operation has been completed successfully, FALSE otherwise
4183 def CreateFlatElementsOnFacesGroups(self, theGroupsOfFaces ):
4184 return self.editor.CreateFlatElementsOnFacesGroups( theGroupsOfFaces )
4186 def _valueFromFunctor(self, funcType, elemId):
4187 fn = self.smeshpyD.GetFunctor(funcType)
4188 fn.SetMesh(self.mesh)
4189 if fn.GetElementType() == self.GetElementType(elemId, True):
4190 val = fn.GetValue(elemId)
4195 ## Get length of 1D element.
4196 # @param elemId mesh element ID
4197 # @return element's length value
4198 # @ingroup l1_measurements
4199 def GetLength(self, elemId):
4200 return self._valueFromFunctor(SMESH.FT_Length, elemId)
4202 ## Get area of 2D element.
4203 # @param elemId mesh element ID
4204 # @return element's area value
4205 # @ingroup l1_measurements
4206 def GetArea(self, elemId):
4207 return self._valueFromFunctor(SMESH.FT_Area, elemId)
4209 ## Get volume of 3D element.
4210 # @param elemId mesh element ID
4211 # @return element's volume value
4212 # @ingroup l1_measurements
4213 def GetVolume(self, elemId):
4214 return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
4216 ## Get maximum element length.
4217 # @param elemId mesh element ID
4218 # @return element's maximum length value
4219 # @ingroup l1_measurements
4220 def GetMaxElementLength(self, elemId):
4221 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4222 ftype = SMESH.FT_MaxElementLength3D
4224 ftype = SMESH.FT_MaxElementLength2D
4225 return self._valueFromFunctor(ftype, elemId)
4227 ## Get aspect ratio of 2D or 3D element.
4228 # @param elemId mesh element ID
4229 # @return element's aspect ratio value
4230 # @ingroup l1_measurements
4231 def GetAspectRatio(self, elemId):
4232 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4233 ftype = SMESH.FT_AspectRatio3D
4235 ftype = SMESH.FT_AspectRatio
4236 return self._valueFromFunctor(ftype, elemId)
4238 ## Get warping angle of 2D element.
4239 # @param elemId mesh element ID
4240 # @return element's warping angle value
4241 # @ingroup l1_measurements
4242 def GetWarping(self, elemId):
4243 return self._valueFromFunctor(SMESH.FT_Warping, elemId)
4245 ## Get minimum angle of 2D element.
4246 # @param elemId mesh element ID
4247 # @return element's minimum angle value
4248 # @ingroup l1_measurements
4249 def GetMinimumAngle(self, elemId):
4250 return self._valueFromFunctor(SMESH.FT_MinimumAngle, elemId)
4252 ## Get taper of 2D element.
4253 # @param elemId mesh element ID
4254 # @return element's taper value
4255 # @ingroup l1_measurements
4256 def GetTaper(self, elemId):
4257 return self._valueFromFunctor(SMESH.FT_Taper, elemId)
4259 ## Get skew of 2D element.
4260 # @param elemId mesh element ID
4261 # @return element's skew value
4262 # @ingroup l1_measurements
4263 def GetSkew(self, elemId):
4264 return self._valueFromFunctor(SMESH.FT_Skew, elemId)
4266 ## The mother class to define algorithm, it is not recommended to use it directly.
4269 # @ingroup l2_algorithms
4270 class Mesh_Algorithm:
4271 # @class Mesh_Algorithm
4272 # @brief Class Mesh_Algorithm
4274 #def __init__(self,smesh):
4282 ## Finds a hypothesis in the study by its type name and parameters.
4283 # Finds only the hypotheses created in smeshpyD engine.
4284 # @return SMESH.SMESH_Hypothesis
4285 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
4286 study = smeshpyD.GetCurrentStudy()
4287 #to do: find component by smeshpyD object, not by its data type
4288 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4289 if scomp is not None:
4290 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
4291 # Check if the root label of the hypotheses exists
4292 if res and hypRoot is not None:
4293 iter = study.NewChildIterator(hypRoot)
4294 # Check all published hypotheses
4296 hypo_so_i = iter.Value()
4297 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
4298 if attr is not None:
4299 anIOR = attr.Value()
4300 hypo_o_i = salome.orb.string_to_object(anIOR)
4301 if hypo_o_i is not None:
4302 # Check if this is a hypothesis
4303 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
4304 if hypo_i is not None:
4305 # Check if the hypothesis belongs to current engine
4306 if smeshpyD.GetObjectId(hypo_i) > 0:
4307 # Check if this is the required hypothesis
4308 if hypo_i.GetName() == hypname:
4310 if CompareMethod(hypo_i, args):
4324 ## Finds the algorithm in the study by its type name.
4325 # Finds only the algorithms, which have been created in smeshpyD engine.
4326 # @return SMESH.SMESH_Algo
4327 def FindAlgorithm (self, algoname, smeshpyD):
4328 study = smeshpyD.GetCurrentStudy()
4329 #to do: find component by smeshpyD object, not by its data type
4330 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4331 if scomp is not None:
4332 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
4333 # Check if the root label of the algorithms exists
4334 if res and hypRoot is not None:
4335 iter = study.NewChildIterator(hypRoot)
4336 # Check all published algorithms
4338 algo_so_i = iter.Value()
4339 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
4340 if attr is not None:
4341 anIOR = attr.Value()
4342 algo_o_i = salome.orb.string_to_object(anIOR)
4343 if algo_o_i is not None:
4344 # Check if this is an algorithm
4345 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
4346 if algo_i is not None:
4347 # Checks if the algorithm belongs to the current engine
4348 if smeshpyD.GetObjectId(algo_i) > 0:
4349 # Check if this is the required algorithm
4350 if algo_i.GetName() == algoname:
4363 ## If the algorithm is global, returns 0; \n
4364 # else returns the submesh associated to this algorithm.
4365 def GetSubMesh(self):
4368 ## Returns the wrapped mesher.
4369 def GetAlgorithm(self):
4372 ## Gets the list of hypothesis that can be used with this algorithm
4373 def GetCompatibleHypothesis(self):
4376 mylist = self.algo.GetCompatibleHypothesis()
4379 ## Gets the name of the algorithm
4383 ## Sets the name to the algorithm
4384 def SetName(self, name):
4385 self.mesh.smeshpyD.SetName(self.algo, name)
4387 ## Gets the id of the algorithm
4389 return self.algo.GetId()
4392 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
4394 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
4395 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
4397 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
4399 self.Assign(algo, mesh, geom)
4403 def Assign(self, algo, mesh, geom):
4405 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
4409 self.geom = mesh.geom
4412 AssureGeomPublished( mesh, geom )
4414 name = GetName(geom)
4418 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
4420 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
4421 TreatHypoStatus( status, algo.GetName(), name, True )
4424 def CompareHyp (self, hyp, args):
4425 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
4428 def CompareEqualHyp (self, hyp, args):
4432 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
4433 UseExisting=0, CompareMethod=""):
4436 if CompareMethod == "": CompareMethod = self.CompareHyp
4437 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
4440 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
4446 a = a + s + str(args[i])
4450 self.mesh.smeshpyD.SetName(hypo, hyp + a)
4454 geomName = GetName(self.geom)
4455 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
4456 TreatHypoStatus( status, GetName(hypo), geomName, 0 )
4459 ## Returns entry of the shape to mesh in the study
4460 def MainShapeEntry(self):
4462 if not self.mesh or not self.mesh.GetMesh(): return entry
4463 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
4464 study = self.mesh.smeshpyD.GetCurrentStudy()
4465 ior = salome.orb.object_to_string( self.mesh.GetShape() )
4466 sobj = study.FindObjectIOR(ior)
4467 if sobj: entry = sobj.GetID()
4468 if not entry: return ""
4471 ## Defines "ViscousLayers" hypothesis to give parameters of layers of prisms to build
4472 # near mesh boundary. This hypothesis can be used by several 3D algorithms:
4473 # NETGEN 3D, GHS3D, Hexahedron(i,j,k)
4474 # @param thickness total thickness of layers of prisms
4475 # @param numberOfLayers number of layers of prisms
4476 # @param stretchFactor factor (>1.0) of growth of layer thickness towards inside of mesh
4477 # @param ignoreFaces list of geometrical faces (or their ids) not to generate layers on
4478 # @ingroup l3_hypos_additi
4479 def ViscousLayers(self, thickness, numberOfLayers, stretchFactor, ignoreFaces=[]):
4480 if not isinstance(self.algo, SMESH._objref_SMESH_3D_Algo):
4481 raise TypeError, "ViscousLayers are supported by 3D algorithms only"
4482 if not "ViscousLayers" in self.GetCompatibleHypothesis():
4483 raise TypeError, "ViscousLayers are not supported by %s"%self.algo.GetName()
4484 if ignoreFaces and isinstance( ignoreFaces[0], geompyDC.GEOM._objref_GEOM_Object ):
4485 ignoreFaces = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, f) for f in ignoreFaces ]
4486 hyp = self.Hypothesis("ViscousLayers",
4487 [thickness, numberOfLayers, stretchFactor, ignoreFaces])
4488 hyp.SetTotalThickness(thickness)
4489 hyp.SetNumberLayers(numberOfLayers)
4490 hyp.SetStretchFactor(stretchFactor)
4491 hyp.SetIgnoreFaces(ignoreFaces)
4494 # Public class: Mesh_Segment
4495 # --------------------------
4497 ## Class to define a segment 1D algorithm for discretization
4500 # @ingroup l3_algos_basic
4501 class Mesh_Segment(Mesh_Algorithm):
4503 ## Private constructor.
4504 def __init__(self, mesh, geom=0):
4505 Mesh_Algorithm.__init__(self)
4506 self.Create(mesh, geom, "Regular_1D")
4508 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
4509 # @param l for the length of segments that cut an edge
4510 # @param UseExisting if ==true - searches for an existing hypothesis created with
4511 # the same parameters, else (default) - creates a new one
4512 # @param p precision, used for calculation of the number of segments.
4513 # The precision should be a positive, meaningful value within the range [0,1].
4514 # In general, the number of segments is calculated with the formula:
4515 # nb = ceil((edge_length / l) - p)
4516 # Function ceil rounds its argument to the higher integer.
4517 # So, p=0 means rounding of (edge_length / l) to the higher integer,
4518 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
4519 # p=1 means rounding of (edge_length / l) to the lower integer.
4520 # Default value is 1e-07.
4521 # @return an instance of StdMeshers_LocalLength hypothesis
4522 # @ingroup l3_hypos_1dhyps
4523 def LocalLength(self, l, UseExisting=0, p=1e-07):
4524 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
4525 CompareMethod=self.CompareLocalLength)
4531 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
4532 def CompareLocalLength(self, hyp, args):
4533 if IsEqual(hyp.GetLength(), args[0]):
4534 return IsEqual(hyp.GetPrecision(), args[1])
4537 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
4538 # @param length is optional maximal allowed length of segment, if it is omitted
4539 # the preestimated length is used that depends on geometry size
4540 # @param UseExisting if ==true - searches for an existing hypothesis created with
4541 # the same parameters, else (default) - create a new one
4542 # @return an instance of StdMeshers_MaxLength hypothesis
4543 # @ingroup l3_hypos_1dhyps
4544 def MaxSize(self, length=0.0, UseExisting=0):
4545 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
4548 hyp.SetLength(length)
4550 # set preestimated length
4551 gen = self.mesh.smeshpyD
4552 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
4553 self.mesh.GetMesh(), self.mesh.GetShape(),
4555 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
4557 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
4560 hyp.SetUsePreestimatedLength( length == 0.0 )
4563 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
4564 # @param n for the number of segments that cut an edge
4565 # @param s for the scale factor (optional)
4566 # @param reversedEdges is a list of edges to mesh using reversed orientation
4567 # @param UseExisting if ==true - searches for an existing hypothesis created with
4568 # the same parameters, else (default) - create a new one
4569 # @return an instance of StdMeshers_NumberOfSegments hypothesis
4570 # @ingroup l3_hypos_1dhyps
4571 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4572 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4573 reversedEdges, UseExisting = [], reversedEdges
4574 entry = self.MainShapeEntry()
4575 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4576 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4578 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
4579 UseExisting=UseExisting,
4580 CompareMethod=self.CompareNumberOfSegments)
4582 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
4583 UseExisting=UseExisting,
4584 CompareMethod=self.CompareNumberOfSegments)
4585 hyp.SetDistrType( 1 )
4586 hyp.SetScaleFactor(s)
4587 hyp.SetNumberOfSegments(n)
4588 hyp.SetReversedEdges( reversedEdges )
4589 hyp.SetObjectEntry( entry )
4593 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4594 def CompareNumberOfSegments(self, hyp, args):
4595 if hyp.GetNumberOfSegments() == args[0]:
4597 if hyp.GetReversedEdges() == args[1]:
4598 if not args[1] or hyp.GetObjectEntry() == args[2]:
4601 if hyp.GetReversedEdges() == args[2]:
4602 if not args[2] or hyp.GetObjectEntry() == args[3]:
4603 if hyp.GetDistrType() == 1:
4604 if IsEqual(hyp.GetScaleFactor(), args[1]):
4608 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4609 # @param start defines the length of the first segment
4610 # @param end defines the length of the last segment
4611 # @param reversedEdges is a list of edges to mesh using reversed orientation
4612 # @param UseExisting if ==true - searches for an existing hypothesis created with
4613 # the same parameters, else (default) - creates a new one
4614 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4615 # @ingroup l3_hypos_1dhyps
4616 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4617 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4618 reversedEdges, UseExisting = [], reversedEdges
4619 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4620 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4621 entry = self.MainShapeEntry()
4622 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
4623 UseExisting=UseExisting,
4624 CompareMethod=self.CompareArithmetic1D)
4625 hyp.SetStartLength(start)
4626 hyp.SetEndLength(end)
4627 hyp.SetReversedEdges( reversedEdges )
4628 hyp.SetObjectEntry( entry )
4632 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4633 def CompareArithmetic1D(self, hyp, args):
4634 if IsEqual(hyp.GetLength(1), args[0]):
4635 if IsEqual(hyp.GetLength(0), args[1]):
4636 if hyp.GetReversedEdges() == args[2]:
4637 if not args[2] or hyp.GetObjectEntry() == args[3]:
4642 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4643 # on curve from 0 to 1 (additionally it is neecessary to check
4644 # orientation of edges and create list of reversed edges if it is
4645 # needed) and sets numbers of segments between given points (default
4646 # values are equals 1
4647 # @param points defines the list of parameters on curve
4648 # @param nbSegs defines the list of numbers of segments
4649 # @param reversedEdges is a list of edges to mesh using reversed orientation
4650 # @param UseExisting if ==true - searches for an existing hypothesis created with
4651 # the same parameters, else (default) - creates a new one
4652 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4653 # @ingroup l3_hypos_1dhyps
4654 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4655 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4656 reversedEdges, UseExisting = [], reversedEdges
4657 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4658 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4659 entry = self.MainShapeEntry()
4660 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
4661 UseExisting=UseExisting,
4662 CompareMethod=self.CompareFixedPoints1D)
4663 hyp.SetPoints(points)
4664 hyp.SetNbSegments(nbSegs)
4665 hyp.SetReversedEdges(reversedEdges)
4666 hyp.SetObjectEntry(entry)
4670 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4671 ## as the given arguments
4672 def CompareFixedPoints1D(self, hyp, args):
4673 if hyp.GetPoints() == args[0]:
4674 if hyp.GetNbSegments() == args[1]:
4675 if hyp.GetReversedEdges() == args[2]:
4676 if not args[2] or hyp.GetObjectEntry() == args[3]:
4682 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4683 # @param start defines the length of the first segment
4684 # @param end defines the length of the last segment
4685 # @param reversedEdges is a list of edges to mesh using reversed orientation
4686 # @param UseExisting if ==true - searches for an existing hypothesis created with
4687 # the same parameters, else (default) - creates a new one
4688 # @return an instance of StdMeshers_StartEndLength hypothesis
4689 # @ingroup l3_hypos_1dhyps
4690 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4691 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4692 reversedEdges, UseExisting = [], reversedEdges
4693 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4694 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4695 entry = self.MainShapeEntry()
4696 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
4697 UseExisting=UseExisting,
4698 CompareMethod=self.CompareStartEndLength)
4699 hyp.SetStartLength(start)
4700 hyp.SetEndLength(end)
4701 hyp.SetReversedEdges( reversedEdges )
4702 hyp.SetObjectEntry( entry )
4705 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4706 def CompareStartEndLength(self, hyp, args):
4707 if IsEqual(hyp.GetLength(1), args[0]):
4708 if IsEqual(hyp.GetLength(0), args[1]):
4709 if hyp.GetReversedEdges() == args[2]:
4710 if not args[2] or hyp.GetObjectEntry() == args[3]:
4714 ## Defines "Deflection1D" hypothesis
4715 # @param d for the deflection
4716 # @param UseExisting if ==true - searches for an existing hypothesis created with
4717 # the same parameters, else (default) - create a new one
4718 # @ingroup l3_hypos_1dhyps
4719 def Deflection1D(self, d, UseExisting=0):
4720 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4721 CompareMethod=self.CompareDeflection1D)
4722 hyp.SetDeflection(d)
4725 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4726 def CompareDeflection1D(self, hyp, args):
4727 return IsEqual(hyp.GetDeflection(), args[0])
4729 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4730 # the opposite side in case of quadrangular faces
4731 # @ingroup l3_hypos_additi
4732 def Propagation(self):
4733 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4735 ## Defines "AutomaticLength" hypothesis
4736 # @param fineness for the fineness [0-1]
4737 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4738 # same parameters, else (default) - create a new one
4739 # @ingroup l3_hypos_1dhyps
4740 def AutomaticLength(self, fineness=0, UseExisting=0):
4741 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4742 CompareMethod=self.CompareAutomaticLength)
4743 hyp.SetFineness( fineness )
4746 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4747 def CompareAutomaticLength(self, hyp, args):
4748 return IsEqual(hyp.GetFineness(), args[0])
4750 ## Defines "SegmentLengthAroundVertex" hypothesis
4751 # @param length for the segment length
4752 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4753 # Any other integer value means that the hypothesis will be set on the
4754 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4755 # @param UseExisting if ==true - searches for an existing hypothesis created with
4756 # the same parameters, else (default) - creates a new one
4757 # @ingroup l3_algos_segmarv
4758 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4760 store_geom = self.geom
4761 if type(vertex) is types.IntType:
4762 if vertex == 0 or vertex == 1:
4763 vertex = self.mesh.geompyD.ExtractShapes(self.geom, geompyDC.ShapeType["VERTEX"],True)[vertex]
4771 if self.geom is None:
4772 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4773 AssureGeomPublished( self.mesh, self.geom )
4774 name = GetName(self.geom)
4776 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4778 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4780 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4781 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4783 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4784 CompareMethod=self.CompareLengthNearVertex)
4785 self.geom = store_geom
4786 hyp.SetLength( length )
4789 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4790 # @ingroup l3_algos_segmarv
4791 def CompareLengthNearVertex(self, hyp, args):
4792 return IsEqual(hyp.GetLength(), args[0])
4794 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4795 # If the 2D mesher sees that all boundary edges are quadratic,
4796 # it generates quadratic faces, else it generates linear faces using
4797 # medium nodes as if they are vertices.
4798 # The 3D mesher generates quadratic volumes only if all boundary faces
4799 # are quadratic, else it fails.
4801 # @ingroup l3_hypos_additi
4802 def QuadraticMesh(self):
4803 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4806 # Public class: Mesh_CompositeSegment
4807 # --------------------------
4809 ## Defines a segment 1D algorithm for discretization
4811 # @ingroup l3_algos_basic
4812 class Mesh_CompositeSegment(Mesh_Segment):
4814 ## Private constructor.
4815 def __init__(self, mesh, geom=0):
4816 self.Create(mesh, geom, "CompositeSegment_1D")
4819 # Public class: Mesh_Segment_Python
4820 # ---------------------------------
4822 ## Defines a segment 1D algorithm for discretization with python function
4824 # @ingroup l3_algos_basic
4825 class Mesh_Segment_Python(Mesh_Segment):
4827 ## Private constructor.
4828 def __init__(self, mesh, geom=0):
4829 import Python1dPlugin
4830 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4832 ## Defines "PythonSplit1D" hypothesis
4833 # @param n for the number of segments that cut an edge
4834 # @param func for the python function that calculates the length of all segments
4835 # @param UseExisting if ==true - searches for the existing hypothesis created with
4836 # the same parameters, else (default) - creates a new one
4837 # @ingroup l3_hypos_1dhyps
4838 def PythonSplit1D(self, n, func, UseExisting=0):
4839 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4840 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4841 hyp.SetNumberOfSegments(n)
4842 hyp.SetPythonLog10RatioFunction(func)
4845 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4846 def ComparePythonSplit1D(self, hyp, args):
4847 #if hyp.GetNumberOfSegments() == args[0]:
4848 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4852 # Public class: Mesh_Triangle
4853 # ---------------------------
4855 ## Defines a triangle 2D algorithm
4857 # @ingroup l3_algos_basic
4858 class Mesh_Triangle(Mesh_Algorithm):
4867 ## Private constructor.
4868 def __init__(self, mesh, algoType, geom=0):
4869 Mesh_Algorithm.__init__(self)
4871 self.algoType = algoType
4872 if algoType == MEFISTO:
4873 self.Create(mesh, geom, "MEFISTO_2D")
4875 elif algoType == BLSURF:
4877 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4878 #self.SetPhysicalMesh() - PAL19680
4879 elif algoType == NETGEN:
4881 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4883 elif algoType == NETGEN_2D:
4885 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4888 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4889 # @param area for the maximum area of each triangle
4890 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4891 # same parameters, else (default) - creates a new one
4893 # Only for algoType == MEFISTO || NETGEN_2D
4894 # @ingroup l3_hypos_2dhyps
4895 def MaxElementArea(self, area, UseExisting=0):
4896 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4897 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4898 CompareMethod=self.CompareMaxElementArea)
4899 elif self.algoType == NETGEN:
4900 hyp = self.Parameters(SIMPLE)
4901 hyp.SetMaxElementArea(area)
4904 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4905 def CompareMaxElementArea(self, hyp, args):
4906 return IsEqual(hyp.GetMaxElementArea(), args[0])
4908 ## Defines "LengthFromEdges" hypothesis to build triangles
4909 # based on the length of the edges taken from the wire
4911 # Only for algoType == MEFISTO || NETGEN_2D
4912 # @ingroup l3_hypos_2dhyps
4913 def LengthFromEdges(self):
4914 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4915 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4917 elif self.algoType == NETGEN:
4918 hyp = self.Parameters(SIMPLE)
4919 hyp.LengthFromEdges()
4922 ## Sets a way to define size of mesh elements to generate.
4923 # @param thePhysicalMesh is: DefaultSize or Custom.
4924 # @ingroup l3_hypos_blsurf
4925 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4926 # Parameter of BLSURF algo
4927 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4929 ## Sets size of mesh elements to generate.
4930 # @ingroup l3_hypos_blsurf
4931 def SetPhySize(self, theVal):
4932 # Parameter of BLSURF algo
4933 self.SetPhysicalMesh(1) #Custom - else why to set the size?
4934 self.Parameters().SetPhySize(theVal)
4936 ## Sets lower boundary of mesh element size (PhySize).
4937 # @ingroup l3_hypos_blsurf
4938 def SetPhyMin(self, theVal=-1):
4939 # Parameter of BLSURF algo
4940 self.Parameters().SetPhyMin(theVal)
4942 ## Sets upper boundary of mesh element size (PhySize).
4943 # @ingroup l3_hypos_blsurf
4944 def SetPhyMax(self, theVal=-1):
4945 # Parameter of BLSURF algo
4946 self.Parameters().SetPhyMax(theVal)
4948 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4949 # @param theGeometricMesh is: 0 (None) or 1 (Custom)
4950 # @ingroup l3_hypos_blsurf
4951 def SetGeometricMesh(self, theGeometricMesh=0):
4952 # Parameter of BLSURF algo
4953 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4954 self.params.SetGeometricMesh(theGeometricMesh)
4956 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4957 # @ingroup l3_hypos_blsurf
4958 def SetAngleMeshS(self, theVal=_angleMeshS):
4959 # Parameter of BLSURF algo
4960 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4961 self.params.SetAngleMeshS(theVal)
4963 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4964 # @ingroup l3_hypos_blsurf
4965 def SetAngleMeshC(self, theVal=_angleMeshS):
4966 # Parameter of BLSURF algo
4967 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4968 self.params.SetAngleMeshC(theVal)
4970 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4971 # @ingroup l3_hypos_blsurf
4972 def SetGeoMin(self, theVal=-1):
4973 # Parameter of BLSURF algo
4974 self.Parameters().SetGeoMin(theVal)
4976 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4977 # @ingroup l3_hypos_blsurf
4978 def SetGeoMax(self, theVal=-1):
4979 # Parameter of BLSURF algo
4980 self.Parameters().SetGeoMax(theVal)
4982 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4983 # @ingroup l3_hypos_blsurf
4984 def SetGradation(self, theVal=_gradation):
4985 # Parameter of BLSURF algo
4986 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4987 self.params.SetGradation(theVal)
4989 ## Sets topology usage way.
4990 # @param way defines how mesh conformity is assured <ul>
4991 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4992 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4993 # @ingroup l3_hypos_blsurf
4994 def SetTopology(self, way):
4995 # Parameter of BLSURF algo
4996 self.Parameters().SetTopology(way)
4998 ## To respect geometrical edges or not.
4999 # @ingroup l3_hypos_blsurf
5000 def SetDecimesh(self, toIgnoreEdges=False):
5001 # Parameter of BLSURF algo
5002 self.Parameters().SetDecimesh(toIgnoreEdges)
5004 ## Sets verbosity level in the range 0 to 100.
5005 # @ingroup l3_hypos_blsurf
5006 def SetVerbosity(self, level):
5007 # Parameter of BLSURF algo
5008 self.Parameters().SetVerbosity(level)
5010 ## Sets advanced option value.
5011 # @ingroup l3_hypos_blsurf
5012 def SetOptionValue(self, optionName, level):
5013 # Parameter of BLSURF algo
5014 self.Parameters().SetOptionValue(optionName,level)
5016 ## 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 ]
5017 # @param theFace : face on which the attractor will be defined
5018 # @param theAttractor : geometrical object from which the mesh size "h" decreases exponentially
5019 # @param theStartSize : mesh size on theAttractor
5020 # @param theEndSize : maximum size that will be reached on theFace
5021 # @param theInfluenceDistance : influence of the attractor ( the size grow slower on theFace if it's high)
5022 # @param theConstantSizeDistance : distance until which the mesh size will be kept constant on theFace
5023 # @ingroup l3_hypos_blsurf
5024 def SetAttractorGeom(self, theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance):
5025 AssureGeomPublished( self.mesh, theFace )
5026 AssureGeomPublished( self.mesh, theAttractor )
5027 # Parameter of BLSURF algo
5028 self.Parameters().SetAttractorGeom(theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance)
5030 ## Unsets an attractor on the chosen face.
5031 # @param theFace : face on which the attractor has to be removed
5032 # @ingroup l3_hypos_blsurf
5033 def UnsetAttractorGeom(self, theFace):
5034 AssureGeomPublished( self.mesh, theFace )
5035 # Parameter of BLSURF algo
5036 self.Parameters().SetAttractorGeom(theFace)
5038 ## Sets QuadAllowed flag.
5039 # Only for algoType == NETGEN(NETGEN_1D2D) || NETGEN_2D || BLSURF
5040 # @ingroup l3_hypos_netgen l3_hypos_blsurf
5041 def SetQuadAllowed(self, toAllow=True):
5042 if self.algoType == NETGEN_2D:
5045 hasSimpleHyps = False
5046 simpleHyps = ["QuadranglePreference","LengthFromEdges","MaxElementArea"]
5047 for hyp in self.mesh.GetHypothesisList( self.geom ):
5048 if hyp.GetName() in simpleHyps:
5049 hasSimpleHyps = True
5050 if hyp.GetName() == "QuadranglePreference":
5051 if not toAllow: # remove QuadranglePreference
5052 self.mesh.RemoveHypothesis( self.geom, hyp )
5058 if toAllow: # add QuadranglePreference
5059 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
5064 if self.Parameters():
5065 self.params.SetQuadAllowed(toAllow)
5068 ## Defines hypothesis having several parameters
5070 # @ingroup l3_hypos_netgen
5071 def Parameters(self, which=SOLE):
5073 if self.algoType == NETGEN:
5075 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
5076 "libNETGENEngine.so", UseExisting=0)
5078 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
5079 "libNETGENEngine.so", UseExisting=0)
5080 elif self.algoType == MEFISTO:
5081 print "Mefisto algo support no multi-parameter hypothesis"
5082 elif self.algoType == NETGEN_2D:
5083 self.params = self.Hypothesis("NETGEN_Parameters_2D_ONLY", [],
5084 "libNETGENEngine.so", UseExisting=0)
5085 elif self.algoType == BLSURF:
5086 self.params = self.Hypothesis("BLSURF_Parameters", [],
5087 "libBLSURFEngine.so", UseExisting=0)
5089 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
5094 # Only for algoType == NETGEN
5095 # @ingroup l3_hypos_netgen
5096 def SetMaxSize(self, theSize):
5097 if self.Parameters():
5098 self.params.SetMaxSize(theSize)
5100 ## Sets SecondOrder flag
5102 # Only for algoType == NETGEN
5103 # @ingroup l3_hypos_netgen
5104 def SetSecondOrder(self, theVal):
5105 if self.Parameters():
5106 self.params.SetSecondOrder(theVal)
5108 ## Sets Optimize flag
5110 # Only for algoType == NETGEN
5111 # @ingroup l3_hypos_netgen
5112 def SetOptimize(self, theVal):
5113 if self.Parameters():
5114 self.params.SetOptimize(theVal)
5117 # @param theFineness is:
5118 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5120 # Only for algoType == NETGEN
5121 # @ingroup l3_hypos_netgen
5122 def SetFineness(self, theFineness):
5123 if self.Parameters():
5124 self.params.SetFineness(theFineness)
5128 # Only for algoType == NETGEN
5129 # @ingroup l3_hypos_netgen
5130 def SetGrowthRate(self, theRate):
5131 if self.Parameters():
5132 self.params.SetGrowthRate(theRate)
5134 ## Sets NbSegPerEdge
5136 # Only for algoType == NETGEN
5137 # @ingroup l3_hypos_netgen
5138 def SetNbSegPerEdge(self, theVal):
5139 if self.Parameters():
5140 self.params.SetNbSegPerEdge(theVal)
5142 ## Sets NbSegPerRadius
5144 # Only for algoType == NETGEN
5145 # @ingroup l3_hypos_netgen
5146 def SetNbSegPerRadius(self, theVal):
5147 if self.Parameters():
5148 self.params.SetNbSegPerRadius(theVal)
5150 ## Sets number of segments overriding value set by SetLocalLength()
5152 # Only for algoType == NETGEN
5153 # @ingroup l3_hypos_netgen
5154 def SetNumberOfSegments(self, theVal):
5155 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5157 ## Sets number of segments overriding value set by SetNumberOfSegments()
5159 # Only for algoType == NETGEN
5160 # @ingroup l3_hypos_netgen
5161 def SetLocalLength(self, theVal):
5162 self.Parameters(SIMPLE).SetLocalLength(theVal)
5167 # Public class: Mesh_Quadrangle
5168 # -----------------------------
5170 ## Defines a quadrangle 2D algorithm
5172 # @ingroup l3_algos_basic
5173 class Mesh_Quadrangle(Mesh_Algorithm):
5177 ## Private constructor.
5178 def __init__(self, mesh, geom=0):
5179 Mesh_Algorithm.__init__(self)
5180 self.Create(mesh, geom, "Quadrangle_2D")
5183 ## Defines "QuadrangleParameters" hypothesis
5184 # @param quadType defines the algorithm of transition between differently descretized
5185 # sides of a geometrical face:
5186 # - QUAD_STANDARD - both triangles and quadrangles are possible in the transition
5187 # area along the finer meshed sides.
5188 # - QUAD_TRIANGLE_PREF - only triangles are built in the transition area along the
5189 # finer meshed sides.
5190 # - QUAD_QUADRANGLE_PREF - only quadrangles are built in the transition area along
5191 # the finer meshed sides, iff the total quantity of segments on
5192 # all four sides of the face is even (divisible by 2).
5193 # - QUAD_QUADRANGLE_PREF_REVERSED - same as QUAD_QUADRANGLE_PREF but the transition
5194 # area is located along the coarser meshed sides.
5195 # - QUAD_REDUCED - only quadrangles are built and the transition between the sides
5196 # is made gradually, layer by layer. This type has a limitation on
5197 # the number of segments: one pair of opposite sides must have the
5198 # same number of segments, the other pair must have an even difference
5199 # between the numbers of segments on the sides.
5200 # @param triangleVertex: vertex of a trilateral geometrical face, around which triangles
5201 # will be created while other elements will be quadrangles.
5202 # Vertex can be either a GEOM_Object or a vertex ID within the
5204 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5205 # the same parameters, else (default) - creates a new one
5206 # @ingroup l3_hypos_quad
5207 def QuadrangleParameters(self, quadType=StdMeshers.QUAD_STANDARD, triangleVertex=0, UseExisting=0):
5208 vertexID = triangleVertex
5209 if isinstance( triangleVertex, geompyDC.GEOM._objref_GEOM_Object ):
5210 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, triangleVertex )
5212 compFun = lambda hyp,args: \
5213 hyp.GetQuadType() == args[0] and \
5214 ( hyp.GetTriaVertex()==args[1] or ( hyp.GetTriaVertex()<1 and args[1]<1))
5215 self.params = self.Hypothesis("QuadrangleParams", [quadType,vertexID],
5216 UseExisting = UseExisting, CompareMethod=compFun)
5218 if self.params.GetQuadType() != quadType:
5219 self.params.SetQuadType(quadType)
5221 self.params.SetTriaVertex( vertexID )
5224 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5225 # quadrangles are built in the transition area along the finer meshed sides,
5226 # iff the total quantity of segments on all four sides of the face is even.
5227 # @param reversed if True, transition area is located along the coarser meshed sides.
5228 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5229 # the same parameters, else (default) - creates a new one
5230 # @ingroup l3_hypos_quad
5231 def QuadranglePreference(self, reversed=False, UseExisting=0):
5233 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF_REVERSED,UseExisting=UseExisting)
5234 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF,UseExisting=UseExisting)
5236 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5237 # triangles are built in the transition area along the finer meshed sides.
5238 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5239 # the same parameters, else (default) - creates a new one
5240 # @ingroup l3_hypos_quad
5241 def TrianglePreference(self, UseExisting=0):
5242 return self.QuadrangleParameters(QUAD_TRIANGLE_PREF,UseExisting=UseExisting)
5244 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5245 # quadrangles are built and the transition between the sides is made gradually,
5246 # layer by layer. This type has a limitation on the number of segments: one pair
5247 # of opposite sides must have the same number of segments, the other pair must
5248 # have an even difference between the numbers of segments on the sides.
5249 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5250 # the same parameters, else (default) - creates a new one
5251 # @ingroup l3_hypos_quad
5252 def Reduced(self, UseExisting=0):
5253 return self.QuadrangleParameters(QUAD_REDUCED,UseExisting=UseExisting)
5255 ## Defines "QuadrangleParams" hypothesis with QUAD_STANDARD type of quadrangulation
5256 # @param vertex: vertex of a trilateral geometrical face, around which triangles
5257 # will be created while other elements will be quadrangles.
5258 # Vertex can be either a GEOM_Object or a vertex ID within the
5260 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5261 # the same parameters, else (default) - creates a new one
5262 # @ingroup l3_hypos_quad
5263 def TriangleVertex(self, vertex, UseExisting=0):
5264 return self.QuadrangleParameters(QUAD_STANDARD,vertex,UseExisting)
5267 # Public class: Mesh_Tetrahedron
5268 # ------------------------------
5270 ## Defines a tetrahedron 3D algorithm
5272 # @ingroup l3_algos_basic
5273 class Mesh_Tetrahedron(Mesh_Algorithm):
5278 ## Private constructor.
5279 def __init__(self, mesh, algoType, geom=0):
5280 Mesh_Algorithm.__init__(self)
5282 if algoType == NETGEN:
5284 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
5287 elif algoType == FULL_NETGEN:
5289 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5292 elif algoType == GHS3D:
5294 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
5297 elif algoType == GHS3DPRL:
5298 CheckPlugin(GHS3DPRL)
5299 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
5302 self.algoType = algoType
5304 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
5305 # @param vol for the maximum volume of each tetrahedron
5306 # @param UseExisting if ==true - searches for the existing hypothesis created with
5307 # the same parameters, else (default) - creates a new one
5308 # @ingroup l3_hypos_maxvol
5309 def MaxElementVolume(self, vol, UseExisting=0):
5310 if self.algoType == NETGEN:
5311 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
5312 CompareMethod=self.CompareMaxElementVolume)
5313 hyp.SetMaxElementVolume(vol)
5315 elif self.algoType == FULL_NETGEN:
5316 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
5319 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
5320 def CompareMaxElementVolume(self, hyp, args):
5321 return IsEqual(hyp.GetMaxElementVolume(), args[0])
5323 ## Defines hypothesis having several parameters
5325 # @ingroup l3_hypos_netgen
5326 def Parameters(self, which=SOLE):
5329 if self.algoType == FULL_NETGEN:
5331 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
5332 "libNETGENEngine.so", UseExisting=0)
5334 self.params = self.Hypothesis("NETGEN_Parameters", [],
5335 "libNETGENEngine.so", UseExisting=0)
5337 elif self.algoType == NETGEN:
5338 self.params = self.Hypothesis("NETGEN_Parameters_3D", [],
5339 "libNETGENEngine.so", UseExisting=0)
5341 elif self.algoType == GHS3D:
5342 self.params = self.Hypothesis("GHS3D_Parameters", [],
5343 "libGHS3DEngine.so", UseExisting=0)
5345 elif self.algoType == GHS3DPRL:
5346 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
5347 "libGHS3DPRLEngine.so", UseExisting=0)
5349 print "Warning: %s supports no multi-parameter hypothesis"%self.algo.GetName()
5354 # Parameter of FULL_NETGEN and NETGEN
5355 # @ingroup l3_hypos_netgen
5356 def SetMaxSize(self, theSize):
5357 self.Parameters().SetMaxSize(theSize)
5359 ## Sets SecondOrder flag
5360 # Parameter of FULL_NETGEN
5361 # @ingroup l3_hypos_netgen
5362 def SetSecondOrder(self, theVal):
5363 self.Parameters().SetSecondOrder(theVal)
5365 ## Sets Optimize flag
5366 # Parameter of FULL_NETGEN and NETGEN
5367 # @ingroup l3_hypos_netgen
5368 def SetOptimize(self, theVal):
5369 self.Parameters().SetOptimize(theVal)
5372 # @param theFineness is:
5373 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5374 # Parameter of FULL_NETGEN
5375 # @ingroup l3_hypos_netgen
5376 def SetFineness(self, theFineness):
5377 self.Parameters().SetFineness(theFineness)
5380 # Parameter of FULL_NETGEN
5381 # @ingroup l3_hypos_netgen
5382 def SetGrowthRate(self, theRate):
5383 self.Parameters().SetGrowthRate(theRate)
5385 ## Sets NbSegPerEdge
5386 # Parameter of FULL_NETGEN
5387 # @ingroup l3_hypos_netgen
5388 def SetNbSegPerEdge(self, theVal):
5389 self.Parameters().SetNbSegPerEdge(theVal)
5391 ## Sets NbSegPerRadius
5392 # Parameter of FULL_NETGEN
5393 # @ingroup l3_hypos_netgen
5394 def SetNbSegPerRadius(self, theVal):
5395 self.Parameters().SetNbSegPerRadius(theVal)
5397 ## Sets number of segments overriding value set by SetLocalLength()
5398 # Only for algoType == NETGEN_FULL
5399 # @ingroup l3_hypos_netgen
5400 def SetNumberOfSegments(self, theVal):
5401 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5403 ## Sets number of segments overriding value set by SetNumberOfSegments()
5404 # Only for algoType == NETGEN_FULL
5405 # @ingroup l3_hypos_netgen
5406 def SetLocalLength(self, theVal):
5407 self.Parameters(SIMPLE).SetLocalLength(theVal)
5409 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
5410 # Overrides value set by LengthFromEdges()
5411 # Only for algoType == NETGEN_FULL
5412 # @ingroup l3_hypos_netgen
5413 def MaxElementArea(self, area):
5414 self.Parameters(SIMPLE).SetMaxElementArea(area)
5416 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
5417 # Overrides value set by MaxElementArea()
5418 # Only for algoType == NETGEN_FULL
5419 # @ingroup l3_hypos_netgen
5420 def LengthFromEdges(self):
5421 self.Parameters(SIMPLE).LengthFromEdges()
5423 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
5424 # Overrides value set by MaxElementVolume()
5425 # Only for algoType == NETGEN_FULL
5426 # @ingroup l3_hypos_netgen
5427 def LengthFromFaces(self):
5428 self.Parameters(SIMPLE).LengthFromFaces()
5430 ## To mesh "holes" in a solid or not. Default is to mesh.
5431 # @ingroup l3_hypos_ghs3dh
5432 def SetToMeshHoles(self, toMesh):
5433 # Parameter of GHS3D
5434 self.Parameters().SetToMeshHoles(toMesh)
5436 ## Set Optimization level:
5437 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
5438 # Strong_Optimization.
5439 # Default is Standard_Optimization
5440 # @ingroup l3_hypos_ghs3dh
5441 def SetOptimizationLevel(self, level):
5442 # Parameter of GHS3D
5443 self.Parameters().SetOptimizationLevel(level)
5445 ## Maximal size of memory to be used by the algorithm (in Megabytes).
5446 # @ingroup l3_hypos_ghs3dh
5447 def SetMaximumMemory(self, MB):
5448 # Advanced parameter of GHS3D
5449 self.Parameters().SetMaximumMemory(MB)
5451 ## Initial size of memory to be used by the algorithm (in Megabytes) in
5452 # automatic memory adjustment mode.
5453 # @ingroup l3_hypos_ghs3dh
5454 def SetInitialMemory(self, MB):
5455 # Advanced parameter of GHS3D
5456 self.Parameters().SetInitialMemory(MB)
5458 ## Path to working directory.
5459 # @ingroup l3_hypos_ghs3dh
5460 def SetWorkingDirectory(self, path):
5461 # Advanced parameter of GHS3D
5462 self.Parameters().SetWorkingDirectory(path)
5464 ## To keep working files or remove them. Log file remains in case of errors anyway.
5465 # @ingroup l3_hypos_ghs3dh
5466 def SetKeepFiles(self, toKeep):
5467 # Advanced parameter of GHS3D and GHS3DPRL
5468 self.Parameters().SetKeepFiles(toKeep)
5470 ## To set verbose level [0-10]. <ul>
5471 #<li> 0 - no standard output,
5472 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
5473 # indicates when the final mesh is being saved. In addition the software
5474 # gives indication regarding the CPU time.
5475 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
5476 # histogram of the skin mesh, quality statistics histogram together with
5477 # the characteristics of the final mesh.</ul>
5478 # @ingroup l3_hypos_ghs3dh
5479 def SetVerboseLevel(self, level):
5480 # Advanced parameter of GHS3D
5481 self.Parameters().SetVerboseLevel(level)
5483 ## To create new nodes.
5484 # @ingroup l3_hypos_ghs3dh
5485 def SetToCreateNewNodes(self, toCreate):
5486 # Advanced parameter of GHS3D
5487 self.Parameters().SetToCreateNewNodes(toCreate)
5489 ## To use boundary recovery version which tries to create mesh on a very poor
5490 # quality surface mesh.
5491 # @ingroup l3_hypos_ghs3dh
5492 def SetToUseBoundaryRecoveryVersion(self, toUse):
5493 # Advanced parameter of GHS3D
5494 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
5496 ## Applies finite-element correction by replacing overconstrained elements where
5497 # it is possible. The process is cutting first the overconstrained edges and
5498 # second the overconstrained facets. This insure that no edges have two boundary
5499 # vertices and that no facets have three boundary vertices.
5500 # @ingroup l3_hypos_ghs3dh
5501 def SetFEMCorrection(self, toUseFem):
5502 # Advanced parameter of GHS3D
5503 self.Parameters().SetFEMCorrection(toUseFem)
5505 ## To removes initial central point.
5506 # @ingroup l3_hypos_ghs3dh
5507 def SetToRemoveCentralPoint(self, toRemove):
5508 # Advanced parameter of GHS3D
5509 self.Parameters().SetToRemoveCentralPoint(toRemove)
5511 ## To set an enforced vertex.
5512 # @ingroup l3_hypos_ghs3dh
5513 def SetEnforcedVertex(self, x, y, z, size):
5514 # Advanced parameter of GHS3D
5515 return self.Parameters().SetEnforcedVertex(x, y, z, size)
5517 ## To set an enforced vertex and add it in the group "groupName".
5518 # Only on meshes w/o geometry
5519 # @ingroup l3_hypos_ghs3dh
5520 def SetEnforcedVertexWithGroup(self, x, y, z, size, groupName):
5521 # Advanced parameter of GHS3D
5522 return self.Parameters().SetEnforcedVertex(x, y, z, size,groupName)
5524 ## To remove an enforced vertex.
5525 # @ingroup l3_hypos_ghs3dh
5526 def RemoveEnforcedVertex(self, x, y, z):
5527 # Advanced parameter of GHS3D
5528 return self.Parameters().RemoveEnforcedVertex(x, y, z)
5530 ## To set an enforced vertex given a GEOM vertex, group or compound.
5531 # @ingroup l3_hypos_ghs3dh
5532 def SetEnforcedVertexGeom(self, theVertex, size):
5533 AssureGeomPublished( self.mesh, theVertex )
5534 # Advanced parameter of GHS3D
5535 return self.Parameters().SetEnforcedVertexGeom(theVertex, size)
5537 ## To set an enforced vertex given a GEOM vertex, group or compound
5538 # and add it in the group "groupName".
5539 # Only on meshes w/o geometry
5540 # @ingroup l3_hypos_ghs3dh
5541 def SetEnforcedVertexGeomWithGroup(self, theVertex, size, groupName):
5542 AssureGeomPublished( self.mesh, theVertex )
5543 # Advanced parameter of GHS3D
5544 return self.Parameters().SetEnforcedVertexGeomWithGroup(theVertex, size,groupName)
5546 ## To remove an enforced vertex given a GEOM vertex, group or compound.
5547 # @ingroup l3_hypos_ghs3dh
5548 def RemoveEnforcedVertexGeom(self, theVertex):
5549 AssureGeomPublished( self.mesh, theVertex )
5550 # Advanced parameter of GHS3D
5551 return self.Parameters().RemoveEnforcedVertexGeom(theVertex)
5553 ## To set an enforced mesh.
5554 # @ingroup l3_hypos_ghs3dh
5555 def SetEnforcedMesh(self, theSource, elementType):
5556 # Advanced parameter of GHS3D
5557 return self.Parameters().SetEnforcedMesh(theSource, elementType)
5559 ## To set an enforced mesh and add the enforced elements in the group "groupName".
5560 # @ingroup l3_hypos_ghs3dh
5561 def SetEnforcedMeshWithGroup(self, theSource, elementType, groupName):
5562 # Advanced parameter of GHS3D
5563 return self.Parameters().SetEnforcedMeshWithGroup(theSource, elementType, groupName)
5565 ## To set an enforced mesh with given size.
5566 # @ingroup l3_hypos_ghs3dh
5567 def SetEnforcedMeshSize(self, theSource, elementType, size):
5568 # Advanced parameter of GHS3D
5569 return self.Parameters().SetEnforcedMeshSize(theSource, elementType, size)
5571 ## To set an enforced mesh with given size and add the enforced elements in the group "groupName".
5572 # @ingroup l3_hypos_ghs3dh
5573 def SetEnforcedMeshSizeWithGroup(self, theSource, elementType, size, groupName):
5574 # Advanced parameter of GHS3D
5575 return self.Parameters().SetEnforcedMeshSizeWithGroup(theSource, elementType, size, groupName)
5577 ## Sets command line option as text.
5578 # @ingroup l3_hypos_ghs3dh
5579 def SetTextOption(self, option):
5580 # Advanced parameter of GHS3D
5581 self.Parameters().SetTextOption(option)
5583 ## Sets MED files name and path.
5584 def SetMEDName(self, value):
5585 self.Parameters().SetMEDName(value)
5587 ## Sets the number of partition of the initial mesh
5588 def SetNbPart(self, value):
5589 self.Parameters().SetNbPart(value)
5591 ## When big mesh, start tepal in background
5592 def SetBackground(self, value):
5593 self.Parameters().SetBackground(value)
5595 # Public class: Mesh_Hexahedron
5596 # ------------------------------
5598 ## Defines a hexahedron 3D algorithm
5600 # @ingroup l3_algos_basic
5601 class Mesh_Hexahedron(Mesh_Algorithm):
5606 ## Private constructor.
5607 def __init__(self, mesh, algoType=Hexa, geom=0):
5608 Mesh_Algorithm.__init__(self)
5610 self.algoType = algoType
5612 if algoType == Hexa:
5613 self.Create(mesh, geom, "Hexa_3D")
5616 elif algoType == Hexotic:
5617 CheckPlugin(Hexotic)
5618 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
5621 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
5622 # @ingroup l3_hypos_hexotic
5623 def MinMaxQuad(self, min=3, max=8, quad=True):
5624 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
5626 self.params.SetHexesMinLevel(min)
5627 self.params.SetHexesMaxLevel(max)
5628 self.params.SetHexoticQuadrangles(quad)
5631 # Deprecated, only for compatibility!
5632 # Public class: Mesh_Netgen
5633 # ------------------------------
5635 ## Defines a NETGEN-based 2D or 3D algorithm
5636 # that needs no discrete boundary (i.e. independent)
5638 # This class is deprecated, only for compatibility!
5641 # @ingroup l3_algos_basic
5642 class Mesh_Netgen(Mesh_Algorithm):
5646 ## Private constructor.
5647 def __init__(self, mesh, is3D, geom=0):
5648 Mesh_Algorithm.__init__(self)
5654 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5658 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
5661 ## Defines the hypothesis containing parameters of the algorithm
5662 def Parameters(self):
5664 hyp = self.Hypothesis("NETGEN_Parameters", [],
5665 "libNETGENEngine.so", UseExisting=0)
5667 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
5668 "libNETGENEngine.so", UseExisting=0)
5671 # Public class: Mesh_Projection1D
5672 # ------------------------------
5674 ## Defines a projection 1D algorithm
5675 # @ingroup l3_algos_proj
5677 class Mesh_Projection1D(Mesh_Algorithm):
5679 ## Private constructor.
5680 def __init__(self, mesh, geom=0):
5681 Mesh_Algorithm.__init__(self)
5682 self.Create(mesh, geom, "Projection_1D")
5684 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
5685 # a mesh pattern is taken, and, optionally, the association of vertices
5686 # between the source edge and a target edge (to which a hypothesis is assigned)
5687 # @param edge from which nodes distribution is taken
5688 # @param mesh from which nodes distribution is taken (optional)
5689 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
5690 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
5691 # to associate with \a srcV (optional)
5692 # @param UseExisting if ==true - searches for the existing hypothesis created with
5693 # the same parameters, else (default) - creates a new one
5694 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
5695 AssureGeomPublished( self.mesh, edge )
5696 AssureGeomPublished( self.mesh, srcV )
5697 AssureGeomPublished( self.mesh, tgtV )
5698 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
5700 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
5701 hyp.SetSourceEdge( edge )
5702 if not mesh is None and isinstance(mesh, Mesh):
5703 mesh = mesh.GetMesh()
5704 hyp.SetSourceMesh( mesh )
5705 hyp.SetVertexAssociation( srcV, tgtV )
5708 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
5709 #def CompareSourceEdge(self, hyp, args):
5710 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
5714 # Public class: Mesh_Projection2D
5715 # ------------------------------
5717 ## Defines a projection 2D algorithm
5718 # @ingroup l3_algos_proj
5720 class Mesh_Projection2D(Mesh_Algorithm):
5722 ## Private constructor.
5723 def __init__(self, mesh, geom=0):
5724 Mesh_Algorithm.__init__(self)
5725 self.Create(mesh, geom, "Projection_2D")
5727 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
5728 # a mesh pattern is taken, and, optionally, the association of vertices
5729 # between the source face and the target face (to which a hypothesis is assigned)
5730 # @param face from which the mesh pattern is taken
5731 # @param mesh from which the mesh pattern is taken (optional)
5732 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
5733 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
5734 # to associate with \a srcV1 (optional)
5735 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
5736 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
5737 # to associate with \a srcV2 (optional)
5738 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
5739 # the same parameters, else (default) - forces the creation a new one
5741 # Note: all association vertices must belong to one edge of a face
5742 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
5743 srcV2=None, tgtV2=None, UseExisting=0):
5744 for geom in [ face, srcV1, tgtV1, srcV2, tgtV2 ]:
5745 AssureGeomPublished( self.mesh, geom )
5746 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
5748 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
5749 hyp.SetSourceFace( face )
5750 if isinstance(mesh, Mesh):
5751 mesh = mesh.GetMesh()
5752 hyp.SetSourceMesh( mesh )
5753 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5756 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
5757 #def CompareSourceFace(self, hyp, args):
5758 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
5761 # Public class: Mesh_Projection3D
5762 # ------------------------------
5764 ## Defines a projection 3D algorithm
5765 # @ingroup l3_algos_proj
5767 class Mesh_Projection3D(Mesh_Algorithm):
5769 ## Private constructor.
5770 def __init__(self, mesh, geom=0):
5771 Mesh_Algorithm.__init__(self)
5772 self.Create(mesh, geom, "Projection_3D")
5774 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
5775 # the mesh pattern is taken, and, optionally, the association of vertices
5776 # between the source and the target solid (to which a hipothesis is assigned)
5777 # @param solid from where the mesh pattern is taken
5778 # @param mesh from where the mesh pattern is taken (optional)
5779 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
5780 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
5781 # to associate with \a srcV1 (optional)
5782 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
5783 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
5784 # to associate with \a srcV2 (optional)
5785 # @param UseExisting - if ==true - searches for the existing hypothesis created with
5786 # the same parameters, else (default) - creates a new one
5788 # Note: association vertices must belong to one edge of a solid
5789 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
5790 srcV2=0, tgtV2=0, UseExisting=0):
5791 for geom in [ solid, srcV1, tgtV1, srcV2, tgtV2 ]:
5792 AssureGeomPublished( self.mesh, geom )
5793 hyp = self.Hypothesis("ProjectionSource3D",
5794 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
5796 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
5797 hyp.SetSource3DShape( solid )
5798 if not mesh is None and isinstance(mesh, Mesh):
5799 mesh = mesh.GetMesh()
5800 hyp.SetSourceMesh( mesh )
5801 if srcV1 and srcV2 and tgtV1 and tgtV2:
5802 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5803 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
5806 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
5807 #def CompareSourceShape3D(self, hyp, args):
5808 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
5812 # Public class: Mesh_Prism
5813 # ------------------------
5815 ## Defines a 3D extrusion algorithm
5816 # @ingroup l3_algos_3dextr
5818 class Mesh_Prism3D(Mesh_Algorithm):
5820 ## Private constructor.
5821 def __init__(self, mesh, geom=0):
5822 Mesh_Algorithm.__init__(self)
5823 self.Create(mesh, geom, "Prism_3D")
5825 # Public class: Mesh_RadialPrism
5826 # -------------------------------
5828 ## Defines a Radial Prism 3D algorithm
5829 # @ingroup l3_algos_radialp
5831 class Mesh_RadialPrism3D(Mesh_Algorithm):
5833 ## Private constructor.
5834 def __init__(self, mesh, geom=0):
5835 Mesh_Algorithm.__init__(self)
5836 self.Create(mesh, geom, "RadialPrism_3D")
5838 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
5839 self.nbLayers = None
5841 ## Return 3D hypothesis holding the 1D one
5842 def Get3DHypothesis(self):
5843 return self.distribHyp
5845 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5846 # hypothesis. Returns the created hypothesis
5847 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5848 #print "OwnHypothesis",hypType
5849 if not self.nbLayers is None:
5850 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5851 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5852 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5853 self.mesh.smeshpyD.SetCurrentStudy( None )
5854 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5855 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5856 self.distribHyp.SetLayerDistribution( hyp )
5859 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
5860 # prisms to build between the inner and outer shells
5861 # @param n number of layers
5862 # @param UseExisting if ==true - searches for the existing hypothesis created with
5863 # the same parameters, else (default) - creates a new one
5864 def NumberOfLayers(self, n, UseExisting=0):
5865 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5866 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
5867 CompareMethod=self.CompareNumberOfLayers)
5868 self.nbLayers.SetNumberOfLayers( n )
5869 return self.nbLayers
5871 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5872 def CompareNumberOfLayers(self, hyp, args):
5873 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5875 ## Defines "LocalLength" hypothesis, specifying the segment length
5876 # to build between the inner and the outer shells
5877 # @param l the length of segments
5878 # @param p the precision of rounding
5879 def LocalLength(self, l, p=1e-07):
5880 hyp = self.OwnHypothesis("LocalLength", [l,p])
5885 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
5886 # prisms to build between the inner and the outer shells.
5887 # @param n the number of layers
5888 # @param s the scale factor (optional)
5889 def NumberOfSegments(self, n, s=[]):
5891 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5893 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5894 hyp.SetDistrType( 1 )
5895 hyp.SetScaleFactor(s)
5896 hyp.SetNumberOfSegments(n)
5899 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5900 # to build between the inner and the outer shells with a length that changes in arithmetic progression
5901 # @param start the length of the first segment
5902 # @param end the length of the last segment
5903 def Arithmetic1D(self, start, end ):
5904 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5905 hyp.SetLength(start, 1)
5906 hyp.SetLength(end , 0)
5909 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5910 # to build between the inner and the outer shells as geometric length increasing
5911 # @param start for the length of the first segment
5912 # @param end for the length of the last segment
5913 def StartEndLength(self, start, end):
5914 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5915 hyp.SetLength(start, 1)
5916 hyp.SetLength(end , 0)
5919 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5920 # to build between the inner and outer shells
5921 # @param fineness defines the quality of the mesh within the range [0-1]
5922 def AutomaticLength(self, fineness=0):
5923 hyp = self.OwnHypothesis("AutomaticLength")
5924 hyp.SetFineness( fineness )
5927 # Public class: Mesh_RadialQuadrangle1D2D
5928 # -------------------------------
5930 ## Defines a Radial Quadrangle 1D2D algorithm
5931 # @ingroup l2_algos_radialq
5933 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
5935 ## Private constructor.
5936 def __init__(self, mesh, geom=0):
5937 Mesh_Algorithm.__init__(self)
5938 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5940 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
5941 self.nbLayers = None
5943 ## Return 2D hypothesis holding the 1D one
5944 def Get2DHypothesis(self):
5945 return self.distribHyp
5947 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5948 # hypothesis. Returns the created hypothesis
5949 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5950 #print "OwnHypothesis",hypType
5952 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5953 if self.distribHyp is None:
5954 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5956 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5957 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5958 self.mesh.smeshpyD.SetCurrentStudy( None )
5959 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5960 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5961 self.distribHyp.SetLayerDistribution( hyp )
5964 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
5965 # @param n number of layers
5966 # @param UseExisting if ==true - searches for the existing hypothesis created with
5967 # the same parameters, else (default) - creates a new one
5968 def NumberOfLayers(self, n, UseExisting=0):
5970 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5971 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5972 CompareMethod=self.CompareNumberOfLayers)
5973 self.nbLayers.SetNumberOfLayers( n )
5974 return self.nbLayers
5976 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5977 def CompareNumberOfLayers(self, hyp, args):
5978 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5980 ## Defines "LocalLength" hypothesis, specifying the segment length
5981 # @param l the length of segments
5982 # @param p the precision of rounding
5983 def LocalLength(self, l, p=1e-07):
5984 hyp = self.OwnHypothesis("LocalLength", [l,p])
5989 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5990 # @param n the number of layers
5991 # @param s the scale factor (optional)
5992 def NumberOfSegments(self, n, s=[]):
5994 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5996 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5997 hyp.SetDistrType( 1 )
5998 hyp.SetScaleFactor(s)
5999 hyp.SetNumberOfSegments(n)
6002 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
6003 # with a length that changes in arithmetic progression
6004 # @param start the length of the first segment
6005 # @param end the length of the last segment
6006 def Arithmetic1D(self, start, end ):
6007 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
6008 hyp.SetLength(start, 1)
6009 hyp.SetLength(end , 0)
6012 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
6013 # as geometric length increasing
6014 # @param start for the length of the first segment
6015 # @param end for the length of the last segment
6016 def StartEndLength(self, start, end):
6017 hyp = self.OwnHypothesis("StartEndLength", [start, end])
6018 hyp.SetLength(start, 1)
6019 hyp.SetLength(end , 0)
6022 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
6023 # @param fineness defines the quality of the mesh within the range [0-1]
6024 def AutomaticLength(self, fineness=0):
6025 hyp = self.OwnHypothesis("AutomaticLength")
6026 hyp.SetFineness( fineness )
6030 # Public class: Mesh_UseExistingElements
6031 # --------------------------------------
6032 ## Defines a Radial Quadrangle 1D2D algorithm
6033 # @ingroup l3_algos_basic
6035 class Mesh_UseExistingElements(Mesh_Algorithm):
6037 def __init__(self, dim, mesh, geom=0):
6039 self.Create(mesh, geom, "Import_1D")
6041 self.Create(mesh, geom, "Import_1D2D")
6044 ## Defines "Source edges" hypothesis, specifying groups of edges to import
6045 # @param groups list of groups of edges
6046 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
6047 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
6048 # @param UseExisting if ==true - searches for the existing hypothesis created with
6049 # the same parameters, else (default) - creates a new one
6050 def SourceEdges(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
6051 if self.algo.GetName() == "Import_2D":
6052 raise ValueError, "algoritm dimension mismatch"
6053 for group in groups:
6054 AssureGeomPublished( self.mesh, group )
6055 hyp = self.Hypothesis("ImportSource1D", [groups, toCopyMesh, toCopyGroups],
6056 UseExisting=UseExisting, CompareMethod=self._compareHyp)
6057 hyp.SetSourceEdges(groups)
6058 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
6061 ## Defines "Source faces" hypothesis, specifying groups of faces to import
6062 # @param groups list of groups of faces
6063 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
6064 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
6065 # @param UseExisting if ==true - searches for the existing hypothesis created with
6066 # the same parameters, else (default) - creates a new one
6067 def SourceFaces(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
6068 if self.algo.GetName() == "Import_1D":
6069 raise ValueError, "algoritm dimension mismatch"
6070 for group in groups:
6071 AssureGeomPublished( self.mesh, group )
6072 hyp = self.Hypothesis("ImportSource2D", [groups, toCopyMesh, toCopyGroups],
6073 UseExisting=UseExisting, CompareMethod=self._compareHyp)
6074 hyp.SetSourceFaces(groups)
6075 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
6078 def _compareHyp(self,hyp,args):
6079 if hasattr( hyp, "GetSourceEdges"):
6080 entries = hyp.GetSourceEdges()
6082 entries = hyp.GetSourceFaces()
6084 toCopyMesh,toCopyGroups = hyp.GetCopySourceMesh()
6085 if len(entries)==len(groups) and toCopyMesh==args[1] and toCopyGroups==args[2]:
6087 study = self.mesh.smeshpyD.GetCurrentStudy()
6090 ior = salome.orb.object_to_string(g)
6091 sobj = study.FindObjectIOR(ior)
6092 if sobj: entries2.append( sobj.GetID() )
6097 return entries == entries2
6101 # Private class: Mesh_UseExisting
6102 # -------------------------------
6103 class Mesh_UseExisting(Mesh_Algorithm):
6105 def __init__(self, dim, mesh, geom=0):
6107 self.Create(mesh, geom, "UseExisting_1D")
6109 self.Create(mesh, geom, "UseExisting_2D")
6112 import salome_notebook
6113 notebook = salome_notebook.notebook
6115 ##Return values of the notebook variables
6116 def ParseParameters(last, nbParams,nbParam, value):
6120 listSize = len(last)
6121 for n in range(0,nbParams):
6123 if counter < listSize:
6124 strResult = strResult + last[counter]
6126 strResult = strResult + ""
6128 if isinstance(value, str):
6129 if notebook.isVariable(value):
6130 result = notebook.get(value)
6131 strResult=strResult+value
6133 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
6135 strResult=strResult+str(value)
6137 if nbParams - 1 != counter:
6138 strResult=strResult+var_separator #":"
6140 return result, strResult
6142 #Wrapper class for StdMeshers_LocalLength hypothesis
6143 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
6145 ## Set Length parameter value
6146 # @param length numerical value or name of variable from notebook
6147 def SetLength(self, length):
6148 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
6149 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6150 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
6152 ## Set Precision parameter value
6153 # @param precision numerical value or name of variable from notebook
6154 def SetPrecision(self, precision):
6155 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
6156 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6157 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
6159 #Registering the new proxy for LocalLength
6160 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
6163 #Wrapper class for StdMeshers_LayerDistribution hypothesis
6164 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
6166 def SetLayerDistribution(self, hypo):
6167 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
6168 hypo.ClearParameters();
6169 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
6171 #Registering the new proxy for LayerDistribution
6172 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
6174 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
6175 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
6177 ## Set Length parameter value
6178 # @param length numerical value or name of variable from notebook
6179 def SetLength(self, length):
6180 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
6181 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
6182 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
6184 #Registering the new proxy for SegmentLengthAroundVertex
6185 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
6188 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
6189 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
6191 ## Set Length parameter value
6192 # @param length numerical value or name of variable from notebook
6193 # @param isStart true is length is Start Length, otherwise false
6194 def SetLength(self, length, isStart):
6198 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
6199 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
6200 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
6202 #Registering the new proxy for Arithmetic1D
6203 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
6205 #Wrapper class for StdMeshers_Deflection1D hypothesis
6206 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
6208 ## Set Deflection parameter value
6209 # @param deflection numerical value or name of variable from notebook
6210 def SetDeflection(self, deflection):
6211 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
6212 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
6213 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
6215 #Registering the new proxy for Deflection1D
6216 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
6218 #Wrapper class for StdMeshers_StartEndLength hypothesis
6219 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
6221 ## Set Length parameter value
6222 # @param length numerical value or name of variable from notebook
6223 # @param isStart true is length is Start Length, otherwise false
6224 def SetLength(self, length, isStart):
6228 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
6229 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
6230 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
6232 #Registering the new proxy for StartEndLength
6233 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
6235 #Wrapper class for StdMeshers_MaxElementArea hypothesis
6236 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
6238 ## Set Max Element Area parameter value
6239 # @param area numerical value or name of variable from notebook
6240 def SetMaxElementArea(self, area):
6241 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
6242 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
6243 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
6245 #Registering the new proxy for MaxElementArea
6246 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
6249 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
6250 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
6252 ## Set Max Element Volume parameter value
6253 # @param volume numerical value or name of variable from notebook
6254 def SetMaxElementVolume(self, volume):
6255 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
6256 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
6257 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
6259 #Registering the new proxy for MaxElementVolume
6260 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
6263 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
6264 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
6266 ## Set Number Of Layers parameter value
6267 # @param nbLayers numerical value or name of variable from notebook
6268 def SetNumberOfLayers(self, nbLayers):
6269 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
6270 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
6271 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
6273 #Registering the new proxy for NumberOfLayers
6274 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
6276 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
6277 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
6279 ## Set Number Of Segments parameter value
6280 # @param nbSeg numerical value or name of variable from notebook
6281 def SetNumberOfSegments(self, nbSeg):
6282 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
6283 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
6284 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6285 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
6287 ## Set Scale Factor parameter value
6288 # @param factor numerical value or name of variable from notebook
6289 def SetScaleFactor(self, factor):
6290 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
6291 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6292 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
6294 #Registering the new proxy for NumberOfSegments
6295 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
6297 if not noNETGENPlugin:
6298 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
6299 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
6301 ## Set Max Size parameter value
6302 # @param maxsize numerical value or name of variable from notebook
6303 def SetMaxSize(self, maxsize):
6304 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6305 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
6306 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6307 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
6309 ## Set Growth Rate parameter value
6310 # @param value numerical value or name of variable from notebook
6311 def SetGrowthRate(self, value):
6312 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6313 value, parameters = ParseParameters(lastParameters,4,2,value)
6314 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6315 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
6317 ## Set Number of Segments per Edge parameter value
6318 # @param value numerical value or name of variable from notebook
6319 def SetNbSegPerEdge(self, value):
6320 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6321 value, parameters = ParseParameters(lastParameters,4,3,value)
6322 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6323 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
6325 ## Set Number of Segments per Radius parameter value
6326 # @param value numerical value or name of variable from notebook
6327 def SetNbSegPerRadius(self, value):
6328 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6329 value, parameters = ParseParameters(lastParameters,4,4,value)
6330 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6331 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
6333 #Registering the new proxy for NETGENPlugin_Hypothesis
6334 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
6337 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
6338 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
6341 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
6342 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
6344 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
6345 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
6347 ## Set Number of Segments parameter value
6348 # @param nbSeg numerical value or name of variable from notebook
6349 def SetNumberOfSegments(self, nbSeg):
6350 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6351 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
6352 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6353 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
6355 ## Set Local Length parameter value
6356 # @param length numerical value or name of variable from notebook
6357 def SetLocalLength(self, length):
6358 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6359 length, parameters = ParseParameters(lastParameters,2,1,length)
6360 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6361 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
6363 ## Set Max Element Area parameter value
6364 # @param area numerical value or name of variable from notebook
6365 def SetMaxElementArea(self, area):
6366 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6367 area, parameters = ParseParameters(lastParameters,2,2,area)
6368 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6369 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
6371 def LengthFromEdges(self):
6372 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6374 value, parameters = ParseParameters(lastParameters,2,2,value)
6375 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6376 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
6378 #Registering the new proxy for NETGEN_SimpleParameters_2D
6379 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
6382 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
6383 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
6384 ## Set Max Element Volume parameter value
6385 # @param volume numerical value or name of variable from notebook
6386 def SetMaxElementVolume(self, volume):
6387 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6388 volume, parameters = ParseParameters(lastParameters,3,3,volume)
6389 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6390 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
6392 def LengthFromFaces(self):
6393 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6395 value, parameters = ParseParameters(lastParameters,3,3,value)
6396 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6397 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
6399 #Registering the new proxy for NETGEN_SimpleParameters_3D
6400 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
6402 pass # if not noNETGENPlugin:
6404 class Pattern(SMESH._objref_SMESH_Pattern):
6406 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
6408 if isinstance(theNodeIndexOnKeyPoint1,str):
6410 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
6412 theNodeIndexOnKeyPoint1 -= 1
6413 theMesh.SetParameters(Parameters)
6414 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
6416 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
6419 if isinstance(theNode000Index,str):
6421 if isinstance(theNode001Index,str):
6423 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
6425 theNode000Index -= 1
6427 theNode001Index -= 1
6428 theMesh.SetParameters(Parameters)
6429 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
6431 #Registering the new proxy for Pattern
6432 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)