1 # Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 # Author : Francis KLOSS, OCC
28 ## @defgroup l1_auxiliary Auxiliary methods and structures
29 ## @defgroup l1_creating Creating meshes
31 ## @defgroup l2_impexp Importing and exporting meshes
32 ## @defgroup l2_construct Constructing meshes
33 ## @defgroup l2_algorithms Defining Algorithms
35 ## @defgroup l3_algos_basic Basic meshing algorithms
36 ## @defgroup l3_algos_proj Projection Algorithms
37 ## @defgroup l3_algos_radialp Radial Prism
38 ## @defgroup l3_algos_segmarv Segments around Vertex
39 ## @defgroup l3_algos_3dextr 3D extrusion meshing algorithm
42 ## @defgroup l2_hypotheses Defining hypotheses
44 ## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
45 ## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
46 ## @defgroup l3_hypos_maxvol Max Element Volume hypothesis
47 ## @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
48 ## @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
49 ## @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
50 ## @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
51 ## @defgroup l3_hypos_quad Quadrangle Parameters hypothesis
52 ## @defgroup l3_hypos_additi Additional Hypotheses
55 ## @defgroup l2_submeshes Constructing submeshes
56 ## @defgroup l2_compounds Building Compounds
57 ## @defgroup l2_editing Editing Meshes
60 ## @defgroup l1_meshinfo Mesh Information
61 ## @defgroup l1_controls Quality controls and Filtering
62 ## @defgroup l1_grouping Grouping elements
64 ## @defgroup l2_grps_create Creating groups
65 ## @defgroup l2_grps_edit Editing groups
66 ## @defgroup l2_grps_operon Using operations on groups
67 ## @defgroup l2_grps_delete Deleting Groups
70 ## @defgroup l1_modifying Modifying meshes
72 ## @defgroup l2_modif_add Adding nodes and elements
73 ## @defgroup l2_modif_del Removing nodes and elements
74 ## @defgroup l2_modif_edit Modifying nodes and elements
75 ## @defgroup l2_modif_renumber Renumbering nodes and elements
76 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
77 ## @defgroup l2_modif_movenode Moving nodes
78 ## @defgroup l2_modif_throughp Mesh through point
79 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
80 ## @defgroup l2_modif_unitetri Uniting triangles
81 ## @defgroup l2_modif_changori Changing orientation of elements
82 ## @defgroup l2_modif_cutquadr Cutting quadrangles
83 ## @defgroup l2_modif_smooth Smoothing
84 ## @defgroup l2_modif_extrurev Extrusion and Revolution
85 ## @defgroup l2_modif_patterns Pattern mapping
86 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
89 ## @defgroup l1_measurements Measurements
94 import SMESH # This is necessary for back compatibility
102 # import NETGENPlugin module if possible
110 # import GHS3DPlugin module if possible
118 # import GHS3DPRLPlugin module if possible
121 import GHS3DPRLPlugin
126 # import HexoticPlugin module if possible
134 # import BLSURFPlugin module if possible
142 ## @addtogroup l1_auxiliary
145 # Types of algorithms
158 NETGEN_1D2D3D = FULL_NETGEN
159 NETGEN_FULL = FULL_NETGEN
167 # MirrorType enumeration
168 POINT = SMESH_MeshEditor.POINT
169 AXIS = SMESH_MeshEditor.AXIS
170 PLANE = SMESH_MeshEditor.PLANE
172 # Smooth_Method enumeration
173 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
174 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
176 # Fineness enumeration (for NETGEN)
184 # Optimization level of GHS3D
186 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
187 # V4.1 (partialy redefines V3.1). Issue 0020574
188 None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization, Strong_Optimization = 0,1,2,3,4
190 # Topology treatment way of BLSURF
191 FromCAD, PreProcess, PreProcessPlus, PreCAD = 0,1,2,3
193 # Element size flag of BLSURF
194 DefaultSize, DefaultGeom, BLSURF_Custom, SizeMap = 0,0,1,2
196 PrecisionConfusion = 1e-07
198 # TopAbs_State enumeration
199 [TopAbs_IN, TopAbs_OUT, TopAbs_ON, TopAbs_UNKNOWN] = range(4)
201 # Methods of splitting a hexahedron into tetrahedra
202 Hex_5Tet, Hex_6Tet, Hex_24Tet = 1, 2, 3
204 # import items of enum QuadType
205 for e in StdMeshers.QuadType._items: exec('%s = StdMeshers.%s'%(e,e))
207 ## Converts an angle from degrees to radians
208 def DegreesToRadians(AngleInDegrees):
210 return AngleInDegrees * pi / 180.0
212 # Salome notebook variable separator
215 # Parametrized substitute for PointStruct
216 class PointStructStr:
225 def __init__(self, xStr, yStr, zStr):
229 if isinstance(xStr, str) and notebook.isVariable(xStr):
230 self.x = notebook.get(xStr)
233 if isinstance(yStr, str) and notebook.isVariable(yStr):
234 self.y = notebook.get(yStr)
237 if isinstance(zStr, str) and notebook.isVariable(zStr):
238 self.z = notebook.get(zStr)
242 # Parametrized substitute for PointStruct (with 6 parameters)
243 class PointStructStr6:
258 def __init__(self, x1Str, x2Str, y1Str, y2Str, z1Str, z2Str):
265 if isinstance(x1Str, str) and notebook.isVariable(x1Str):
266 self.x1 = notebook.get(x1Str)
269 if isinstance(x2Str, str) and notebook.isVariable(x2Str):
270 self.x2 = notebook.get(x2Str)
273 if isinstance(y1Str, str) and notebook.isVariable(y1Str):
274 self.y1 = notebook.get(y1Str)
277 if isinstance(y2Str, str) and notebook.isVariable(y2Str):
278 self.y2 = notebook.get(y2Str)
281 if isinstance(z1Str, str) and notebook.isVariable(z1Str):
282 self.z1 = notebook.get(z1Str)
285 if isinstance(z2Str, str) and notebook.isVariable(z2Str):
286 self.z2 = notebook.get(z2Str)
290 # Parametrized substitute for AxisStruct
306 def __init__(self, xStr, yStr, zStr, dxStr, dyStr, dzStr):
313 if isinstance(xStr, str) and notebook.isVariable(xStr):
314 self.x = notebook.get(xStr)
317 if isinstance(yStr, str) and notebook.isVariable(yStr):
318 self.y = notebook.get(yStr)
321 if isinstance(zStr, str) and notebook.isVariable(zStr):
322 self.z = notebook.get(zStr)
325 if isinstance(dxStr, str) and notebook.isVariable(dxStr):
326 self.dx = notebook.get(dxStr)
329 if isinstance(dyStr, str) and notebook.isVariable(dyStr):
330 self.dy = notebook.get(dyStr)
333 if isinstance(dzStr, str) and notebook.isVariable(dzStr):
334 self.dz = notebook.get(dzStr)
338 # Parametrized substitute for DirStruct
341 def __init__(self, pointStruct):
342 self.pointStruct = pointStruct
344 # Returns list of variable values from salome notebook
345 def ParsePointStruct(Point):
346 Parameters = 2*var_separator
347 if isinstance(Point, PointStructStr):
348 Parameters = str(Point.xStr) + var_separator + str(Point.yStr) + var_separator + str(Point.zStr)
349 Point = PointStruct(Point.x, Point.y, Point.z)
350 return Point, Parameters
352 # Returns list of variable values from salome notebook
353 def ParseDirStruct(Dir):
354 Parameters = 2*var_separator
355 if isinstance(Dir, DirStructStr):
356 pntStr = Dir.pointStruct
357 if isinstance(pntStr, PointStructStr6):
358 Parameters = str(pntStr.x1Str) + var_separator + str(pntStr.x2Str) + var_separator
359 Parameters += str(pntStr.y1Str) + var_separator + str(pntStr.y2Str) + var_separator
360 Parameters += str(pntStr.z1Str) + var_separator + str(pntStr.z2Str)
361 Point = PointStruct(pntStr.x2 - pntStr.x1, pntStr.y2 - pntStr.y1, pntStr.z2 - pntStr.z1)
363 Parameters = str(pntStr.xStr) + var_separator + str(pntStr.yStr) + var_separator + str(pntStr.zStr)
364 Point = PointStruct(pntStr.x, pntStr.y, pntStr.z)
365 Dir = DirStruct(Point)
366 return Dir, Parameters
368 # Returns list of variable values from salome notebook
369 def ParseAxisStruct(Axis):
370 Parameters = 5*var_separator
371 if isinstance(Axis, AxisStructStr):
372 Parameters = str(Axis.xStr) + var_separator + str(Axis.yStr) + var_separator + str(Axis.zStr) + var_separator
373 Parameters += str(Axis.dxStr) + var_separator + str(Axis.dyStr) + var_separator + str(Axis.dzStr)
374 Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz)
375 return Axis, Parameters
377 ## Return list of variable values from salome notebook
378 def ParseAngles(list):
381 for parameter in list:
382 if isinstance(parameter,str) and notebook.isVariable(parameter):
383 Result.append(DegreesToRadians(notebook.get(parameter)))
386 Result.append(parameter)
389 Parameters = Parameters + str(parameter)
390 Parameters = Parameters + var_separator
392 Parameters = Parameters[:len(Parameters)-1]
393 return Result, Parameters
395 def IsEqual(val1, val2, tol=PrecisionConfusion):
396 if abs(val1 - val2) < tol:
406 if isinstance(obj, SALOMEDS._objref_SObject):
409 ior = salome.orb.object_to_string(obj)
412 studies = salome.myStudyManager.GetOpenStudies()
413 for sname in studies:
414 s = salome.myStudyManager.GetStudyByName(sname)
416 sobj = s.FindObjectIOR(ior)
417 if not sobj: continue
418 return sobj.GetName()
419 if hasattr(obj, "GetName"):
420 # unknown CORBA object, having GetName() method
423 # unknown CORBA object, no GetName() method
426 if hasattr(obj, "GetName"):
427 # unknown non-CORBA object, having GetName() method
430 raise RuntimeError, "Null or invalid object"
432 ## Prints error message if a hypothesis was not assigned.
433 def TreatHypoStatus(status, hypName, geomName, isAlgo):
435 hypType = "algorithm"
437 hypType = "hypothesis"
439 if status == HYP_UNKNOWN_FATAL :
440 reason = "for unknown reason"
441 elif status == HYP_INCOMPATIBLE :
442 reason = "this hypothesis mismatches the algorithm"
443 elif status == HYP_NOTCONFORM :
444 reason = "a non-conform mesh would be built"
445 elif status == HYP_ALREADY_EXIST :
446 if isAlgo: return # it does not influence anything
447 reason = hypType + " of the same dimension is already assigned to this shape"
448 elif status == HYP_BAD_DIM :
449 reason = hypType + " mismatches the shape"
450 elif status == HYP_CONCURENT :
451 reason = "there are concurrent hypotheses on sub-shapes"
452 elif status == HYP_BAD_SUBSHAPE :
453 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
454 elif status == HYP_BAD_GEOMETRY:
455 reason = "geometry mismatches the expectation of the algorithm"
456 elif status == HYP_HIDDEN_ALGO:
457 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
458 elif status == HYP_HIDING_ALGO:
459 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
460 elif status == HYP_NEED_SHAPE:
461 reason = "Algorithm can't work without shape"
464 hypName = '"' + hypName + '"'
465 geomName= '"' + geomName+ '"'
466 if status < HYP_UNKNOWN_FATAL and not geomName =='""':
467 print hypName, "was assigned to", geomName,"but", reason
468 elif not geomName == '""':
469 print hypName, "was not assigned to",geomName,":", reason
471 print hypName, "was not assigned:", reason
474 ## Check meshing plugin availability
475 def CheckPlugin(plugin):
476 if plugin == NETGEN and noNETGENPlugin:
477 print "Warning: NETGENPlugin module unavailable"
479 elif plugin == GHS3D and noGHS3DPlugin:
480 print "Warning: GHS3DPlugin module unavailable"
482 elif plugin == GHS3DPRL and noGHS3DPRLPlugin:
483 print "Warning: GHS3DPRLPlugin module unavailable"
485 elif plugin == Hexotic and noHexoticPlugin:
486 print "Warning: HexoticPlugin module unavailable"
488 elif plugin == BLSURF and noBLSURFPlugin:
489 print "Warning: BLSURFPlugin module unavailable"
493 ## Private method. Add geom (sub-shape of the main shape) into the study if not yet there
494 def AssureGeomPublished(mesh, geom, name=''):
495 if not isinstance( geom, geompyDC.GEOM._objref_GEOM_Object ):
497 if not geom.IsSame( mesh.geom ) and not geom.GetStudyEntry():
499 studyID = mesh.smeshpyD.GetCurrentStudy()._get_StudyId()
500 if studyID != mesh.geompyD.myStudyId:
501 mesh.geompyD.init_geom( mesh.smeshpyD.GetCurrentStudy())
503 if not name and geom.GetShapeType() != geompyDC.GEOM.COMPOUND:
504 # for all groups SubShapeName() returns "Compound_-1"
505 name = mesh.geompyD.SubShapeName(geom, mesh.geom)
507 name = "%s_%s"%(geom.GetShapeType(), id(geom)%10000)
509 mesh.geompyD.addToStudyInFather( mesh.geom, geom, name )
512 # 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 ## Creates Mesh objects importing data from the given CGNS file
689 # @return an instance of Mesh class
691 def CreateMeshesFromCGNS( self, theFileName ):
692 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromCGNS(self,theFileName)
694 for iMesh in range(len(aSmeshMeshes)) :
695 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
696 aMeshes.append(aMesh)
697 return aMeshes, aStatus
699 ## Concatenate the given meshes into one mesh.
700 # @return an instance of Mesh class
701 # @param meshes the meshes to combine into one mesh
702 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
703 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
704 # @param mergeTolerance tolerance for merging nodes
705 # @param allGroups forces creation of groups of all elements
706 def Concatenate( self, meshes, uniteIdenticalGroups,
707 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
708 mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
709 for i,m in enumerate(meshes):
710 if isinstance(m, Mesh):
711 meshes[i] = m.GetMesh()
713 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
714 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
716 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
717 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
718 aSmeshMesh.SetParameters(Parameters)
719 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
722 ## Create a mesh by copying a part of another mesh.
723 # @param meshPart a part of mesh to copy, either a Mesh, a sub-mesh or a group;
724 # to copy nodes or elements not contained in any mesh object,
725 # pass result of Mesh.GetIDSource( list_of_ids, type ) as meshPart
726 # @param meshName a name of the new mesh
727 # @param toCopyGroups to create in the new mesh groups the copied elements belongs to
728 # @param toKeepIDs to preserve IDs of the copied elements or not
729 # @return an instance of Mesh class
730 def CopyMesh( self, meshPart, meshName, toCopyGroups=False, toKeepIDs=False):
731 if (isinstance( meshPart, Mesh )):
732 meshPart = meshPart.GetMesh()
733 mesh = SMESH._objref_SMESH_Gen.CopyMesh( self,meshPart,meshName,toCopyGroups,toKeepIDs )
734 return Mesh(self, self.geompyD, mesh)
736 ## From SMESH_Gen interface
737 # @return the list of integer values
738 # @ingroup l1_auxiliary
739 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
740 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
742 ## From SMESH_Gen interface. Creates a pattern
743 # @return an instance of SMESH_Pattern
745 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
746 # @ingroup l2_modif_patterns
747 def GetPattern(self):
748 return SMESH._objref_SMESH_Gen.GetPattern(self)
750 ## Sets number of segments per diagonal of boundary box of geometry by which
751 # default segment length of appropriate 1D hypotheses is defined.
752 # Default value is 10
753 # @ingroup l1_auxiliary
754 def SetBoundaryBoxSegmentation(self, nbSegments):
755 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
757 # Filtering. Auxiliary functions:
758 # ------------------------------
760 ## Creates an empty criterion
761 # @return SMESH.Filter.Criterion
762 # @ingroup l1_controls
763 def GetEmptyCriterion(self):
764 Type = self.EnumToLong(FT_Undefined)
765 Compare = self.EnumToLong(FT_Undefined)
769 UnaryOp = self.EnumToLong(FT_Undefined)
770 BinaryOp = self.EnumToLong(FT_Undefined)
773 Precision = -1 ##@1e-07
774 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
775 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
777 ## Creates a criterion by the given parameters
778 # \n Criterion structures allow to define complex filters by combining them with logical operations (AND / OR) (see example below)
779 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
780 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
781 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
782 # @param Treshold the threshold value (range of ids as string, shape, numeric)
783 # @param UnaryOp FT_LogicalNOT or FT_Undefined
784 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
785 # FT_Undefined (must be for the last criterion of all criteria)
786 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
787 # FT_LyingOnGeom, FT_CoplanarFaces criteria
788 # @return SMESH.Filter.Criterion
790 # <a href="../tui_filters_page.html#combining_filters">Example of Criteria usage</a>
791 # @ingroup l1_controls
792 def GetCriterion(self,elementType,
794 Compare = FT_EqualTo,
796 UnaryOp=FT_Undefined,
797 BinaryOp=FT_Undefined,
799 aCriterion = self.GetEmptyCriterion()
800 aCriterion.TypeOfElement = elementType
801 aCriterion.Type = self.EnumToLong(CritType)
802 aCriterion.Tolerance = Tolerance
806 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
807 aCriterion.Compare = self.EnumToLong(Compare)
808 elif Compare == "=" or Compare == "==":
809 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
811 aCriterion.Compare = self.EnumToLong(FT_LessThan)
813 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
814 elif Compare != FT_Undefined:
815 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
818 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
819 FT_BelongToCylinder, FT_LyingOnGeom]:
820 # Checks the treshold
821 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
822 aCriterion.ThresholdStr = GetName(aTreshold)
823 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
825 print "Error: The treshold should be a shape."
827 if isinstance(UnaryOp,float):
828 aCriterion.Tolerance = UnaryOp
829 UnaryOp = FT_Undefined
831 elif CritType == FT_RangeOfIds:
832 # Checks the treshold
833 if isinstance(aTreshold, str):
834 aCriterion.ThresholdStr = aTreshold
836 print "Error: The treshold should be a string."
838 elif CritType == FT_CoplanarFaces:
839 # Checks the treshold
840 if isinstance(aTreshold, int):
841 aCriterion.ThresholdID = "%s"%aTreshold
842 elif isinstance(aTreshold, str):
845 raise ValueError, "Invalid ID of mesh face: '%s'"%aTreshold
846 aCriterion.ThresholdID = aTreshold
849 "The treshold should be an ID of mesh face and not '%s'"%aTreshold
850 elif CritType == FT_ElemGeomType:
851 # Checks the treshold
853 aCriterion.Threshold = self.EnumToLong(aTreshold)
855 if isinstance(aTreshold, int):
856 aCriterion.Threshold = aTreshold
858 print "Error: The treshold should be an integer or SMESH.GeometryType."
862 elif CritType == FT_GroupColor:
863 # Checks the treshold
865 aCriterion.ThresholdStr = self.ColorToString(aTreshold)
867 print "Error: The threshold value should be of SALOMEDS.Color type"
870 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
871 FT_FreeFaces, FT_LinearOrQuadratic,
872 FT_BareBorderFace, FT_BareBorderVolume,
873 FT_OverConstrainedFace, FT_OverConstrainedVolume]:
874 # At this point the treshold is unnecessary
875 if aTreshold == FT_LogicalNOT:
876 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
877 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
878 aCriterion.BinaryOp = aTreshold
882 aTreshold = float(aTreshold)
883 aCriterion.Threshold = aTreshold
885 print "Error: The treshold should be a number."
888 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
889 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
891 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
892 aCriterion.BinaryOp = self.EnumToLong(Treshold)
894 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
895 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
897 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
898 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
902 ## Creates a filter with the given parameters
903 # @param elementType the type of elements in the group
904 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
905 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
906 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
907 # @param UnaryOp FT_LogicalNOT or FT_Undefined
908 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
909 # FT_LyingOnGeom, FT_CoplanarFaces criteria
910 # @return SMESH_Filter
912 # <a href="../tui_filters_page.html#tui_filters">Example of Filters usage</a>
913 # @ingroup l1_controls
914 def GetFilter(self,elementType,
915 CritType=FT_Undefined,
918 UnaryOp=FT_Undefined,
920 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined,Tolerance)
921 aFilterMgr = self.CreateFilterManager()
922 aFilter = aFilterMgr.CreateFilter()
924 aCriteria.append(aCriterion)
925 aFilter.SetCriteria(aCriteria)
926 aFilterMgr.UnRegister()
929 ## Creates a filter from criteria
930 # @param criteria a list of criteria
931 # @return SMESH_Filter
933 # <a href="../tui_filters_page.html#tui_filters">Example of Filters usage</a>
934 # @ingroup l1_controls
935 def GetFilterFromCriteria(self,criteria):
936 aFilterMgr = self.CreateFilterManager()
937 aFilter = aFilterMgr.CreateFilter()
938 aFilter.SetCriteria(criteria)
939 aFilterMgr.UnRegister()
942 ## Creates a numerical functor by its type
943 # @param theCriterion FT_...; functor type
944 # @return SMESH_NumericalFunctor
945 # @ingroup l1_controls
946 def GetFunctor(self,theCriterion):
947 aFilterMgr = self.CreateFilterManager()
948 if theCriterion == FT_AspectRatio:
949 return aFilterMgr.CreateAspectRatio()
950 elif theCriterion == FT_AspectRatio3D:
951 return aFilterMgr.CreateAspectRatio3D()
952 elif theCriterion == FT_Warping:
953 return aFilterMgr.CreateWarping()
954 elif theCriterion == FT_MinimumAngle:
955 return aFilterMgr.CreateMinimumAngle()
956 elif theCriterion == FT_Taper:
957 return aFilterMgr.CreateTaper()
958 elif theCriterion == FT_Skew:
959 return aFilterMgr.CreateSkew()
960 elif theCriterion == FT_Area:
961 return aFilterMgr.CreateArea()
962 elif theCriterion == FT_Volume3D:
963 return aFilterMgr.CreateVolume3D()
964 elif theCriterion == FT_MaxElementLength2D:
965 return aFilterMgr.CreateMaxElementLength2D()
966 elif theCriterion == FT_MaxElementLength3D:
967 return aFilterMgr.CreateMaxElementLength3D()
968 elif theCriterion == FT_MultiConnection:
969 return aFilterMgr.CreateMultiConnection()
970 elif theCriterion == FT_MultiConnection2D:
971 return aFilterMgr.CreateMultiConnection2D()
972 elif theCriterion == FT_Length:
973 return aFilterMgr.CreateLength()
974 elif theCriterion == FT_Length2D:
975 return aFilterMgr.CreateLength2D()
977 print "Error: given parameter is not numerucal functor type."
979 ## Creates hypothesis
980 # @param theHType mesh hypothesis type (string)
981 # @param theLibName mesh plug-in library name
982 # @return created hypothesis instance
983 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
984 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
986 ## Gets the mesh statistic
987 # @return dictionary "element type" - "count of elements"
988 # @ingroup l1_meshinfo
989 def GetMeshInfo(self, obj):
990 if isinstance( obj, Mesh ):
993 if hasattr(obj, "GetMeshInfo"):
994 values = obj.GetMeshInfo()
995 for i in range(SMESH.Entity_Last._v):
996 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
1000 ## Get minimum distance between two objects
1002 # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
1003 # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
1005 # @param src1 first source object
1006 # @param src2 second source object
1007 # @param id1 node/element id from the first source
1008 # @param id2 node/element id from the second (or first) source
1009 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
1010 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
1011 # @return minimum distance value
1012 # @sa GetMinDistance()
1013 # @ingroup l1_measurements
1014 def MinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
1015 result = self.GetMinDistance(src1, src2, id1, id2, isElem1, isElem2)
1019 result = result.value
1022 ## Get measure structure specifying minimum distance data between two objects
1024 # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
1025 # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
1027 # @param src1 first source object
1028 # @param src2 second source object
1029 # @param id1 node/element id from the first source
1030 # @param id2 node/element id from the second (or first) source
1031 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
1032 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
1033 # @return Measure structure or None if input data is invalid
1035 # @ingroup l1_measurements
1036 def GetMinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
1037 if isinstance(src1, Mesh): src1 = src1.mesh
1038 if isinstance(src2, Mesh): src2 = src2.mesh
1039 if src2 is None and id2 != 0: src2 = src1
1040 if not hasattr(src1, "_narrow"): return None
1041 src1 = src1._narrow(SMESH.SMESH_IDSource)
1042 if not src1: return None
1045 e = m.GetMeshEditor()
1047 src1 = e.MakeIDSource([id1], SMESH.FACE)
1049 src1 = e.MakeIDSource([id1], SMESH.NODE)
1051 if hasattr(src2, "_narrow"):
1052 src2 = src2._narrow(SMESH.SMESH_IDSource)
1053 if src2 and id2 != 0:
1055 e = m.GetMeshEditor()
1057 src2 = e.MakeIDSource([id2], SMESH.FACE)
1059 src2 = e.MakeIDSource([id2], SMESH.NODE)
1062 aMeasurements = self.CreateMeasurements()
1063 result = aMeasurements.MinDistance(src1, src2)
1064 aMeasurements.UnRegister()
1067 ## Get bounding box of the specified object(s)
1068 # @param objects single source object or list of source objects
1069 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
1070 # @sa GetBoundingBox()
1071 # @ingroup l1_measurements
1072 def BoundingBox(self, objects):
1073 result = self.GetBoundingBox(objects)
1077 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
1080 ## Get measure structure specifying bounding box data of the specified object(s)
1081 # @param objects single source object or list of source objects
1082 # @return Measure structure
1084 # @ingroup l1_measurements
1085 def GetBoundingBox(self, objects):
1086 if isinstance(objects, tuple):
1087 objects = list(objects)
1088 if not isinstance(objects, list):
1092 if isinstance(o, Mesh):
1093 srclist.append(o.mesh)
1094 elif hasattr(o, "_narrow"):
1095 src = o._narrow(SMESH.SMESH_IDSource)
1096 if src: srclist.append(src)
1099 aMeasurements = self.CreateMeasurements()
1100 result = aMeasurements.BoundingBox(srclist)
1101 aMeasurements.UnRegister()
1105 #Registering the new proxy for SMESH_Gen
1106 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
1109 # Public class: Mesh
1110 # ==================
1112 ## This class allows defining and managing a mesh.
1113 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
1114 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
1115 # new nodes and elements and by changing the existing entities), to get information
1116 # about a mesh and to export a mesh into different formats.
1125 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
1126 # sets the GUI name of this mesh to \a name.
1127 # @param smeshpyD an instance of smeshDC class
1128 # @param geompyD an instance of geompyDC class
1129 # @param obj Shape to be meshed or SMESH_Mesh object
1130 # @param name Study name of the mesh
1131 # @ingroup l2_construct
1132 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
1133 self.smeshpyD=smeshpyD
1134 self.geompyD=geompyD
1138 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
1140 # publish geom of mesh (issue 0021122)
1141 if not self.geom.GetStudyEntry():
1142 studyID = smeshpyD.GetCurrentStudy()._get_StudyId()
1143 if studyID != geompyD.myStudyId:
1144 geompyD.init_geom( smeshpyD.GetCurrentStudy())
1146 geo_name = "%s_%s"%(self.geom.GetShapeType(), id(self.geom)%100)
1147 geompyD.addToStudy( self.geom, geo_name )
1148 self.mesh = self.smeshpyD.CreateMesh(self.geom)
1150 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
1153 self.mesh = self.smeshpyD.CreateEmptyMesh()
1155 self.smeshpyD.SetName(self.mesh, name)
1157 self.smeshpyD.SetName(self.mesh, GetName(obj))
1160 self.geom = self.mesh.GetShapeToMesh()
1162 self.editor = self.mesh.GetMeshEditor()
1164 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
1165 # @param theMesh a SMESH_Mesh object
1166 # @ingroup l2_construct
1167 def SetMesh(self, theMesh):
1169 self.geom = self.mesh.GetShapeToMesh()
1171 ## Returns the mesh, that is an instance of SMESH_Mesh interface
1172 # @return a SMESH_Mesh object
1173 # @ingroup l2_construct
1177 ## Gets the name of the mesh
1178 # @return the name of the mesh as a string
1179 # @ingroup l2_construct
1181 name = GetName(self.GetMesh())
1184 ## Sets a name to the mesh
1185 # @param name a new name of the mesh
1186 # @ingroup l2_construct
1187 def SetName(self, name):
1188 self.smeshpyD.SetName(self.GetMesh(), name)
1190 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
1191 # The subMesh object gives access to the IDs of nodes and elements.
1192 # @param geom a geometrical object (shape)
1193 # @param name a name for the submesh
1194 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
1195 # @ingroup l2_submeshes
1196 def GetSubMesh(self, geom, name):
1197 AssureGeomPublished( self, geom, name )
1198 submesh = self.mesh.GetSubMesh( geom, name )
1201 ## Returns the shape associated to the mesh
1202 # @return a GEOM_Object
1203 # @ingroup l2_construct
1207 ## Associates the given shape to the mesh (entails the recreation of the mesh)
1208 # @param geom the shape to be meshed (GEOM_Object)
1209 # @ingroup l2_construct
1210 def SetShape(self, geom):
1211 self.mesh = self.smeshpyD.CreateMesh(geom)
1213 ## Returns true if the hypotheses are defined well
1214 # @param theSubObject a subshape of a mesh shape
1215 # @return True or False
1216 # @ingroup l2_construct
1217 def IsReadyToCompute(self, theSubObject):
1218 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
1220 ## Returns errors of hypotheses definition.
1221 # The list of errors is empty if everything is OK.
1222 # @param theSubObject a subshape of a mesh shape
1223 # @return a list of errors
1224 # @ingroup l2_construct
1225 def GetAlgoState(self, theSubObject):
1226 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
1228 ## Returns a geometrical object on which the given element was built.
1229 # The returned geometrical object, if not nil, is either found in the
1230 # study or published by this method with the given name
1231 # @param theElementID the id of the mesh element
1232 # @param theGeomName the user-defined name of the geometrical object
1233 # @return GEOM::GEOM_Object instance
1234 # @ingroup l2_construct
1235 def GetGeometryByMeshElement(self, theElementID, theGeomName):
1236 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
1238 ## Returns the mesh dimension depending on the dimension of the underlying shape
1239 # @return mesh dimension as an integer value [0,3]
1240 # @ingroup l1_auxiliary
1241 def MeshDimension(self):
1242 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
1243 if len( shells ) > 0 :
1245 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
1247 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
1253 ## Creates a segment discretization 1D algorithm.
1254 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
1255 # \n If the optional \a geom parameter is not set, this algorithm is global.
1256 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1257 # @param algo the type of the required algorithm. Possible values are:
1259 # - smesh.PYTHON for discretization via a python function,
1260 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
1261 # @param geom If defined is the subshape to be meshed
1262 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
1263 # @ingroup l3_algos_basic
1264 def Segment(self, algo=REGULAR, geom=0):
1265 ## if Segment(geom) is called by mistake
1266 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
1267 algo, geom = geom, algo
1268 if not algo: algo = REGULAR
1271 return Mesh_Segment(self, geom)
1272 elif algo == PYTHON:
1273 return Mesh_Segment_Python(self, geom)
1274 elif algo == COMPOSITE:
1275 return Mesh_CompositeSegment(self, geom)
1277 return Mesh_Segment(self, geom)
1279 ## Creates 1D algorithm importing segments conatined in groups of other mesh.
1280 # If the optional \a geom parameter is not set, this algorithm is global.
1281 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1282 # @param geom If defined the subshape is to be meshed
1283 # @return an instance of Mesh_UseExistingElements class
1284 # @ingroup l3_algos_basic
1285 def UseExisting1DElements(self, geom=0):
1286 return Mesh_UseExistingElements(1,self, geom)
1288 ## Creates 2D algorithm importing faces conatined in groups of other mesh.
1289 # If the optional \a geom parameter is not set, this algorithm is global.
1290 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1291 # @param geom If defined the subshape is to be meshed
1292 # @return an instance of Mesh_UseExistingElements class
1293 # @ingroup l3_algos_basic
1294 def UseExisting2DElements(self, geom=0):
1295 return Mesh_UseExistingElements(2,self, geom)
1297 ## Enables creation of nodes and segments usable by 2D algoritms.
1298 # The added nodes and segments must be bound to edges and vertices by
1299 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
1300 # If the optional \a geom parameter is not set, this algorithm is global.
1301 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1302 # @param geom the subshape to be manually meshed
1303 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
1304 # @ingroup l3_algos_basic
1305 def UseExistingSegments(self, geom=0):
1306 algo = Mesh_UseExisting(1,self,geom)
1307 return algo.GetAlgorithm()
1309 ## Enables creation of nodes and faces usable by 3D algoritms.
1310 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
1311 # and SetMeshElementOnShape()
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 the subshape to be manually meshed
1315 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1316 # @ingroup l3_algos_basic
1317 def UseExistingFaces(self, geom=0):
1318 algo = Mesh_UseExisting(2,self,geom)
1319 return algo.GetAlgorithm()
1321 ## Creates a triangle 2D algorithm for faces.
1322 # If the optional \a geom parameter is not set, this algorithm is global.
1323 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1324 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1325 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1326 # @return an instance of Mesh_Triangle algorithm
1327 # @ingroup l3_algos_basic
1328 def Triangle(self, algo=MEFISTO, geom=0):
1329 ## if Triangle(geom) is called by mistake
1330 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1333 return Mesh_Triangle(self, algo, geom)
1335 ## Creates a quadrangle 2D algorithm for faces.
1336 # If the optional \a geom parameter is not set, this algorithm is global.
1337 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1338 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1339 # @param algo values are: smesh.QUADRANGLE || smesh.RADIAL_QUAD
1340 # @return an instance of Mesh_Quadrangle algorithm
1341 # @ingroup l3_algos_basic
1342 def Quadrangle(self, geom=0, algo=QUADRANGLE):
1343 if algo==RADIAL_QUAD:
1344 return Mesh_RadialQuadrangle1D2D(self,geom)
1346 return Mesh_Quadrangle(self, geom)
1348 ## Creates a tetrahedron 3D algorithm for solids.
1349 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1350 # If the optional \a geom parameter is not set, this algorithm is global.
1351 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1352 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1353 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1354 # @return an instance of Mesh_Tetrahedron algorithm
1355 # @ingroup l3_algos_basic
1356 def Tetrahedron(self, algo=NETGEN, geom=0):
1357 ## if Tetrahedron(geom) is called by mistake
1358 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1359 algo, geom = geom, algo
1360 if not algo: algo = NETGEN
1362 return Mesh_Tetrahedron(self, algo, geom)
1364 ## Creates a hexahedron 3D algorithm for solids.
1365 # If the optional \a geom parameter is not set, this algorithm is global.
1366 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1367 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1368 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1369 # @return an instance of Mesh_Hexahedron algorithm
1370 # @ingroup l3_algos_basic
1371 def Hexahedron(self, algo=Hexa, geom=0):
1372 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1373 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1374 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1375 elif geom == 0: algo, geom = Hexa, algo
1376 return Mesh_Hexahedron(self, algo, geom)
1378 ## Deprecated, used only for compatibility!
1379 # @return an instance of Mesh_Netgen algorithm
1380 # @ingroup l3_algos_basic
1381 def Netgen(self, is3D, geom=0):
1382 return Mesh_Netgen(self, is3D, geom)
1384 ## Creates a projection 1D algorithm for edges.
1385 # If the optional \a geom parameter is not set, this algorithm is global.
1386 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1387 # @param geom If defined, the subshape to be meshed
1388 # @return an instance of Mesh_Projection1D algorithm
1389 # @ingroup l3_algos_proj
1390 def Projection1D(self, geom=0):
1391 return Mesh_Projection1D(self, geom)
1393 ## Creates a projection 2D algorithm for faces.
1394 # If the optional \a geom parameter is not set, this algorithm is global.
1395 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1396 # @param geom If defined, the subshape to be meshed
1397 # @return an instance of Mesh_Projection2D algorithm
1398 # @ingroup l3_algos_proj
1399 def Projection2D(self, geom=0):
1400 return Mesh_Projection2D(self, geom)
1402 ## Creates a projection 3D algorithm for solids.
1403 # If the optional \a geom parameter is not set, this algorithm is global.
1404 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1405 # @param geom If defined, the subshape to be meshed
1406 # @return an instance of Mesh_Projection3D algorithm
1407 # @ingroup l3_algos_proj
1408 def Projection3D(self, geom=0):
1409 return Mesh_Projection3D(self, geom)
1411 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1412 # If the optional \a geom parameter is not set, this algorithm is global.
1413 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1414 # @param geom If defined, the subshape to be meshed
1415 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1416 # @ingroup l3_algos_radialp l3_algos_3dextr
1417 def Prism(self, geom=0):
1421 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1422 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1423 if nbSolids == 0 or nbSolids == nbShells:
1424 return Mesh_Prism3D(self, geom)
1425 return Mesh_RadialPrism3D(self, geom)
1427 ## Evaluates size of prospective mesh on a shape
1428 # @return a list where i-th element is a number of elements of i-th SMESH.EntityType
1429 # To know predicted number of e.g. edges, inquire it this way
1430 # Evaluate()[ EnumToLong( Entity_Edge )]
1431 def Evaluate(self, geom=0):
1432 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1434 geom = self.mesh.GetShapeToMesh()
1437 return self.smeshpyD.Evaluate(self.mesh, geom)
1440 ## Computes the mesh and returns the status of the computation
1441 # @param geom geomtrical shape on which mesh data should be computed
1442 # @param discardModifs if True and the mesh has been edited since
1443 # a last total re-compute and that may prevent successful partial re-compute,
1444 # then the mesh is cleaned before Compute()
1445 # @return True or False
1446 # @ingroup l2_construct
1447 def Compute(self, geom=0, discardModifs=False):
1448 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1450 geom = self.mesh.GetShapeToMesh()
1455 if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693
1457 ok = self.smeshpyD.Compute(self.mesh, geom)
1458 except SALOME.SALOME_Exception, ex:
1459 print "Mesh computation failed, exception caught:"
1460 print " ", ex.details.text
1463 print "Mesh computation failed, exception caught:"
1464 traceback.print_exc()
1468 # Treat compute errors
1469 computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
1470 for err in computeErrors:
1472 if self.mesh.HasShapeToMesh():
1474 mainIOR = salome.orb.object_to_string(geom)
1475 for sname in salome.myStudyManager.GetOpenStudies():
1476 s = salome.myStudyManager.GetStudyByName(sname)
1478 mainSO = s.FindObjectIOR(mainIOR)
1479 if not mainSO: continue
1480 if err.subShapeID == 1:
1481 shapeText = ' on "%s"' % mainSO.GetName()
1482 subIt = s.NewChildIterator(mainSO)
1484 subSO = subIt.Value()
1486 obj = subSO.GetObject()
1487 if not obj: continue
1488 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
1490 ids = go.GetSubShapeIndices()
1491 if len(ids) == 1 and ids[0] == err.subShapeID:
1492 shapeText = ' on "%s"' % subSO.GetName()
1495 shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
1497 shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID)
1499 shapeText = " on subshape #%s" % (err.subShapeID)
1501 shapeText = " on subshape #%s" % (err.subShapeID)
1503 stdErrors = ["OK", #COMPERR_OK
1504 "Invalid input mesh", #COMPERR_BAD_INPUT_MESH
1505 "std::exception", #COMPERR_STD_EXCEPTION
1506 "OCC exception", #COMPERR_OCC_EXCEPTION
1507 "SALOME exception", #COMPERR_SLM_EXCEPTION
1508 "Unknown exception", #COMPERR_EXCEPTION
1509 "Memory allocation problem", #COMPERR_MEMORY_PB
1510 "Algorithm failed", #COMPERR_ALGO_FAILED
1511 "Unexpected geometry"]#COMPERR_BAD_SHAPE
1513 if err.code < len(stdErrors): errText = stdErrors[err.code]
1515 errText = "code %s" % -err.code
1516 if errText: errText += ". "
1517 errText += err.comment
1518 if allReasons != "":allReasons += "\n"
1519 allReasons += '"%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
1523 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1525 if err.isGlobalAlgo:
1533 reason = '%s %sD algorithm is missing' % (glob, dim)
1534 elif err.state == HYP_MISSING:
1535 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1536 % (glob, dim, name, dim))
1537 elif err.state == HYP_NOTCONFORM:
1538 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1539 elif err.state == HYP_BAD_PARAMETER:
1540 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1541 % ( glob, dim, name ))
1542 elif err.state == HYP_BAD_GEOMETRY:
1543 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1544 'geometry' % ( glob, dim, name ))
1546 reason = "For unknown reason."+\
1547 " Revise Mesh.Compute() implementation in smeshDC.py!"
1549 if allReasons != "":allReasons += "\n"
1550 allReasons += reason
1552 if allReasons != "":
1553 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1557 print '"' + GetName(self.mesh) + '"',"has not been computed."
1560 if salome.sg.hasDesktop():
1561 smeshgui = salome.ImportComponentGUI("SMESH")
1562 smeshgui.Init(self.mesh.GetStudyId())
1563 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1564 salome.sg.updateObjBrowser(1)
1568 ## Return submesh objects list in meshing order
1569 # @return list of list of submesh objects
1570 # @ingroup l2_construct
1571 def GetMeshOrder(self):
1572 return self.mesh.GetMeshOrder()
1574 ## Return submesh objects list in meshing order
1575 # @return list of list of submesh objects
1576 # @ingroup l2_construct
1577 def SetMeshOrder(self, submeshes):
1578 return self.mesh.SetMeshOrder(submeshes)
1580 ## Removes all nodes and elements
1581 # @ingroup l2_construct
1584 if salome.sg.hasDesktop():
1585 smeshgui = salome.ImportComponentGUI("SMESH")
1586 smeshgui.Init(self.mesh.GetStudyId())
1587 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1588 salome.sg.updateObjBrowser(1)
1590 ## Removes all nodes and elements of indicated shape
1591 # @ingroup l2_construct
1592 def ClearSubMesh(self, geomId):
1593 self.mesh.ClearSubMesh(geomId)
1594 if salome.sg.hasDesktop():
1595 smeshgui = salome.ImportComponentGUI("SMESH")
1596 smeshgui.Init(self.mesh.GetStudyId())
1597 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1598 salome.sg.updateObjBrowser(1)
1600 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1601 # @param fineness [0.0,1.0] defines mesh fineness
1602 # @return True or False
1603 # @ingroup l3_algos_basic
1604 def AutomaticTetrahedralization(self, fineness=0):
1605 dim = self.MeshDimension()
1607 self.RemoveGlobalHypotheses()
1608 self.Segment().AutomaticLength(fineness)
1610 self.Triangle().LengthFromEdges()
1613 self.Tetrahedron(NETGEN)
1615 return self.Compute()
1617 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1618 # @param fineness [0.0, 1.0] defines mesh fineness
1619 # @return True or False
1620 # @ingroup l3_algos_basic
1621 def AutomaticHexahedralization(self, fineness=0):
1622 dim = self.MeshDimension()
1623 # assign the hypotheses
1624 self.RemoveGlobalHypotheses()
1625 self.Segment().AutomaticLength(fineness)
1632 return self.Compute()
1634 ## Assigns a hypothesis
1635 # @param hyp a hypothesis to assign
1636 # @param geom a subhape of mesh geometry
1637 # @return SMESH.Hypothesis_Status
1638 # @ingroup l2_hypotheses
1639 def AddHypothesis(self, hyp, geom=0):
1640 if isinstance( hyp, Mesh_Algorithm ):
1641 hyp = hyp.GetAlgorithm()
1646 geom = self.mesh.GetShapeToMesh()
1648 status = self.mesh.AddHypothesis(geom, hyp)
1649 isAlgo = hyp._narrow( SMESH_Algo )
1650 hyp_name = GetName( hyp )
1653 geom_name = GetName( geom )
1654 TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1657 ## Unassigns a hypothesis
1658 # @param hyp a hypothesis to unassign
1659 # @param geom a subshape of mesh geometry
1660 # @return SMESH.Hypothesis_Status
1661 # @ingroup l2_hypotheses
1662 def RemoveHypothesis(self, hyp, geom=0):
1663 if isinstance( hyp, Mesh_Algorithm ):
1664 hyp = hyp.GetAlgorithm()
1669 status = self.mesh.RemoveHypothesis(geom, hyp)
1672 ## Gets the list of hypotheses added on a geometry
1673 # @param geom a subshape of mesh geometry
1674 # @return the sequence of SMESH_Hypothesis
1675 # @ingroup l2_hypotheses
1676 def GetHypothesisList(self, geom):
1677 return self.mesh.GetHypothesisList( geom )
1679 ## Removes all global hypotheses
1680 # @ingroup l2_hypotheses
1681 def RemoveGlobalHypotheses(self):
1682 current_hyps = self.mesh.GetHypothesisList( self.geom )
1683 for hyp in current_hyps:
1684 self.mesh.RemoveHypothesis( self.geom, hyp )
1688 ## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead.
1689 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1690 ## allowing to overwrite the file if it exists or add the exported data to its contents
1691 # @param f the file name
1692 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1693 # @param opt boolean parameter for creating/not creating
1694 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1695 # @param overwrite boolean parameter for overwriting/not overwriting the file
1696 # @ingroup l2_impexp
1697 def ExportToMED(self, f, version, opt=0, overwrite=1):
1698 self.mesh.ExportToMEDX(f, opt, version, overwrite)
1700 ## Exports the mesh in a file in MED format and chooses the \a version of MED format
1701 ## allowing to overwrite the file if it exists or add the exported data to its contents
1702 # @param f is the file name
1703 # @param auto_groups boolean parameter for creating/not creating
1704 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1705 # the typical use is auto_groups=false.
1706 # @param version MED format version(MED_V2_1 or MED_V2_2)
1707 # @param overwrite boolean parameter for overwriting/not overwriting the file
1708 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1709 # @ingroup l2_impexp
1710 def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1, meshPart=None):
1712 if isinstance( meshPart, list ):
1713 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1714 self.mesh.ExportPartToMED( meshPart, f, auto_groups, version, overwrite )
1716 self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
1718 ## Exports the mesh in a file in DAT format
1719 # @param f the file name
1720 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1721 # @ingroup l2_impexp
1722 def ExportDAT(self, f, meshPart=None):
1724 if isinstance( meshPart, list ):
1725 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1726 self.mesh.ExportPartToDAT( meshPart, f )
1728 self.mesh.ExportDAT(f)
1730 ## Exports the mesh in a file in UNV format
1731 # @param f the file name
1732 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1733 # @ingroup l2_impexp
1734 def ExportUNV(self, f, meshPart=None):
1736 if isinstance( meshPart, list ):
1737 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1738 self.mesh.ExportPartToUNV( meshPart, f )
1740 self.mesh.ExportUNV(f)
1742 ## Export the mesh in a file in STL format
1743 # @param f the file name
1744 # @param ascii defines the file encoding
1745 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1746 # @ingroup l2_impexp
1747 def ExportSTL(self, f, ascii=1, meshPart=None):
1749 if isinstance( meshPart, list ):
1750 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1751 self.mesh.ExportPartToSTL( meshPart, f, ascii )
1753 self.mesh.ExportSTL(f, ascii)
1755 ## Exports the mesh in a file in CGNS format
1756 # @param f is the file name
1757 # @param overwrite boolean parameter for overwriting/not overwriting the file
1758 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1759 # @ingroup l2_impexp
1760 def ExportCGNS(self, f, overwrite=1, meshPart=None):
1761 if isinstance( meshPart, list ):
1762 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1763 if isinstance( meshPart, Mesh ):
1764 meshPart = meshPart.mesh
1766 meshPart = self.mesh
1767 self.mesh.ExportCGNS(meshPart, f, overwrite)
1769 # Operations with groups:
1770 # ----------------------
1772 ## Creates an empty mesh group
1773 # @param elementType the type of elements in the group
1774 # @param name the name of the mesh group
1775 # @return SMESH_Group
1776 # @ingroup l2_grps_create
1777 def CreateEmptyGroup(self, elementType, name):
1778 return self.mesh.CreateGroup(elementType, name)
1780 ## Creates a mesh group based on the geometric object \a grp
1781 # and gives a \a name, \n if this parameter is not defined
1782 # the name is the same as the geometric group name \n
1783 # Note: Works like GroupOnGeom().
1784 # @param grp a geometric group, a vertex, an edge, a face or a solid
1785 # @param name the name of the mesh group
1786 # @return SMESH_GroupOnGeom
1787 # @ingroup l2_grps_create
1788 def Group(self, grp, name=""):
1789 return self.GroupOnGeom(grp, name)
1791 ## Creates a mesh group based on the geometrical object \a grp
1792 # and gives a \a name, \n if this parameter is not defined
1793 # the name is the same as the geometrical group name
1794 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1795 # @param name the name of the mesh group
1796 # @param typ the type of elements in the group. If not set, it is
1797 # automatically detected by the type of the geometry
1798 # @return SMESH_GroupOnGeom
1799 # @ingroup l2_grps_create
1800 def GroupOnGeom(self, grp, name="", typ=None):
1801 AssureGeomPublished( self, grp, name )
1803 name = grp.GetName()
1805 typ = self._groupTypeFromShape( grp )
1806 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1808 ## Pivate method to get a type of group on geometry
1809 def _groupTypeFromShape( self, shape ):
1810 tgeo = str(shape.GetShapeType())
1811 if tgeo == "VERTEX":
1813 elif tgeo == "EDGE":
1815 elif tgeo == "FACE" or tgeo == "SHELL":
1817 elif tgeo == "SOLID" or tgeo == "COMPSOLID":
1819 elif tgeo == "COMPOUND":
1820 sub = self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHAPE"])
1822 raise ValueError,"_groupTypeFromShape(): empty geometric group or compound '%s'" % GetName(shape)
1823 return self._groupTypeFromShape( sub[0] )
1826 "_groupTypeFromShape(): invalid geometry '%s'" % GetName(shape)
1829 ## Creates a mesh group with given \a name based on the \a filter which
1830 ## is a special type of group dynamically updating it's contents during
1831 ## mesh modification
1832 # @param typ the type of elements in the group
1833 # @param name the name of the mesh group
1834 # @param filter the filter defining group contents
1835 # @return SMESH_GroupOnFilter
1836 # @ingroup l2_grps_create
1837 def GroupOnFilter(self, typ, name, filter):
1838 return self.mesh.CreateGroupFromFilter(typ, name, filter)
1840 ## Creates a mesh group by the given ids of elements
1841 # @param groupName the name of the mesh group
1842 # @param elementType the type of elements in the group
1843 # @param elemIDs the list of ids
1844 # @return SMESH_Group
1845 # @ingroup l2_grps_create
1846 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1847 group = self.mesh.CreateGroup(elementType, groupName)
1851 ## Creates a mesh group by the given conditions
1852 # @param groupName the name of the mesh group
1853 # @param elementType the type of elements in the group
1854 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1855 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1856 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1857 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1858 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
1859 # FT_LyingOnGeom, FT_CoplanarFaces criteria
1860 # @return SMESH_Group
1861 # @ingroup l2_grps_create
1865 CritType=FT_Undefined,
1868 UnaryOp=FT_Undefined,
1870 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined,Tolerance)
1871 group = self.MakeGroupByCriterion(groupName, aCriterion)
1874 ## Creates a mesh group by the given criterion
1875 # @param groupName the name of the mesh group
1876 # @param Criterion the instance of Criterion class
1877 # @return SMESH_Group
1878 # @ingroup l2_grps_create
1879 def MakeGroupByCriterion(self, groupName, Criterion):
1880 aFilterMgr = self.smeshpyD.CreateFilterManager()
1881 aFilter = aFilterMgr.CreateFilter()
1883 aCriteria.append(Criterion)
1884 aFilter.SetCriteria(aCriteria)
1885 group = self.MakeGroupByFilter(groupName, aFilter)
1886 aFilterMgr.UnRegister()
1889 ## Creates a mesh group by the given criteria (list of criteria)
1890 # @param groupName the name of the mesh group
1891 # @param theCriteria the list of criteria
1892 # @return SMESH_Group
1893 # @ingroup l2_grps_create
1894 def MakeGroupByCriteria(self, groupName, theCriteria):
1895 aFilterMgr = self.smeshpyD.CreateFilterManager()
1896 aFilter = aFilterMgr.CreateFilter()
1897 aFilter.SetCriteria(theCriteria)
1898 group = self.MakeGroupByFilter(groupName, aFilter)
1899 aFilterMgr.UnRegister()
1902 ## Creates a mesh group by the given filter
1903 # @param groupName the name of the mesh group
1904 # @param theFilter the instance of Filter class
1905 # @return SMESH_Group
1906 # @ingroup l2_grps_create
1907 def MakeGroupByFilter(self, groupName, theFilter):
1908 group = self.CreateEmptyGroup(theFilter.GetElementType(), groupName)
1909 theFilter.SetMesh( self.mesh )
1910 group.AddFrom( theFilter )
1913 ## Passes mesh elements through the given filter and return IDs of fitting elements
1914 # @param theFilter SMESH_Filter
1915 # @return a list of ids
1916 # @ingroup l1_controls
1917 def GetIdsFromFilter(self, theFilter):
1918 theFilter.SetMesh( self.mesh )
1919 return theFilter.GetIDs()
1921 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1922 # Returns a list of special structures (borders).
1923 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1924 # @ingroup l1_controls
1925 def GetFreeBorders(self):
1926 aFilterMgr = self.smeshpyD.CreateFilterManager()
1927 aPredicate = aFilterMgr.CreateFreeEdges()
1928 aPredicate.SetMesh(self.mesh)
1929 aBorders = aPredicate.GetBorders()
1930 aFilterMgr.UnRegister()
1934 # @ingroup l2_grps_delete
1935 def RemoveGroup(self, group):
1936 self.mesh.RemoveGroup(group)
1938 ## Removes a group with its contents
1939 # @ingroup l2_grps_delete
1940 def RemoveGroupWithContents(self, group):
1941 self.mesh.RemoveGroupWithContents(group)
1943 ## Gets the list of groups existing in the mesh
1944 # @return a sequence of SMESH_GroupBase
1945 # @ingroup l2_grps_create
1946 def GetGroups(self):
1947 return self.mesh.GetGroups()
1949 ## Gets the number of groups existing in the mesh
1950 # @return the quantity of groups as an integer value
1951 # @ingroup l2_grps_create
1953 return self.mesh.NbGroups()
1955 ## Gets the list of names of groups existing in the mesh
1956 # @return list of strings
1957 # @ingroup l2_grps_create
1958 def GetGroupNames(self):
1959 groups = self.GetGroups()
1961 for group in groups:
1962 names.append(group.GetName())
1965 ## Produces a union of two groups
1966 # A new group is created. All mesh elements that are
1967 # present in the initial groups are added to the new one
1968 # @return an instance of SMESH_Group
1969 # @ingroup l2_grps_operon
1970 def UnionGroups(self, group1, group2, name):
1971 return self.mesh.UnionGroups(group1, group2, name)
1973 ## Produces a union list of groups
1974 # New group is created. All mesh elements that are present in
1975 # initial groups are added to the new one
1976 # @return an instance of SMESH_Group
1977 # @ingroup l2_grps_operon
1978 def UnionListOfGroups(self, groups, name):
1979 return self.mesh.UnionListOfGroups(groups, name)
1981 ## Prodices an intersection of two groups
1982 # A new group is created. All mesh elements that are common
1983 # for the two initial groups are added to the new one.
1984 # @return an instance of SMESH_Group
1985 # @ingroup l2_grps_operon
1986 def IntersectGroups(self, group1, group2, name):
1987 return self.mesh.IntersectGroups(group1, group2, name)
1989 ## Produces an intersection of groups
1990 # New group is created. All mesh elements that are present in all
1991 # initial groups simultaneously are added to the new one
1992 # @return an instance of SMESH_Group
1993 # @ingroup l2_grps_operon
1994 def IntersectListOfGroups(self, groups, name):
1995 return self.mesh.IntersectListOfGroups(groups, name)
1997 ## Produces a cut of two groups
1998 # A new group is created. All mesh elements that are present in
1999 # the main group but are not present in the tool group are added to the new one
2000 # @return an instance of SMESH_Group
2001 # @ingroup l2_grps_operon
2002 def CutGroups(self, main_group, tool_group, name):
2003 return self.mesh.CutGroups(main_group, tool_group, name)
2005 ## Produces a cut of groups
2006 # A new group is created. All mesh elements that are present in main groups
2007 # but do not present in tool groups are added to the new one
2008 # @return an instance of SMESH_Group
2009 # @ingroup l2_grps_operon
2010 def CutListOfGroups(self, main_groups, tool_groups, name):
2011 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
2013 ## Produces a group of elements of specified type using list of existing groups
2014 # A new group is created. System
2015 # 1) extracts all nodes on which groups elements are built
2016 # 2) combines all elements of specified dimension laying on these nodes
2017 # @return an instance of SMESH_Group
2018 # @ingroup l2_grps_operon
2019 def CreateDimGroup(self, groups, elem_type, name):
2020 return self.mesh.CreateDimGroup(groups, elem_type, name)
2023 ## Convert group on geom into standalone group
2024 # @ingroup l2_grps_delete
2025 def ConvertToStandalone(self, group):
2026 return self.mesh.ConvertToStandalone(group)
2028 # Get some info about mesh:
2029 # ------------------------
2031 ## Returns the log of nodes and elements added or removed
2032 # since the previous clear of the log.
2033 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
2034 # @return list of log_block structures:
2039 # @ingroup l1_auxiliary
2040 def GetLog(self, clearAfterGet):
2041 return self.mesh.GetLog(clearAfterGet)
2043 ## Clears the log of nodes and elements added or removed since the previous
2044 # clear. Must be used immediately after GetLog if clearAfterGet is false.
2045 # @ingroup l1_auxiliary
2047 self.mesh.ClearLog()
2049 ## Toggles auto color mode on the object.
2050 # @param theAutoColor the flag which toggles auto color mode.
2051 # @ingroup l1_auxiliary
2052 def SetAutoColor(self, theAutoColor):
2053 self.mesh.SetAutoColor(theAutoColor)
2055 ## Gets flag of object auto color mode.
2056 # @return True or False
2057 # @ingroup l1_auxiliary
2058 def GetAutoColor(self):
2059 return self.mesh.GetAutoColor()
2061 ## Gets the internal ID
2062 # @return integer value, which is the internal Id of the mesh
2063 # @ingroup l1_auxiliary
2065 return self.mesh.GetId()
2068 # @return integer value, which is the study Id of the mesh
2069 # @ingroup l1_auxiliary
2070 def GetStudyId(self):
2071 return self.mesh.GetStudyId()
2073 ## Checks the group names for duplications.
2074 # Consider the maximum group name length stored in MED file.
2075 # @return True or False
2076 # @ingroup l1_auxiliary
2077 def HasDuplicatedGroupNamesMED(self):
2078 return self.mesh.HasDuplicatedGroupNamesMED()
2080 ## Obtains the mesh editor tool
2081 # @return an instance of SMESH_MeshEditor
2082 # @ingroup l1_modifying
2083 def GetMeshEditor(self):
2084 return self.mesh.GetMeshEditor()
2086 ## Wrap a list of IDs of elements or nodes into SMESH_IDSource which
2087 # can be passed as argument to accepting mesh, group or sub-mesh
2088 # @return an instance of SMESH_IDSource
2089 # @ingroup l1_auxiliary
2090 def GetIDSource(self, ids, elemType):
2091 return self.GetMeshEditor().MakeIDSource(ids, elemType)
2094 # @return an instance of SALOME_MED::MESH
2095 # @ingroup l1_auxiliary
2096 def GetMEDMesh(self):
2097 return self.mesh.GetMEDMesh()
2100 # Get informations about mesh contents:
2101 # ------------------------------------
2103 ## Gets the mesh stattistic
2104 # @return dictionary type element - count of elements
2105 # @ingroup l1_meshinfo
2106 def GetMeshInfo(self, obj = None):
2107 if not obj: obj = self.mesh
2108 return self.smeshpyD.GetMeshInfo(obj)
2110 ## Returns the number of nodes in the mesh
2111 # @return an integer value
2112 # @ingroup l1_meshinfo
2114 return self.mesh.NbNodes()
2116 ## Returns the number of elements in the mesh
2117 # @return an integer value
2118 # @ingroup l1_meshinfo
2119 def NbElements(self):
2120 return self.mesh.NbElements()
2122 ## Returns the number of 0d elements in the mesh
2123 # @return an integer value
2124 # @ingroup l1_meshinfo
2125 def Nb0DElements(self):
2126 return self.mesh.Nb0DElements()
2128 ## Returns the number of edges in the mesh
2129 # @return an integer value
2130 # @ingroup l1_meshinfo
2132 return self.mesh.NbEdges()
2134 ## Returns the number of edges with the given order in the mesh
2135 # @param elementOrder the order of elements:
2136 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2137 # @return an integer value
2138 # @ingroup l1_meshinfo
2139 def NbEdgesOfOrder(self, elementOrder):
2140 return self.mesh.NbEdgesOfOrder(elementOrder)
2142 ## Returns the number of faces in the mesh
2143 # @return an integer value
2144 # @ingroup l1_meshinfo
2146 return self.mesh.NbFaces()
2148 ## Returns the number of faces with the given order in the mesh
2149 # @param elementOrder the order of elements:
2150 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2151 # @return an integer value
2152 # @ingroup l1_meshinfo
2153 def NbFacesOfOrder(self, elementOrder):
2154 return self.mesh.NbFacesOfOrder(elementOrder)
2156 ## Returns the number of triangles in the mesh
2157 # @return an integer value
2158 # @ingroup l1_meshinfo
2159 def NbTriangles(self):
2160 return self.mesh.NbTriangles()
2162 ## Returns the number of triangles with the given order in the mesh
2163 # @param elementOrder is the order of elements:
2164 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2165 # @return an integer value
2166 # @ingroup l1_meshinfo
2167 def NbTrianglesOfOrder(self, elementOrder):
2168 return self.mesh.NbTrianglesOfOrder(elementOrder)
2170 ## Returns the number of quadrangles in the mesh
2171 # @return an integer value
2172 # @ingroup l1_meshinfo
2173 def NbQuadrangles(self):
2174 return self.mesh.NbQuadrangles()
2176 ## Returns the number of quadrangles with the given order in the mesh
2177 # @param elementOrder the order of elements:
2178 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2179 # @return an integer value
2180 # @ingroup l1_meshinfo
2181 def NbQuadranglesOfOrder(self, elementOrder):
2182 return self.mesh.NbQuadranglesOfOrder(elementOrder)
2184 ## Returns the number of polygons in the mesh
2185 # @return an integer value
2186 # @ingroup l1_meshinfo
2187 def NbPolygons(self):
2188 return self.mesh.NbPolygons()
2190 ## Returns the number of volumes in the mesh
2191 # @return an integer value
2192 # @ingroup l1_meshinfo
2193 def NbVolumes(self):
2194 return self.mesh.NbVolumes()
2196 ## Returns the number of volumes with the given order in the mesh
2197 # @param elementOrder the order of elements:
2198 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2199 # @return an integer value
2200 # @ingroup l1_meshinfo
2201 def NbVolumesOfOrder(self, elementOrder):
2202 return self.mesh.NbVolumesOfOrder(elementOrder)
2204 ## Returns the number of tetrahedrons in the mesh
2205 # @return an integer value
2206 # @ingroup l1_meshinfo
2208 return self.mesh.NbTetras()
2210 ## Returns the number of tetrahedrons with the given order in the mesh
2211 # @param elementOrder the order of elements:
2212 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2213 # @return an integer value
2214 # @ingroup l1_meshinfo
2215 def NbTetrasOfOrder(self, elementOrder):
2216 return self.mesh.NbTetrasOfOrder(elementOrder)
2218 ## Returns the number of hexahedrons in the mesh
2219 # @return an integer value
2220 # @ingroup l1_meshinfo
2222 return self.mesh.NbHexas()
2224 ## Returns the number of hexahedrons with the given order in the mesh
2225 # @param elementOrder the order of elements:
2226 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2227 # @return an integer value
2228 # @ingroup l1_meshinfo
2229 def NbHexasOfOrder(self, elementOrder):
2230 return self.mesh.NbHexasOfOrder(elementOrder)
2232 ## Returns the number of pyramids in the mesh
2233 # @return an integer value
2234 # @ingroup l1_meshinfo
2235 def NbPyramids(self):
2236 return self.mesh.NbPyramids()
2238 ## Returns the number of pyramids with the given order in the mesh
2239 # @param elementOrder the order of elements:
2240 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2241 # @return an integer value
2242 # @ingroup l1_meshinfo
2243 def NbPyramidsOfOrder(self, elementOrder):
2244 return self.mesh.NbPyramidsOfOrder(elementOrder)
2246 ## Returns the number of prisms in the mesh
2247 # @return an integer value
2248 # @ingroup l1_meshinfo
2250 return self.mesh.NbPrisms()
2252 ## Returns the number of prisms with the given order in the mesh
2253 # @param elementOrder the order of elements:
2254 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2255 # @return an integer value
2256 # @ingroup l1_meshinfo
2257 def NbPrismsOfOrder(self, elementOrder):
2258 return self.mesh.NbPrismsOfOrder(elementOrder)
2260 ## Returns the number of polyhedrons in the mesh
2261 # @return an integer value
2262 # @ingroup l1_meshinfo
2263 def NbPolyhedrons(self):
2264 return self.mesh.NbPolyhedrons()
2266 ## Returns the number of submeshes in the mesh
2267 # @return an integer value
2268 # @ingroup l1_meshinfo
2269 def NbSubMesh(self):
2270 return self.mesh.NbSubMesh()
2272 ## Returns the list of mesh elements IDs
2273 # @return the list of integer values
2274 # @ingroup l1_meshinfo
2275 def GetElementsId(self):
2276 return self.mesh.GetElementsId()
2278 ## Returns the list of IDs of mesh elements with the given type
2279 # @param elementType the required type of elements (SMESH.NODE, SMESH.EDGE, SMESH.FACE or SMESH.VOLUME)
2280 # @return list of integer values
2281 # @ingroup l1_meshinfo
2282 def GetElementsByType(self, elementType):
2283 return self.mesh.GetElementsByType(elementType)
2285 ## Returns the list of mesh nodes IDs
2286 # @return the list of integer values
2287 # @ingroup l1_meshinfo
2288 def GetNodesId(self):
2289 return self.mesh.GetNodesId()
2291 # Get the information about mesh elements:
2292 # ------------------------------------
2294 ## Returns the type of mesh element
2295 # @return the value from SMESH::ElementType enumeration
2296 # @ingroup l1_meshinfo
2297 def GetElementType(self, id, iselem):
2298 return self.mesh.GetElementType(id, iselem)
2300 ## Returns the geometric type of mesh element
2301 # @return the value from SMESH::EntityType enumeration
2302 # @ingroup l1_meshinfo
2303 def GetElementGeomType(self, id):
2304 return self.mesh.GetElementGeomType(id)
2306 ## Returns the list of submesh elements IDs
2307 # @param Shape a geom object(subshape) IOR
2308 # Shape must be the subshape of a ShapeToMesh()
2309 # @return the list of integer values
2310 # @ingroup l1_meshinfo
2311 def GetSubMeshElementsId(self, Shape):
2312 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2313 ShapeID = Shape.GetSubShapeIndices()[0]
2316 return self.mesh.GetSubMeshElementsId(ShapeID)
2318 ## Returns the list of submesh nodes IDs
2319 # @param Shape a geom object(subshape) IOR
2320 # Shape must be the subshape of a ShapeToMesh()
2321 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
2322 # @return the list of integer values
2323 # @ingroup l1_meshinfo
2324 def GetSubMeshNodesId(self, Shape, all):
2325 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2326 ShapeID = Shape.GetSubShapeIndices()[0]
2329 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2331 ## Returns type of elements on given shape
2332 # @param Shape a geom object(subshape) IOR
2333 # Shape must be a subshape of a ShapeToMesh()
2334 # @return element type
2335 # @ingroup l1_meshinfo
2336 def GetSubMeshElementType(self, Shape):
2337 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2338 ShapeID = Shape.GetSubShapeIndices()[0]
2341 return self.mesh.GetSubMeshElementType(ShapeID)
2343 ## Gets the mesh description
2344 # @return string value
2345 # @ingroup l1_meshinfo
2347 return self.mesh.Dump()
2350 # Get the information about nodes and elements of a mesh by its IDs:
2351 # -----------------------------------------------------------
2353 ## Gets XYZ coordinates of a node
2354 # \n If there is no nodes for the given ID - returns an empty list
2355 # @return a list of double precision values
2356 # @ingroup l1_meshinfo
2357 def GetNodeXYZ(self, id):
2358 return self.mesh.GetNodeXYZ(id)
2360 ## Returns list of IDs of inverse elements for the given node
2361 # \n If there is no node for the given ID - returns an empty list
2362 # @return a list of integer values
2363 # @ingroup l1_meshinfo
2364 def GetNodeInverseElements(self, id):
2365 return self.mesh.GetNodeInverseElements(id)
2367 ## @brief Returns the position of a node on the shape
2368 # @return SMESH::NodePosition
2369 # @ingroup l1_meshinfo
2370 def GetNodePosition(self,NodeID):
2371 return self.mesh.GetNodePosition(NodeID)
2373 ## If the given element is a node, returns the ID of shape
2374 # \n If there is no node for the given ID - returns -1
2375 # @return an integer value
2376 # @ingroup l1_meshinfo
2377 def GetShapeID(self, id):
2378 return self.mesh.GetShapeID(id)
2380 ## Returns the ID of the result shape after
2381 # FindShape() from SMESH_MeshEditor for the given element
2382 # \n If there is no element for the given ID - returns -1
2383 # @return an integer value
2384 # @ingroup l1_meshinfo
2385 def GetShapeIDForElem(self,id):
2386 return self.mesh.GetShapeIDForElem(id)
2388 ## Returns the number of nodes for the given element
2389 # \n If there is no element for the given ID - returns -1
2390 # @return an integer value
2391 # @ingroup l1_meshinfo
2392 def GetElemNbNodes(self, id):
2393 return self.mesh.GetElemNbNodes(id)
2395 ## Returns the node ID the given index for the given element
2396 # \n If there is no element for the given ID - returns -1
2397 # \n If there is no node for the given index - returns -2
2398 # @return an integer value
2399 # @ingroup l1_meshinfo
2400 def GetElemNode(self, id, index):
2401 return self.mesh.GetElemNode(id, index)
2403 ## Returns the IDs of nodes of the given element
2404 # @return a list of integer values
2405 # @ingroup l1_meshinfo
2406 def GetElemNodes(self, id):
2407 return self.mesh.GetElemNodes(id)
2409 ## Returns true if the given node is the medium node in the given quadratic element
2410 # @ingroup l1_meshinfo
2411 def IsMediumNode(self, elementID, nodeID):
2412 return self.mesh.IsMediumNode(elementID, nodeID)
2414 ## Returns true if the given node is the medium node in one of quadratic elements
2415 # @ingroup l1_meshinfo
2416 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2417 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2419 ## Returns the number of edges for the given element
2420 # @ingroup l1_meshinfo
2421 def ElemNbEdges(self, id):
2422 return self.mesh.ElemNbEdges(id)
2424 ## Returns the number of faces for the given element
2425 # @ingroup l1_meshinfo
2426 def ElemNbFaces(self, id):
2427 return self.mesh.ElemNbFaces(id)
2429 ## Returns nodes of given face (counted from zero) for given volumic element.
2430 # @ingroup l1_meshinfo
2431 def GetElemFaceNodes(self,elemId, faceIndex):
2432 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2434 ## Returns an element based on all given nodes.
2435 # @ingroup l1_meshinfo
2436 def FindElementByNodes(self,nodes):
2437 return self.mesh.FindElementByNodes(nodes)
2439 ## Returns true if the given element is a polygon
2440 # @ingroup l1_meshinfo
2441 def IsPoly(self, id):
2442 return self.mesh.IsPoly(id)
2444 ## Returns true if the given element is quadratic
2445 # @ingroup l1_meshinfo
2446 def IsQuadratic(self, id):
2447 return self.mesh.IsQuadratic(id)
2449 ## Returns XYZ coordinates of the barycenter of the given element
2450 # \n If there is no element for the given ID - returns an empty list
2451 # @return a list of three double values
2452 # @ingroup l1_meshinfo
2453 def BaryCenter(self, id):
2454 return self.mesh.BaryCenter(id)
2457 # Get mesh measurements information:
2458 # ------------------------------------
2460 ## Get minimum distance between two nodes, elements or distance to the origin
2461 # @param id1 first node/element id
2462 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2463 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2464 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2465 # @return minimum distance value
2466 # @sa GetMinDistance()
2467 def MinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2468 aMeasure = self.GetMinDistance(id1, id2, isElem1, isElem2)
2469 return aMeasure.value
2471 ## Get measure structure specifying minimum distance data between two objects
2472 # @param id1 first node/element id
2473 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2474 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2475 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2476 # @return Measure structure
2478 def GetMinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2480 id1 = self.editor.MakeIDSource([id1], SMESH.FACE)
2482 id1 = self.editor.MakeIDSource([id1], SMESH.NODE)
2485 id2 = self.editor.MakeIDSource([id2], SMESH.FACE)
2487 id2 = self.editor.MakeIDSource([id2], SMESH.NODE)
2492 aMeasurements = self.smeshpyD.CreateMeasurements()
2493 aMeasure = aMeasurements.MinDistance(id1, id2)
2494 aMeasurements.UnRegister()
2497 ## Get bounding box of the specified object(s)
2498 # @param objects single source object or list of source objects or list of nodes/elements IDs
2499 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2500 # @c False specifies that @a objects are nodes
2501 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
2502 # @sa GetBoundingBox()
2503 def BoundingBox(self, objects=None, isElem=False):
2504 result = self.GetBoundingBox(objects, isElem)
2508 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
2511 ## Get measure structure specifying bounding box data of the specified object(s)
2512 # @param IDs single source object or list of source objects or list of nodes/elements IDs
2513 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2514 # @c False specifies that @a objects are nodes
2515 # @return Measure structure
2517 def GetBoundingBox(self, IDs=None, isElem=False):
2520 elif isinstance(IDs, tuple):
2522 if not isinstance(IDs, list):
2524 if len(IDs) > 0 and isinstance(IDs[0], int):
2528 if isinstance(o, Mesh):
2529 srclist.append(o.mesh)
2530 elif hasattr(o, "_narrow"):
2531 src = o._narrow(SMESH.SMESH_IDSource)
2532 if src: srclist.append(src)
2534 elif isinstance(o, list):
2536 srclist.append(self.editor.MakeIDSource(o, SMESH.FACE))
2538 srclist.append(self.editor.MakeIDSource(o, SMESH.NODE))
2541 aMeasurements = self.smeshpyD.CreateMeasurements()
2542 aMeasure = aMeasurements.BoundingBox(srclist)
2543 aMeasurements.UnRegister()
2546 # Mesh edition (SMESH_MeshEditor functionality):
2547 # ---------------------------------------------
2549 ## Removes the elements from the mesh by ids
2550 # @param IDsOfElements is a list of ids of elements to remove
2551 # @return True or False
2552 # @ingroup l2_modif_del
2553 def RemoveElements(self, IDsOfElements):
2554 return self.editor.RemoveElements(IDsOfElements)
2556 ## Removes nodes from mesh by ids
2557 # @param IDsOfNodes is a list of ids of nodes to remove
2558 # @return True or False
2559 # @ingroup l2_modif_del
2560 def RemoveNodes(self, IDsOfNodes):
2561 return self.editor.RemoveNodes(IDsOfNodes)
2563 ## Removes all orphan (free) nodes from mesh
2564 # @return number of the removed nodes
2565 # @ingroup l2_modif_del
2566 def RemoveOrphanNodes(self):
2567 return self.editor.RemoveOrphanNodes()
2569 ## Add a node to the mesh by coordinates
2570 # @return Id of the new node
2571 # @ingroup l2_modif_add
2572 def AddNode(self, x, y, z):
2573 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2574 self.mesh.SetParameters(Parameters)
2575 return self.editor.AddNode( x, y, z)
2577 ## Creates a 0D element on a node with given number.
2578 # @param IDOfNode the ID of node for creation of the element.
2579 # @return the Id of the new 0D element
2580 # @ingroup l2_modif_add
2581 def Add0DElement(self, IDOfNode):
2582 return self.editor.Add0DElement(IDOfNode)
2584 ## Creates a linear or quadratic edge (this is determined
2585 # by the number of given nodes).
2586 # @param IDsOfNodes the list of node IDs for creation of the element.
2587 # The order of nodes in this list should correspond to the description
2588 # of MED. \n This description is located by the following link:
2589 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2590 # @return the Id of the new edge
2591 # @ingroup l2_modif_add
2592 def AddEdge(self, IDsOfNodes):
2593 return self.editor.AddEdge(IDsOfNodes)
2595 ## Creates a linear or quadratic face (this is determined
2596 # by the number of given nodes).
2597 # @param IDsOfNodes the list of node IDs for creation of the element.
2598 # The order of nodes in this list should correspond to the description
2599 # of MED. \n This description is located by the following link:
2600 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2601 # @return the Id of the new face
2602 # @ingroup l2_modif_add
2603 def AddFace(self, IDsOfNodes):
2604 return self.editor.AddFace(IDsOfNodes)
2606 ## Adds a polygonal face to the mesh by the list of node IDs
2607 # @param IdsOfNodes the list of node IDs for creation of the element.
2608 # @return the Id of the new face
2609 # @ingroup l2_modif_add
2610 def AddPolygonalFace(self, IdsOfNodes):
2611 return self.editor.AddPolygonalFace(IdsOfNodes)
2613 ## Creates both simple and quadratic volume (this is determined
2614 # by the number of given nodes).
2615 # @param IDsOfNodes the list of node IDs for creation of the element.
2616 # The order of nodes in this list should correspond to the description
2617 # of MED. \n This description is located by the following link:
2618 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2619 # @return the Id of the new volumic element
2620 # @ingroup l2_modif_add
2621 def AddVolume(self, IDsOfNodes):
2622 return self.editor.AddVolume(IDsOfNodes)
2624 ## Creates a volume of many faces, giving nodes for each face.
2625 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2626 # @param Quantities the list of integer values, Quantities[i]
2627 # gives the quantity of nodes in face number i.
2628 # @return the Id of the new volumic element
2629 # @ingroup l2_modif_add
2630 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2631 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2633 ## Creates a volume of many faces, giving the IDs of the existing faces.
2634 # @param IdsOfFaces the list of face IDs for volume creation.
2636 # Note: The created volume will refer only to the nodes
2637 # of the given faces, not to the faces themselves.
2638 # @return the Id of the new volumic element
2639 # @ingroup l2_modif_add
2640 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2641 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2644 ## @brief Binds a node to a vertex
2645 # @param NodeID a node ID
2646 # @param Vertex a vertex or vertex ID
2647 # @return True if succeed else raises an exception
2648 # @ingroup l2_modif_add
2649 def SetNodeOnVertex(self, NodeID, Vertex):
2650 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2651 VertexID = Vertex.GetSubShapeIndices()[0]
2655 self.editor.SetNodeOnVertex(NodeID, VertexID)
2656 except SALOME.SALOME_Exception, inst:
2657 raise ValueError, inst.details.text
2661 ## @brief Stores the node position on an edge
2662 # @param NodeID a node ID
2663 # @param Edge an edge or edge ID
2664 # @param paramOnEdge a parameter on the edge where the node is located
2665 # @return True if succeed else raises an exception
2666 # @ingroup l2_modif_add
2667 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2668 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2669 EdgeID = Edge.GetSubShapeIndices()[0]
2673 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2674 except SALOME.SALOME_Exception, inst:
2675 raise ValueError, inst.details.text
2678 ## @brief Stores node position on a face
2679 # @param NodeID a node ID
2680 # @param Face a face or face ID
2681 # @param u U parameter on the face where the node is located
2682 # @param v V parameter on the face where the node is located
2683 # @return True if succeed else raises an exception
2684 # @ingroup l2_modif_add
2685 def SetNodeOnFace(self, NodeID, Face, u, v):
2686 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2687 FaceID = Face.GetSubShapeIndices()[0]
2691 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2692 except SALOME.SALOME_Exception, inst:
2693 raise ValueError, inst.details.text
2696 ## @brief Binds a node to a solid
2697 # @param NodeID a node ID
2698 # @param Solid a solid or solid ID
2699 # @return True if succeed else raises an exception
2700 # @ingroup l2_modif_add
2701 def SetNodeInVolume(self, NodeID, Solid):
2702 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2703 SolidID = Solid.GetSubShapeIndices()[0]
2707 self.editor.SetNodeInVolume(NodeID, SolidID)
2708 except SALOME.SALOME_Exception, inst:
2709 raise ValueError, inst.details.text
2712 ## @brief Bind an element to a shape
2713 # @param ElementID an element ID
2714 # @param Shape a shape or shape ID
2715 # @return True if succeed else raises an exception
2716 # @ingroup l2_modif_add
2717 def SetMeshElementOnShape(self, ElementID, Shape):
2718 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2719 ShapeID = Shape.GetSubShapeIndices()[0]
2723 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2724 except SALOME.SALOME_Exception, inst:
2725 raise ValueError, inst.details.text
2729 ## Moves the node with the given id
2730 # @param NodeID the id of the node
2731 # @param x a new X coordinate
2732 # @param y a new Y coordinate
2733 # @param z a new Z coordinate
2734 # @return True if succeed else False
2735 # @ingroup l2_modif_movenode
2736 def MoveNode(self, NodeID, x, y, z):
2737 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2738 self.mesh.SetParameters(Parameters)
2739 return self.editor.MoveNode(NodeID, x, y, z)
2741 ## Finds the node closest to a point and moves it to a point location
2742 # @param x the X coordinate of a point
2743 # @param y the Y coordinate of a point
2744 # @param z the Z coordinate of a point
2745 # @param NodeID if specified (>0), the node with this ID is moved,
2746 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2747 # @return the ID of a node
2748 # @ingroup l2_modif_throughp
2749 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2750 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2751 self.mesh.SetParameters(Parameters)
2752 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2754 ## Finds the node closest to a point
2755 # @param x the X coordinate of a point
2756 # @param y the Y coordinate of a point
2757 # @param z the Z coordinate of a point
2758 # @return the ID of a node
2759 # @ingroup l2_modif_throughp
2760 def FindNodeClosestTo(self, x, y, z):
2761 #preview = self.mesh.GetMeshEditPreviewer()
2762 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2763 return self.editor.FindNodeClosestTo(x, y, z)
2765 ## Finds the elements where a point lays IN or ON
2766 # @param x the X coordinate of a point
2767 # @param y the Y coordinate of a point
2768 # @param z the Z coordinate of a point
2769 # @param elementType type of elements to find (SMESH.ALL type
2770 # means elements of any type excluding nodes and 0D elements)
2771 # @param meshPart a part of mesh (group, sub-mesh) to search within
2772 # @return list of IDs of found elements
2773 # @ingroup l2_modif_throughp
2774 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL, meshPart=None):
2776 return self.editor.FindAmongElementsByPoint( meshPart, x, y, z, elementType );
2778 return self.editor.FindElementsByPoint(x, y, z, elementType)
2780 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2781 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2783 def GetPointState(self, x, y, z):
2784 return self.editor.GetPointState(x, y, z)
2786 ## Finds the node closest to a point and moves it to a point location
2787 # @param x the X coordinate of a point
2788 # @param y the Y coordinate of a point
2789 # @param z the Z coordinate of a point
2790 # @return the ID of a moved node
2791 # @ingroup l2_modif_throughp
2792 def MeshToPassThroughAPoint(self, x, y, z):
2793 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2795 ## Replaces two neighbour triangles sharing Node1-Node2 link
2796 # with the triangles built on the same 4 nodes but having other common link.
2797 # @param NodeID1 the ID of the first node
2798 # @param NodeID2 the ID of the second node
2799 # @return false if proper faces were not found
2800 # @ingroup l2_modif_invdiag
2801 def InverseDiag(self, NodeID1, NodeID2):
2802 return self.editor.InverseDiag(NodeID1, NodeID2)
2804 ## Replaces two neighbour triangles sharing Node1-Node2 link
2805 # with a quadrangle built on the same 4 nodes.
2806 # @param NodeID1 the ID of the first node
2807 # @param NodeID2 the ID of the second node
2808 # @return false if proper faces were not found
2809 # @ingroup l2_modif_unitetri
2810 def DeleteDiag(self, NodeID1, NodeID2):
2811 return self.editor.DeleteDiag(NodeID1, NodeID2)
2813 ## Reorients elements by ids
2814 # @param IDsOfElements if undefined reorients all mesh elements
2815 # @return True if succeed else False
2816 # @ingroup l2_modif_changori
2817 def Reorient(self, IDsOfElements=None):
2818 if IDsOfElements == None:
2819 IDsOfElements = self.GetElementsId()
2820 return self.editor.Reorient(IDsOfElements)
2822 ## Reorients all elements of the object
2823 # @param theObject mesh, submesh or group
2824 # @return True if succeed else False
2825 # @ingroup l2_modif_changori
2826 def ReorientObject(self, theObject):
2827 if ( isinstance( theObject, Mesh )):
2828 theObject = theObject.GetMesh()
2829 return self.editor.ReorientObject(theObject)
2831 ## Fuses the neighbouring triangles into quadrangles.
2832 # @param IDsOfElements The triangles to be fused,
2833 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2834 # @param MaxAngle is the maximum angle between element normals at which the fusion
2835 # is still performed; theMaxAngle is mesured in radians.
2836 # Also it could be a name of variable which defines angle in degrees.
2837 # @return TRUE in case of success, FALSE otherwise.
2838 # @ingroup l2_modif_unitetri
2839 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2841 if isinstance(MaxAngle,str):
2843 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2845 MaxAngle = DegreesToRadians(MaxAngle)
2846 if IDsOfElements == []:
2847 IDsOfElements = self.GetElementsId()
2848 self.mesh.SetParameters(Parameters)
2850 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2851 Functor = theCriterion
2853 Functor = self.smeshpyD.GetFunctor(theCriterion)
2854 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2856 ## Fuses the neighbouring triangles of the object into quadrangles
2857 # @param theObject is mesh, submesh or group
2858 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2859 # @param MaxAngle a max angle between element normals at which the fusion
2860 # is still performed; theMaxAngle is mesured in radians.
2861 # @return TRUE in case of success, FALSE otherwise.
2862 # @ingroup l2_modif_unitetri
2863 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2864 if ( isinstance( theObject, Mesh )):
2865 theObject = theObject.GetMesh()
2866 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2868 ## Splits quadrangles into triangles.
2869 # @param IDsOfElements the faces to be splitted.
2870 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2871 # @return TRUE in case of success, FALSE otherwise.
2872 # @ingroup l2_modif_cutquadr
2873 def QuadToTri (self, IDsOfElements, theCriterion):
2874 if IDsOfElements == []:
2875 IDsOfElements = self.GetElementsId()
2876 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2878 ## Splits quadrangles into triangles.
2879 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2880 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2881 # @return TRUE in case of success, FALSE otherwise.
2882 # @ingroup l2_modif_cutquadr
2883 def QuadToTriObject (self, theObject, theCriterion):
2884 if ( isinstance( theObject, Mesh )):
2885 theObject = theObject.GetMesh()
2886 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2888 ## Splits quadrangles into triangles.
2889 # @param IDsOfElements the faces to be splitted
2890 # @param Diag13 is used to choose a diagonal for splitting.
2891 # @return TRUE in case of success, FALSE otherwise.
2892 # @ingroup l2_modif_cutquadr
2893 def SplitQuad (self, IDsOfElements, Diag13):
2894 if IDsOfElements == []:
2895 IDsOfElements = self.GetElementsId()
2896 return self.editor.SplitQuad(IDsOfElements, Diag13)
2898 ## Splits quadrangles into triangles.
2899 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2900 # @param Diag13 is used to choose a diagonal for splitting.
2901 # @return TRUE in case of success, FALSE otherwise.
2902 # @ingroup l2_modif_cutquadr
2903 def SplitQuadObject (self, theObject, Diag13):
2904 if ( isinstance( theObject, Mesh )):
2905 theObject = theObject.GetMesh()
2906 return self.editor.SplitQuadObject(theObject, Diag13)
2908 ## Finds a better splitting of the given quadrangle.
2909 # @param IDOfQuad the ID of the quadrangle to be splitted.
2910 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2911 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2912 # diagonal is better, 0 if error occurs.
2913 # @ingroup l2_modif_cutquadr
2914 def BestSplit (self, IDOfQuad, theCriterion):
2915 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2917 ## Splits volumic elements into tetrahedrons
2918 # @param elemIDs either list of elements or mesh or group or submesh
2919 # @param method flags passing splitting method: Hex_5Tet, Hex_6Tet, Hex_24Tet
2920 # Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc
2921 # @ingroup l2_modif_cutquadr
2922 def SplitVolumesIntoTetra(self, elemIDs, method=Hex_5Tet ):
2923 if isinstance( elemIDs, Mesh ):
2924 elemIDs = elemIDs.GetMesh()
2925 if ( isinstance( elemIDs, list )):
2926 elemIDs = self.editor.MakeIDSource(elemIDs, SMESH.VOLUME)
2927 self.editor.SplitVolumesIntoTetra(elemIDs, method)
2929 ## Splits quadrangle faces near triangular facets of volumes
2931 # @ingroup l1_auxiliary
2932 def SplitQuadsNearTriangularFacets(self):
2933 faces_array = self.GetElementsByType(SMESH.FACE)
2934 for face_id in faces_array:
2935 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2936 quad_nodes = self.mesh.GetElemNodes(face_id)
2937 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2938 isVolumeFound = False
2939 for node1_elem in node1_elems:
2940 if not isVolumeFound:
2941 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2942 nb_nodes = self.GetElemNbNodes(node1_elem)
2943 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2944 volume_elem = node1_elem
2945 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2946 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2947 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2948 isVolumeFound = True
2949 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2950 self.SplitQuad([face_id], False) # diagonal 2-4
2951 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2952 isVolumeFound = True
2953 self.SplitQuad([face_id], True) # diagonal 1-3
2954 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2955 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2956 isVolumeFound = True
2957 self.SplitQuad([face_id], True) # diagonal 1-3
2959 ## @brief Splits hexahedrons into tetrahedrons.
2961 # This operation uses pattern mapping functionality for splitting.
2962 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2963 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2964 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2965 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2966 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2967 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2968 # @return TRUE in case of success, FALSE otherwise.
2969 # @ingroup l1_auxiliary
2970 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2971 # Pattern: 5.---------.6
2976 # (0,0,1) 4.---------.7 * |
2983 # (0,0,0) 0.---------.3
2984 pattern_tetra = "!!! Nb of points: \n 8 \n\
2994 !!! Indices of points of 6 tetras: \n\
3002 pattern = self.smeshpyD.GetPattern()
3003 isDone = pattern.LoadFromFile(pattern_tetra)
3005 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
3008 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
3009 isDone = pattern.MakeMesh(self.mesh, False, False)
3010 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
3012 # split quafrangle faces near triangular facets of volumes
3013 self.SplitQuadsNearTriangularFacets()
3017 ## @brief Split hexahedrons into prisms.
3019 # Uses the pattern mapping functionality for splitting.
3020 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
3021 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
3022 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
3023 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
3024 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
3025 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
3026 # @return TRUE in case of success, FALSE otherwise.
3027 # @ingroup l1_auxiliary
3028 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
3029 # Pattern: 5.---------.6
3034 # (0,0,1) 4.---------.7 |
3041 # (0,0,0) 0.---------.3
3042 pattern_prism = "!!! Nb of points: \n 8 \n\
3052 !!! Indices of points of 2 prisms: \n\
3056 pattern = self.smeshpyD.GetPattern()
3057 isDone = pattern.LoadFromFile(pattern_prism)
3059 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
3062 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
3063 isDone = pattern.MakeMesh(self.mesh, False, False)
3064 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
3066 # Splits quafrangle faces near triangular facets of volumes
3067 self.SplitQuadsNearTriangularFacets()
3071 ## Smoothes elements
3072 # @param IDsOfElements the list if ids of elements to smooth
3073 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3074 # Note that nodes built on edges and boundary nodes are always fixed.
3075 # @param MaxNbOfIterations the maximum number of iterations
3076 # @param MaxAspectRatio varies in range [1.0, inf]
3077 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3078 # @return TRUE in case of success, FALSE otherwise.
3079 # @ingroup l2_modif_smooth
3080 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
3081 MaxNbOfIterations, MaxAspectRatio, Method):
3082 if IDsOfElements == []:
3083 IDsOfElements = self.GetElementsId()
3084 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
3085 self.mesh.SetParameters(Parameters)
3086 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
3087 MaxNbOfIterations, MaxAspectRatio, Method)
3089 ## Smoothes elements which belong to the given object
3090 # @param theObject the object to smooth
3091 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3092 # Note that nodes built on edges and boundary nodes are always fixed.
3093 # @param MaxNbOfIterations the maximum number of iterations
3094 # @param MaxAspectRatio varies in range [1.0, inf]
3095 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3096 # @return TRUE in case of success, FALSE otherwise.
3097 # @ingroup l2_modif_smooth
3098 def SmoothObject(self, theObject, IDsOfFixedNodes,
3099 MaxNbOfIterations, MaxAspectRatio, Method):
3100 if ( isinstance( theObject, Mesh )):
3101 theObject = theObject.GetMesh()
3102 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
3103 MaxNbOfIterations, MaxAspectRatio, Method)
3105 ## Parametrically smoothes the given elements
3106 # @param IDsOfElements the list if ids of elements to smooth
3107 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3108 # Note that nodes built on edges and boundary nodes are always fixed.
3109 # @param MaxNbOfIterations the maximum number of iterations
3110 # @param MaxAspectRatio varies in range [1.0, inf]
3111 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3112 # @return TRUE in case of success, FALSE otherwise.
3113 # @ingroup l2_modif_smooth
3114 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
3115 MaxNbOfIterations, MaxAspectRatio, Method):
3116 if IDsOfElements == []:
3117 IDsOfElements = self.GetElementsId()
3118 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
3119 self.mesh.SetParameters(Parameters)
3120 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
3121 MaxNbOfIterations, MaxAspectRatio, Method)
3123 ## Parametrically smoothes the elements which belong to the given object
3124 # @param theObject the object to smooth
3125 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3126 # Note that nodes built on edges and boundary nodes are always fixed.
3127 # @param MaxNbOfIterations the maximum number of iterations
3128 # @param MaxAspectRatio varies in range [1.0, inf]
3129 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3130 # @return TRUE in case of success, FALSE otherwise.
3131 # @ingroup l2_modif_smooth
3132 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
3133 MaxNbOfIterations, MaxAspectRatio, Method):
3134 if ( isinstance( theObject, Mesh )):
3135 theObject = theObject.GetMesh()
3136 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
3137 MaxNbOfIterations, MaxAspectRatio, Method)
3139 ## Converts the mesh to quadratic, deletes old elements, replacing
3140 # them with quadratic with the same id.
3141 # @param theForce3d new node creation method:
3142 # 0 - the medium node lies at the geometrical entity from which the mesh element is built
3143 # 1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element
3144 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
3145 # @ingroup l2_modif_tofromqu
3146 def ConvertToQuadratic(self, theForce3d, theSubMesh=None):
3148 self.editor.ConvertToQuadraticObject(theForce3d,theSubMesh)
3150 self.editor.ConvertToQuadratic(theForce3d)
3152 ## Converts the mesh from quadratic to ordinary,
3153 # deletes old quadratic elements, \n replacing
3154 # them with ordinary mesh elements with the same id.
3155 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
3156 # @ingroup l2_modif_tofromqu
3157 def ConvertFromQuadratic(self, theSubMesh=None):
3159 self.editor.ConvertFromQuadraticObject(theSubMesh)
3161 return self.editor.ConvertFromQuadratic()
3163 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
3164 # @return TRUE if operation has been completed successfully, FALSE otherwise
3165 # @ingroup l2_modif_edit
3166 def Make2DMeshFrom3D(self):
3167 return self.editor. Make2DMeshFrom3D()
3169 ## Creates missing boundary elements
3170 # @param elements - elements whose boundary is to be checked:
3171 # mesh, group, sub-mesh or list of elements
3172 # if elements is mesh, it must be the mesh whose MakeBoundaryMesh() is called
3173 # @param dimension - defines type of boundary elements to create:
3174 # SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D
3175 # SMESH.BND_1DFROM3D creates mesh edges on all borders of free facets of 3D cells
3176 # @param groupName - a name of group to store created boundary elements in,
3177 # "" means not to create the group
3178 # @param meshName - a name of new mesh to store created boundary elements in,
3179 # "" means not to create the new mesh
3180 # @param toCopyElements - if true, the checked elements will be copied into
3181 # the new mesh else only boundary elements will be copied into the new mesh
3182 # @param toCopyExistingBondary - if true, not only new but also pre-existing
3183 # boundary elements will be copied into the new mesh
3184 # @return tuple (mesh, group) where bondary elements were added to
3185 # @ingroup l2_modif_edit
3186 def MakeBoundaryMesh(self, elements, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3187 toCopyElements=False, toCopyExistingBondary=False):
3188 if isinstance( elements, Mesh ):
3189 elements = elements.GetMesh()
3190 if ( isinstance( elements, list )):
3191 elemType = SMESH.ALL
3192 if elements: elemType = self.GetElementType( elements[0], iselem=True)
3193 elements = self.editor.MakeIDSource(elements, elemType)
3194 mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName,
3195 toCopyElements,toCopyExistingBondary)
3196 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3200 # @brief Creates missing boundary elements around either the whole mesh or
3201 # groups of 2D elements
3202 # @param dimension - defines type of boundary elements to create
3203 # @param groupName - a name of group to store all boundary elements in,
3204 # "" means not to create the group
3205 # @param meshName - a name of a new mesh, which is a copy of the initial
3206 # mesh + created boundary elements; "" means not to create the new mesh
3207 # @param toCopyAll - if true, the whole initial mesh will be copied into
3208 # the new mesh else only boundary elements will be copied into the new mesh
3209 # @param groups - groups of 2D elements to make boundary around
3210 # @retval tuple( long, mesh, groups )
3211 # long - number of added boundary elements
3212 # mesh - the mesh where elements were added to
3213 # group - the group of boundary elements or None
3215 def MakeBoundaryElements(self, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3216 toCopyAll=False, groups=[]):
3217 nb, mesh, group = self.editor.MakeBoundaryElements(dimension,groupName,meshName,
3219 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3220 return nb, mesh, group
3222 ## Renumber mesh nodes
3223 # @ingroup l2_modif_renumber
3224 def RenumberNodes(self):
3225 self.editor.RenumberNodes()
3227 ## Renumber mesh elements
3228 # @ingroup l2_modif_renumber
3229 def RenumberElements(self):
3230 self.editor.RenumberElements()
3232 ## Generates new elements by rotation of the elements around the axis
3233 # @param IDsOfElements the list of ids of elements to sweep
3234 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3235 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
3236 # @param NbOfSteps the number of steps
3237 # @param Tolerance tolerance
3238 # @param MakeGroups forces the generation of new groups from existing ones
3239 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3240 # of all steps, else - size of each step
3241 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3242 # @ingroup l2_modif_extrurev
3243 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
3244 MakeGroups=False, TotalAngle=False):
3246 if isinstance(AngleInRadians,str):
3248 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3250 AngleInRadians = DegreesToRadians(AngleInRadians)
3251 if IDsOfElements == []:
3252 IDsOfElements = self.GetElementsId()
3253 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3254 Axis = self.smeshpyD.GetAxisStruct(Axis)
3255 Axis,AxisParameters = ParseAxisStruct(Axis)
3256 if TotalAngle and NbOfSteps:
3257 AngleInRadians /= NbOfSteps
3258 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3259 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3260 self.mesh.SetParameters(Parameters)
3262 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
3263 AngleInRadians, NbOfSteps, Tolerance)
3264 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
3267 ## Generates new elements by rotation of the elements of object around the axis
3268 # @param theObject object which elements should be sweeped.
3269 # It can be a mesh, a sub mesh or a group.
3270 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3271 # @param AngleInRadians the angle of Rotation
3272 # @param NbOfSteps number of steps
3273 # @param Tolerance tolerance
3274 # @param MakeGroups forces the generation of new groups from existing ones
3275 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3276 # of all steps, else - size of each step
3277 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3278 # @ingroup l2_modif_extrurev
3279 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3280 MakeGroups=False, TotalAngle=False):
3282 if isinstance(AngleInRadians,str):
3284 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3286 AngleInRadians = DegreesToRadians(AngleInRadians)
3287 if ( isinstance( theObject, Mesh )):
3288 theObject = theObject.GetMesh()
3289 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3290 Axis = self.smeshpyD.GetAxisStruct(Axis)
3291 Axis,AxisParameters = ParseAxisStruct(Axis)
3292 if TotalAngle and NbOfSteps:
3293 AngleInRadians /= NbOfSteps
3294 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3295 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3296 self.mesh.SetParameters(Parameters)
3298 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
3299 NbOfSteps, Tolerance)
3300 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3303 ## Generates new elements by rotation of the elements of object around the axis
3304 # @param theObject object which elements should be sweeped.
3305 # It can be a mesh, a sub mesh or a group.
3306 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3307 # @param AngleInRadians the angle of Rotation
3308 # @param NbOfSteps number of steps
3309 # @param Tolerance tolerance
3310 # @param MakeGroups forces the generation of new groups from existing ones
3311 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3312 # of all steps, else - size of each step
3313 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3314 # @ingroup l2_modif_extrurev
3315 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3316 MakeGroups=False, TotalAngle=False):
3318 if isinstance(AngleInRadians,str):
3320 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3322 AngleInRadians = DegreesToRadians(AngleInRadians)
3323 if ( isinstance( theObject, Mesh )):
3324 theObject = theObject.GetMesh()
3325 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3326 Axis = self.smeshpyD.GetAxisStruct(Axis)
3327 Axis,AxisParameters = ParseAxisStruct(Axis)
3328 if TotalAngle and NbOfSteps:
3329 AngleInRadians /= NbOfSteps
3330 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3331 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3332 self.mesh.SetParameters(Parameters)
3334 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
3335 NbOfSteps, Tolerance)
3336 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3339 ## Generates new elements by rotation of the elements of object around the axis
3340 # @param theObject object which elements should be sweeped.
3341 # It can be a mesh, a sub mesh or a group.
3342 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3343 # @param AngleInRadians the angle of Rotation
3344 # @param NbOfSteps number of steps
3345 # @param Tolerance tolerance
3346 # @param MakeGroups forces the generation of new groups from existing ones
3347 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3348 # of all steps, else - size of each step
3349 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3350 # @ingroup l2_modif_extrurev
3351 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3352 MakeGroups=False, TotalAngle=False):
3354 if isinstance(AngleInRadians,str):
3356 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3358 AngleInRadians = DegreesToRadians(AngleInRadians)
3359 if ( isinstance( theObject, Mesh )):
3360 theObject = theObject.GetMesh()
3361 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3362 Axis = self.smeshpyD.GetAxisStruct(Axis)
3363 Axis,AxisParameters = ParseAxisStruct(Axis)
3364 if TotalAngle and NbOfSteps:
3365 AngleInRadians /= NbOfSteps
3366 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3367 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3368 self.mesh.SetParameters(Parameters)
3370 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
3371 NbOfSteps, Tolerance)
3372 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3375 ## Generates new elements by extrusion of the elements with given ids
3376 # @param IDsOfElements the list of elements ids for extrusion
3377 # @param StepVector vector or DirStruct, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3378 # @param NbOfSteps the number of steps
3379 # @param MakeGroups forces the generation of new groups from existing ones
3380 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3381 # @ingroup l2_modif_extrurev
3382 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
3383 if IDsOfElements == []:
3384 IDsOfElements = self.GetElementsId()
3385 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3386 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3387 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3388 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3389 Parameters = StepVectorParameters + var_separator + Parameters
3390 self.mesh.SetParameters(Parameters)
3392 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
3393 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
3396 ## Generates new elements by extrusion of the elements with given ids
3397 # @param IDsOfElements is ids of elements
3398 # @param StepVector vector, defining the direction and value of extrusion
3399 # @param NbOfSteps the number of steps
3400 # @param ExtrFlags sets flags for extrusion
3401 # @param SewTolerance uses for comparing locations of nodes if flag
3402 # EXTRUSION_FLAG_SEW is set
3403 # @param MakeGroups forces the generation of new groups from existing ones
3404 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3405 # @ingroup l2_modif_extrurev
3406 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
3407 ExtrFlags, SewTolerance, MakeGroups=False):
3408 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3409 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3411 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
3412 ExtrFlags, SewTolerance)
3413 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
3414 ExtrFlags, SewTolerance)
3417 ## Generates new elements by extrusion of the elements which belong to the object
3418 # @param theObject the object which elements should be processed.
3419 # It can be a mesh, a sub mesh or a group.
3420 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3421 # @param NbOfSteps the number of steps
3422 # @param MakeGroups forces the generation of new groups from existing ones
3423 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3424 # @ingroup l2_modif_extrurev
3425 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3426 if ( isinstance( theObject, Mesh )):
3427 theObject = theObject.GetMesh()
3428 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3429 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3430 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3431 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3432 Parameters = StepVectorParameters + var_separator + Parameters
3433 self.mesh.SetParameters(Parameters)
3435 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3436 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
3439 ## Generates new elements by extrusion of the elements which belong to the object
3440 # @param theObject object which elements should be processed.
3441 # It can be a mesh, a sub mesh or a group.
3442 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3443 # @param NbOfSteps the number of steps
3444 # @param MakeGroups to generate new groups from existing ones
3445 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3446 # @ingroup l2_modif_extrurev
3447 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3448 if ( isinstance( theObject, Mesh )):
3449 theObject = theObject.GetMesh()
3450 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3451 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3452 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3453 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3454 Parameters = StepVectorParameters + var_separator + Parameters
3455 self.mesh.SetParameters(Parameters)
3457 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3458 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3461 ## Generates new elements by extrusion of the elements which belong to the object
3462 # @param theObject object which elements should be processed.
3463 # It can be a mesh, a sub mesh or a group.
3464 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3465 # @param NbOfSteps the number of steps
3466 # @param MakeGroups forces the generation of new groups from existing ones
3467 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3468 # @ingroup l2_modif_extrurev
3469 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3470 if ( isinstance( theObject, Mesh )):
3471 theObject = theObject.GetMesh()
3472 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3473 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3474 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3475 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3476 Parameters = StepVectorParameters + var_separator + Parameters
3477 self.mesh.SetParameters(Parameters)
3479 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3480 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3485 ## Generates new elements by extrusion of the given elements
3486 # The path of extrusion must be a meshed edge.
3487 # @param Base mesh or group, or submesh, or list of ids of elements for extrusion
3488 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3489 # @param NodeStart the start node from Path. Defines the direction of extrusion
3490 # @param HasAngles allows the shape to be rotated around the path
3491 # to get the resulting mesh in a helical fashion
3492 # @param Angles list of angles in radians
3493 # @param LinearVariation forces the computation of rotation angles as linear
3494 # variation of the given Angles along path steps
3495 # @param HasRefPoint allows using the reference point
3496 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3497 # The User can specify any point as the Reference Point.
3498 # @param MakeGroups forces the generation of new groups from existing ones
3499 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3500 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3501 # only SMESH::Extrusion_Error otherwise
3502 # @ingroup l2_modif_extrurev
3503 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3504 HasAngles, Angles, LinearVariation,
3505 HasRefPoint, RefPoint, MakeGroups, ElemType):
3506 Angles,AnglesParameters = ParseAngles(Angles)
3507 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3508 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3509 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3511 Parameters = AnglesParameters + var_separator + RefPointParameters
3512 self.mesh.SetParameters(Parameters)
3514 if (isinstance(Path, Mesh)): Path = Path.GetMesh()
3516 if isinstance(Base, list):
3518 if Base == []: IDsOfElements = self.GetElementsId()
3519 else: IDsOfElements = Base
3520 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3521 HasAngles, Angles, LinearVariation,
3522 HasRefPoint, RefPoint, MakeGroups, ElemType)
3524 if isinstance(Base, Mesh): Base = Base.GetMesh()
3525 if isinstance(Base, SMESH._objref_SMESH_Mesh) or isinstance(Base, SMESH._objref_SMESH_Group) or isinstance(Base, SMESH._objref_SMESH_subMesh):
3526 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3527 HasAngles, Angles, LinearVariation,
3528 HasRefPoint, RefPoint, MakeGroups, ElemType)
3530 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3533 ## Generates new elements by extrusion of the given elements
3534 # The path of extrusion must be a meshed edge.
3535 # @param IDsOfElements ids of elements
3536 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3537 # @param PathShape shape(edge) defines the sub-mesh for the path
3538 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3539 # @param HasAngles allows the shape to be rotated around the path
3540 # to get the resulting mesh in a helical fashion
3541 # @param Angles list of angles in radians
3542 # @param HasRefPoint allows using the reference point
3543 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3544 # The User can specify any point as the Reference Point.
3545 # @param MakeGroups forces the generation of new groups from existing ones
3546 # @param LinearVariation forces the computation of rotation angles as linear
3547 # variation of the given Angles along path steps
3548 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3549 # only SMESH::Extrusion_Error otherwise
3550 # @ingroup l2_modif_extrurev
3551 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3552 HasAngles, Angles, HasRefPoint, RefPoint,
3553 MakeGroups=False, LinearVariation=False):
3554 Angles,AnglesParameters = ParseAngles(Angles)
3555 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3556 if IDsOfElements == []:
3557 IDsOfElements = self.GetElementsId()
3558 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3559 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3561 if ( isinstance( PathMesh, Mesh )):
3562 PathMesh = PathMesh.GetMesh()
3563 if HasAngles and Angles and LinearVariation:
3564 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3566 Parameters = AnglesParameters + var_separator + RefPointParameters
3567 self.mesh.SetParameters(Parameters)
3569 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3570 PathShape, NodeStart, HasAngles,
3571 Angles, HasRefPoint, RefPoint)
3572 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3573 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3575 ## Generates new elements by extrusion of the elements which belong to the object
3576 # The path of extrusion must be a meshed edge.
3577 # @param theObject the object which elements should be processed.
3578 # It can be a mesh, a sub mesh or a group.
3579 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3580 # @param PathShape shape(edge) defines the sub-mesh for the path
3581 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3582 # @param HasAngles allows the shape to be rotated around the path
3583 # to get the resulting mesh in a helical fashion
3584 # @param Angles list of angles
3585 # @param HasRefPoint allows using the reference point
3586 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3587 # The User can specify any point as the Reference Point.
3588 # @param MakeGroups forces the generation of new groups from existing ones
3589 # @param LinearVariation forces the computation of rotation angles as linear
3590 # variation of the given Angles along path steps
3591 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3592 # only SMESH::Extrusion_Error otherwise
3593 # @ingroup l2_modif_extrurev
3594 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3595 HasAngles, Angles, HasRefPoint, RefPoint,
3596 MakeGroups=False, LinearVariation=False):
3597 Angles,AnglesParameters = ParseAngles(Angles)
3598 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3599 if ( isinstance( theObject, Mesh )):
3600 theObject = theObject.GetMesh()
3601 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3602 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3603 if ( isinstance( PathMesh, Mesh )):
3604 PathMesh = PathMesh.GetMesh()
3605 if HasAngles and Angles and LinearVariation:
3606 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3608 Parameters = AnglesParameters + var_separator + RefPointParameters
3609 self.mesh.SetParameters(Parameters)
3611 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3612 PathShape, NodeStart, HasAngles,
3613 Angles, HasRefPoint, RefPoint)
3614 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3615 NodeStart, HasAngles, Angles, HasRefPoint,
3618 ## Generates new elements by extrusion of the elements which belong to the object
3619 # The path of extrusion must be a meshed edge.
3620 # @param theObject the object which elements should be processed.
3621 # It can be a mesh, a sub mesh or a group.
3622 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3623 # @param PathShape shape(edge) defines the sub-mesh for the path
3624 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3625 # @param HasAngles allows the shape to be rotated around the path
3626 # to get the resulting mesh in a helical fashion
3627 # @param Angles list of angles
3628 # @param HasRefPoint allows using the reference point
3629 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3630 # The User can specify any point as the Reference Point.
3631 # @param MakeGroups forces the generation of new groups from existing ones
3632 # @param LinearVariation forces the computation of rotation angles as linear
3633 # variation of the given Angles along path steps
3634 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3635 # only SMESH::Extrusion_Error otherwise
3636 # @ingroup l2_modif_extrurev
3637 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3638 HasAngles, Angles, HasRefPoint, RefPoint,
3639 MakeGroups=False, LinearVariation=False):
3640 Angles,AnglesParameters = ParseAngles(Angles)
3641 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3642 if ( isinstance( theObject, Mesh )):
3643 theObject = theObject.GetMesh()
3644 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3645 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3646 if ( isinstance( PathMesh, Mesh )):
3647 PathMesh = PathMesh.GetMesh()
3648 if HasAngles and Angles and LinearVariation:
3649 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3651 Parameters = AnglesParameters + var_separator + RefPointParameters
3652 self.mesh.SetParameters(Parameters)
3654 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3655 PathShape, NodeStart, HasAngles,
3656 Angles, HasRefPoint, RefPoint)
3657 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3658 NodeStart, HasAngles, Angles, HasRefPoint,
3661 ## Generates new elements by extrusion of the elements which belong to the object
3662 # The path of extrusion must be a meshed edge.
3663 # @param theObject the object which elements should be processed.
3664 # It can be a mesh, a sub mesh or a group.
3665 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3666 # @param PathShape shape(edge) defines the sub-mesh for the path
3667 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3668 # @param HasAngles allows the shape to be rotated around the path
3669 # to get the resulting mesh in a helical fashion
3670 # @param Angles list of angles
3671 # @param HasRefPoint allows using the reference point
3672 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3673 # The User can specify any point as the Reference Point.
3674 # @param MakeGroups forces the generation of new groups from existing ones
3675 # @param LinearVariation forces the computation of rotation angles as linear
3676 # variation of the given Angles along path steps
3677 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3678 # only SMESH::Extrusion_Error otherwise
3679 # @ingroup l2_modif_extrurev
3680 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3681 HasAngles, Angles, HasRefPoint, RefPoint,
3682 MakeGroups=False, LinearVariation=False):
3683 Angles,AnglesParameters = ParseAngles(Angles)
3684 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3685 if ( isinstance( theObject, Mesh )):
3686 theObject = theObject.GetMesh()
3687 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3688 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3689 if ( isinstance( PathMesh, Mesh )):
3690 PathMesh = PathMesh.GetMesh()
3691 if HasAngles and Angles and LinearVariation:
3692 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3694 Parameters = AnglesParameters + var_separator + RefPointParameters
3695 self.mesh.SetParameters(Parameters)
3697 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3698 PathShape, NodeStart, HasAngles,
3699 Angles, HasRefPoint, RefPoint)
3700 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3701 NodeStart, HasAngles, Angles, HasRefPoint,
3704 ## Creates a symmetrical copy of mesh elements
3705 # @param IDsOfElements list of elements ids
3706 # @param Mirror is AxisStruct or geom object(point, line, plane)
3707 # @param theMirrorType is POINT, AXIS or PLANE
3708 # If the Mirror is a geom object this parameter is unnecessary
3709 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3710 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3711 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3712 # @ingroup l2_modif_trsf
3713 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3714 if IDsOfElements == []:
3715 IDsOfElements = self.GetElementsId()
3716 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3717 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3718 Mirror,Parameters = ParseAxisStruct(Mirror)
3719 self.mesh.SetParameters(Parameters)
3720 if Copy and MakeGroups:
3721 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3722 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3725 ## Creates a new mesh by a symmetrical copy of mesh elements
3726 # @param IDsOfElements the list of elements ids
3727 # @param Mirror is AxisStruct or geom object (point, line, plane)
3728 # @param theMirrorType is POINT, AXIS or PLANE
3729 # If the Mirror is a geom object this parameter is unnecessary
3730 # @param MakeGroups to generate new groups from existing ones
3731 # @param NewMeshName a name of the new mesh to create
3732 # @return instance of Mesh class
3733 # @ingroup l2_modif_trsf
3734 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3735 if IDsOfElements == []:
3736 IDsOfElements = self.GetElementsId()
3737 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3738 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3739 Mirror,Parameters = ParseAxisStruct(Mirror)
3740 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3741 MakeGroups, NewMeshName)
3742 mesh.SetParameters(Parameters)
3743 return Mesh(self.smeshpyD,self.geompyD,mesh)
3745 ## Creates a symmetrical copy of the object
3746 # @param theObject mesh, submesh or group
3747 # @param Mirror AxisStruct or geom object (point, line, plane)
3748 # @param theMirrorType is POINT, AXIS or PLANE
3749 # If the Mirror is a geom object this parameter is unnecessary
3750 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3751 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3752 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3753 # @ingroup l2_modif_trsf
3754 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3755 if ( isinstance( theObject, Mesh )):
3756 theObject = theObject.GetMesh()
3757 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3758 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3759 Mirror,Parameters = ParseAxisStruct(Mirror)
3760 self.mesh.SetParameters(Parameters)
3761 if Copy and MakeGroups:
3762 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3763 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3766 ## Creates a new mesh by a symmetrical copy of the object
3767 # @param theObject mesh, submesh or group
3768 # @param Mirror AxisStruct or geom object (point, line, plane)
3769 # @param theMirrorType POINT, AXIS or PLANE
3770 # If the Mirror is a geom object this parameter is unnecessary
3771 # @param MakeGroups forces the generation of new groups from existing ones
3772 # @param NewMeshName the name of the new mesh to create
3773 # @return instance of Mesh class
3774 # @ingroup l2_modif_trsf
3775 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3776 if ( isinstance( theObject, Mesh )):
3777 theObject = theObject.GetMesh()
3778 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3779 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3780 Mirror,Parameters = ParseAxisStruct(Mirror)
3781 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3782 MakeGroups, NewMeshName)
3783 mesh.SetParameters(Parameters)
3784 return Mesh( self.smeshpyD,self.geompyD,mesh )
3786 ## Translates the elements
3787 # @param IDsOfElements list of elements ids
3788 # @param Vector the direction of translation (DirStruct or vector)
3789 # @param Copy allows copying the translated elements
3790 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3791 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3792 # @ingroup l2_modif_trsf
3793 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3794 if IDsOfElements == []:
3795 IDsOfElements = self.GetElementsId()
3796 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3797 Vector = self.smeshpyD.GetDirStruct(Vector)
3798 Vector,Parameters = ParseDirStruct(Vector)
3799 self.mesh.SetParameters(Parameters)
3800 if Copy and MakeGroups:
3801 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3802 self.editor.Translate(IDsOfElements, Vector, Copy)
3805 ## Creates a new mesh of translated elements
3806 # @param IDsOfElements list of elements ids
3807 # @param Vector the direction of translation (DirStruct or vector)
3808 # @param MakeGroups forces the generation of new groups from existing ones
3809 # @param NewMeshName the name of the newly created mesh
3810 # @return instance of Mesh class
3811 # @ingroup l2_modif_trsf
3812 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3813 if IDsOfElements == []:
3814 IDsOfElements = self.GetElementsId()
3815 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3816 Vector = self.smeshpyD.GetDirStruct(Vector)
3817 Vector,Parameters = ParseDirStruct(Vector)
3818 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3819 mesh.SetParameters(Parameters)
3820 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3822 ## Translates the object
3823 # @param theObject the object to translate (mesh, submesh, or group)
3824 # @param Vector direction of translation (DirStruct or geom vector)
3825 # @param Copy allows copying the translated elements
3826 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3827 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3828 # @ingroup l2_modif_trsf
3829 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3830 if ( isinstance( theObject, Mesh )):
3831 theObject = theObject.GetMesh()
3832 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3833 Vector = self.smeshpyD.GetDirStruct(Vector)
3834 Vector,Parameters = ParseDirStruct(Vector)
3835 self.mesh.SetParameters(Parameters)
3836 if Copy and MakeGroups:
3837 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3838 self.editor.TranslateObject(theObject, Vector, Copy)
3841 ## Creates a new mesh from the translated object
3842 # @param theObject the object to translate (mesh, submesh, or group)
3843 # @param Vector the direction of translation (DirStruct or geom vector)
3844 # @param MakeGroups forces the generation of new groups from existing ones
3845 # @param NewMeshName the name of the newly created mesh
3846 # @return instance of Mesh class
3847 # @ingroup l2_modif_trsf
3848 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3849 if (isinstance(theObject, Mesh)):
3850 theObject = theObject.GetMesh()
3851 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3852 Vector = self.smeshpyD.GetDirStruct(Vector)
3853 Vector,Parameters = ParseDirStruct(Vector)
3854 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3855 mesh.SetParameters(Parameters)
3856 return Mesh( self.smeshpyD, self.geompyD, mesh )
3860 ## Scales the object
3861 # @param theObject - the object to translate (mesh, submesh, or group)
3862 # @param thePoint - base point for scale
3863 # @param theScaleFact - list of 1-3 scale factors for axises
3864 # @param Copy - allows copying the translated elements
3865 # @param MakeGroups - forces the generation of new groups from existing
3867 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3868 # empty list otherwise
3869 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3870 if ( isinstance( theObject, Mesh )):
3871 theObject = theObject.GetMesh()
3872 if ( isinstance( theObject, list )):
3873 theObject = self.GetIDSource(theObject, SMESH.ALL)
3875 thePoint, Parameters = ParsePointStruct(thePoint)
3876 self.mesh.SetParameters(Parameters)
3878 if Copy and MakeGroups:
3879 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3880 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3883 ## Creates a new mesh from the translated object
3884 # @param theObject - the object to translate (mesh, submesh, or group)
3885 # @param thePoint - base point for scale
3886 # @param theScaleFact - list of 1-3 scale factors for axises
3887 # @param MakeGroups - forces the generation of new groups from existing ones
3888 # @param NewMeshName - the name of the newly created mesh
3889 # @return instance of Mesh class
3890 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3891 if (isinstance(theObject, Mesh)):
3892 theObject = theObject.GetMesh()
3893 if ( isinstance( theObject, list )):
3894 theObject = self.GetIDSource(theObject,SMESH.ALL)
3896 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3897 MakeGroups, NewMeshName)
3898 #mesh.SetParameters(Parameters)
3899 return Mesh( self.smeshpyD, self.geompyD, mesh )
3903 ## Rotates the elements
3904 # @param IDsOfElements list of elements ids
3905 # @param Axis the axis of rotation (AxisStruct or geom line)
3906 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3907 # @param Copy allows copying the rotated elements
3908 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3909 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3910 # @ingroup l2_modif_trsf
3911 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3913 if isinstance(AngleInRadians,str):
3915 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3917 AngleInRadians = DegreesToRadians(AngleInRadians)
3918 if IDsOfElements == []:
3919 IDsOfElements = self.GetElementsId()
3920 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3921 Axis = self.smeshpyD.GetAxisStruct(Axis)
3922 Axis,AxisParameters = ParseAxisStruct(Axis)
3923 Parameters = AxisParameters + var_separator + Parameters
3924 self.mesh.SetParameters(Parameters)
3925 if Copy and MakeGroups:
3926 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3927 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3930 ## Creates a new mesh of rotated elements
3931 # @param IDsOfElements list of element ids
3932 # @param Axis the axis of rotation (AxisStruct or geom line)
3933 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3934 # @param MakeGroups forces the generation of new groups from existing ones
3935 # @param NewMeshName the name of the newly created mesh
3936 # @return instance of Mesh class
3937 # @ingroup l2_modif_trsf
3938 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3940 if isinstance(AngleInRadians,str):
3942 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3944 AngleInRadians = DegreesToRadians(AngleInRadians)
3945 if IDsOfElements == []:
3946 IDsOfElements = self.GetElementsId()
3947 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3948 Axis = self.smeshpyD.GetAxisStruct(Axis)
3949 Axis,AxisParameters = ParseAxisStruct(Axis)
3950 Parameters = AxisParameters + var_separator + Parameters
3951 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3952 MakeGroups, NewMeshName)
3953 mesh.SetParameters(Parameters)
3954 return Mesh( self.smeshpyD, self.geompyD, mesh )
3956 ## Rotates the object
3957 # @param theObject the object to rotate( mesh, submesh, or group)
3958 # @param Axis the axis of rotation (AxisStruct or geom line)
3959 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3960 # @param Copy allows copying the rotated elements
3961 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3962 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3963 # @ingroup l2_modif_trsf
3964 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3966 if isinstance(AngleInRadians,str):
3968 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3970 AngleInRadians = DegreesToRadians(AngleInRadians)
3971 if (isinstance(theObject, Mesh)):
3972 theObject = theObject.GetMesh()
3973 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3974 Axis = self.smeshpyD.GetAxisStruct(Axis)
3975 Axis,AxisParameters = ParseAxisStruct(Axis)
3976 Parameters = AxisParameters + ":" + Parameters
3977 self.mesh.SetParameters(Parameters)
3978 if Copy and MakeGroups:
3979 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3980 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3983 ## Creates a new mesh from the rotated object
3984 # @param theObject the object to rotate (mesh, submesh, or group)
3985 # @param Axis the axis of rotation (AxisStruct or geom line)
3986 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3987 # @param MakeGroups forces the generation of new groups from existing ones
3988 # @param NewMeshName the name of the newly created mesh
3989 # @return instance of Mesh class
3990 # @ingroup l2_modif_trsf
3991 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3993 if isinstance(AngleInRadians,str):
3995 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3997 AngleInRadians = DegreesToRadians(AngleInRadians)
3998 if (isinstance( theObject, Mesh )):
3999 theObject = theObject.GetMesh()
4000 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
4001 Axis = self.smeshpyD.GetAxisStruct(Axis)
4002 Axis,AxisParameters = ParseAxisStruct(Axis)
4003 Parameters = AxisParameters + ":" + Parameters
4004 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
4005 MakeGroups, NewMeshName)
4006 mesh.SetParameters(Parameters)
4007 return Mesh( self.smeshpyD, self.geompyD, mesh )
4009 ## Finds groups of ajacent nodes within Tolerance.
4010 # @param Tolerance the value of tolerance
4011 # @return the list of groups of nodes
4012 # @ingroup l2_modif_trsf
4013 def FindCoincidentNodes (self, Tolerance):
4014 return self.editor.FindCoincidentNodes(Tolerance)
4016 ## Finds groups of ajacent nodes within Tolerance.
4017 # @param Tolerance the value of tolerance
4018 # @param SubMeshOrGroup SubMesh or Group
4019 # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
4020 # @return the list of groups of nodes
4021 # @ingroup l2_modif_trsf
4022 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
4023 if (isinstance( SubMeshOrGroup, Mesh )):
4024 SubMeshOrGroup = SubMeshOrGroup.GetMesh()
4025 if not isinstance( exceptNodes, list):
4026 exceptNodes = [ exceptNodes ]
4027 if exceptNodes and isinstance( exceptNodes[0], int):
4028 exceptNodes = [ self.GetIDSource( exceptNodes, SMESH.NODE)]
4029 return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes)
4032 # @param GroupsOfNodes the list of groups of nodes
4033 # @ingroup l2_modif_trsf
4034 def MergeNodes (self, GroupsOfNodes):
4035 self.editor.MergeNodes(GroupsOfNodes)
4037 ## Finds the elements built on the same nodes.
4038 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
4039 # @return a list of groups of equal elements
4040 # @ingroup l2_modif_trsf
4041 def FindEqualElements (self, MeshOrSubMeshOrGroup):
4042 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
4043 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
4044 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
4046 ## Merges elements in each given group.
4047 # @param GroupsOfElementsID groups of elements for merging
4048 # @ingroup l2_modif_trsf
4049 def MergeElements(self, GroupsOfElementsID):
4050 self.editor.MergeElements(GroupsOfElementsID)
4052 ## Leaves one element and removes all other elements built on the same nodes.
4053 # @ingroup l2_modif_trsf
4054 def MergeEqualElements(self):
4055 self.editor.MergeEqualElements()
4057 ## Sews free borders
4058 # @return SMESH::Sew_Error
4059 # @ingroup l2_modif_trsf
4060 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
4061 FirstNodeID2, SecondNodeID2, LastNodeID2,
4062 CreatePolygons, CreatePolyedrs):
4063 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
4064 FirstNodeID2, SecondNodeID2, LastNodeID2,
4065 CreatePolygons, CreatePolyedrs)
4067 ## Sews conform free borders
4068 # @return SMESH::Sew_Error
4069 # @ingroup l2_modif_trsf
4070 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
4071 FirstNodeID2, SecondNodeID2):
4072 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
4073 FirstNodeID2, SecondNodeID2)
4075 ## Sews border to side
4076 # @return SMESH::Sew_Error
4077 # @ingroup l2_modif_trsf
4078 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
4079 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
4080 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
4081 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
4083 ## Sews two sides of a mesh. The nodes belonging to Side1 are
4084 # merged with the nodes of elements of Side2.
4085 # The number of elements in theSide1 and in theSide2 must be
4086 # equal and they should have similar nodal connectivity.
4087 # The nodes to merge should belong to side borders and
4088 # the first node should be linked to the second.
4089 # @return SMESH::Sew_Error
4090 # @ingroup l2_modif_trsf
4091 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
4092 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
4093 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
4094 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
4095 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
4096 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
4098 ## Sets new nodes for the given element.
4099 # @param ide the element id
4100 # @param newIDs nodes ids
4101 # @return If the number of nodes does not correspond to the type of element - returns false
4102 # @ingroup l2_modif_edit
4103 def ChangeElemNodes(self, ide, newIDs):
4104 return self.editor.ChangeElemNodes(ide, newIDs)
4106 ## If during the last operation of MeshEditor some nodes were
4107 # created, this method returns the list of their IDs, \n
4108 # if new nodes were not created - returns empty list
4109 # @return the list of integer values (can be empty)
4110 # @ingroup l1_auxiliary
4111 def GetLastCreatedNodes(self):
4112 return self.editor.GetLastCreatedNodes()
4114 ## If during the last operation of MeshEditor some elements were
4115 # created this method returns the list of their IDs, \n
4116 # if new elements were not created - returns empty list
4117 # @return the list of integer values (can be empty)
4118 # @ingroup l1_auxiliary
4119 def GetLastCreatedElems(self):
4120 return self.editor.GetLastCreatedElems()
4122 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4123 # @param theNodes identifiers of nodes to be doubled
4124 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
4125 # nodes. If list of element identifiers is empty then nodes are doubled but
4126 # they not assigned to elements
4127 # @return TRUE if operation has been completed successfully, FALSE otherwise
4128 # @ingroup l2_modif_edit
4129 def DoubleNodes(self, theNodes, theModifiedElems):
4130 return self.editor.DoubleNodes(theNodes, theModifiedElems)
4132 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4133 # This method provided for convenience works as DoubleNodes() described above.
4134 # @param theNodeId identifiers of node to be doubled
4135 # @param theModifiedElems identifiers of elements to be updated
4136 # @return TRUE if operation has been completed successfully, FALSE otherwise
4137 # @ingroup l2_modif_edit
4138 def DoubleNode(self, theNodeId, theModifiedElems):
4139 return self.editor.DoubleNode(theNodeId, theModifiedElems)
4141 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4142 # This method provided for convenience works as DoubleNodes() described above.
4143 # @param theNodes group of nodes to be doubled
4144 # @param theModifiedElems group of elements to be updated.
4145 # @param theMakeGroup forces the generation of a group containing new nodes.
4146 # @return TRUE or a created group if operation has been completed successfully,
4147 # FALSE or None otherwise
4148 # @ingroup l2_modif_edit
4149 def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
4151 return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
4152 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
4154 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4155 # This method provided for convenience works as DoubleNodes() described above.
4156 # @param theNodes list of groups of nodes to be doubled
4157 # @param theModifiedElems list of groups of elements to be updated.
4158 # @param theMakeGroup forces the generation of a group containing new nodes.
4159 # @return TRUE if operation has been completed successfully, FALSE otherwise
4160 # @ingroup l2_modif_edit
4161 def DoubleNodeGroups(self, theNodes, theModifiedElems, theMakeGroup=False):
4163 return self.editor.DoubleNodeGroupsNew(theNodes, theModifiedElems)
4164 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
4166 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4167 # @param theElems - the list of elements (edges or faces) to be replicated
4168 # The nodes for duplication could be found from these elements
4169 # @param theNodesNot - list of nodes to NOT replicate
4170 # @param theAffectedElems - the list of elements (cells and edges) to which the
4171 # replicated nodes should be associated to.
4172 # @return TRUE if operation has been completed successfully, FALSE otherwise
4173 # @ingroup l2_modif_edit
4174 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
4175 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
4177 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4178 # @param theElems - the list of elements (edges or faces) to be replicated
4179 # The nodes for duplication could be found from these elements
4180 # @param theNodesNot - list of nodes to NOT replicate
4181 # @param theShape - shape to detect affected elements (element which geometric center
4182 # located on or inside shape).
4183 # The replicated nodes should be associated to affected elements.
4184 # @return TRUE if operation has been completed successfully, FALSE otherwise
4185 # @ingroup l2_modif_edit
4186 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
4187 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
4189 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4190 # This method provided for convenience works as DoubleNodes() described above.
4191 # @param theElems - group of of elements (edges or faces) to be replicated
4192 # @param theNodesNot - group of nodes not to replicated
4193 # @param theAffectedElems - group of elements to which the replicated nodes
4194 # should be associated to.
4195 # @param theMakeGroup forces the generation of a group containing new elements.
4196 # @return TRUE or a created group if operation has been completed successfully,
4197 # FALSE or None otherwise
4198 # @ingroup l2_modif_edit
4199 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4201 return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
4202 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
4204 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4205 # This method provided for convenience works as DoubleNodes() described above.
4206 # @param theElems - group of of elements (edges or faces) to be replicated
4207 # @param theNodesNot - group of nodes not to replicated
4208 # @param theShape - shape to detect affected elements (element which geometric center
4209 # located on or inside shape).
4210 # The replicated nodes should be associated to affected elements.
4211 # @ingroup l2_modif_edit
4212 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
4213 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
4215 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4216 # This method provided for convenience works as DoubleNodes() described above.
4217 # @param theElems - list of groups of elements (edges or faces) to be replicated
4218 # @param theNodesNot - list of groups of nodes not to replicated
4219 # @param theAffectedElems - group of elements to which the replicated nodes
4220 # should be associated to.
4221 # @param theMakeGroup forces the generation of a group containing new elements.
4222 # @return TRUE or a created group if operation has been completed successfully,
4223 # FALSE or None otherwise
4224 # @ingroup l2_modif_edit
4225 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4227 return self.editor.DoubleNodeElemGroupsNew(theElems, theNodesNot, theAffectedElems)
4228 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
4230 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4231 # This method provided for convenience works as DoubleNodes() described above.
4232 # @param theElems - list of groups of elements (edges or faces) to be replicated
4233 # @param theNodesNot - list of groups of nodes not to replicated
4234 # @param theShape - shape to detect affected elements (element which geometric center
4235 # located on or inside shape).
4236 # The replicated nodes should be associated to affected elements.
4237 # @return TRUE if operation has been completed successfully, FALSE otherwise
4238 # @ingroup l2_modif_edit
4239 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
4240 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
4242 ## Double nodes on shared faces between groups of volumes and create flat elements on demand.
4243 # The list of groups must describe a partition of the mesh volumes.
4244 # The nodes of the internal faces at the boundaries of the groups are doubled.
4245 # In option, the internal faces are replaced by flat elements.
4246 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4247 # @param theDomains - list of groups of volumes
4248 # @param createJointElems - if TRUE, create the elements
4249 # @return TRUE if operation has been completed successfully, FALSE otherwise
4250 def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems ):
4251 return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems )
4253 ## Double nodes on some external faces and create flat elements.
4254 # Flat elements are mainly used by some types of mechanic calculations.
4256 # Each group of the list must be constituted of faces.
4257 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4258 # @param theGroupsOfFaces - list of groups of faces
4259 # @return TRUE if operation has been completed successfully, FALSE otherwise
4260 def CreateFlatElementsOnFacesGroups(self, theGroupsOfFaces ):
4261 return self.editor.CreateFlatElementsOnFacesGroups( theGroupsOfFaces )
4263 def _valueFromFunctor(self, funcType, elemId):
4264 fn = self.smeshpyD.GetFunctor(funcType)
4265 fn.SetMesh(self.mesh)
4266 if fn.GetElementType() == self.GetElementType(elemId, True):
4267 val = fn.GetValue(elemId)
4272 ## Get length of 1D element.
4273 # @param elemId mesh element ID
4274 # @return element's length value
4275 # @ingroup l1_measurements
4276 def GetLength(self, elemId):
4277 return self._valueFromFunctor(SMESH.FT_Length, elemId)
4279 ## Get area of 2D element.
4280 # @param elemId mesh element ID
4281 # @return element's area value
4282 # @ingroup l1_measurements
4283 def GetArea(self, elemId):
4284 return self._valueFromFunctor(SMESH.FT_Area, elemId)
4286 ## Get volume of 3D element.
4287 # @param elemId mesh element ID
4288 # @return element's volume value
4289 # @ingroup l1_measurements
4290 def GetVolume(self, elemId):
4291 return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
4293 ## Get maximum element length.
4294 # @param elemId mesh element ID
4295 # @return element's maximum length value
4296 # @ingroup l1_measurements
4297 def GetMaxElementLength(self, elemId):
4298 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4299 ftype = SMESH.FT_MaxElementLength3D
4301 ftype = SMESH.FT_MaxElementLength2D
4302 return self._valueFromFunctor(ftype, elemId)
4304 ## Get aspect ratio of 2D or 3D element.
4305 # @param elemId mesh element ID
4306 # @return element's aspect ratio value
4307 # @ingroup l1_measurements
4308 def GetAspectRatio(self, elemId):
4309 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4310 ftype = SMESH.FT_AspectRatio3D
4312 ftype = SMESH.FT_AspectRatio
4313 return self._valueFromFunctor(ftype, elemId)
4315 ## Get warping angle of 2D element.
4316 # @param elemId mesh element ID
4317 # @return element's warping angle value
4318 # @ingroup l1_measurements
4319 def GetWarping(self, elemId):
4320 return self._valueFromFunctor(SMESH.FT_Warping, elemId)
4322 ## Get minimum angle of 2D element.
4323 # @param elemId mesh element ID
4324 # @return element's minimum angle value
4325 # @ingroup l1_measurements
4326 def GetMinimumAngle(self, elemId):
4327 return self._valueFromFunctor(SMESH.FT_MinimumAngle, elemId)
4329 ## Get taper of 2D element.
4330 # @param elemId mesh element ID
4331 # @return element's taper value
4332 # @ingroup l1_measurements
4333 def GetTaper(self, elemId):
4334 return self._valueFromFunctor(SMESH.FT_Taper, elemId)
4336 ## Get skew of 2D element.
4337 # @param elemId mesh element ID
4338 # @return element's skew value
4339 # @ingroup l1_measurements
4340 def GetSkew(self, elemId):
4341 return self._valueFromFunctor(SMESH.FT_Skew, elemId)
4343 ## The mother class to define algorithm, it is not recommended to use it directly.
4346 # @ingroup l2_algorithms
4347 class Mesh_Algorithm:
4348 # @class Mesh_Algorithm
4349 # @brief Class Mesh_Algorithm
4351 #def __init__(self,smesh):
4359 ## Finds a hypothesis in the study by its type name and parameters.
4360 # Finds only the hypotheses created in smeshpyD engine.
4361 # @return SMESH.SMESH_Hypothesis
4362 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
4363 study = smeshpyD.GetCurrentStudy()
4364 #to do: find component by smeshpyD object, not by its data type
4365 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4366 if scomp is not None:
4367 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
4368 # Check if the root label of the hypotheses exists
4369 if res and hypRoot is not None:
4370 iter = study.NewChildIterator(hypRoot)
4371 # Check all published hypotheses
4373 hypo_so_i = iter.Value()
4374 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
4375 if attr is not None:
4376 anIOR = attr.Value()
4377 hypo_o_i = salome.orb.string_to_object(anIOR)
4378 if hypo_o_i is not None:
4379 # Check if this is a hypothesis
4380 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
4381 if hypo_i is not None:
4382 # Check if the hypothesis belongs to current engine
4383 if smeshpyD.GetObjectId(hypo_i) > 0:
4384 # Check if this is the required hypothesis
4385 if hypo_i.GetName() == hypname:
4387 if CompareMethod(hypo_i, args):
4401 ## Finds the algorithm in the study by its type name.
4402 # Finds only the algorithms, which have been created in smeshpyD engine.
4403 # @return SMESH.SMESH_Algo
4404 def FindAlgorithm (self, algoname, smeshpyD):
4405 study = smeshpyD.GetCurrentStudy()
4406 #to do: find component by smeshpyD object, not by its data type
4407 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4408 if scomp is not None:
4409 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
4410 # Check if the root label of the algorithms exists
4411 if res and hypRoot is not None:
4412 iter = study.NewChildIterator(hypRoot)
4413 # Check all published algorithms
4415 algo_so_i = iter.Value()
4416 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
4417 if attr is not None:
4418 anIOR = attr.Value()
4419 algo_o_i = salome.orb.string_to_object(anIOR)
4420 if algo_o_i is not None:
4421 # Check if this is an algorithm
4422 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
4423 if algo_i is not None:
4424 # Checks if the algorithm belongs to the current engine
4425 if smeshpyD.GetObjectId(algo_i) > 0:
4426 # Check if this is the required algorithm
4427 if algo_i.GetName() == algoname:
4440 ## If the algorithm is global, returns 0; \n
4441 # else returns the submesh associated to this algorithm.
4442 def GetSubMesh(self):
4445 ## Returns the wrapped mesher.
4446 def GetAlgorithm(self):
4449 ## Gets the list of hypothesis that can be used with this algorithm
4450 def GetCompatibleHypothesis(self):
4453 mylist = self.algo.GetCompatibleHypothesis()
4456 ## Gets the name of the algorithm
4460 ## Sets the name to the algorithm
4461 def SetName(self, name):
4462 self.mesh.smeshpyD.SetName(self.algo, name)
4464 ## Gets the id of the algorithm
4466 return self.algo.GetId()
4469 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
4471 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
4472 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
4474 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
4476 self.Assign(algo, mesh, geom)
4480 def Assign(self, algo, mesh, geom):
4482 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
4486 self.geom = mesh.geom
4489 AssureGeomPublished( mesh, geom )
4491 name = GetName(geom)
4495 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
4497 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
4498 TreatHypoStatus( status, algo.GetName(), name, True )
4501 def CompareHyp (self, hyp, args):
4502 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
4505 def CompareEqualHyp (self, hyp, args):
4509 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
4510 UseExisting=0, CompareMethod=""):
4513 if CompareMethod == "": CompareMethod = self.CompareHyp
4514 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
4517 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
4523 a = a + s + str(args[i])
4527 self.mesh.smeshpyD.SetName(hypo, hyp + a)
4531 geomName = GetName(self.geom)
4532 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
4533 TreatHypoStatus( status, GetName(hypo), geomName, 0 )
4536 ## Returns entry of the shape to mesh in the study
4537 def MainShapeEntry(self):
4539 if not self.mesh or not self.mesh.GetMesh(): return entry
4540 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
4541 study = self.mesh.smeshpyD.GetCurrentStudy()
4542 ior = salome.orb.object_to_string( self.mesh.GetShape() )
4543 sobj = study.FindObjectIOR(ior)
4544 if sobj: entry = sobj.GetID()
4545 if not entry: return ""
4548 ## Defines "ViscousLayers" hypothesis to give parameters of layers of prisms to build
4549 # near mesh boundary. This hypothesis can be used by several 3D algorithms:
4550 # NETGEN 3D, GHS3D, Hexahedron(i,j,k)
4551 # @param thickness total thickness of layers of prisms
4552 # @param numberOfLayers number of layers of prisms
4553 # @param stretchFactor factor (>1.0) of growth of layer thickness towards inside of mesh
4554 # @param ignoreFaces list of geometrical faces (or their ids) not to generate layers on
4555 # @ingroup l3_hypos_additi
4556 def ViscousLayers(self, thickness, numberOfLayers, stretchFactor, ignoreFaces=[]):
4557 if not isinstance(self.algo, SMESH._objref_SMESH_3D_Algo):
4558 raise TypeError, "ViscousLayers are supported by 3D algorithms only"
4559 if not "ViscousLayers" in self.GetCompatibleHypothesis():
4560 raise TypeError, "ViscousLayers are not supported by %s"%self.algo.GetName()
4561 if ignoreFaces and isinstance( ignoreFaces[0], geompyDC.GEOM._objref_GEOM_Object ):
4562 ignoreFaces = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, f) for f in ignoreFaces ]
4563 hyp = self.Hypothesis("ViscousLayers",
4564 [thickness, numberOfLayers, stretchFactor, ignoreFaces])
4565 hyp.SetTotalThickness(thickness)
4566 hyp.SetNumberLayers(numberOfLayers)
4567 hyp.SetStretchFactor(stretchFactor)
4568 hyp.SetIgnoreFaces(ignoreFaces)
4571 # Public class: Mesh_Segment
4572 # --------------------------
4574 ## Class to define a segment 1D algorithm for discretization
4577 # @ingroup l3_algos_basic
4578 class Mesh_Segment(Mesh_Algorithm):
4580 ## Private constructor.
4581 def __init__(self, mesh, geom=0):
4582 Mesh_Algorithm.__init__(self)
4583 self.Create(mesh, geom, "Regular_1D")
4585 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
4586 # @param l for the length of segments that cut an edge
4587 # @param UseExisting if ==true - searches for an existing hypothesis created with
4588 # the same parameters, else (default) - creates a new one
4589 # @param p precision, used for calculation of the number of segments.
4590 # The precision should be a positive, meaningful value within the range [0,1].
4591 # In general, the number of segments is calculated with the formula:
4592 # nb = ceil((edge_length / l) - p)
4593 # Function ceil rounds its argument to the higher integer.
4594 # So, p=0 means rounding of (edge_length / l) to the higher integer,
4595 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
4596 # p=1 means rounding of (edge_length / l) to the lower integer.
4597 # Default value is 1e-07.
4598 # @return an instance of StdMeshers_LocalLength hypothesis
4599 # @ingroup l3_hypos_1dhyps
4600 def LocalLength(self, l, UseExisting=0, p=1e-07):
4601 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
4602 CompareMethod=self.CompareLocalLength)
4608 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
4609 def CompareLocalLength(self, hyp, args):
4610 if IsEqual(hyp.GetLength(), args[0]):
4611 return IsEqual(hyp.GetPrecision(), args[1])
4614 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
4615 # @param length is optional maximal allowed length of segment, if it is omitted
4616 # the preestimated length is used that depends on geometry size
4617 # @param UseExisting if ==true - searches for an existing hypothesis created with
4618 # the same parameters, else (default) - create a new one
4619 # @return an instance of StdMeshers_MaxLength hypothesis
4620 # @ingroup l3_hypos_1dhyps
4621 def MaxSize(self, length=0.0, UseExisting=0):
4622 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
4625 hyp.SetLength(length)
4627 # set preestimated length
4628 gen = self.mesh.smeshpyD
4629 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
4630 self.mesh.GetMesh(), self.mesh.GetShape(),
4632 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
4634 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
4637 hyp.SetUsePreestimatedLength( length == 0.0 )
4640 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
4641 # @param n for the number of segments that cut an edge
4642 # @param s for the scale factor (optional)
4643 # @param reversedEdges is a list of edges to mesh using reversed orientation
4644 # @param UseExisting if ==true - searches for an existing hypothesis created with
4645 # the same parameters, else (default) - create a new one
4646 # @return an instance of StdMeshers_NumberOfSegments hypothesis
4647 # @ingroup l3_hypos_1dhyps
4648 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4649 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4650 reversedEdges, UseExisting = [], reversedEdges
4651 entry = self.MainShapeEntry()
4652 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4653 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4655 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
4656 UseExisting=UseExisting,
4657 CompareMethod=self.CompareNumberOfSegments)
4659 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
4660 UseExisting=UseExisting,
4661 CompareMethod=self.CompareNumberOfSegments)
4662 hyp.SetDistrType( 1 )
4663 hyp.SetScaleFactor(s)
4664 hyp.SetNumberOfSegments(n)
4665 hyp.SetReversedEdges( reversedEdges )
4666 hyp.SetObjectEntry( entry )
4670 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4671 def CompareNumberOfSegments(self, hyp, args):
4672 if hyp.GetNumberOfSegments() == args[0]:
4674 if hyp.GetReversedEdges() == args[1]:
4675 if not args[1] or hyp.GetObjectEntry() == args[2]:
4678 if hyp.GetReversedEdges() == args[2]:
4679 if not args[2] or hyp.GetObjectEntry() == args[3]:
4680 if hyp.GetDistrType() == 1:
4681 if IsEqual(hyp.GetScaleFactor(), args[1]):
4685 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4686 # @param start defines the length of the first segment
4687 # @param end defines the length of the last segment
4688 # @param reversedEdges is a list of edges to mesh using reversed orientation
4689 # @param UseExisting if ==true - searches for an existing hypothesis created with
4690 # the same parameters, else (default) - creates a new one
4691 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4692 # @ingroup l3_hypos_1dhyps
4693 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4694 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4695 reversedEdges, UseExisting = [], reversedEdges
4696 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4697 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4698 entry = self.MainShapeEntry()
4699 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
4700 UseExisting=UseExisting,
4701 CompareMethod=self.CompareArithmetic1D)
4702 hyp.SetStartLength(start)
4703 hyp.SetEndLength(end)
4704 hyp.SetReversedEdges( reversedEdges )
4705 hyp.SetObjectEntry( entry )
4709 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4710 def CompareArithmetic1D(self, hyp, args):
4711 if IsEqual(hyp.GetLength(1), args[0]):
4712 if IsEqual(hyp.GetLength(0), args[1]):
4713 if hyp.GetReversedEdges() == args[2]:
4714 if not args[2] or hyp.GetObjectEntry() == args[3]:
4719 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4720 # on curve from 0 to 1 (additionally it is neecessary to check
4721 # orientation of edges and create list of reversed edges if it is
4722 # needed) and sets numbers of segments between given points (default
4723 # values are equals 1
4724 # @param points defines the list of parameters on curve
4725 # @param nbSegs defines the list of numbers of segments
4726 # @param reversedEdges is a list of edges to mesh using reversed orientation
4727 # @param UseExisting if ==true - searches for an existing hypothesis created with
4728 # the same parameters, else (default) - creates a new one
4729 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4730 # @ingroup l3_hypos_1dhyps
4731 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4732 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4733 reversedEdges, UseExisting = [], reversedEdges
4734 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4735 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4736 entry = self.MainShapeEntry()
4737 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
4738 UseExisting=UseExisting,
4739 CompareMethod=self.CompareFixedPoints1D)
4740 hyp.SetPoints(points)
4741 hyp.SetNbSegments(nbSegs)
4742 hyp.SetReversedEdges(reversedEdges)
4743 hyp.SetObjectEntry(entry)
4747 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4748 ## as the given arguments
4749 def CompareFixedPoints1D(self, hyp, args):
4750 if hyp.GetPoints() == args[0]:
4751 if hyp.GetNbSegments() == args[1]:
4752 if hyp.GetReversedEdges() == args[2]:
4753 if not args[2] or hyp.GetObjectEntry() == args[3]:
4759 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4760 # @param start defines the length of the first segment
4761 # @param end defines the length of the last segment
4762 # @param reversedEdges is a list of edges to mesh using reversed orientation
4763 # @param UseExisting if ==true - searches for an existing hypothesis created with
4764 # the same parameters, else (default) - creates a new one
4765 # @return an instance of StdMeshers_StartEndLength hypothesis
4766 # @ingroup l3_hypos_1dhyps
4767 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4768 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4769 reversedEdges, UseExisting = [], reversedEdges
4770 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4771 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4772 entry = self.MainShapeEntry()
4773 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
4774 UseExisting=UseExisting,
4775 CompareMethod=self.CompareStartEndLength)
4776 hyp.SetStartLength(start)
4777 hyp.SetEndLength(end)
4778 hyp.SetReversedEdges( reversedEdges )
4779 hyp.SetObjectEntry( entry )
4782 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4783 def CompareStartEndLength(self, hyp, args):
4784 if IsEqual(hyp.GetLength(1), args[0]):
4785 if IsEqual(hyp.GetLength(0), args[1]):
4786 if hyp.GetReversedEdges() == args[2]:
4787 if not args[2] or hyp.GetObjectEntry() == args[3]:
4791 ## Defines "Deflection1D" hypothesis
4792 # @param d for the deflection
4793 # @param UseExisting if ==true - searches for an existing hypothesis created with
4794 # the same parameters, else (default) - create a new one
4795 # @ingroup l3_hypos_1dhyps
4796 def Deflection1D(self, d, UseExisting=0):
4797 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4798 CompareMethod=self.CompareDeflection1D)
4799 hyp.SetDeflection(d)
4802 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4803 def CompareDeflection1D(self, hyp, args):
4804 return IsEqual(hyp.GetDeflection(), args[0])
4806 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4807 # the opposite side in case of quadrangular faces
4808 # @ingroup l3_hypos_additi
4809 def Propagation(self):
4810 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4812 ## Defines "AutomaticLength" hypothesis
4813 # @param fineness for the fineness [0-1]
4814 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4815 # same parameters, else (default) - create a new one
4816 # @ingroup l3_hypos_1dhyps
4817 def AutomaticLength(self, fineness=0, UseExisting=0):
4818 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4819 CompareMethod=self.CompareAutomaticLength)
4820 hyp.SetFineness( fineness )
4823 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4824 def CompareAutomaticLength(self, hyp, args):
4825 return IsEqual(hyp.GetFineness(), args[0])
4827 ## Defines "SegmentLengthAroundVertex" hypothesis
4828 # @param length for the segment length
4829 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4830 # Any other integer value means that the hypothesis will be set on the
4831 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4832 # @param UseExisting if ==true - searches for an existing hypothesis created with
4833 # the same parameters, else (default) - creates a new one
4834 # @ingroup l3_algos_segmarv
4835 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4837 store_geom = self.geom
4838 if type(vertex) is types.IntType:
4839 if vertex == 0 or vertex == 1:
4840 vertex = self.mesh.geompyD.ExtractShapes(self.geom, geompyDC.ShapeType["VERTEX"],True)[vertex]
4848 if self.geom is None:
4849 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4850 AssureGeomPublished( self.mesh, self.geom )
4851 name = GetName(self.geom)
4853 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4855 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4857 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4858 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4860 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4861 CompareMethod=self.CompareLengthNearVertex)
4862 self.geom = store_geom
4863 hyp.SetLength( length )
4866 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4867 # @ingroup l3_algos_segmarv
4868 def CompareLengthNearVertex(self, hyp, args):
4869 return IsEqual(hyp.GetLength(), args[0])
4871 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4872 # If the 2D mesher sees that all boundary edges are quadratic,
4873 # it generates quadratic faces, else it generates linear faces using
4874 # medium nodes as if they are vertices.
4875 # The 3D mesher generates quadratic volumes only if all boundary faces
4876 # are quadratic, else it fails.
4878 # @ingroup l3_hypos_additi
4879 def QuadraticMesh(self):
4880 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4883 # Public class: Mesh_CompositeSegment
4884 # --------------------------
4886 ## Defines a segment 1D algorithm for discretization
4888 # @ingroup l3_algos_basic
4889 class Mesh_CompositeSegment(Mesh_Segment):
4891 ## Private constructor.
4892 def __init__(self, mesh, geom=0):
4893 self.Create(mesh, geom, "CompositeSegment_1D")
4896 # Public class: Mesh_Segment_Python
4897 # ---------------------------------
4899 ## Defines a segment 1D algorithm for discretization with python function
4901 # @ingroup l3_algos_basic
4902 class Mesh_Segment_Python(Mesh_Segment):
4904 ## Private constructor.
4905 def __init__(self, mesh, geom=0):
4906 import Python1dPlugin
4907 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4909 ## Defines "PythonSplit1D" hypothesis
4910 # @param n for the number of segments that cut an edge
4911 # @param func for the python function that calculates the length of all segments
4912 # @param UseExisting if ==true - searches for the existing hypothesis created with
4913 # the same parameters, else (default) - creates a new one
4914 # @ingroup l3_hypos_1dhyps
4915 def PythonSplit1D(self, n, func, UseExisting=0):
4916 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4917 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4918 hyp.SetNumberOfSegments(n)
4919 hyp.SetPythonLog10RatioFunction(func)
4922 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4923 def ComparePythonSplit1D(self, hyp, args):
4924 #if hyp.GetNumberOfSegments() == args[0]:
4925 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4929 # Public class: Mesh_Triangle
4930 # ---------------------------
4932 ## Defines a triangle 2D algorithm
4934 # @ingroup l3_algos_basic
4935 class Mesh_Triangle(Mesh_Algorithm):
4944 ## Private constructor.
4945 def __init__(self, mesh, algoType, geom=0):
4946 Mesh_Algorithm.__init__(self)
4948 if algoType == MEFISTO:
4949 self.Create(mesh, geom, "MEFISTO_2D")
4951 elif algoType == BLSURF:
4953 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4954 #self.SetPhysicalMesh() - PAL19680
4955 elif algoType == NETGEN:
4957 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4959 elif algoType == NETGEN_2D:
4961 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4964 self.algoType = algoType
4966 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4967 # @param area for the maximum area of each triangle
4968 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4969 # same parameters, else (default) - creates a new one
4971 # Only for algoType == MEFISTO || NETGEN_2D
4972 # @ingroup l3_hypos_2dhyps
4973 def MaxElementArea(self, area, UseExisting=0):
4974 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4975 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4976 CompareMethod=self.CompareMaxElementArea)
4977 elif self.algoType == NETGEN:
4978 hyp = self.Parameters(SIMPLE)
4979 hyp.SetMaxElementArea(area)
4982 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4983 def CompareMaxElementArea(self, hyp, args):
4984 return IsEqual(hyp.GetMaxElementArea(), args[0])
4986 ## Defines "LengthFromEdges" hypothesis to build triangles
4987 # based on the length of the edges taken from the wire
4989 # Only for algoType == MEFISTO || NETGEN_2D
4990 # @ingroup l3_hypos_2dhyps
4991 def LengthFromEdges(self):
4992 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4993 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4995 elif self.algoType == NETGEN:
4996 hyp = self.Parameters(SIMPLE)
4997 hyp.LengthFromEdges()
5000 ## Sets a way to define size of mesh elements to generate.
5001 # @param thePhysicalMesh is: DefaultSize, BLSURF_Custom or SizeMap.
5002 # @ingroup l3_hypos_blsurf
5003 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
5004 if self.Parameters():
5005 # Parameter of BLSURF algo
5006 self.params.SetPhysicalMesh(thePhysicalMesh)
5008 ## Sets size of mesh elements to generate.
5009 # @ingroup l3_hypos_blsurf
5010 def SetPhySize(self, theVal):
5011 if self.Parameters():
5012 # Parameter of BLSURF algo
5013 self.params.SetPhySize(theVal)
5015 ## Sets lower boundary of mesh element size (PhySize).
5016 # @ingroup l3_hypos_blsurf
5017 def SetPhyMin(self, theVal=-1):
5018 if self.Parameters():
5019 # Parameter of BLSURF algo
5020 self.params.SetPhyMin(theVal)
5022 ## Sets upper boundary of mesh element size (PhySize).
5023 # @ingroup l3_hypos_blsurf
5024 def SetPhyMax(self, theVal=-1):
5025 if self.Parameters():
5026 # Parameter of BLSURF algo
5027 self.params.SetPhyMax(theVal)
5029 ## Sets a way to define maximum angular deflection of mesh from CAD model.
5030 # @param theGeometricMesh is: 0 (None) or 1 (Custom)
5031 # @ingroup l3_hypos_blsurf
5032 def SetGeometricMesh(self, theGeometricMesh=0):
5033 if self.Parameters():
5034 # Parameter of BLSURF algo
5035 if self.params.GetPhysicalMesh() == 0: theGeometricMesh = 1
5036 self.params.SetGeometricMesh(theGeometricMesh)
5038 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
5039 # @ingroup l3_hypos_blsurf
5040 def SetAngleMeshS(self, theVal=_angleMeshS):
5041 if self.Parameters():
5042 # Parameter of BLSURF algo
5043 if self.params.GetGeometricMesh() == 0: theVal = self._angleMeshS
5044 self.params.SetAngleMeshS(theVal)
5046 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
5047 # @ingroup l3_hypos_blsurf
5048 def SetAngleMeshC(self, theVal=_angleMeshS):
5049 if self.Parameters():
5050 # Parameter of BLSURF algo
5051 if self.params.GetGeometricMesh() == 0: theVal = self._angleMeshS
5052 self.params.SetAngleMeshC(theVal)
5054 ## Sets lower boundary of mesh element size computed to respect angular deflection.
5055 # @ingroup l3_hypos_blsurf
5056 def SetGeoMin(self, theVal=-1):
5057 if self.Parameters():
5058 # Parameter of BLSURF algo
5059 self.params.SetGeoMin(theVal)
5061 ## Sets upper boundary of mesh element size computed to respect angular deflection.
5062 # @ingroup l3_hypos_blsurf
5063 def SetGeoMax(self, theVal=-1):
5064 if self.Parameters():
5065 # Parameter of BLSURF algo
5066 self.params.SetGeoMax(theVal)
5068 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
5069 # @ingroup l3_hypos_blsurf
5070 def SetGradation(self, theVal=_gradation):
5071 if self.Parameters():
5072 # Parameter of BLSURF algo
5073 if self.params.GetGeometricMesh() == 0: theVal = self._gradation
5074 self.params.SetGradation(theVal)
5076 ## Sets topology usage way.
5077 # @param way defines how mesh conformity is assured <ul>
5078 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
5079 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
5080 # <li>PreCAD - by pre-processing with PreCAD a CAD model</li></ul>
5081 # @ingroup l3_hypos_blsurf
5082 def SetTopology(self, way):
5083 if self.Parameters():
5084 # Parameter of BLSURF algo
5085 self.params.SetTopology(way)
5087 ## To respect geometrical edges or not.
5088 # @ingroup l3_hypos_blsurf
5089 def SetDecimesh(self, toIgnoreEdges=False):
5090 if self.Parameters():
5091 # Parameter of BLSURF algo
5092 self.params.SetDecimesh(toIgnoreEdges)
5094 ## Sets verbosity level in the range 0 to 100.
5095 # @ingroup l3_hypos_blsurf
5096 def SetVerbosity(self, level):
5097 if self.Parameters():
5098 # Parameter of BLSURF algo
5099 self.params.SetVerbosity(level)
5101 ## To optimize the CAD (merges edges and removes nano edges).
5102 # @ingroup l3_hypos_blsurf
5103 def SetPreCADOptimCAD(self, toOptimizeCAD=False):
5104 if self.Parameters():
5105 # Parameter of BLSURF algo
5106 self.params.SetPreCADOptimCAD(toOptimizeCAD)
5108 ## To compute topology from scratch
5109 # @ingroup l3_hypos_blsurf
5110 def SetPreCADDiscardInput(self, toDiscardInput=False):
5111 if self.Parameters():
5112 # Parameter of BLSURF algo
5113 self.params.SetPreCADDiscardInput(toDiscardInput)
5115 ## To help PreCAD treat some very dirty cases.
5116 # If the treated object is manifold.
5117 # @ingroup l3_hypos_blsurf
5118 def SetPreCADManifoldGeom(self, manifold=False):
5119 if self.Parameters():
5120 # Parameter of BLSURF algo
5121 self.params.SetPreCADManifoldGeom(manifold)
5123 ## To help PreCAD treat some very dirty cases.
5124 # If the object is also closed (imagine a shell).
5125 # @ingroup l3_hypos_blsurf
5126 def SetPreCADClosedGeom(self, closed=False):
5127 if self.Parameters():
5128 # Parameter of BLSURF algo
5129 self.params.SetPreCADClosedGeom(closed)
5131 ## Sets advanced option value.
5132 # @ingroup l3_hypos_blsurf
5133 def SetOptionValue(self, optionName, level):
5134 if self.Parameters():
5135 # Parameter of BLSURF algo
5136 self.params.SetOptionValue(optionName,level)
5138 ## Sets GMF file for export at computation
5139 # @ingroup l3_hypos_blsurf
5140 def SetGMFFile(self, fileName):
5141 if self.Parameters():
5142 # Parameter of BLSURF algo
5143 self.params.SetGMFFile(fileName)
5145 ## Enforced vertices (BLSURF)
5147 ## To get all the enforced vertices
5148 # @ingroup l3_hypos_blsurf
5149 def GetAllEnforcedVertices(self):
5150 if self.Parameters():
5151 # Parameter of BLSURF algo
5152 return self.params.GetAllEnforcedVertices()
5154 ## To get all the enforced vertices sorted by face (or group, compound)
5155 # @ingroup l3_hypos_blsurf
5156 def GetAllEnforcedVerticesByFace(self):
5157 if self.Parameters():
5158 # Parameter of BLSURF algo
5159 return self.params.GetAllEnforcedVerticesByFace()
5161 ## To get all the enforced vertices sorted by coords of input vertices
5162 # @ingroup l3_hypos_blsurf
5163 def GetAllEnforcedVerticesByCoords(self):
5164 if self.Parameters():
5165 # Parameter of BLSURF algo
5166 return self.params.GetAllEnforcedVerticesByCoords()
5168 ## To get all the coords of input vertices sorted by face (or group, compound)
5169 # @ingroup l3_hypos_blsurf
5170 def GetAllCoordsByFace(self):
5171 if self.Parameters():
5172 # Parameter of BLSURF algo
5173 return self.params.GetAllCoordsByFace()
5175 ## To get all the enforced vertices on a face (or group, compound)
5176 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
5177 # @ingroup l3_hypos_blsurf
5178 def GetEnforcedVertices(self, theFace):
5179 if self.Parameters():
5180 # Parameter of BLSURF algo
5181 AssureGeomPublished( self.mesh, theFace )
5182 return self.params.GetEnforcedVertices(theFace)
5184 ## To clear all the enforced vertices
5185 # @ingroup l3_hypos_blsurf
5186 def ClearAllEnforcedVertices(self):
5187 if self.Parameters():
5188 # Parameter of BLSURF algo
5189 return self.params.ClearAllEnforcedVertices()
5191 ## To set an enforced vertex on a face (or group, compound) given the coordinates of a point. If the point is not on the face, it will projected on it. If there is no projection, no enforced vertex is created.
5192 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
5193 # @param x : x coordinate
5194 # @param y : y coordinate
5195 # @param z : z coordinate
5196 # @ingroup l3_hypos_blsurf
5197 def SetEnforcedVertex(self, theFace, x, y, z):
5198 if self.Parameters():
5199 # Parameter of BLSURF algo
5200 AssureGeomPublished( self.mesh, theFace )
5201 return self.params.SetEnforcedVertex(theFace, x, y, z)
5203 ## To set an enforced vertex as SetEnforcedVertex. The created enforced vertex is identified by a name.
5204 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
5205 # @param x : x coordinate
5206 # @param y : y coordinate
5207 # @param z : z coordinate
5208 # @param vertexName : name of the enforced vertex
5209 # @ingroup l3_hypos_blsurf
5210 def SetEnforcedVertexNamed(self, theFace, x, y, z, vertexName):
5211 if self.Parameters():
5212 # Parameter of BLSURF algo
5213 AssureGeomPublished( self.mesh, theFace )
5214 return self.params.SetEnforcedVertexNamed(theFace, x, y, z, vertexName)
5216 ## To set an enforced vertex on a face (or group, compound) given a GEOM vertex, group or compound.
5217 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
5218 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
5219 # @ingroup l3_hypos_blsurf
5220 def SetEnforcedVertexGeom(self, theFace, theVertex):
5221 if self.Parameters():
5222 # Parameter of BLSURF algo
5223 AssureGeomPublished( self.mesh, theFace )
5224 AssureGeomPublished( self.mesh, theVertex )
5225 return self.params.SetEnforcedVertexGeom(theFace, theVertex)
5227 ## To set an enforced vertex as SetEnforcedVertex and add it in the group "groupName".
5228 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
5229 # @param x : x coordinate
5230 # @param y : y coordinate
5231 # @param z : z coordinate
5232 # @param groupName : name of the group
5233 # @ingroup l3_hypos_blsurf
5234 def SetEnforcedVertexWithGroup(self, theFace, x, y, z, groupName):
5235 if self.Parameters():
5236 # Parameter of BLSURF algo
5237 AssureGeomPublished( self.mesh, theFace )
5238 return self.params.SetEnforcedVertexWithGroup(theFace, x, y, z, groupName)
5240 ## To set an enforced vertex as SetEnforcedVertexNamed and add it in the group "groupName".
5241 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
5242 # @param x : x coordinate
5243 # @param y : y coordinate
5244 # @param z : z coordinate
5245 # @param vertexName : name of the enforced vertex
5246 # @param groupName : name of the group
5247 # @ingroup l3_hypos_blsurf
5248 def SetEnforcedVertexNamedWithGroup(self, theFace, x, y, z, vertexName, groupName):
5249 if self.Parameters():
5250 # Parameter of BLSURF algo
5251 AssureGeomPublished( self.mesh, theFace )
5252 return self.params.SetEnforcedVertexNamedWithGroup(theFace, x, y, z, vertexName, groupName)
5254 ## To set an enforced vertex as SetEnforcedVertexGeom and add it in the group "groupName".
5255 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
5256 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
5257 # @param groupName : name of the group
5258 # @ingroup l3_hypos_blsurf
5259 def SetEnforcedVertexGeomWithGroup(self, theFace, theVertex, groupName):
5260 if self.Parameters():
5261 # Parameter of BLSURF algo
5262 AssureGeomPublished( self.mesh, theFace )
5263 AssureGeomPublished( self.mesh, theVertex )
5264 return self.params.SetEnforcedVertexGeomWithGroup(theFace, theVertex,groupName)
5266 ## To remove an enforced vertex on a given GEOM face (or group, compound) given the coordinates.
5267 # @param theFace : GEOM face (or group, compound) on which to remove the enforced vertex
5268 # @param x : x coordinate
5269 # @param y : y coordinate
5270 # @param z : z coordinate
5271 # @ingroup l3_hypos_blsurf
5272 def UnsetEnforcedVertex(self, theFace, x, y, z):
5273 if self.Parameters():
5274 # Parameter of BLSURF algo
5275 AssureGeomPublished( self.mesh, theFace )
5276 return self.params.UnsetEnforcedVertex(theFace, x, y, z)
5278 ## To remove an enforced vertex on a given GEOM face (or group, compound) given a GEOM vertex, group or compound.
5279 # @param theFace : GEOM face (or group, compound) on which to remove the enforced vertex
5280 # @param theVertex : GEOM vertex (or group, compound) to remove.
5281 # @ingroup l3_hypos_blsurf
5282 def UnsetEnforcedVertexGeom(self, theFace, theVertex):
5283 if self.Parameters():
5284 # Parameter of BLSURF algo
5285 AssureGeomPublished( self.mesh, theFace )
5286 AssureGeomPublished( self.mesh, theVertex )
5287 return self.params.UnsetEnforcedVertexGeom(theFace, theVertex)
5289 ## To remove all enforced vertices on a given face.
5290 # @param theFace : face (or group/compound of faces) on which to remove all enforced vertices
5291 # @ingroup l3_hypos_blsurf
5292 def UnsetEnforcedVertices(self, theFace):
5293 if self.Parameters():
5294 # Parameter of BLSURF algo
5295 AssureGeomPublished( self.mesh, theFace )
5296 return self.params.UnsetEnforcedVertices(theFace)
5298 ## Attractors (BLSURF)
5300 ## 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 ]
5301 # @param theFace : face on which the attractor will be defined
5302 # @param theAttractor : geometrical object from which the mesh size "h" decreases exponentially
5303 # @param theStartSize : mesh size on theAttractor
5304 # @param theEndSize : maximum size that will be reached on theFace
5305 # @param theInfluenceDistance : influence of the attractor ( the size grow slower on theFace if it's high)
5306 # @param theConstantSizeDistance : distance until which the mesh size will be kept constant on theFace
5307 # @ingroup l3_hypos_blsurf
5308 def SetAttractorGeom(self, theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance):
5309 if self.Parameters():
5310 # Parameter of BLSURF algo
5311 AssureGeomPublished( self.mesh, theFace )
5312 AssureGeomPublished( self.mesh, theAttractor )
5313 self.params.SetAttractorGeom(theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance)
5315 ## Unsets an attractor on the chosen face.
5316 # @param theFace : face on which the attractor has to be removed
5317 # @ingroup l3_hypos_blsurf
5318 def UnsetAttractorGeom(self, theFace):
5319 if self.Parameters():
5320 # Parameter of BLSURF algo
5321 AssureGeomPublished( self.mesh, theFace )
5322 self.params.SetAttractorGeom(theFace)
5324 ## Size maps (BLSURF)
5326 ## To set a size map on a face, edge or vertex (or group, compound) given Python function.
5327 # If theObject is a face, the function can be: def f(u,v): return u+v
5328 # If theObject is an edge, the function can be: def f(t): return t/2
5329 # If theObject is a vertex, the function can be: def f(): return 10
5330 # @param theObject : GEOM face, edge or vertex (or group, compound) on which to define a size map
5331 # @param theSizeMap : Size map defined as a string
5332 # @ingroup l3_hypos_blsurf
5333 def SetSizeMap(self, theObject, theSizeMap):
5334 if self.Parameters():
5335 # Parameter of BLSURF algo
5336 AssureGeomPublished( self.mesh, theObject )
5337 return self.params.SetSizeMap(theObject, theSizeMap)
5339 ## To remove a size map defined on a face, edge or vertex (or group, compound)
5340 # @param theObject : GEOM face, edge or vertex (or group, compound) on which to define a size map
5341 # @ingroup l3_hypos_blsurf
5342 def UnsetSizeMap(self, theObject):
5343 if self.Parameters():
5344 # Parameter of BLSURF algo
5345 AssureGeomPublished( self.mesh, theObject )
5346 return self.params.UnsetSizeMap(theObject)
5348 ## To remove all the size maps
5349 # @ingroup l3_hypos_blsurf
5350 def ClearSizeMaps(self):
5351 if self.Parameters():
5352 # Parameter of BLSURF algo
5353 return self.params.ClearSizeMaps()
5356 ## Sets QuadAllowed flag.
5357 # Only for algoType == NETGEN(NETGEN_1D2D) || NETGEN_2D || BLSURF
5358 # @ingroup l3_hypos_netgen l3_hypos_blsurf
5359 def SetQuadAllowed(self, toAllow=True):
5360 if self.algoType == NETGEN_2D:
5363 hasSimpleHyps = False
5364 simpleHyps = ["QuadranglePreference","LengthFromEdges","MaxElementArea"]
5365 for hyp in self.mesh.GetHypothesisList( self.geom ):
5366 if hyp.GetName() in simpleHyps:
5367 hasSimpleHyps = True
5368 if hyp.GetName() == "QuadranglePreference":
5369 if not toAllow: # remove QuadranglePreference
5370 self.mesh.RemoveHypothesis( self.geom, hyp )
5376 if toAllow: # add QuadranglePreference
5377 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
5382 if self.Parameters():
5383 self.params.SetQuadAllowed(toAllow)
5386 ## Defines hypothesis having several parameters
5388 # @ingroup l3_hypos_netgen
5389 def Parameters(self, which=SOLE):
5391 if self.algoType == NETGEN:
5393 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
5394 "libNETGENEngine.so", UseExisting=0)
5396 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
5397 "libNETGENEngine.so", UseExisting=0)
5398 elif self.algoType == MEFISTO:
5399 print "Mefisto algo support no multi-parameter hypothesis"
5400 elif self.algoType == NETGEN_2D:
5401 self.params = self.Hypothesis("NETGEN_Parameters_2D_ONLY", [],
5402 "libNETGENEngine.so", UseExisting=0)
5403 elif self.algoType == BLSURF:
5404 self.params = self.Hypothesis("BLSURF_Parameters", [],
5405 "libBLSURFEngine.so", UseExisting=0)
5407 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
5412 # Only for algoType == NETGEN
5413 # @ingroup l3_hypos_netgen
5414 def SetMaxSize(self, theSize):
5415 if self.Parameters():
5416 self.params.SetMaxSize(theSize)
5418 ## Sets SecondOrder flag
5420 # Only for algoType == NETGEN
5421 # @ingroup l3_hypos_netgen
5422 def SetSecondOrder(self, theVal):
5423 if self.Parameters():
5424 self.params.SetSecondOrder(theVal)
5426 ## Sets Optimize flag
5428 # Only for algoType == NETGEN
5429 # @ingroup l3_hypos_netgen
5430 def SetOptimize(self, theVal):
5431 if self.Parameters():
5432 self.params.SetOptimize(theVal)
5435 # @param theFineness is:
5436 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5438 # Only for algoType == NETGEN
5439 # @ingroup l3_hypos_netgen
5440 def SetFineness(self, theFineness):
5441 if self.Parameters():
5442 self.params.SetFineness(theFineness)
5446 # Only for algoType == NETGEN
5447 # @ingroup l3_hypos_netgen
5448 def SetGrowthRate(self, theRate):
5449 if self.Parameters():
5450 self.params.SetGrowthRate(theRate)
5452 ## Sets NbSegPerEdge
5454 # Only for algoType == NETGEN
5455 # @ingroup l3_hypos_netgen
5456 def SetNbSegPerEdge(self, theVal):
5457 if self.Parameters():
5458 self.params.SetNbSegPerEdge(theVal)
5460 ## Sets NbSegPerRadius
5462 # Only for algoType == NETGEN
5463 # @ingroup l3_hypos_netgen
5464 def SetNbSegPerRadius(self, theVal):
5465 if self.Parameters():
5466 self.params.SetNbSegPerRadius(theVal)
5468 ## Sets number of segments overriding value set by SetLocalLength()
5470 # Only for algoType == NETGEN
5471 # @ingroup l3_hypos_netgen
5472 def SetNumberOfSegments(self, theVal):
5473 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5475 ## Sets number of segments overriding value set by SetNumberOfSegments()
5477 # Only for algoType == NETGEN
5478 # @ingroup l3_hypos_netgen
5479 def SetLocalLength(self, theVal):
5480 self.Parameters(SIMPLE).SetLocalLength(theVal)
5485 # Public class: Mesh_Quadrangle
5486 # -----------------------------
5488 ## Defines a quadrangle 2D algorithm
5490 # @ingroup l3_algos_basic
5491 class Mesh_Quadrangle(Mesh_Algorithm):
5495 ## Private constructor.
5496 def __init__(self, mesh, geom=0):
5497 Mesh_Algorithm.__init__(self)
5498 self.Create(mesh, geom, "Quadrangle_2D")
5501 ## Defines "QuadrangleParameters" hypothesis
5502 # @param quadType defines the algorithm of transition between differently descretized
5503 # sides of a geometrical face:
5504 # - QUAD_STANDARD - both triangles and quadrangles are possible in the transition
5505 # area along the finer meshed sides.
5506 # - QUAD_TRIANGLE_PREF - only triangles are built in the transition area along the
5507 # finer meshed sides.
5508 # - QUAD_QUADRANGLE_PREF - only quadrangles are built in the transition area along
5509 # the finer meshed sides, iff the total quantity of segments on
5510 # all four sides of the face is even (divisible by 2).
5511 # - QUAD_QUADRANGLE_PREF_REVERSED - same as QUAD_QUADRANGLE_PREF but the transition
5512 # area is located along the coarser meshed sides.
5513 # - QUAD_REDUCED - only quadrangles are built and the transition between the sides
5514 # is made gradually, layer by layer. This type has a limitation on
5515 # the number of segments: one pair of opposite sides must have the
5516 # same number of segments, the other pair must have an even difference
5517 # between the numbers of segments on the sides.
5518 # @param triangleVertex: vertex of a trilateral geometrical face, around which triangles
5519 # will be created while other elements will be quadrangles.
5520 # Vertex can be either a GEOM_Object or a vertex ID within the
5522 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5523 # the same parameters, else (default) - creates a new one
5524 # @ingroup l3_hypos_quad
5525 def QuadrangleParameters(self, quadType=StdMeshers.QUAD_STANDARD, triangleVertex=0, UseExisting=0):
5526 vertexID = triangleVertex
5527 if isinstance( triangleVertex, geompyDC.GEOM._objref_GEOM_Object ):
5528 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, triangleVertex )
5530 compFun = lambda hyp,args: \
5531 hyp.GetQuadType() == args[0] and \
5532 ( hyp.GetTriaVertex()==args[1] or ( hyp.GetTriaVertex()<1 and args[1]<1))
5533 self.params = self.Hypothesis("QuadrangleParams", [quadType,vertexID],
5534 UseExisting = UseExisting, CompareMethod=compFun)
5536 if self.params.GetQuadType() != quadType:
5537 self.params.SetQuadType(quadType)
5539 self.params.SetTriaVertex( vertexID )
5542 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5543 # quadrangles are built in the transition area along the finer meshed sides,
5544 # iff the total quantity of segments on all four sides of the face is even.
5545 # @param reversed if True, transition area is located along the coarser meshed sides.
5546 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5547 # the same parameters, else (default) - creates a new one
5548 # @ingroup l3_hypos_quad
5549 def QuadranglePreference(self, reversed=False, UseExisting=0):
5551 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF_REVERSED,UseExisting=UseExisting)
5552 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF,UseExisting=UseExisting)
5554 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5555 # triangles are built in the transition area along the finer meshed sides.
5556 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5557 # the same parameters, else (default) - creates a new one
5558 # @ingroup l3_hypos_quad
5559 def TrianglePreference(self, UseExisting=0):
5560 return self.QuadrangleParameters(QUAD_TRIANGLE_PREF,UseExisting=UseExisting)
5562 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5563 # quadrangles are built and the transition between the sides is made gradually,
5564 # layer by layer. This type has a limitation on the number of segments: one pair
5565 # of opposite sides must have the same number of segments, the other pair must
5566 # have an even difference between the numbers of segments on the sides.
5567 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5568 # the same parameters, else (default) - creates a new one
5569 # @ingroup l3_hypos_quad
5570 def Reduced(self, UseExisting=0):
5571 return self.QuadrangleParameters(QUAD_REDUCED,UseExisting=UseExisting)
5573 ## Defines "QuadrangleParams" hypothesis with QUAD_STANDARD type of quadrangulation
5574 # @param vertex: vertex of a trilateral geometrical face, around which triangles
5575 # will be created while other elements will be quadrangles.
5576 # Vertex can be either a GEOM_Object or a vertex ID within the
5578 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5579 # the same parameters, else (default) - creates a new one
5580 # @ingroup l3_hypos_quad
5581 def TriangleVertex(self, vertex, UseExisting=0):
5582 return self.QuadrangleParameters(QUAD_STANDARD,vertex,UseExisting)
5585 # Public class: Mesh_Tetrahedron
5586 # ------------------------------
5588 ## Defines a tetrahedron 3D algorithm
5590 # @ingroup l3_algos_basic
5591 class Mesh_Tetrahedron(Mesh_Algorithm):
5596 ## Private constructor.
5597 def __init__(self, mesh, algoType, geom=0):
5598 Mesh_Algorithm.__init__(self)
5600 if algoType == NETGEN:
5602 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
5605 elif algoType == FULL_NETGEN:
5607 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5610 elif algoType == GHS3D:
5612 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
5615 elif algoType == GHS3DPRL:
5616 CheckPlugin(GHS3DPRL)
5617 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
5620 self.algoType = algoType
5622 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
5623 # @param vol for the maximum volume of each tetrahedron
5624 # @param UseExisting if ==true - searches for the existing hypothesis created with
5625 # the same parameters, else (default) - creates a new one
5626 # @ingroup l3_hypos_maxvol
5627 def MaxElementVolume(self, vol, UseExisting=0):
5628 if self.algoType == NETGEN:
5629 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
5630 CompareMethod=self.CompareMaxElementVolume)
5631 hyp.SetMaxElementVolume(vol)
5633 elif self.algoType == FULL_NETGEN:
5634 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
5637 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
5638 def CompareMaxElementVolume(self, hyp, args):
5639 return IsEqual(hyp.GetMaxElementVolume(), args[0])
5641 ## Defines hypothesis having several parameters
5643 # @ingroup l3_hypos_netgen
5644 def Parameters(self, which=SOLE):
5647 if self.algoType == FULL_NETGEN:
5649 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
5650 "libNETGENEngine.so", UseExisting=0)
5652 self.params = self.Hypothesis("NETGEN_Parameters", [],
5653 "libNETGENEngine.so", UseExisting=0)
5655 elif self.algoType == NETGEN:
5656 self.params = self.Hypothesis("NETGEN_Parameters_3D", [],
5657 "libNETGENEngine.so", UseExisting=0)
5659 elif self.algoType == GHS3D:
5660 self.params = self.Hypothesis("GHS3D_Parameters", [],
5661 "libGHS3DEngine.so", UseExisting=0)
5663 elif self.algoType == GHS3DPRL:
5664 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
5665 "libGHS3DPRLEngine.so", UseExisting=0)
5667 print "Warning: %s supports no multi-parameter hypothesis"%self.algo.GetName()
5672 # Parameter of FULL_NETGEN and NETGEN
5673 # @ingroup l3_hypos_netgen
5674 def SetMaxSize(self, theSize):
5675 self.Parameters().SetMaxSize(theSize)
5677 ## Sets SecondOrder flag
5678 # Parameter of FULL_NETGEN
5679 # @ingroup l3_hypos_netgen
5680 def SetSecondOrder(self, theVal):
5681 self.Parameters().SetSecondOrder(theVal)
5683 ## Sets Optimize flag
5684 # Parameter of FULL_NETGEN and NETGEN
5685 # @ingroup l3_hypos_netgen
5686 def SetOptimize(self, theVal):
5687 self.Parameters().SetOptimize(theVal)
5690 # @param theFineness is:
5691 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5692 # Parameter of FULL_NETGEN
5693 # @ingroup l3_hypos_netgen
5694 def SetFineness(self, theFineness):
5695 self.Parameters().SetFineness(theFineness)
5698 # Parameter of FULL_NETGEN
5699 # @ingroup l3_hypos_netgen
5700 def SetGrowthRate(self, theRate):
5701 self.Parameters().SetGrowthRate(theRate)
5703 ## Sets NbSegPerEdge
5704 # Parameter of FULL_NETGEN
5705 # @ingroup l3_hypos_netgen
5706 def SetNbSegPerEdge(self, theVal):
5707 self.Parameters().SetNbSegPerEdge(theVal)
5709 ## Sets NbSegPerRadius
5710 # Parameter of FULL_NETGEN
5711 # @ingroup l3_hypos_netgen
5712 def SetNbSegPerRadius(self, theVal):
5713 self.Parameters().SetNbSegPerRadius(theVal)
5715 ## Sets number of segments overriding value set by SetLocalLength()
5716 # Only for algoType == NETGEN_FULL
5717 # @ingroup l3_hypos_netgen
5718 def SetNumberOfSegments(self, theVal):
5719 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5721 ## Sets number of segments overriding value set by SetNumberOfSegments()
5722 # Only for algoType == NETGEN_FULL
5723 # @ingroup l3_hypos_netgen
5724 def SetLocalLength(self, theVal):
5725 self.Parameters(SIMPLE).SetLocalLength(theVal)
5727 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
5728 # Overrides value set by LengthFromEdges()
5729 # Only for algoType == NETGEN_FULL
5730 # @ingroup l3_hypos_netgen
5731 def MaxElementArea(self, area):
5732 self.Parameters(SIMPLE).SetMaxElementArea(area)
5734 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
5735 # Overrides value set by MaxElementArea()
5736 # Only for algoType == NETGEN_FULL
5737 # @ingroup l3_hypos_netgen
5738 def LengthFromEdges(self):
5739 self.Parameters(SIMPLE).LengthFromEdges()
5741 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
5742 # Overrides value set by MaxElementVolume()
5743 # Only for algoType == NETGEN_FULL
5744 # @ingroup l3_hypos_netgen
5745 def LengthFromFaces(self):
5746 self.Parameters(SIMPLE).LengthFromFaces()
5748 ## To mesh "holes" in a solid or not. Default is to mesh.
5749 # @ingroup l3_hypos_ghs3dh
5750 def SetToMeshHoles(self, toMesh):
5751 # Parameter of GHS3D
5752 if self.Parameters():
5753 self.params.SetToMeshHoles(toMesh)
5755 ## Set Optimization level:
5756 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
5757 # Strong_Optimization.
5758 # Default is Standard_Optimization
5759 # @ingroup l3_hypos_ghs3dh
5760 def SetOptimizationLevel(self, level):
5761 # Parameter of GHS3D
5762 if self.Parameters():
5763 self.params.SetOptimizationLevel(level)
5765 ## Maximal size of memory to be used by the algorithm (in Megabytes).
5766 # @ingroup l3_hypos_ghs3dh
5767 def SetMaximumMemory(self, MB):
5768 # Advanced parameter of GHS3D
5769 if self.Parameters():
5770 self.params.SetMaximumMemory(MB)
5772 ## Initial size of memory to be used by the algorithm (in Megabytes) in
5773 # automatic memory adjustment mode.
5774 # @ingroup l3_hypos_ghs3dh
5775 def SetInitialMemory(self, MB):
5776 # Advanced parameter of GHS3D
5777 if self.Parameters():
5778 self.params.SetInitialMemory(MB)
5780 ## Path to working directory.
5781 # @ingroup l3_hypos_ghs3dh
5782 def SetWorkingDirectory(self, path):
5783 # Advanced parameter of GHS3D
5784 if self.Parameters():
5785 self.params.SetWorkingDirectory(path)
5787 ## To keep working files or remove them. Log file remains in case of errors anyway.
5788 # @ingroup l3_hypos_ghs3dh
5789 def SetKeepFiles(self, toKeep):
5790 # Advanced parameter of GHS3D and GHS3DPRL
5791 if self.Parameters():
5792 self.params.SetKeepFiles(toKeep)
5794 ## To set verbose level [0-10]. <ul>
5795 #<li> 0 - no standard output,
5796 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
5797 # indicates when the final mesh is being saved. In addition the software
5798 # gives indication regarding the CPU time.
5799 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
5800 # histogram of the skin mesh, quality statistics histogram together with
5801 # the characteristics of the final mesh.</ul>
5802 # @ingroup l3_hypos_ghs3dh
5803 def SetVerboseLevel(self, level):
5804 # Advanced parameter of GHS3D
5805 if self.Parameters():
5806 self.params.SetVerboseLevel(level)
5808 ## To create new nodes.
5809 # @ingroup l3_hypos_ghs3dh
5810 def SetToCreateNewNodes(self, toCreate):
5811 # Advanced parameter of GHS3D
5812 if self.Parameters():
5813 self.params.SetToCreateNewNodes(toCreate)
5815 ## To use boundary recovery version which tries to create mesh on a very poor
5816 # quality surface mesh.
5817 # @ingroup l3_hypos_ghs3dh
5818 def SetToUseBoundaryRecoveryVersion(self, toUse):
5819 # Advanced parameter of GHS3D
5820 if self.Parameters():
5821 self.params.SetToUseBoundaryRecoveryVersion(toUse)
5823 ## Applies finite-element correction by replacing overconstrained elements where
5824 # it is possible. The process is cutting first the overconstrained edges and
5825 # second the overconstrained facets. This insure that no edges have two boundary
5826 # vertices and that no facets have three boundary vertices.
5827 # @ingroup l3_hypos_ghs3dh
5828 def SetFEMCorrection(self, toUseFem):
5829 # Advanced parameter of GHS3D
5830 if self.Parameters():
5831 self.params.SetFEMCorrection(toUseFem)
5833 ## To removes initial central point.
5834 # @ingroup l3_hypos_ghs3dh
5835 def SetToRemoveCentralPoint(self, toRemove):
5836 # Advanced parameter of GHS3D
5837 if self.Parameters():
5838 self.params.SetToRemoveCentralPoint(toRemove)
5840 ## To set an enforced vertex.
5841 # @ingroup l3_hypos_ghs3dh
5842 def SetEnforcedVertex(self, x, y, z, size):
5843 # Advanced parameter of GHS3D
5844 if self.Parameters():
5845 return self.params.SetEnforcedVertex(x, y, z, size)
5847 ## To set an enforced vertex and add it in the group "groupName".
5848 # Only on meshes w/o geometry
5849 # @ingroup l3_hypos_ghs3dh
5850 def SetEnforcedVertexWithGroup(self, x, y, z, size, groupName):
5851 # Advanced parameter of GHS3D
5852 if self.Parameters():
5853 return self.params.SetEnforcedVertexWithGroup(x, y, z, size,groupName)
5855 ## To remove an enforced vertex.
5856 # @ingroup l3_hypos_ghs3dh
5857 def RemoveEnforcedVertex(self, x, y, z):
5858 # Advanced parameter of GHS3D
5859 if self.Parameters():
5860 return self.params.RemoveEnforcedVertex(x, y, z)
5862 ## To set an enforced vertex given a GEOM vertex, group or compound.
5863 # @ingroup l3_hypos_ghs3dh
5864 def SetEnforcedVertexGeom(self, theVertex, size):
5865 AssureGeomPublished( self.mesh, theVertex )
5866 # Advanced parameter of GHS3D
5867 if self.Parameters():
5868 return self.params.SetEnforcedVertexGeom(theVertex, size)
5870 ## To set an enforced vertex given a GEOM vertex, group or compound
5871 # and add it in the group "groupName".
5872 # Only on meshes w/o geometry
5873 # @ingroup l3_hypos_ghs3dh
5874 def SetEnforcedVertexGeomWithGroup(self, theVertex, size, groupName):
5875 AssureGeomPublished( self.mesh, theVertex )
5876 # Advanced parameter of GHS3D
5877 if self.Parameters():
5878 return self.params.SetEnforcedVertexGeomWithGroup(theVertex, size,groupName)
5880 ## To remove an enforced vertex given a GEOM vertex, group or compound.
5881 # @ingroup l3_hypos_ghs3dh
5882 def RemoveEnforcedVertexGeom(self, theVertex):
5883 AssureGeomPublished( self.mesh, theVertex )
5884 # Advanced parameter of GHS3D
5885 if self.Parameters():
5886 return self.params.RemoveEnforcedVertexGeom(theVertex)
5888 ## To set an enforced mesh.
5889 # @ingroup l3_hypos_ghs3dh
5890 def SetEnforcedMesh(self, theSource, elementType):
5891 # Advanced parameter of GHS3D
5892 if self.Parameters():
5893 return self.params.SetEnforcedMesh(theSource, elementType)
5895 ## To set an enforced mesh and add the enforced elements in the group "groupName".
5896 # @ingroup l3_hypos_ghs3dh
5897 def SetEnforcedMeshWithGroup(self, theSource, elementType, groupName):
5898 # Advanced parameter of GHS3D
5899 if self.Parameters():
5900 return self.params.SetEnforcedMeshWithGroup(theSource, elementType, groupName)
5902 ## To set an enforced mesh with given size.
5903 # @ingroup l3_hypos_ghs3dh
5904 def SetEnforcedMeshSize(self, theSource, elementType, size):
5905 # Advanced parameter of GHS3D
5906 if self.Parameters():
5907 return self.params.SetEnforcedMeshSize(theSource, elementType, size)
5909 ## To set an enforced mesh with given size and add the enforced elements in the group "groupName".
5910 # @ingroup l3_hypos_ghs3dh
5911 def SetEnforcedMeshSizeWithGroup(self, theSource, elementType, size, groupName):
5912 # Advanced parameter of GHS3D
5913 if self.Parameters():
5914 return self.params.SetEnforcedMeshSizeWithGroup(theSource, elementType, size, groupName)
5916 ## Sets command line option as text.
5917 # @ingroup l3_hypos_ghs3dh
5918 def SetTextOption(self, option):
5919 # Advanced parameter of GHS3D
5920 if self.Parameters():
5921 self.params.SetTextOption(option)
5923 ## Sets MED files name and path.
5924 def SetMEDName(self, value):
5925 if self.Parameters():
5926 self.params.SetMEDName(value)
5928 ## Sets the number of partition of the initial mesh
5929 def SetNbPart(self, value):
5930 if self.Parameters():
5931 self.params.SetNbPart(value)
5933 ## When big mesh, start tepal in background
5934 def SetBackground(self, value):
5935 if self.Parameters():
5936 self.params.SetBackground(value)
5938 # Public class: Mesh_Hexahedron
5939 # ------------------------------
5941 ## Defines a hexahedron 3D algorithm
5943 # @ingroup l3_algos_basic
5944 class Mesh_Hexahedron(Mesh_Algorithm):
5949 ## Private constructor.
5950 def __init__(self, mesh, algoType=Hexa, geom=0):
5951 Mesh_Algorithm.__init__(self)
5953 self.algoType = algoType
5955 if algoType == Hexa:
5956 self.Create(mesh, geom, "Hexa_3D")
5959 elif algoType == Hexotic:
5960 CheckPlugin(Hexotic)
5961 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
5964 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
5965 # @ingroup l3_hypos_hexotic
5966 def MinMaxQuad(self, min=3, max=8, quad=True):
5967 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
5969 self.params.SetHexesMinLevel(min)
5970 self.params.SetHexesMaxLevel(max)
5971 self.params.SetHexoticQuadrangles(quad)
5974 # Deprecated, only for compatibility!
5975 # Public class: Mesh_Netgen
5976 # ------------------------------
5978 ## Defines a NETGEN-based 2D or 3D algorithm
5979 # that needs no discrete boundary (i.e. independent)
5981 # This class is deprecated, only for compatibility!
5984 # @ingroup l3_algos_basic
5985 class Mesh_Netgen(Mesh_Algorithm):
5989 ## Private constructor.
5990 def __init__(self, mesh, is3D, geom=0):
5991 Mesh_Algorithm.__init__(self)
5997 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
6001 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
6004 ## Defines the hypothesis containing parameters of the algorithm
6005 def Parameters(self):
6007 hyp = self.Hypothesis("NETGEN_Parameters", [],
6008 "libNETGENEngine.so", UseExisting=0)
6010 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
6011 "libNETGENEngine.so", UseExisting=0)
6014 # Public class: Mesh_Projection1D
6015 # ------------------------------
6017 ## Defines a projection 1D algorithm
6018 # @ingroup l3_algos_proj
6020 class Mesh_Projection1D(Mesh_Algorithm):
6022 ## Private constructor.
6023 def __init__(self, mesh, geom=0):
6024 Mesh_Algorithm.__init__(self)
6025 self.Create(mesh, geom, "Projection_1D")
6027 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
6028 # a mesh pattern is taken, and, optionally, the association of vertices
6029 # between the source edge and a target edge (to which a hypothesis is assigned)
6030 # @param edge from which nodes distribution is taken
6031 # @param mesh from which nodes distribution is taken (optional)
6032 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
6033 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
6034 # to associate with \a srcV (optional)
6035 # @param UseExisting if ==true - searches for the existing hypothesis created with
6036 # the same parameters, else (default) - creates a new one
6037 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
6038 AssureGeomPublished( self.mesh, edge )
6039 AssureGeomPublished( self.mesh, srcV )
6040 AssureGeomPublished( self.mesh, tgtV )
6041 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
6043 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
6044 hyp.SetSourceEdge( edge )
6045 if not mesh is None and isinstance(mesh, Mesh):
6046 mesh = mesh.GetMesh()
6047 hyp.SetSourceMesh( mesh )
6048 hyp.SetVertexAssociation( srcV, tgtV )
6051 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
6052 #def CompareSourceEdge(self, hyp, args):
6053 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
6057 # Public class: Mesh_Projection2D
6058 # ------------------------------
6060 ## Defines a projection 2D algorithm
6061 # @ingroup l3_algos_proj
6063 class Mesh_Projection2D(Mesh_Algorithm):
6065 ## Private constructor.
6066 def __init__(self, mesh, geom=0):
6067 Mesh_Algorithm.__init__(self)
6068 self.Create(mesh, geom, "Projection_2D")
6070 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
6071 # a mesh pattern is taken, and, optionally, the association of vertices
6072 # between the source face and the target face (to which a hypothesis is assigned)
6073 # @param face from which the mesh pattern is taken
6074 # @param mesh from which the mesh pattern is taken (optional)
6075 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
6076 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
6077 # to associate with \a srcV1 (optional)
6078 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
6079 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
6080 # to associate with \a srcV2 (optional)
6081 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
6082 # the same parameters, else (default) - forces the creation a new one
6084 # Note: all association vertices must belong to one edge of a face
6085 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
6086 srcV2=None, tgtV2=None, UseExisting=0):
6087 for geom in [ face, srcV1, tgtV1, srcV2, tgtV2 ]:
6088 AssureGeomPublished( self.mesh, geom )
6089 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
6091 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
6092 hyp.SetSourceFace( face )
6093 if isinstance(mesh, Mesh):
6094 mesh = mesh.GetMesh()
6095 hyp.SetSourceMesh( mesh )
6096 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
6099 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
6100 #def CompareSourceFace(self, hyp, args):
6101 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
6104 # Public class: Mesh_Projection3D
6105 # ------------------------------
6107 ## Defines a projection 3D algorithm
6108 # @ingroup l3_algos_proj
6110 class Mesh_Projection3D(Mesh_Algorithm):
6112 ## Private constructor.
6113 def __init__(self, mesh, geom=0):
6114 Mesh_Algorithm.__init__(self)
6115 self.Create(mesh, geom, "Projection_3D")
6117 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
6118 # the mesh pattern is taken, and, optionally, the association of vertices
6119 # between the source and the target solid (to which a hipothesis is assigned)
6120 # @param solid from where the mesh pattern is taken
6121 # @param mesh from where the mesh pattern is taken (optional)
6122 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
6123 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
6124 # to associate with \a srcV1 (optional)
6125 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
6126 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
6127 # to associate with \a srcV2 (optional)
6128 # @param UseExisting - if ==true - searches for the existing hypothesis created with
6129 # the same parameters, else (default) - creates a new one
6131 # Note: association vertices must belong to one edge of a solid
6132 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
6133 srcV2=0, tgtV2=0, UseExisting=0):
6134 for geom in [ solid, srcV1, tgtV1, srcV2, tgtV2 ]:
6135 AssureGeomPublished( self.mesh, geom )
6136 hyp = self.Hypothesis("ProjectionSource3D",
6137 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
6139 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
6140 hyp.SetSource3DShape( solid )
6141 if not mesh is None and isinstance(mesh, Mesh):
6142 mesh = mesh.GetMesh()
6143 hyp.SetSourceMesh( mesh )
6144 if srcV1 and srcV2 and tgtV1 and tgtV2:
6145 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
6146 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
6149 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
6150 #def CompareSourceShape3D(self, hyp, args):
6151 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
6155 # Public class: Mesh_Prism
6156 # ------------------------
6158 ## Defines a 3D extrusion algorithm
6159 # @ingroup l3_algos_3dextr
6161 class Mesh_Prism3D(Mesh_Algorithm):
6163 ## Private constructor.
6164 def __init__(self, mesh, geom=0):
6165 Mesh_Algorithm.__init__(self)
6166 self.Create(mesh, geom, "Prism_3D")
6168 # Public class: Mesh_RadialPrism
6169 # -------------------------------
6171 ## Defines a Radial Prism 3D algorithm
6172 # @ingroup l3_algos_radialp
6174 class Mesh_RadialPrism3D(Mesh_Algorithm):
6176 ## Private constructor.
6177 def __init__(self, mesh, geom=0):
6178 Mesh_Algorithm.__init__(self)
6179 self.Create(mesh, geom, "RadialPrism_3D")
6181 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
6182 self.nbLayers = None
6184 ## Return 3D hypothesis holding the 1D one
6185 def Get3DHypothesis(self):
6186 return self.distribHyp
6188 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
6189 # hypothesis. Returns the created hypothesis
6190 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
6191 #print "OwnHypothesis",hypType
6192 if not self.nbLayers is None:
6193 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
6194 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
6195 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
6196 self.mesh.smeshpyD.SetCurrentStudy( None )
6197 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
6198 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
6199 self.distribHyp.SetLayerDistribution( hyp )
6202 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
6203 # prisms to build between the inner and outer shells
6204 # @param n number of layers
6205 # @param UseExisting if ==true - searches for the existing hypothesis created with
6206 # the same parameters, else (default) - creates a new one
6207 def NumberOfLayers(self, n, UseExisting=0):
6208 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
6209 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
6210 CompareMethod=self.CompareNumberOfLayers)
6211 self.nbLayers.SetNumberOfLayers( n )
6212 return self.nbLayers
6214 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
6215 def CompareNumberOfLayers(self, hyp, args):
6216 return IsEqual(hyp.GetNumberOfLayers(), args[0])
6218 ## Defines "LocalLength" hypothesis, specifying the segment length
6219 # to build between the inner and the outer shells
6220 # @param l the length of segments
6221 # @param p the precision of rounding
6222 def LocalLength(self, l, p=1e-07):
6223 hyp = self.OwnHypothesis("LocalLength", [l,p])
6228 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
6229 # prisms to build between the inner and the outer shells.
6230 # @param n the number of layers
6231 # @param s the scale factor (optional)
6232 def NumberOfSegments(self, n, s=[]):
6234 hyp = self.OwnHypothesis("NumberOfSegments", [n])
6236 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
6237 hyp.SetDistrType( 1 )
6238 hyp.SetScaleFactor(s)
6239 hyp.SetNumberOfSegments(n)
6242 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
6243 # to build between the inner and the outer shells with a length that changes in arithmetic progression
6244 # @param start the length of the first segment
6245 # @param end the length of the last segment
6246 def Arithmetic1D(self, start, end ):
6247 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
6248 hyp.SetLength(start, 1)
6249 hyp.SetLength(end , 0)
6252 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
6253 # to build between the inner and the outer shells as geometric length increasing
6254 # @param start for the length of the first segment
6255 # @param end for the length of the last segment
6256 def StartEndLength(self, start, end):
6257 hyp = self.OwnHypothesis("StartEndLength", [start, end])
6258 hyp.SetLength(start, 1)
6259 hyp.SetLength(end , 0)
6262 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
6263 # to build between the inner and outer shells
6264 # @param fineness defines the quality of the mesh within the range [0-1]
6265 def AutomaticLength(self, fineness=0):
6266 hyp = self.OwnHypothesis("AutomaticLength")
6267 hyp.SetFineness( fineness )
6270 # Public class: Mesh_RadialQuadrangle1D2D
6271 # -------------------------------
6273 ## Defines a Radial Quadrangle 1D2D algorithm
6274 # @ingroup l2_algos_radialq
6276 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
6278 ## Private constructor.
6279 def __init__(self, mesh, geom=0):
6280 Mesh_Algorithm.__init__(self)
6281 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
6283 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
6284 self.nbLayers = None
6286 ## Return 2D hypothesis holding the 1D one
6287 def Get2DHypothesis(self):
6288 return self.distribHyp
6290 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
6291 # hypothesis. Returns the created hypothesis
6292 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
6293 #print "OwnHypothesis",hypType
6295 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
6296 if self.distribHyp is None:
6297 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
6299 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
6300 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
6301 self.mesh.smeshpyD.SetCurrentStudy( None )
6302 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
6303 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
6304 self.distribHyp.SetLayerDistribution( hyp )
6307 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
6308 # @param n number of layers
6309 # @param UseExisting if ==true - searches for the existing hypothesis created with
6310 # the same parameters, else (default) - creates a new one
6311 def NumberOfLayers(self, n, UseExisting=0):
6313 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
6314 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
6315 CompareMethod=self.CompareNumberOfLayers)
6316 self.nbLayers.SetNumberOfLayers( n )
6317 return self.nbLayers
6319 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
6320 def CompareNumberOfLayers(self, hyp, args):
6321 return IsEqual(hyp.GetNumberOfLayers(), args[0])
6323 ## Defines "LocalLength" hypothesis, specifying the segment length
6324 # @param l the length of segments
6325 # @param p the precision of rounding
6326 def LocalLength(self, l, p=1e-07):
6327 hyp = self.OwnHypothesis("LocalLength", [l,p])
6332 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
6333 # @param n the number of layers
6334 # @param s the scale factor (optional)
6335 def NumberOfSegments(self, n, s=[]):
6337 hyp = self.OwnHypothesis("NumberOfSegments", [n])
6339 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
6340 hyp.SetDistrType( 1 )
6341 hyp.SetScaleFactor(s)
6342 hyp.SetNumberOfSegments(n)
6345 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
6346 # with a length that changes in arithmetic progression
6347 # @param start the length of the first segment
6348 # @param end the length of the last segment
6349 def Arithmetic1D(self, start, end ):
6350 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
6351 hyp.SetLength(start, 1)
6352 hyp.SetLength(end , 0)
6355 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
6356 # as geometric length increasing
6357 # @param start for the length of the first segment
6358 # @param end for the length of the last segment
6359 def StartEndLength(self, start, end):
6360 hyp = self.OwnHypothesis("StartEndLength", [start, end])
6361 hyp.SetLength(start, 1)
6362 hyp.SetLength(end , 0)
6365 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
6366 # @param fineness defines the quality of the mesh within the range [0-1]
6367 def AutomaticLength(self, fineness=0):
6368 hyp = self.OwnHypothesis("AutomaticLength")
6369 hyp.SetFineness( fineness )
6373 # Public class: Mesh_UseExistingElements
6374 # --------------------------------------
6375 ## Defines a Radial Quadrangle 1D2D algorithm
6376 # @ingroup l3_algos_basic
6378 class Mesh_UseExistingElements(Mesh_Algorithm):
6380 def __init__(self, dim, mesh, geom=0):
6382 self.Create(mesh, geom, "Import_1D")
6384 self.Create(mesh, geom, "Import_1D2D")
6387 ## Defines "Source edges" hypothesis, specifying groups of edges to import
6388 # @param groups list of groups of edges
6389 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
6390 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
6391 # @param UseExisting if ==true - searches for the existing hypothesis created with
6392 # the same parameters, else (default) - creates a new one
6393 def SourceEdges(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
6394 if self.algo.GetName() == "Import_2D":
6395 raise ValueError, "algoritm dimension mismatch"
6396 for group in groups:
6397 AssureGeomPublished( self.mesh, group )
6398 hyp = self.Hypothesis("ImportSource1D", [groups, toCopyMesh, toCopyGroups],
6399 UseExisting=UseExisting, CompareMethod=self._compareHyp)
6400 hyp.SetSourceEdges(groups)
6401 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
6404 ## Defines "Source faces" hypothesis, specifying groups of faces to import
6405 # @param groups list of groups of faces
6406 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
6407 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
6408 # @param UseExisting if ==true - searches for the existing hypothesis created with
6409 # the same parameters, else (default) - creates a new one
6410 def SourceFaces(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
6411 if self.algo.GetName() == "Import_1D":
6412 raise ValueError, "algoritm dimension mismatch"
6413 for group in groups:
6414 AssureGeomPublished( self.mesh, group )
6415 hyp = self.Hypothesis("ImportSource2D", [groups, toCopyMesh, toCopyGroups],
6416 UseExisting=UseExisting, CompareMethod=self._compareHyp)
6417 hyp.SetSourceFaces(groups)
6418 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
6421 def _compareHyp(self,hyp,args):
6422 if hasattr( hyp, "GetSourceEdges"):
6423 entries = hyp.GetSourceEdges()
6425 entries = hyp.GetSourceFaces()
6427 toCopyMesh,toCopyGroups = hyp.GetCopySourceMesh()
6428 if len(entries)==len(groups) and toCopyMesh==args[1] and toCopyGroups==args[2]:
6430 study = self.mesh.smeshpyD.GetCurrentStudy()
6433 ior = salome.orb.object_to_string(g)
6434 sobj = study.FindObjectIOR(ior)
6435 if sobj: entries2.append( sobj.GetID() )
6440 return entries == entries2
6444 # Private class: Mesh_UseExisting
6445 # -------------------------------
6446 class Mesh_UseExisting(Mesh_Algorithm):
6448 def __init__(self, dim, mesh, geom=0):
6450 self.Create(mesh, geom, "UseExisting_1D")
6452 self.Create(mesh, geom, "UseExisting_2D")
6455 import salome_notebook
6456 notebook = salome_notebook.notebook
6458 ##Return values of the notebook variables
6459 def ParseParameters(last, nbParams,nbParam, value):
6463 listSize = len(last)
6464 for n in range(0,nbParams):
6466 if counter < listSize:
6467 strResult = strResult + last[counter]
6469 strResult = strResult + ""
6471 if isinstance(value, str):
6472 if notebook.isVariable(value):
6473 result = notebook.get(value)
6474 strResult=strResult+value
6476 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
6478 strResult=strResult+str(value)
6480 if nbParams - 1 != counter:
6481 strResult=strResult+var_separator #":"
6483 return result, strResult
6485 #Wrapper class for StdMeshers_LocalLength hypothesis
6486 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
6488 ## Set Length parameter value
6489 # @param length numerical value or name of variable from notebook
6490 def SetLength(self, length):
6491 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
6492 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6493 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
6495 ## Set Precision parameter value
6496 # @param precision numerical value or name of variable from notebook
6497 def SetPrecision(self, precision):
6498 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
6499 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6500 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
6502 #Registering the new proxy for LocalLength
6503 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
6506 #Wrapper class for StdMeshers_LayerDistribution hypothesis
6507 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
6509 def SetLayerDistribution(self, hypo):
6510 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
6511 hypo.ClearParameters();
6512 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
6514 #Registering the new proxy for LayerDistribution
6515 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
6517 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
6518 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
6520 ## Set Length parameter value
6521 # @param length numerical value or name of variable from notebook
6522 def SetLength(self, length):
6523 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
6524 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
6525 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
6527 #Registering the new proxy for SegmentLengthAroundVertex
6528 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
6531 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
6532 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
6534 ## Set Length parameter value
6535 # @param length numerical value or name of variable from notebook
6536 # @param isStart true is length is Start Length, otherwise false
6537 def SetLength(self, length, isStart):
6541 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
6542 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
6543 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
6545 #Registering the new proxy for Arithmetic1D
6546 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
6548 #Wrapper class for StdMeshers_Deflection1D hypothesis
6549 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
6551 ## Set Deflection parameter value
6552 # @param deflection numerical value or name of variable from notebook
6553 def SetDeflection(self, deflection):
6554 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
6555 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
6556 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
6558 #Registering the new proxy for Deflection1D
6559 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
6561 #Wrapper class for StdMeshers_StartEndLength hypothesis
6562 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
6564 ## Set Length parameter value
6565 # @param length numerical value or name of variable from notebook
6566 # @param isStart true is length is Start Length, otherwise false
6567 def SetLength(self, length, isStart):
6571 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
6572 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
6573 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
6575 #Registering the new proxy for StartEndLength
6576 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
6578 #Wrapper class for StdMeshers_MaxElementArea hypothesis
6579 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
6581 ## Set Max Element Area parameter value
6582 # @param area numerical value or name of variable from notebook
6583 def SetMaxElementArea(self, area):
6584 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
6585 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
6586 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
6588 #Registering the new proxy for MaxElementArea
6589 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
6592 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
6593 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
6595 ## Set Max Element Volume parameter value
6596 # @param volume numerical value or name of variable from notebook
6597 def SetMaxElementVolume(self, volume):
6598 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
6599 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
6600 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
6602 #Registering the new proxy for MaxElementVolume
6603 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
6606 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
6607 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
6609 ## Set Number Of Layers parameter value
6610 # @param nbLayers numerical value or name of variable from notebook
6611 def SetNumberOfLayers(self, nbLayers):
6612 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
6613 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
6614 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
6616 #Registering the new proxy for NumberOfLayers
6617 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
6619 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
6620 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
6622 ## Set Number Of Segments parameter value
6623 # @param nbSeg numerical value or name of variable from notebook
6624 def SetNumberOfSegments(self, nbSeg):
6625 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
6626 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
6627 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6628 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
6630 ## Set Scale Factor parameter value
6631 # @param factor numerical value or name of variable from notebook
6632 def SetScaleFactor(self, factor):
6633 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
6634 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6635 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
6637 #Registering the new proxy for NumberOfSegments
6638 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
6640 if not noNETGENPlugin:
6641 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
6642 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
6644 ## Set Max Size parameter value
6645 # @param maxsize numerical value or name of variable from notebook
6646 def SetMaxSize(self, maxsize):
6647 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6648 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
6649 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6650 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
6652 ## Set Growth Rate parameter value
6653 # @param value numerical value or name of variable from notebook
6654 def SetGrowthRate(self, value):
6655 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6656 value, parameters = ParseParameters(lastParameters,4,2,value)
6657 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6658 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
6660 ## Set Number of Segments per Edge parameter value
6661 # @param value numerical value or name of variable from notebook
6662 def SetNbSegPerEdge(self, value):
6663 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6664 value, parameters = ParseParameters(lastParameters,4,3,value)
6665 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6666 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
6668 ## Set Number of Segments per Radius parameter value
6669 # @param value numerical value or name of variable from notebook
6670 def SetNbSegPerRadius(self, value):
6671 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6672 value, parameters = ParseParameters(lastParameters,4,4,value)
6673 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6674 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
6676 #Registering the new proxy for NETGENPlugin_Hypothesis
6677 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
6680 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
6681 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
6684 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
6685 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
6687 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
6688 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
6690 ## Set Number of Segments parameter value
6691 # @param nbSeg numerical value or name of variable from notebook
6692 def SetNumberOfSegments(self, nbSeg):
6693 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6694 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
6695 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6696 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
6698 ## Set Local Length parameter value
6699 # @param length numerical value or name of variable from notebook
6700 def SetLocalLength(self, length):
6701 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6702 length, parameters = ParseParameters(lastParameters,2,1,length)
6703 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6704 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
6706 ## Set Max Element Area parameter value
6707 # @param area numerical value or name of variable from notebook
6708 def SetMaxElementArea(self, area):
6709 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6710 area, parameters = ParseParameters(lastParameters,2,2,area)
6711 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6712 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
6714 def LengthFromEdges(self):
6715 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6717 value, parameters = ParseParameters(lastParameters,2,2,value)
6718 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6719 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
6721 #Registering the new proxy for NETGEN_SimpleParameters_2D
6722 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
6725 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
6726 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
6727 ## Set Max Element Volume parameter value
6728 # @param volume numerical value or name of variable from notebook
6729 def SetMaxElementVolume(self, volume):
6730 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6731 volume, parameters = ParseParameters(lastParameters,3,3,volume)
6732 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6733 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
6735 def LengthFromFaces(self):
6736 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6738 value, parameters = ParseParameters(lastParameters,3,3,value)
6739 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6740 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
6742 #Registering the new proxy for NETGEN_SimpleParameters_3D
6743 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
6745 pass # if not noNETGENPlugin:
6747 class Pattern(SMESH._objref_SMESH_Pattern):
6749 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
6751 if isinstance(theNodeIndexOnKeyPoint1,str):
6753 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
6755 theNodeIndexOnKeyPoint1 -= 1
6756 theMesh.SetParameters(Parameters)
6757 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
6759 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
6762 if isinstance(theNode000Index,str):
6764 if isinstance(theNode001Index,str):
6766 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
6768 theNode000Index -= 1
6770 theNode001Index -= 1
6771 theMesh.SetParameters(Parameters)
6772 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
6774 #Registering the new proxy for Pattern
6775 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)