1 # Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 # Author : Francis KLOSS, OCC
28 ## @defgroup l1_auxiliary Auxiliary methods and structures
29 ## @defgroup l1_creating Creating meshes
31 ## @defgroup l2_impexp Importing and exporting meshes
32 ## @defgroup l2_construct Constructing meshes
33 ## @defgroup l2_algorithms Defining Algorithms
35 ## @defgroup l3_algos_basic Basic meshing algorithms
36 ## @defgroup l3_algos_proj Projection Algorithms
37 ## @defgroup l3_algos_radialp Radial Prism
38 ## @defgroup l3_algos_segmarv Segments around Vertex
39 ## @defgroup l3_algos_3dextr 3D extrusion meshing algorithm
42 ## @defgroup l2_hypotheses Defining hypotheses
44 ## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
45 ## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
46 ## @defgroup l3_hypos_maxvol Max Element Volume hypothesis
47 ## @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
48 ## @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
49 ## @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
50 ## @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
51 ## @defgroup l3_hypos_quad Quadrangle Parameters hypothesis
52 ## @defgroup l3_hypos_additi Additional Hypotheses
55 ## @defgroup l2_submeshes Constructing submeshes
56 ## @defgroup l2_compounds Building Compounds
57 ## @defgroup l2_editing Editing Meshes
60 ## @defgroup l1_meshinfo Mesh Information
61 ## @defgroup l1_controls Quality controls and Filtering
62 ## @defgroup l1_grouping Grouping elements
64 ## @defgroup l2_grps_create Creating groups
65 ## @defgroup l2_grps_edit Editing groups
66 ## @defgroup l2_grps_operon Using operations on groups
67 ## @defgroup l2_grps_delete Deleting Groups
70 ## @defgroup l1_modifying Modifying meshes
72 ## @defgroup l2_modif_add Adding nodes and elements
73 ## @defgroup l2_modif_del Removing nodes and elements
74 ## @defgroup l2_modif_edit Modifying nodes and elements
75 ## @defgroup l2_modif_renumber Renumbering nodes and elements
76 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
77 ## @defgroup l2_modif_movenode Moving nodes
78 ## @defgroup l2_modif_throughp Mesh through point
79 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
80 ## @defgroup l2_modif_unitetri Uniting triangles
81 ## @defgroup l2_modif_changori Changing orientation of elements
82 ## @defgroup l2_modif_cutquadr Cutting quadrangles
83 ## @defgroup l2_modif_smooth Smoothing
84 ## @defgroup l2_modif_extrurev Extrusion and Revolution
85 ## @defgroup l2_modif_patterns Pattern mapping
86 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
89 ## @defgroup l1_measurements Measurements
94 import SMESH # This is necessary for back compatibility
102 # import NETGENPlugin module if possible
110 # import GHS3DPlugin module if possible
118 # import GHS3DPRLPlugin module if possible
121 import GHS3DPRLPlugin
126 # import HexoticPlugin module if possible
134 # import BLSURFPlugin module if possible
142 ## @addtogroup l1_auxiliary
145 # Types of algorithms
158 NETGEN_1D2D3D = FULL_NETGEN
159 NETGEN_FULL = FULL_NETGEN
167 # MirrorType enumeration
168 POINT = SMESH_MeshEditor.POINT
169 AXIS = SMESH_MeshEditor.AXIS
170 PLANE = SMESH_MeshEditor.PLANE
172 # Smooth_Method enumeration
173 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
174 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
176 # Fineness enumeration (for NETGEN)
184 # Optimization level of GHS3D
186 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
187 # V4.1 (partialy redefines V3.1). Issue 0020574
188 None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization, Strong_Optimization = 0,1,2,3,4
190 # Topology treatment way of BLSURF
191 FromCAD, PreProcess, PreProcessPlus, PreCAD = 0,1,2,3
193 # Element size flag of BLSURF
194 DefaultSize, DefaultGeom, BLSURF_Custom, SizeMap = 0,0,1,2
196 PrecisionConfusion = 1e-07
198 # TopAbs_State enumeration
199 [TopAbs_IN, TopAbs_OUT, TopAbs_ON, TopAbs_UNKNOWN] = range(4)
201 # Methods of splitting a hexahedron into tetrahedra
202 Hex_5Tet, Hex_6Tet, Hex_24Tet = 1, 2, 3
204 # import items of enum QuadType
205 for e in StdMeshers.QuadType._items: exec('%s = StdMeshers.%s'%(e,e))
207 ## Converts an angle from degrees to radians
208 def DegreesToRadians(AngleInDegrees):
210 return AngleInDegrees * pi / 180.0
212 # Salome notebook variable separator
215 # Parametrized substitute for PointStruct
216 class PointStructStr:
225 def __init__(self, xStr, yStr, zStr):
229 if isinstance(xStr, str) and notebook.isVariable(xStr):
230 self.x = notebook.get(xStr)
233 if isinstance(yStr, str) and notebook.isVariable(yStr):
234 self.y = notebook.get(yStr)
237 if isinstance(zStr, str) and notebook.isVariable(zStr):
238 self.z = notebook.get(zStr)
242 # Parametrized substitute for PointStruct (with 6 parameters)
243 class PointStructStr6:
258 def __init__(self, x1Str, x2Str, y1Str, y2Str, z1Str, z2Str):
265 if isinstance(x1Str, str) and notebook.isVariable(x1Str):
266 self.x1 = notebook.get(x1Str)
269 if isinstance(x2Str, str) and notebook.isVariable(x2Str):
270 self.x2 = notebook.get(x2Str)
273 if isinstance(y1Str, str) and notebook.isVariable(y1Str):
274 self.y1 = notebook.get(y1Str)
277 if isinstance(y2Str, str) and notebook.isVariable(y2Str):
278 self.y2 = notebook.get(y2Str)
281 if isinstance(z1Str, str) and notebook.isVariable(z1Str):
282 self.z1 = notebook.get(z1Str)
285 if isinstance(z2Str, str) and notebook.isVariable(z2Str):
286 self.z2 = notebook.get(z2Str)
290 # Parametrized substitute for AxisStruct
306 def __init__(self, xStr, yStr, zStr, dxStr, dyStr, dzStr):
313 if isinstance(xStr, str) and notebook.isVariable(xStr):
314 self.x = notebook.get(xStr)
317 if isinstance(yStr, str) and notebook.isVariable(yStr):
318 self.y = notebook.get(yStr)
321 if isinstance(zStr, str) and notebook.isVariable(zStr):
322 self.z = notebook.get(zStr)
325 if isinstance(dxStr, str) and notebook.isVariable(dxStr):
326 self.dx = notebook.get(dxStr)
329 if isinstance(dyStr, str) and notebook.isVariable(dyStr):
330 self.dy = notebook.get(dyStr)
333 if isinstance(dzStr, str) and notebook.isVariable(dzStr):
334 self.dz = notebook.get(dzStr)
338 # Parametrized substitute for DirStruct
341 def __init__(self, pointStruct):
342 self.pointStruct = pointStruct
344 # Returns list of variable values from salome notebook
345 def ParsePointStruct(Point):
346 Parameters = 2*var_separator
347 if isinstance(Point, PointStructStr):
348 Parameters = str(Point.xStr) + var_separator + str(Point.yStr) + var_separator + str(Point.zStr)
349 Point = PointStruct(Point.x, Point.y, Point.z)
350 return Point, Parameters
352 # Returns list of variable values from salome notebook
353 def ParseDirStruct(Dir):
354 Parameters = 2*var_separator
355 if isinstance(Dir, DirStructStr):
356 pntStr = Dir.pointStruct
357 if isinstance(pntStr, PointStructStr6):
358 Parameters = str(pntStr.x1Str) + var_separator + str(pntStr.x2Str) + var_separator
359 Parameters += str(pntStr.y1Str) + var_separator + str(pntStr.y2Str) + var_separator
360 Parameters += str(pntStr.z1Str) + var_separator + str(pntStr.z2Str)
361 Point = PointStruct(pntStr.x2 - pntStr.x1, pntStr.y2 - pntStr.y1, pntStr.z2 - pntStr.z1)
363 Parameters = str(pntStr.xStr) + var_separator + str(pntStr.yStr) + var_separator + str(pntStr.zStr)
364 Point = PointStruct(pntStr.x, pntStr.y, pntStr.z)
365 Dir = DirStruct(Point)
366 return Dir, Parameters
368 # Returns list of variable values from salome notebook
369 def ParseAxisStruct(Axis):
370 Parameters = 5*var_separator
371 if isinstance(Axis, AxisStructStr):
372 Parameters = str(Axis.xStr) + var_separator + str(Axis.yStr) + var_separator + str(Axis.zStr) + var_separator
373 Parameters += str(Axis.dxStr) + var_separator + str(Axis.dyStr) + var_separator + str(Axis.dzStr)
374 Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz)
375 return Axis, Parameters
377 ## Return list of variable values from salome notebook
378 def ParseAngles(list):
381 for parameter in list:
382 if isinstance(parameter,str) and notebook.isVariable(parameter):
383 Result.append(DegreesToRadians(notebook.get(parameter)))
386 Result.append(parameter)
389 Parameters = Parameters + str(parameter)
390 Parameters = Parameters + var_separator
392 Parameters = Parameters[:len(Parameters)-1]
393 return Result, Parameters
395 def IsEqual(val1, val2, tol=PrecisionConfusion):
396 if abs(val1 - val2) < tol:
406 if isinstance(obj, SALOMEDS._objref_SObject):
409 ior = salome.orb.object_to_string(obj)
412 studies = salome.myStudyManager.GetOpenStudies()
413 for sname in studies:
414 s = salome.myStudyManager.GetStudyByName(sname)
416 sobj = s.FindObjectIOR(ior)
417 if not sobj: continue
418 return sobj.GetName()
419 if hasattr(obj, "GetName"):
420 # unknown CORBA object, having GetName() method
423 # unknown CORBA object, no GetName() method
426 if hasattr(obj, "GetName"):
427 # unknown non-CORBA object, having GetName() method
430 raise RuntimeError, "Null or invalid object"
432 ## Prints error message if a hypothesis was not assigned.
433 def TreatHypoStatus(status, hypName, geomName, isAlgo):
435 hypType = "algorithm"
437 hypType = "hypothesis"
439 if status == HYP_UNKNOWN_FATAL :
440 reason = "for unknown reason"
441 elif status == HYP_INCOMPATIBLE :
442 reason = "this hypothesis mismatches the algorithm"
443 elif status == HYP_NOTCONFORM :
444 reason = "a non-conform mesh would be built"
445 elif status == HYP_ALREADY_EXIST :
446 if isAlgo: return # it does not influence anything
447 reason = hypType + " of the same dimension is already assigned to this shape"
448 elif status == HYP_BAD_DIM :
449 reason = hypType + " mismatches the shape"
450 elif status == HYP_CONCURENT :
451 reason = "there are concurrent hypotheses on sub-shapes"
452 elif status == HYP_BAD_SUBSHAPE :
453 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
454 elif status == HYP_BAD_GEOMETRY:
455 reason = "geometry mismatches the expectation of the algorithm"
456 elif status == HYP_HIDDEN_ALGO:
457 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
458 elif status == HYP_HIDING_ALGO:
459 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
460 elif status == HYP_NEED_SHAPE:
461 reason = "Algorithm can't work without shape"
464 hypName = '"' + hypName + '"'
465 geomName= '"' + geomName+ '"'
466 if status < HYP_UNKNOWN_FATAL and not geomName =='""':
467 print hypName, "was assigned to", geomName,"but", reason
468 elif not geomName == '""':
469 print hypName, "was not assigned to",geomName,":", reason
471 print hypName, "was not assigned:", reason
474 ## Check meshing plugin availability
475 def CheckPlugin(plugin):
476 if plugin == NETGEN and noNETGENPlugin:
477 print "Warning: NETGENPlugin module unavailable"
479 elif plugin == GHS3D and noGHS3DPlugin:
480 print "Warning: GHS3DPlugin module unavailable"
482 elif plugin == GHS3DPRL and noGHS3DPRLPlugin:
483 print "Warning: GHS3DPRLPlugin module unavailable"
485 elif plugin == Hexotic and noHexoticPlugin:
486 print "Warning: HexoticPlugin module unavailable"
488 elif plugin == BLSURF and noBLSURFPlugin:
489 print "Warning: BLSURFPlugin module unavailable"
493 ## Private method. Add geom (sub-shape of the main shape) into the study if not yet there
494 def AssureGeomPublished(mesh, geom, name=''):
495 if not isinstance( geom, geompyDC.GEOM._objref_GEOM_Object ):
497 if not geom.IsSame( mesh.geom ) and not geom.GetStudyEntry():
499 studyID = mesh.smeshpyD.GetCurrentStudy()._get_StudyId()
500 if studyID != mesh.geompyD.myStudyId:
501 mesh.geompyD.init_geom( mesh.smeshpyD.GetCurrentStudy())
503 if not name and geom.GetShapeType() != geompyDC.GEOM.COMPOUND:
504 # for all groups SubShapeName() returns "Compound_-1"
505 name = mesh.geompyD.SubShapeName(geom, mesh.geom)
507 name = "%s_%s"%(geom.GetShapeType(), id(geom)%10000)
509 mesh.geompyD.addToStudyInFather( mesh.geom, geom, name )
512 ## Return the first vertex of a geomertical edge by ignoring orienation
513 def FirstVertexOnCurve(edge):
514 from geompy import SubShapeAll, ShapeType, KindOfShape, PointCoordinates
515 vv = SubShapeAll( edge, ShapeType["VERTEX"])
517 raise TypeError, "Given object has no vertices"
518 if len( vv ) == 1: return vv[0]
519 info = KindOfShape(edge)
520 xyz = info[1:4] # coords of the first vertex
521 xyz1 = PointCoordinates( vv[0] )
522 xyz2 = PointCoordinates( vv[1] )
525 dist1 += abs( xyz[i] - xyz1[i] )
526 dist2 += abs( xyz[i] - xyz2[i] )
532 # end of l1_auxiliary
535 # All methods of this class are accessible directly from the smesh.py package.
536 class smeshDC(SMESH._objref_SMESH_Gen):
538 ## Dump component to the Python script
539 # This method overrides IDL function to allow default values for the parameters.
540 def DumpPython(self, theStudy, theIsPublished=True, theIsMultiFile=True):
541 return SMESH._objref_SMESH_Gen.DumpPython(self, theStudy, theIsPublished, theIsMultiFile)
543 ## Sets the current study and Geometry component
544 # @ingroup l1_auxiliary
545 def init_smesh(self,theStudy,geompyD):
546 self.SetCurrentStudy(theStudy,geompyD)
548 ## Creates an empty Mesh. This mesh can have an underlying geometry.
549 # @param obj the Geometrical object on which the mesh is built. If not defined,
550 # the mesh will have no underlying geometry.
551 # @param name the name for the new mesh.
552 # @return an instance of Mesh class.
553 # @ingroup l2_construct
554 def Mesh(self, obj=0, name=0):
555 if isinstance(obj,str):
557 return Mesh(self,self.geompyD,obj,name)
559 ## Returns a long value from enumeration
560 # Should be used for SMESH.FunctorType enumeration
561 # @ingroup l1_controls
562 def EnumToLong(self,theItem):
565 ## Returns a string representation of the color.
566 # To be used with filters.
567 # @param c color value (SALOMEDS.Color)
568 # @ingroup l1_controls
569 def ColorToString(self,c):
571 if isinstance(c, SALOMEDS.Color):
572 val = "%s;%s;%s" % (c.R, c.G, c.B)
573 elif isinstance(c, str):
576 raise ValueError, "Color value should be of string or SALOMEDS.Color type"
579 ## Gets PointStruct from vertex
580 # @param theVertex a GEOM object(vertex)
581 # @return SMESH.PointStruct
582 # @ingroup l1_auxiliary
583 def GetPointStruct(self,theVertex):
584 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
585 return PointStruct(x,y,z)
587 ## Gets DirStruct from vector
588 # @param theVector a GEOM object(vector)
589 # @return SMESH.DirStruct
590 # @ingroup l1_auxiliary
591 def GetDirStruct(self,theVector):
592 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
593 if(len(vertices) != 2):
594 print "Error: vector object is incorrect."
596 p1 = self.geompyD.PointCoordinates(vertices[0])
597 p2 = self.geompyD.PointCoordinates(vertices[1])
598 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
599 dirst = DirStruct(pnt)
602 ## Makes DirStruct from a triplet
603 # @param x,y,z vector components
604 # @return SMESH.DirStruct
605 # @ingroup l1_auxiliary
606 def MakeDirStruct(self,x,y,z):
607 pnt = PointStruct(x,y,z)
608 return DirStruct(pnt)
610 ## Get AxisStruct from object
611 # @param theObj a GEOM object (line or plane)
612 # @return SMESH.AxisStruct
613 # @ingroup l1_auxiliary
614 def GetAxisStruct(self,theObj):
615 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
617 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
618 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
619 vertex1 = self.geompyD.PointCoordinates(vertex1)
620 vertex2 = self.geompyD.PointCoordinates(vertex2)
621 vertex3 = self.geompyD.PointCoordinates(vertex3)
622 vertex4 = self.geompyD.PointCoordinates(vertex4)
623 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
624 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
625 normal = [ v1[1]*v2[2]-v2[1]*v1[2], v1[2]*v2[0]-v2[2]*v1[0], v1[0]*v2[1]-v2[0]*v1[1] ]
626 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
628 elif len(edges) == 1:
629 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
630 p1 = self.geompyD.PointCoordinates( vertex1 )
631 p2 = self.geompyD.PointCoordinates( vertex2 )
632 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
636 # From SMESH_Gen interface:
637 # ------------------------
639 ## Sets the given name to the object
640 # @param obj the object to rename
641 # @param name a new object name
642 # @ingroup l1_auxiliary
643 def SetName(self, obj, name):
644 if isinstance( obj, Mesh ):
646 elif isinstance( obj, Mesh_Algorithm ):
647 obj = obj.GetAlgorithm()
648 ior = salome.orb.object_to_string(obj)
649 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
651 ## Sets the current mode
652 # @ingroup l1_auxiliary
653 def SetEmbeddedMode( self,theMode ):
654 #self.SetEmbeddedMode(theMode)
655 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
657 ## Gets the current mode
658 # @ingroup l1_auxiliary
659 def IsEmbeddedMode(self):
660 #return self.IsEmbeddedMode()
661 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
663 ## Sets the current study
664 # @ingroup l1_auxiliary
665 def SetCurrentStudy( self, theStudy, geompyD = None ):
666 #self.SetCurrentStudy(theStudy)
669 geompyD = geompy.geom
672 self.SetGeomEngine(geompyD)
673 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
675 ## Gets the current study
676 # @ingroup l1_auxiliary
677 def GetCurrentStudy(self):
678 #return self.GetCurrentStudy()
679 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
681 ## Creates a Mesh object importing data from the given UNV file
682 # @return an instance of Mesh class
684 def CreateMeshesFromUNV( self,theFileName ):
685 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
686 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
689 ## Creates a Mesh object(s) importing data from the given MED file
690 # @return a list of Mesh class instances
692 def CreateMeshesFromMED( self,theFileName ):
693 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
695 for iMesh in range(len(aSmeshMeshes)) :
696 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
697 aMeshes.append(aMesh)
698 return aMeshes, aStatus
700 ## Creates a Mesh object importing data from the given STL file
701 # @return an instance of Mesh class
703 def CreateMeshesFromSTL( self, theFileName ):
704 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
705 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
708 ## Creates Mesh objects importing data from the given CGNS file
709 # @return an instance of Mesh class
711 def CreateMeshesFromCGNS( self, theFileName ):
712 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromCGNS(self,theFileName)
714 for iMesh in range(len(aSmeshMeshes)) :
715 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
716 aMeshes.append(aMesh)
717 return aMeshes, aStatus
719 ## Concatenate the given meshes into one mesh.
720 # @return an instance of Mesh class
721 # @param meshes the meshes to combine into one mesh
722 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
723 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
724 # @param mergeTolerance tolerance for merging nodes
725 # @param allGroups forces creation of groups of all elements
726 def Concatenate( self, meshes, uniteIdenticalGroups,
727 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
728 mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
729 for i,m in enumerate(meshes):
730 if isinstance(m, Mesh):
731 meshes[i] = m.GetMesh()
733 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
734 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
736 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
737 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
738 aSmeshMesh.SetParameters(Parameters)
739 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
742 ## Create a mesh by copying a part of another mesh.
743 # @param meshPart a part of mesh to copy, either a Mesh, a sub-mesh or a group;
744 # to copy nodes or elements not contained in any mesh object,
745 # pass result of Mesh.GetIDSource( list_of_ids, type ) as meshPart
746 # @param meshName a name of the new mesh
747 # @param toCopyGroups to create in the new mesh groups the copied elements belongs to
748 # @param toKeepIDs to preserve IDs of the copied elements or not
749 # @return an instance of Mesh class
750 def CopyMesh( self, meshPart, meshName, toCopyGroups=False, toKeepIDs=False):
751 if (isinstance( meshPart, Mesh )):
752 meshPart = meshPart.GetMesh()
753 mesh = SMESH._objref_SMESH_Gen.CopyMesh( self,meshPart,meshName,toCopyGroups,toKeepIDs )
754 return Mesh(self, self.geompyD, mesh)
756 ## From SMESH_Gen interface
757 # @return the list of integer values
758 # @ingroup l1_auxiliary
759 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
760 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
762 ## From SMESH_Gen interface. Creates a pattern
763 # @return an instance of SMESH_Pattern
765 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
766 # @ingroup l2_modif_patterns
767 def GetPattern(self):
768 return SMESH._objref_SMESH_Gen.GetPattern(self)
770 ## Sets number of segments per diagonal of boundary box of geometry by which
771 # default segment length of appropriate 1D hypotheses is defined.
772 # Default value is 10
773 # @ingroup l1_auxiliary
774 def SetBoundaryBoxSegmentation(self, nbSegments):
775 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
777 # Filtering. Auxiliary functions:
778 # ------------------------------
780 ## Creates an empty criterion
781 # @return SMESH.Filter.Criterion
782 # @ingroup l1_controls
783 def GetEmptyCriterion(self):
784 Type = self.EnumToLong(FT_Undefined)
785 Compare = self.EnumToLong(FT_Undefined)
789 UnaryOp = self.EnumToLong(FT_Undefined)
790 BinaryOp = self.EnumToLong(FT_Undefined)
793 Precision = -1 ##@1e-07
794 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
795 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
797 ## Creates a criterion by the given parameters
798 # \n Criterion structures allow to define complex filters by combining them with logical operations (AND / OR) (see example below)
799 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
800 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
801 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
802 # @param Treshold the threshold value (range of ids as string, shape, numeric)
803 # @param UnaryOp FT_LogicalNOT or FT_Undefined
804 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
805 # FT_Undefined (must be for the last criterion of all criteria)
806 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
807 # FT_LyingOnGeom, FT_CoplanarFaces criteria
808 # @return SMESH.Filter.Criterion
810 # <a href="../tui_filters_page.html#combining_filters">Example of Criteria usage</a>
811 # @ingroup l1_controls
812 def GetCriterion(self,elementType,
814 Compare = FT_EqualTo,
816 UnaryOp=FT_Undefined,
817 BinaryOp=FT_Undefined,
819 if not CritType in SMESH.FunctorType._items:
820 raise TypeError, "CritType should be of SMESH.FunctorType"
821 aCriterion = self.GetEmptyCriterion()
822 aCriterion.TypeOfElement = elementType
823 aCriterion.Type = self.EnumToLong(CritType)
824 aCriterion.Tolerance = Tolerance
828 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
829 aCriterion.Compare = self.EnumToLong(Compare)
830 elif Compare == "=" or Compare == "==":
831 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
833 aCriterion.Compare = self.EnumToLong(FT_LessThan)
835 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
836 elif Compare != FT_Undefined:
837 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
840 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
841 FT_BelongToCylinder, FT_LyingOnGeom]:
842 # Checks the treshold
843 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
844 aCriterion.ThresholdStr = GetName(aTreshold)
845 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
847 print "Error: The treshold should be a shape."
849 if isinstance(UnaryOp,float):
850 aCriterion.Tolerance = UnaryOp
851 UnaryOp = FT_Undefined
853 elif CritType == FT_RangeOfIds:
854 # Checks the treshold
855 if isinstance(aTreshold, str):
856 aCriterion.ThresholdStr = aTreshold
858 print "Error: The treshold should be a string."
860 elif CritType == FT_CoplanarFaces:
861 # Checks the treshold
862 if isinstance(aTreshold, int):
863 aCriterion.ThresholdID = "%s"%aTreshold
864 elif isinstance(aTreshold, str):
867 raise ValueError, "Invalid ID of mesh face: '%s'"%aTreshold
868 aCriterion.ThresholdID = aTreshold
871 "The treshold should be an ID of mesh face and not '%s'"%aTreshold
872 elif CritType == FT_ElemGeomType:
873 # Checks the treshold
875 aCriterion.Threshold = self.EnumToLong(aTreshold)
876 assert( aTreshold in SMESH.GeometryType._items )
878 if isinstance(aTreshold, int):
879 aCriterion.Threshold = aTreshold
881 print "Error: The treshold should be an integer or SMESH.GeometryType."
885 elif CritType == FT_GroupColor:
886 # Checks the treshold
888 aCriterion.ThresholdStr = self.ColorToString(aTreshold)
890 print "Error: The threshold value should be of SALOMEDS.Color type"
893 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
894 FT_FreeFaces, FT_LinearOrQuadratic,
895 FT_BareBorderFace, FT_BareBorderVolume,
896 FT_OverConstrainedFace, FT_OverConstrainedVolume]:
897 # At this point the treshold is unnecessary
898 if aTreshold == FT_LogicalNOT:
899 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
900 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
901 aCriterion.BinaryOp = aTreshold
905 aTreshold = float(aTreshold)
906 aCriterion.Threshold = aTreshold
908 print "Error: The treshold should be a number."
911 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
912 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
914 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
915 aCriterion.BinaryOp = self.EnumToLong(Treshold)
917 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
918 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
920 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
921 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
925 ## Creates a filter with the given parameters
926 # @param elementType the type of elements in the group
927 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
928 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
929 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
930 # @param UnaryOp FT_LogicalNOT or FT_Undefined
931 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
932 # FT_LyingOnGeom, FT_CoplanarFaces criteria
933 # @return SMESH_Filter
935 # <a href="../tui_filters_page.html#tui_filters">Example of Filters usage</a>
936 # @ingroup l1_controls
937 def GetFilter(self,elementType,
938 CritType=FT_Undefined,
941 UnaryOp=FT_Undefined,
943 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined,Tolerance)
944 aFilterMgr = self.CreateFilterManager()
945 aFilter = aFilterMgr.CreateFilter()
947 aCriteria.append(aCriterion)
948 aFilter.SetCriteria(aCriteria)
949 aFilterMgr.UnRegister()
952 ## Creates a filter from criteria
953 # @param criteria a list of criteria
954 # @return SMESH_Filter
956 # <a href="../tui_filters_page.html#tui_filters">Example of Filters usage</a>
957 # @ingroup l1_controls
958 def GetFilterFromCriteria(self,criteria):
959 aFilterMgr = self.CreateFilterManager()
960 aFilter = aFilterMgr.CreateFilter()
961 aFilter.SetCriteria(criteria)
962 aFilterMgr.UnRegister()
965 ## Creates a numerical functor by its type
966 # @param theCriterion FT_...; functor type
967 # @return SMESH_NumericalFunctor
968 # @ingroup l1_controls
969 def GetFunctor(self,theCriterion):
970 aFilterMgr = self.CreateFilterManager()
971 if theCriterion == FT_AspectRatio:
972 return aFilterMgr.CreateAspectRatio()
973 elif theCriterion == FT_AspectRatio3D:
974 return aFilterMgr.CreateAspectRatio3D()
975 elif theCriterion == FT_Warping:
976 return aFilterMgr.CreateWarping()
977 elif theCriterion == FT_MinimumAngle:
978 return aFilterMgr.CreateMinimumAngle()
979 elif theCriterion == FT_Taper:
980 return aFilterMgr.CreateTaper()
981 elif theCriterion == FT_Skew:
982 return aFilterMgr.CreateSkew()
983 elif theCriterion == FT_Area:
984 return aFilterMgr.CreateArea()
985 elif theCriterion == FT_Volume3D:
986 return aFilterMgr.CreateVolume3D()
987 elif theCriterion == FT_MaxElementLength2D:
988 return aFilterMgr.CreateMaxElementLength2D()
989 elif theCriterion == FT_MaxElementLength3D:
990 return aFilterMgr.CreateMaxElementLength3D()
991 elif theCriterion == FT_MultiConnection:
992 return aFilterMgr.CreateMultiConnection()
993 elif theCriterion == FT_MultiConnection2D:
994 return aFilterMgr.CreateMultiConnection2D()
995 elif theCriterion == FT_Length:
996 return aFilterMgr.CreateLength()
997 elif theCriterion == FT_Length2D:
998 return aFilterMgr.CreateLength2D()
1000 print "Error: given parameter is not numerucal functor type."
1002 ## Creates hypothesis
1003 # @param theHType mesh hypothesis type (string)
1004 # @param theLibName mesh plug-in library name
1005 # @return created hypothesis instance
1006 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
1007 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
1009 ## Gets the mesh statistic
1010 # @return dictionary "element type" - "count of elements"
1011 # @ingroup l1_meshinfo
1012 def GetMeshInfo(self, obj):
1013 if isinstance( obj, Mesh ):
1016 if hasattr(obj, "GetMeshInfo"):
1017 values = obj.GetMeshInfo()
1018 for i in range(SMESH.Entity_Last._v):
1019 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
1023 ## Get minimum distance between two objects
1025 # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
1026 # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
1028 # @param src1 first source object
1029 # @param src2 second source object
1030 # @param id1 node/element id from the first source
1031 # @param id2 node/element id from the second (or first) source
1032 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
1033 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
1034 # @return minimum distance value
1035 # @sa GetMinDistance()
1036 # @ingroup l1_measurements
1037 def MinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
1038 result = self.GetMinDistance(src1, src2, id1, id2, isElem1, isElem2)
1042 result = result.value
1045 ## Get measure structure specifying minimum distance data between two objects
1047 # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
1048 # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
1050 # @param src1 first source object
1051 # @param src2 second source object
1052 # @param id1 node/element id from the first source
1053 # @param id2 node/element id from the second (or first) source
1054 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
1055 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
1056 # @return Measure structure or None if input data is invalid
1058 # @ingroup l1_measurements
1059 def GetMinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
1060 if isinstance(src1, Mesh): src1 = src1.mesh
1061 if isinstance(src2, Mesh): src2 = src2.mesh
1062 if src2 is None and id2 != 0: src2 = src1
1063 if not hasattr(src1, "_narrow"): return None
1064 src1 = src1._narrow(SMESH.SMESH_IDSource)
1065 if not src1: return None
1068 e = m.GetMeshEditor()
1070 src1 = e.MakeIDSource([id1], SMESH.FACE)
1072 src1 = e.MakeIDSource([id1], SMESH.NODE)
1074 if hasattr(src2, "_narrow"):
1075 src2 = src2._narrow(SMESH.SMESH_IDSource)
1076 if src2 and id2 != 0:
1078 e = m.GetMeshEditor()
1080 src2 = e.MakeIDSource([id2], SMESH.FACE)
1082 src2 = e.MakeIDSource([id2], SMESH.NODE)
1085 aMeasurements = self.CreateMeasurements()
1086 result = aMeasurements.MinDistance(src1, src2)
1087 aMeasurements.UnRegister()
1090 ## Get bounding box of the specified object(s)
1091 # @param objects single source object or list of source objects
1092 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
1093 # @sa GetBoundingBox()
1094 # @ingroup l1_measurements
1095 def BoundingBox(self, objects):
1096 result = self.GetBoundingBox(objects)
1100 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
1103 ## Get measure structure specifying bounding box data of the specified object(s)
1104 # @param objects single source object or list of source objects
1105 # @return Measure structure
1107 # @ingroup l1_measurements
1108 def GetBoundingBox(self, objects):
1109 if isinstance(objects, tuple):
1110 objects = list(objects)
1111 if not isinstance(objects, list):
1115 if isinstance(o, Mesh):
1116 srclist.append(o.mesh)
1117 elif hasattr(o, "_narrow"):
1118 src = o._narrow(SMESH.SMESH_IDSource)
1119 if src: srclist.append(src)
1122 aMeasurements = self.CreateMeasurements()
1123 result = aMeasurements.BoundingBox(srclist)
1124 aMeasurements.UnRegister()
1128 #Registering the new proxy for SMESH_Gen
1129 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
1132 # Public class: Mesh
1133 # ==================
1135 ## This class allows defining and managing a mesh.
1136 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
1137 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
1138 # new nodes and elements and by changing the existing entities), to get information
1139 # about a mesh and to export a mesh into different formats.
1148 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
1149 # sets the GUI name of this mesh to \a name.
1150 # @param smeshpyD an instance of smeshDC class
1151 # @param geompyD an instance of geompyDC class
1152 # @param obj Shape to be meshed or SMESH_Mesh object
1153 # @param name Study name of the mesh
1154 # @ingroup l2_construct
1155 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
1156 self.smeshpyD=smeshpyD
1157 self.geompyD=geompyD
1161 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
1163 # publish geom of mesh (issue 0021122)
1164 if not self.geom.GetStudyEntry():
1165 studyID = smeshpyD.GetCurrentStudy()._get_StudyId()
1166 if studyID != geompyD.myStudyId:
1167 geompyD.init_geom( smeshpyD.GetCurrentStudy())
1169 geo_name = "%s_%s"%(self.geom.GetShapeType(), id(self.geom)%100)
1170 geompyD.addToStudy( self.geom, geo_name )
1171 self.mesh = self.smeshpyD.CreateMesh(self.geom)
1173 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
1176 self.mesh = self.smeshpyD.CreateEmptyMesh()
1178 self.smeshpyD.SetName(self.mesh, name)
1180 self.smeshpyD.SetName(self.mesh, GetName(obj))
1183 self.geom = self.mesh.GetShapeToMesh()
1185 self.editor = self.mesh.GetMeshEditor()
1187 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
1188 # @param theMesh a SMESH_Mesh object
1189 # @ingroup l2_construct
1190 def SetMesh(self, theMesh):
1192 self.geom = self.mesh.GetShapeToMesh()
1194 ## Returns the mesh, that is an instance of SMESH_Mesh interface
1195 # @return a SMESH_Mesh object
1196 # @ingroup l2_construct
1200 ## Gets the name of the mesh
1201 # @return the name of the mesh as a string
1202 # @ingroup l2_construct
1204 name = GetName(self.GetMesh())
1207 ## Sets a name to the mesh
1208 # @param name a new name of the mesh
1209 # @ingroup l2_construct
1210 def SetName(self, name):
1211 self.smeshpyD.SetName(self.GetMesh(), name)
1213 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
1214 # The subMesh object gives access to the IDs of nodes and elements.
1215 # @param geom a geometrical object (shape)
1216 # @param name a name for the submesh
1217 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
1218 # @ingroup l2_submeshes
1219 def GetSubMesh(self, geom, name):
1220 AssureGeomPublished( self, geom, name )
1221 submesh = self.mesh.GetSubMesh( geom, name )
1224 ## Returns the shape associated to the mesh
1225 # @return a GEOM_Object
1226 # @ingroup l2_construct
1230 ## Associates the given shape to the mesh (entails the recreation of the mesh)
1231 # @param geom the shape to be meshed (GEOM_Object)
1232 # @ingroup l2_construct
1233 def SetShape(self, geom):
1234 self.mesh = self.smeshpyD.CreateMesh(geom)
1236 ## Returns true if the hypotheses are defined well
1237 # @param theSubObject a subshape of a mesh shape
1238 # @return True or False
1239 # @ingroup l2_construct
1240 def IsReadyToCompute(self, theSubObject):
1241 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
1243 ## Returns errors of hypotheses definition.
1244 # The list of errors is empty if everything is OK.
1245 # @param theSubObject a subshape of a mesh shape
1246 # @return a list of errors
1247 # @ingroup l2_construct
1248 def GetAlgoState(self, theSubObject):
1249 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
1251 ## Returns a geometrical object on which the given element was built.
1252 # The returned geometrical object, if not nil, is either found in the
1253 # study or published by this method with the given name
1254 # @param theElementID the id of the mesh element
1255 # @param theGeomName the user-defined name of the geometrical object
1256 # @return GEOM::GEOM_Object instance
1257 # @ingroup l2_construct
1258 def GetGeometryByMeshElement(self, theElementID, theGeomName):
1259 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
1261 ## Returns the mesh dimension depending on the dimension of the underlying shape
1262 # @return mesh dimension as an integer value [0,3]
1263 # @ingroup l1_auxiliary
1264 def MeshDimension(self):
1265 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
1266 if len( shells ) > 0 :
1268 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
1270 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
1276 ## Creates a segment discretization 1D algorithm.
1277 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
1278 # \n If the optional \a geom parameter is not set, this algorithm is global.
1279 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1280 # @param algo the type of the required algorithm. Possible values are:
1282 # - smesh.PYTHON for discretization via a python function,
1283 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
1284 # @param geom If defined is the subshape to be meshed
1285 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
1286 # @ingroup l3_algos_basic
1287 def Segment(self, algo=REGULAR, geom=0):
1288 ## if Segment(geom) is called by mistake
1289 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
1290 algo, geom = geom, algo
1291 if not algo: algo = REGULAR
1294 return Mesh_Segment(self, geom)
1295 elif algo == PYTHON:
1296 return Mesh_Segment_Python(self, geom)
1297 elif algo == COMPOSITE:
1298 return Mesh_CompositeSegment(self, geom)
1300 return Mesh_Segment(self, geom)
1302 ## Creates 1D algorithm importing segments conatined in groups of other mesh.
1303 # If the optional \a geom parameter is not set, this algorithm is global.
1304 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1305 # @param geom If defined the subshape is to be meshed
1306 # @return an instance of Mesh_UseExistingElements class
1307 # @ingroup l3_algos_basic
1308 def UseExisting1DElements(self, geom=0):
1309 return Mesh_UseExistingElements(1,self, geom)
1311 ## Creates 2D algorithm importing faces conatined in groups of other mesh.
1312 # If the optional \a geom parameter is not set, this algorithm is global.
1313 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1314 # @param geom If defined the subshape is to be meshed
1315 # @return an instance of Mesh_UseExistingElements class
1316 # @ingroup l3_algos_basic
1317 def UseExisting2DElements(self, geom=0):
1318 return Mesh_UseExistingElements(2,self, geom)
1320 ## Enables creation of nodes and segments usable by 2D algoritms.
1321 # The added nodes and segments must be bound to edges and vertices by
1322 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
1323 # If the optional \a geom parameter is not set, this algorithm is global.
1324 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1325 # @param geom the subshape to be manually meshed
1326 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
1327 # @ingroup l3_algos_basic
1328 def UseExistingSegments(self, geom=0):
1329 algo = Mesh_UseExisting(1,self,geom)
1330 return algo.GetAlgorithm()
1332 ## Enables creation of nodes and faces usable by 3D algoritms.
1333 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
1334 # and SetMeshElementOnShape()
1335 # If the optional \a geom parameter is not set, this algorithm is global.
1336 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1337 # @param geom the subshape to be manually meshed
1338 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1339 # @ingroup l3_algos_basic
1340 def UseExistingFaces(self, geom=0):
1341 algo = Mesh_UseExisting(2,self,geom)
1342 return algo.GetAlgorithm()
1344 ## Creates a triangle 2D algorithm for faces.
1345 # If the optional \a geom parameter is not set, this algorithm is global.
1346 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1347 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1348 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1349 # @return an instance of Mesh_Triangle algorithm
1350 # @ingroup l3_algos_basic
1351 def Triangle(self, algo=MEFISTO, geom=0):
1352 ## if Triangle(geom) is called by mistake
1353 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1356 return Mesh_Triangle(self, algo, geom)
1358 ## Creates a quadrangle 2D algorithm for faces.
1359 # If the optional \a geom parameter is not set, this algorithm is global.
1360 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1361 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1362 # @param algo values are: smesh.QUADRANGLE || smesh.RADIAL_QUAD
1363 # @return an instance of Mesh_Quadrangle algorithm
1364 # @ingroup l3_algos_basic
1365 def Quadrangle(self, geom=0, algo=QUADRANGLE):
1366 if algo==RADIAL_QUAD:
1367 return Mesh_RadialQuadrangle1D2D(self,geom)
1369 return Mesh_Quadrangle(self, geom)
1371 ## Creates a tetrahedron 3D algorithm for solids.
1372 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1373 # If the optional \a geom parameter is not set, this algorithm is global.
1374 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1375 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1376 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1377 # @return an instance of Mesh_Tetrahedron algorithm
1378 # @ingroup l3_algos_basic
1379 def Tetrahedron(self, algo=NETGEN, geom=0):
1380 ## if Tetrahedron(geom) is called by mistake
1381 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1382 algo, geom = geom, algo
1383 if not algo: algo = NETGEN
1385 return Mesh_Tetrahedron(self, algo, geom)
1387 ## Creates a hexahedron 3D algorithm for solids.
1388 # If the optional \a geom parameter is not set, this algorithm is global.
1389 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1390 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1391 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1392 # @return an instance of Mesh_Hexahedron algorithm
1393 # @ingroup l3_algos_basic
1394 def Hexahedron(self, algo=Hexa, geom=0):
1395 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1396 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1397 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1398 elif geom == 0: algo, geom = Hexa, algo
1399 return Mesh_Hexahedron(self, algo, geom)
1401 ## Deprecated, used only for compatibility!
1402 # @return an instance of Mesh_Netgen algorithm
1403 # @ingroup l3_algos_basic
1404 def Netgen(self, is3D, geom=0):
1405 return Mesh_Netgen(self, is3D, geom)
1407 ## Creates a projection 1D algorithm for edges.
1408 # If the optional \a geom parameter is not set, this algorithm is global.
1409 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1410 # @param geom If defined, the subshape to be meshed
1411 # @return an instance of Mesh_Projection1D algorithm
1412 # @ingroup l3_algos_proj
1413 def Projection1D(self, geom=0):
1414 return Mesh_Projection1D(self, geom)
1416 ## Creates a projection 2D algorithm for faces.
1417 # If the optional \a geom parameter is not set, this algorithm is global.
1418 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1419 # @param geom If defined, the subshape to be meshed
1420 # @return an instance of Mesh_Projection2D algorithm
1421 # @ingroup l3_algos_proj
1422 def Projection2D(self, geom=0):
1423 return Mesh_Projection2D(self, geom)
1425 ## Creates a projection 3D algorithm for solids.
1426 # If the optional \a geom parameter is not set, this algorithm is global.
1427 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1428 # @param geom If defined, the subshape to be meshed
1429 # @return an instance of Mesh_Projection3D algorithm
1430 # @ingroup l3_algos_proj
1431 def Projection3D(self, geom=0):
1432 return Mesh_Projection3D(self, geom)
1434 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1435 # If the optional \a geom parameter is not set, this algorithm is global.
1436 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1437 # @param geom If defined, the subshape to be meshed
1438 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1439 # @ingroup l3_algos_radialp l3_algos_3dextr
1440 def Prism(self, geom=0):
1444 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1445 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1446 if nbSolids == 0 or nbSolids == nbShells:
1447 return Mesh_Prism3D(self, geom)
1448 return Mesh_RadialPrism3D(self, geom)
1450 ## Evaluates size of prospective mesh on a shape
1451 # @return a list where i-th element is a number of elements of i-th SMESH.EntityType
1452 # To know predicted number of e.g. edges, inquire it this way
1453 # Evaluate()[ EnumToLong( Entity_Edge )]
1454 def Evaluate(self, geom=0):
1455 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1457 geom = self.mesh.GetShapeToMesh()
1460 return self.smeshpyD.Evaluate(self.mesh, geom)
1463 ## Computes the mesh and returns the status of the computation
1464 # @param geom geomtrical shape on which mesh data should be computed
1465 # @param discardModifs if True and the mesh has been edited since
1466 # a last total re-compute and that may prevent successful partial re-compute,
1467 # then the mesh is cleaned before Compute()
1468 # @return True or False
1469 # @ingroup l2_construct
1470 def Compute(self, geom=0, discardModifs=False):
1471 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1473 geom = self.mesh.GetShapeToMesh()
1478 if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693
1480 ok = self.smeshpyD.Compute(self.mesh, geom)
1481 except SALOME.SALOME_Exception, ex:
1482 print "Mesh computation failed, exception caught:"
1483 print " ", ex.details.text
1486 print "Mesh computation failed, exception caught:"
1487 traceback.print_exc()
1491 # Treat compute errors
1492 computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
1493 for err in computeErrors:
1495 if self.mesh.HasShapeToMesh():
1497 mainIOR = salome.orb.object_to_string(geom)
1498 for sname in salome.myStudyManager.GetOpenStudies():
1499 s = salome.myStudyManager.GetStudyByName(sname)
1501 mainSO = s.FindObjectIOR(mainIOR)
1502 if not mainSO: continue
1503 if err.subShapeID == 1:
1504 shapeText = ' on "%s"' % mainSO.GetName()
1505 subIt = s.NewChildIterator(mainSO)
1507 subSO = subIt.Value()
1509 obj = subSO.GetObject()
1510 if not obj: continue
1511 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
1513 ids = go.GetSubShapeIndices()
1514 if len(ids) == 1 and ids[0] == err.subShapeID:
1515 shapeText = ' on "%s"' % subSO.GetName()
1518 shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
1520 shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID)
1522 shapeText = " on subshape #%s" % (err.subShapeID)
1524 shapeText = " on subshape #%s" % (err.subShapeID)
1526 stdErrors = ["OK", #COMPERR_OK
1527 "Invalid input mesh", #COMPERR_BAD_INPUT_MESH
1528 "std::exception", #COMPERR_STD_EXCEPTION
1529 "OCC exception", #COMPERR_OCC_EXCEPTION
1530 "SALOME exception", #COMPERR_SLM_EXCEPTION
1531 "Unknown exception", #COMPERR_EXCEPTION
1532 "Memory allocation problem", #COMPERR_MEMORY_PB
1533 "Algorithm failed", #COMPERR_ALGO_FAILED
1534 "Unexpected geometry"]#COMPERR_BAD_SHAPE
1536 if err.code < len(stdErrors): errText = stdErrors[err.code]
1538 errText = "code %s" % -err.code
1539 if errText: errText += ". "
1540 errText += err.comment
1541 if allReasons != "":allReasons += "\n"
1542 allReasons += '"%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
1546 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1548 if err.isGlobalAlgo:
1556 reason = '%s %sD algorithm is missing' % (glob, dim)
1557 elif err.state == HYP_MISSING:
1558 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1559 % (glob, dim, name, dim))
1560 elif err.state == HYP_NOTCONFORM:
1561 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1562 elif err.state == HYP_BAD_PARAMETER:
1563 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1564 % ( glob, dim, name ))
1565 elif err.state == HYP_BAD_GEOMETRY:
1566 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1567 'geometry' % ( glob, dim, name ))
1569 reason = "For unknown reason."+\
1570 " Revise Mesh.Compute() implementation in smeshDC.py!"
1572 if allReasons != "":allReasons += "\n"
1573 allReasons += reason
1575 if allReasons != "":
1576 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1580 print '"' + GetName(self.mesh) + '"',"has not been computed."
1583 if salome.sg.hasDesktop():
1584 smeshgui = salome.ImportComponentGUI("SMESH")
1585 smeshgui.Init(self.mesh.GetStudyId())
1586 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1587 salome.sg.updateObjBrowser(1)
1591 ## Return submesh objects list in meshing order
1592 # @return list of list of submesh objects
1593 # @ingroup l2_construct
1594 def GetMeshOrder(self):
1595 return self.mesh.GetMeshOrder()
1597 ## Return submesh objects list in meshing order
1598 # @return list of list of submesh objects
1599 # @ingroup l2_construct
1600 def SetMeshOrder(self, submeshes):
1601 return self.mesh.SetMeshOrder(submeshes)
1603 ## Removes all nodes and elements
1604 # @ingroup l2_construct
1607 if salome.sg.hasDesktop():
1608 smeshgui = salome.ImportComponentGUI("SMESH")
1609 smeshgui.Init(self.mesh.GetStudyId())
1610 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1611 salome.sg.updateObjBrowser(1)
1613 ## Removes all nodes and elements of indicated shape
1614 # @ingroup l2_construct
1615 def ClearSubMesh(self, geomId):
1616 self.mesh.ClearSubMesh(geomId)
1617 if salome.sg.hasDesktop():
1618 smeshgui = salome.ImportComponentGUI("SMESH")
1619 smeshgui.Init(self.mesh.GetStudyId())
1620 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1621 salome.sg.updateObjBrowser(1)
1623 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1624 # @param fineness [0.0,1.0] defines mesh fineness
1625 # @return True or False
1626 # @ingroup l3_algos_basic
1627 def AutomaticTetrahedralization(self, fineness=0):
1628 dim = self.MeshDimension()
1630 self.RemoveGlobalHypotheses()
1631 self.Segment().AutomaticLength(fineness)
1633 self.Triangle().LengthFromEdges()
1636 self.Tetrahedron(NETGEN)
1638 return self.Compute()
1640 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1641 # @param fineness [0.0, 1.0] defines mesh fineness
1642 # @return True or False
1643 # @ingroup l3_algos_basic
1644 def AutomaticHexahedralization(self, fineness=0):
1645 dim = self.MeshDimension()
1646 # assign the hypotheses
1647 self.RemoveGlobalHypotheses()
1648 self.Segment().AutomaticLength(fineness)
1655 return self.Compute()
1657 ## Assigns a hypothesis
1658 # @param hyp a hypothesis to assign
1659 # @param geom a subhape of mesh geometry
1660 # @return SMESH.Hypothesis_Status
1661 # @ingroup l2_hypotheses
1662 def AddHypothesis(self, hyp, geom=0):
1663 if isinstance( hyp, Mesh_Algorithm ):
1664 hyp = hyp.GetAlgorithm()
1669 geom = self.mesh.GetShapeToMesh()
1671 status = self.mesh.AddHypothesis(geom, hyp)
1672 isAlgo = hyp._narrow( SMESH_Algo )
1673 hyp_name = GetName( hyp )
1676 geom_name = GetName( geom )
1677 TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1680 ## Unassigns a hypothesis
1681 # @param hyp a hypothesis to unassign
1682 # @param geom a subshape of mesh geometry
1683 # @return SMESH.Hypothesis_Status
1684 # @ingroup l2_hypotheses
1685 def RemoveHypothesis(self, hyp, geom=0):
1686 if isinstance( hyp, Mesh_Algorithm ):
1687 hyp = hyp.GetAlgorithm()
1692 status = self.mesh.RemoveHypothesis(geom, hyp)
1695 ## Gets the list of hypotheses added on a geometry
1696 # @param geom a subshape of mesh geometry
1697 # @return the sequence of SMESH_Hypothesis
1698 # @ingroup l2_hypotheses
1699 def GetHypothesisList(self, geom):
1700 return self.mesh.GetHypothesisList( geom )
1702 ## Removes all global hypotheses
1703 # @ingroup l2_hypotheses
1704 def RemoveGlobalHypotheses(self):
1705 current_hyps = self.mesh.GetHypothesisList( self.geom )
1706 for hyp in current_hyps:
1707 self.mesh.RemoveHypothesis( self.geom, hyp )
1711 ## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead.
1712 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1713 ## allowing to overwrite the file if it exists or add the exported data to its contents
1714 # @param f the file name
1715 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1716 # @param opt boolean parameter for creating/not creating
1717 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1718 # @param overwrite boolean parameter for overwriting/not overwriting the file
1719 # @ingroup l2_impexp
1720 def ExportToMED(self, f, version, opt=0, overwrite=1):
1721 self.mesh.ExportToMEDX(f, opt, version, overwrite)
1723 ## Exports the mesh in a file in MED format and chooses the \a version of MED format
1724 ## allowing to overwrite the file if it exists or add the exported data to its contents
1725 # @param f is the file name
1726 # @param auto_groups boolean parameter for creating/not creating
1727 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1728 # the typical use is auto_groups=false.
1729 # @param version MED format version(MED_V2_1 or MED_V2_2)
1730 # @param overwrite boolean parameter for overwriting/not overwriting the file
1731 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1732 # @ingroup l2_impexp
1733 def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1, meshPart=None):
1735 if isinstance( meshPart, list ):
1736 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1737 self.mesh.ExportPartToMED( meshPart, f, auto_groups, version, overwrite )
1739 self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
1741 ## Exports the mesh in a file in DAT format
1742 # @param f the file name
1743 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1744 # @ingroup l2_impexp
1745 def ExportDAT(self, f, meshPart=None):
1747 if isinstance( meshPart, list ):
1748 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1749 self.mesh.ExportPartToDAT( meshPart, f )
1751 self.mesh.ExportDAT(f)
1753 ## Exports the mesh in a file in UNV format
1754 # @param f the file name
1755 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1756 # @ingroup l2_impexp
1757 def ExportUNV(self, f, meshPart=None):
1759 if isinstance( meshPart, list ):
1760 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1761 self.mesh.ExportPartToUNV( meshPart, f )
1763 self.mesh.ExportUNV(f)
1765 ## Export the mesh in a file in STL format
1766 # @param f the file name
1767 # @param ascii defines the file encoding
1768 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1769 # @ingroup l2_impexp
1770 def ExportSTL(self, f, ascii=1, meshPart=None):
1772 if isinstance( meshPart, list ):
1773 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1774 self.mesh.ExportPartToSTL( meshPart, f, ascii )
1776 self.mesh.ExportSTL(f, ascii)
1778 ## Exports the mesh in a file in CGNS format
1779 # @param f is the file name
1780 # @param overwrite boolean parameter for overwriting/not overwriting the file
1781 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1782 # @ingroup l2_impexp
1783 def ExportCGNS(self, f, overwrite=1, meshPart=None):
1784 if isinstance( meshPart, list ):
1785 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1786 if isinstance( meshPart, Mesh ):
1787 meshPart = meshPart.mesh
1789 meshPart = self.mesh
1790 self.mesh.ExportCGNS(meshPart, f, overwrite)
1792 # Operations with groups:
1793 # ----------------------
1795 ## Creates an empty mesh group
1796 # @param elementType the type of elements in the group
1797 # @param name the name of the mesh group
1798 # @return SMESH_Group
1799 # @ingroup l2_grps_create
1800 def CreateEmptyGroup(self, elementType, name):
1801 return self.mesh.CreateGroup(elementType, name)
1803 ## Creates a mesh group based on the geometric object \a grp
1804 # and gives a \a name, \n if this parameter is not defined
1805 # the name is the same as the geometric group name \n
1806 # Note: Works like GroupOnGeom().
1807 # @param grp a geometric group, a vertex, an edge, a face or a solid
1808 # @param name the name of the mesh group
1809 # @return SMESH_GroupOnGeom
1810 # @ingroup l2_grps_create
1811 def Group(self, grp, name=""):
1812 return self.GroupOnGeom(grp, name)
1814 ## Creates a mesh group based on the geometrical object \a grp
1815 # and gives a \a name, \n if this parameter is not defined
1816 # the name is the same as the geometrical group name
1817 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1818 # @param name the name of the mesh group
1819 # @param typ the type of elements in the group. If not set, it is
1820 # automatically detected by the type of the geometry
1821 # @return SMESH_GroupOnGeom
1822 # @ingroup l2_grps_create
1823 def GroupOnGeom(self, grp, name="", typ=None):
1824 AssureGeomPublished( self, grp, name )
1826 name = grp.GetName()
1828 typ = self._groupTypeFromShape( grp )
1829 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1831 ## Pivate method to get a type of group on geometry
1832 def _groupTypeFromShape( self, shape ):
1833 tgeo = str(shape.GetShapeType())
1834 if tgeo == "VERTEX":
1836 elif tgeo == "EDGE":
1838 elif tgeo == "FACE" or tgeo == "SHELL":
1840 elif tgeo == "SOLID" or tgeo == "COMPSOLID":
1842 elif tgeo == "COMPOUND":
1843 sub = self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHAPE"])
1845 raise ValueError,"_groupTypeFromShape(): empty geometric group or compound '%s'" % GetName(shape)
1846 return self._groupTypeFromShape( sub[0] )
1849 "_groupTypeFromShape(): invalid geometry '%s'" % GetName(shape)
1852 ## Creates a mesh group with given \a name based on the \a filter which
1853 ## is a special type of group dynamically updating it's contents during
1854 ## mesh modification
1855 # @param typ the type of elements in the group
1856 # @param name the name of the mesh group
1857 # @param filter the filter defining group contents
1858 # @return SMESH_GroupOnFilter
1859 # @ingroup l2_grps_create
1860 def GroupOnFilter(self, typ, name, filter):
1861 return self.mesh.CreateGroupFromFilter(typ, name, filter)
1863 ## Creates a mesh group by the given ids of elements
1864 # @param groupName the name of the mesh group
1865 # @param elementType the type of elements in the group
1866 # @param elemIDs the list of ids
1867 # @return SMESH_Group
1868 # @ingroup l2_grps_create
1869 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1870 group = self.mesh.CreateGroup(elementType, groupName)
1874 ## Creates a mesh group by the given conditions
1875 # @param groupName the name of the mesh group
1876 # @param elementType the type of elements in the group
1877 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1878 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1879 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1880 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1881 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
1882 # FT_LyingOnGeom, FT_CoplanarFaces criteria
1883 # @return SMESH_Group
1884 # @ingroup l2_grps_create
1888 CritType=FT_Undefined,
1891 UnaryOp=FT_Undefined,
1893 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined,Tolerance)
1894 group = self.MakeGroupByCriterion(groupName, aCriterion)
1897 ## Creates a mesh group by the given criterion
1898 # @param groupName the name of the mesh group
1899 # @param Criterion the instance of Criterion class
1900 # @return SMESH_Group
1901 # @ingroup l2_grps_create
1902 def MakeGroupByCriterion(self, groupName, Criterion):
1903 aFilterMgr = self.smeshpyD.CreateFilterManager()
1904 aFilter = aFilterMgr.CreateFilter()
1906 aCriteria.append(Criterion)
1907 aFilter.SetCriteria(aCriteria)
1908 group = self.MakeGroupByFilter(groupName, aFilter)
1909 aFilterMgr.UnRegister()
1912 ## Creates a mesh group by the given criteria (list of criteria)
1913 # @param groupName the name of the mesh group
1914 # @param theCriteria the list of criteria
1915 # @return SMESH_Group
1916 # @ingroup l2_grps_create
1917 def MakeGroupByCriteria(self, groupName, theCriteria):
1918 aFilterMgr = self.smeshpyD.CreateFilterManager()
1919 aFilter = aFilterMgr.CreateFilter()
1920 aFilter.SetCriteria(theCriteria)
1921 group = self.MakeGroupByFilter(groupName, aFilter)
1922 aFilterMgr.UnRegister()
1925 ## Creates a mesh group by the given filter
1926 # @param groupName the name of the mesh group
1927 # @param theFilter the instance of Filter class
1928 # @return SMESH_Group
1929 # @ingroup l2_grps_create
1930 def MakeGroupByFilter(self, groupName, theFilter):
1931 group = self.CreateEmptyGroup(theFilter.GetElementType(), groupName)
1932 theFilter.SetMesh( self.mesh )
1933 group.AddFrom( theFilter )
1936 ## Passes mesh elements through the given filter and return IDs of fitting elements
1937 # @param theFilter SMESH_Filter
1938 # @return a list of ids
1939 # @ingroup l1_controls
1940 def GetIdsFromFilter(self, theFilter):
1941 theFilter.SetMesh( self.mesh )
1942 return theFilter.GetIDs()
1944 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1945 # Returns a list of special structures (borders).
1946 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1947 # @ingroup l1_controls
1948 def GetFreeBorders(self):
1949 aFilterMgr = self.smeshpyD.CreateFilterManager()
1950 aPredicate = aFilterMgr.CreateFreeEdges()
1951 aPredicate.SetMesh(self.mesh)
1952 aBorders = aPredicate.GetBorders()
1953 aFilterMgr.UnRegister()
1957 # @ingroup l2_grps_delete
1958 def RemoveGroup(self, group):
1959 self.mesh.RemoveGroup(group)
1961 ## Removes a group with its contents
1962 # @ingroup l2_grps_delete
1963 def RemoveGroupWithContents(self, group):
1964 self.mesh.RemoveGroupWithContents(group)
1966 ## Gets the list of groups existing in the mesh
1967 # @return a sequence of SMESH_GroupBase
1968 # @ingroup l2_grps_create
1969 def GetGroups(self):
1970 return self.mesh.GetGroups()
1972 ## Gets the number of groups existing in the mesh
1973 # @return the quantity of groups as an integer value
1974 # @ingroup l2_grps_create
1976 return self.mesh.NbGroups()
1978 ## Gets the list of names of groups existing in the mesh
1979 # @return list of strings
1980 # @ingroup l2_grps_create
1981 def GetGroupNames(self):
1982 groups = self.GetGroups()
1984 for group in groups:
1985 names.append(group.GetName())
1988 ## Produces a union of two groups
1989 # A new group is created. All mesh elements that are
1990 # present in the initial groups are added to the new one
1991 # @return an instance of SMESH_Group
1992 # @ingroup l2_grps_operon
1993 def UnionGroups(self, group1, group2, name):
1994 return self.mesh.UnionGroups(group1, group2, name)
1996 ## Produces a union list of groups
1997 # New group is created. All mesh elements that are present in
1998 # initial groups are added to the new one
1999 # @return an instance of SMESH_Group
2000 # @ingroup l2_grps_operon
2001 def UnionListOfGroups(self, groups, name):
2002 return self.mesh.UnionListOfGroups(groups, name)
2004 ## Prodices an intersection of two groups
2005 # A new group is created. All mesh elements that are common
2006 # for the two initial groups are added to the new one.
2007 # @return an instance of SMESH_Group
2008 # @ingroup l2_grps_operon
2009 def IntersectGroups(self, group1, group2, name):
2010 return self.mesh.IntersectGroups(group1, group2, name)
2012 ## Produces an intersection of groups
2013 # New group is created. All mesh elements that are present in all
2014 # initial groups simultaneously are added to the new one
2015 # @return an instance of SMESH_Group
2016 # @ingroup l2_grps_operon
2017 def IntersectListOfGroups(self, groups, name):
2018 return self.mesh.IntersectListOfGroups(groups, name)
2020 ## Produces a cut of two groups
2021 # A new group is created. All mesh elements that are present in
2022 # the main group but are not present in the tool group are added to the new one
2023 # @return an instance of SMESH_Group
2024 # @ingroup l2_grps_operon
2025 def CutGroups(self, main_group, tool_group, name):
2026 return self.mesh.CutGroups(main_group, tool_group, name)
2028 ## Produces a cut of groups
2029 # A new group is created. All mesh elements that are present in main groups
2030 # but do not present in tool groups are added to the new one
2031 # @return an instance of SMESH_Group
2032 # @ingroup l2_grps_operon
2033 def CutListOfGroups(self, main_groups, tool_groups, name):
2034 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
2036 ## Produces a group of elements of specified type using list of existing groups
2037 # A new group is created. System
2038 # 1) extracts all nodes on which groups elements are built
2039 # 2) combines all elements of specified dimension laying on these nodes
2040 # @return an instance of SMESH_Group
2041 # @ingroup l2_grps_operon
2042 def CreateDimGroup(self, groups, elem_type, name):
2043 return self.mesh.CreateDimGroup(groups, elem_type, name)
2046 ## Convert group on geom into standalone group
2047 # @ingroup l2_grps_delete
2048 def ConvertToStandalone(self, group):
2049 return self.mesh.ConvertToStandalone(group)
2051 # Get some info about mesh:
2052 # ------------------------
2054 ## Returns the log of nodes and elements added or removed
2055 # since the previous clear of the log.
2056 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
2057 # @return list of log_block structures:
2062 # @ingroup l1_auxiliary
2063 def GetLog(self, clearAfterGet):
2064 return self.mesh.GetLog(clearAfterGet)
2066 ## Clears the log of nodes and elements added or removed since the previous
2067 # clear. Must be used immediately after GetLog if clearAfterGet is false.
2068 # @ingroup l1_auxiliary
2070 self.mesh.ClearLog()
2072 ## Toggles auto color mode on the object.
2073 # @param theAutoColor the flag which toggles auto color mode.
2074 # @ingroup l1_auxiliary
2075 def SetAutoColor(self, theAutoColor):
2076 self.mesh.SetAutoColor(theAutoColor)
2078 ## Gets flag of object auto color mode.
2079 # @return True or False
2080 # @ingroup l1_auxiliary
2081 def GetAutoColor(self):
2082 return self.mesh.GetAutoColor()
2084 ## Gets the internal ID
2085 # @return integer value, which is the internal Id of the mesh
2086 # @ingroup l1_auxiliary
2088 return self.mesh.GetId()
2091 # @return integer value, which is the study Id of the mesh
2092 # @ingroup l1_auxiliary
2093 def GetStudyId(self):
2094 return self.mesh.GetStudyId()
2096 ## Checks the group names for duplications.
2097 # Consider the maximum group name length stored in MED file.
2098 # @return True or False
2099 # @ingroup l1_auxiliary
2100 def HasDuplicatedGroupNamesMED(self):
2101 return self.mesh.HasDuplicatedGroupNamesMED()
2103 ## Obtains the mesh editor tool
2104 # @return an instance of SMESH_MeshEditor
2105 # @ingroup l1_modifying
2106 def GetMeshEditor(self):
2107 return self.mesh.GetMeshEditor()
2109 ## Wrap a list of IDs of elements or nodes into SMESH_IDSource which
2110 # can be passed as argument to accepting mesh, group or sub-mesh
2111 # @return an instance of SMESH_IDSource
2112 # @ingroup l1_auxiliary
2113 def GetIDSource(self, ids, elemType):
2114 return self.GetMeshEditor().MakeIDSource(ids, elemType)
2117 # @return an instance of SALOME_MED::MESH
2118 # @ingroup l1_auxiliary
2119 def GetMEDMesh(self):
2120 return self.mesh.GetMEDMesh()
2123 # Get informations about mesh contents:
2124 # ------------------------------------
2126 ## Gets the mesh stattistic
2127 # @return dictionary type element - count of elements
2128 # @ingroup l1_meshinfo
2129 def GetMeshInfo(self, obj = None):
2130 if not obj: obj = self.mesh
2131 return self.smeshpyD.GetMeshInfo(obj)
2133 ## Returns the number of nodes in the mesh
2134 # @return an integer value
2135 # @ingroup l1_meshinfo
2137 return self.mesh.NbNodes()
2139 ## Returns the number of elements in the mesh
2140 # @return an integer value
2141 # @ingroup l1_meshinfo
2142 def NbElements(self):
2143 return self.mesh.NbElements()
2145 ## Returns the number of 0d elements in the mesh
2146 # @return an integer value
2147 # @ingroup l1_meshinfo
2148 def Nb0DElements(self):
2149 return self.mesh.Nb0DElements()
2151 ## Returns the number of edges in the mesh
2152 # @return an integer value
2153 # @ingroup l1_meshinfo
2155 return self.mesh.NbEdges()
2157 ## Returns the number of edges with the given order in the mesh
2158 # @param elementOrder the order of elements:
2159 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2160 # @return an integer value
2161 # @ingroup l1_meshinfo
2162 def NbEdgesOfOrder(self, elementOrder):
2163 return self.mesh.NbEdgesOfOrder(elementOrder)
2165 ## Returns the number of faces in the mesh
2166 # @return an integer value
2167 # @ingroup l1_meshinfo
2169 return self.mesh.NbFaces()
2171 ## Returns the number of faces with the given order in the mesh
2172 # @param elementOrder the order of elements:
2173 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2174 # @return an integer value
2175 # @ingroup l1_meshinfo
2176 def NbFacesOfOrder(self, elementOrder):
2177 return self.mesh.NbFacesOfOrder(elementOrder)
2179 ## Returns the number of triangles in the mesh
2180 # @return an integer value
2181 # @ingroup l1_meshinfo
2182 def NbTriangles(self):
2183 return self.mesh.NbTriangles()
2185 ## Returns the number of triangles with the given order in the mesh
2186 # @param elementOrder is the order of elements:
2187 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2188 # @return an integer value
2189 # @ingroup l1_meshinfo
2190 def NbTrianglesOfOrder(self, elementOrder):
2191 return self.mesh.NbTrianglesOfOrder(elementOrder)
2193 ## Returns the number of quadrangles in the mesh
2194 # @return an integer value
2195 # @ingroup l1_meshinfo
2196 def NbQuadrangles(self):
2197 return self.mesh.NbQuadrangles()
2199 ## Returns the number of quadrangles with the given order in the mesh
2200 # @param elementOrder the order of elements:
2201 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2202 # @return an integer value
2203 # @ingroup l1_meshinfo
2204 def NbQuadranglesOfOrder(self, elementOrder):
2205 return self.mesh.NbQuadranglesOfOrder(elementOrder)
2207 ## Returns the number of polygons in the mesh
2208 # @return an integer value
2209 # @ingroup l1_meshinfo
2210 def NbPolygons(self):
2211 return self.mesh.NbPolygons()
2213 ## Returns the number of volumes in the mesh
2214 # @return an integer value
2215 # @ingroup l1_meshinfo
2216 def NbVolumes(self):
2217 return self.mesh.NbVolumes()
2219 ## Returns the number of volumes with the given order in the mesh
2220 # @param elementOrder the order of elements:
2221 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2222 # @return an integer value
2223 # @ingroup l1_meshinfo
2224 def NbVolumesOfOrder(self, elementOrder):
2225 return self.mesh.NbVolumesOfOrder(elementOrder)
2227 ## Returns the number of tetrahedrons in the mesh
2228 # @return an integer value
2229 # @ingroup l1_meshinfo
2231 return self.mesh.NbTetras()
2233 ## Returns the number of tetrahedrons with the given order in the mesh
2234 # @param elementOrder the order of elements:
2235 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2236 # @return an integer value
2237 # @ingroup l1_meshinfo
2238 def NbTetrasOfOrder(self, elementOrder):
2239 return self.mesh.NbTetrasOfOrder(elementOrder)
2241 ## Returns the number of hexahedrons in the mesh
2242 # @return an integer value
2243 # @ingroup l1_meshinfo
2245 return self.mesh.NbHexas()
2247 ## Returns the number of hexahedrons with the given order in the mesh
2248 # @param elementOrder the order of elements:
2249 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2250 # @return an integer value
2251 # @ingroup l1_meshinfo
2252 def NbHexasOfOrder(self, elementOrder):
2253 return self.mesh.NbHexasOfOrder(elementOrder)
2255 ## Returns the number of pyramids in the mesh
2256 # @return an integer value
2257 # @ingroup l1_meshinfo
2258 def NbPyramids(self):
2259 return self.mesh.NbPyramids()
2261 ## Returns the number of pyramids with the given order in the mesh
2262 # @param elementOrder the order of elements:
2263 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2264 # @return an integer value
2265 # @ingroup l1_meshinfo
2266 def NbPyramidsOfOrder(self, elementOrder):
2267 return self.mesh.NbPyramidsOfOrder(elementOrder)
2269 ## Returns the number of prisms in the mesh
2270 # @return an integer value
2271 # @ingroup l1_meshinfo
2273 return self.mesh.NbPrisms()
2275 ## Returns the number of prisms with the given order in the mesh
2276 # @param elementOrder the order of elements:
2277 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2278 # @return an integer value
2279 # @ingroup l1_meshinfo
2280 def NbPrismsOfOrder(self, elementOrder):
2281 return self.mesh.NbPrismsOfOrder(elementOrder)
2283 ## Returns the number of polyhedrons in the mesh
2284 # @return an integer value
2285 # @ingroup l1_meshinfo
2286 def NbPolyhedrons(self):
2287 return self.mesh.NbPolyhedrons()
2289 ## Returns the number of submeshes in the mesh
2290 # @return an integer value
2291 # @ingroup l1_meshinfo
2292 def NbSubMesh(self):
2293 return self.mesh.NbSubMesh()
2295 ## Returns the list of mesh elements IDs
2296 # @return the list of integer values
2297 # @ingroup l1_meshinfo
2298 def GetElementsId(self):
2299 return self.mesh.GetElementsId()
2301 ## Returns the list of IDs of mesh elements with the given type
2302 # @param elementType the required type of elements (SMESH.NODE, SMESH.EDGE, SMESH.FACE or SMESH.VOLUME)
2303 # @return list of integer values
2304 # @ingroup l1_meshinfo
2305 def GetElementsByType(self, elementType):
2306 return self.mesh.GetElementsByType(elementType)
2308 ## Returns the list of mesh nodes IDs
2309 # @return the list of integer values
2310 # @ingroup l1_meshinfo
2311 def GetNodesId(self):
2312 return self.mesh.GetNodesId()
2314 # Get the information about mesh elements:
2315 # ------------------------------------
2317 ## Returns the type of mesh element
2318 # @return the value from SMESH::ElementType enumeration
2319 # @ingroup l1_meshinfo
2320 def GetElementType(self, id, iselem):
2321 return self.mesh.GetElementType(id, iselem)
2323 ## Returns the geometric type of mesh element
2324 # @return the value from SMESH::EntityType enumeration
2325 # @ingroup l1_meshinfo
2326 def GetElementGeomType(self, id):
2327 return self.mesh.GetElementGeomType(id)
2329 ## Returns the list of submesh elements IDs
2330 # @param Shape a geom object(subshape) IOR
2331 # Shape must be the subshape of a ShapeToMesh()
2332 # @return the list of integer values
2333 # @ingroup l1_meshinfo
2334 def GetSubMeshElementsId(self, Shape):
2335 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2336 ShapeID = Shape.GetSubShapeIndices()[0]
2339 return self.mesh.GetSubMeshElementsId(ShapeID)
2341 ## Returns the list of submesh nodes IDs
2342 # @param Shape a geom object(subshape) IOR
2343 # Shape must be the subshape of a ShapeToMesh()
2344 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
2345 # @return the list of integer values
2346 # @ingroup l1_meshinfo
2347 def GetSubMeshNodesId(self, Shape, all):
2348 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2349 ShapeID = Shape.GetSubShapeIndices()[0]
2352 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2354 ## Returns type of elements on given shape
2355 # @param Shape a geom object(subshape) IOR
2356 # Shape must be a subshape of a ShapeToMesh()
2357 # @return element type
2358 # @ingroup l1_meshinfo
2359 def GetSubMeshElementType(self, Shape):
2360 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2361 ShapeID = Shape.GetSubShapeIndices()[0]
2364 return self.mesh.GetSubMeshElementType(ShapeID)
2366 ## Gets the mesh description
2367 # @return string value
2368 # @ingroup l1_meshinfo
2370 return self.mesh.Dump()
2373 # Get the information about nodes and elements of a mesh by its IDs:
2374 # -----------------------------------------------------------
2376 ## Gets XYZ coordinates of a node
2377 # \n If there is no nodes for the given ID - returns an empty list
2378 # @return a list of double precision values
2379 # @ingroup l1_meshinfo
2380 def GetNodeXYZ(self, id):
2381 return self.mesh.GetNodeXYZ(id)
2383 ## Returns list of IDs of inverse elements for the given node
2384 # \n If there is no node for the given ID - returns an empty list
2385 # @return a list of integer values
2386 # @ingroup l1_meshinfo
2387 def GetNodeInverseElements(self, id):
2388 return self.mesh.GetNodeInverseElements(id)
2390 ## @brief Returns the position of a node on the shape
2391 # @return SMESH::NodePosition
2392 # @ingroup l1_meshinfo
2393 def GetNodePosition(self,NodeID):
2394 return self.mesh.GetNodePosition(NodeID)
2396 ## If the given element is a node, returns the ID of shape
2397 # \n If there is no node for the given ID - returns -1
2398 # @return an integer value
2399 # @ingroup l1_meshinfo
2400 def GetShapeID(self, id):
2401 return self.mesh.GetShapeID(id)
2403 ## Returns the ID of the result shape after
2404 # FindShape() from SMESH_MeshEditor for the given element
2405 # \n If there is no element for the given ID - returns -1
2406 # @return an integer value
2407 # @ingroup l1_meshinfo
2408 def GetShapeIDForElem(self,id):
2409 return self.mesh.GetShapeIDForElem(id)
2411 ## Returns the number of nodes for the given element
2412 # \n If there is no element for the given ID - returns -1
2413 # @return an integer value
2414 # @ingroup l1_meshinfo
2415 def GetElemNbNodes(self, id):
2416 return self.mesh.GetElemNbNodes(id)
2418 ## Returns the node ID the given index for the given element
2419 # \n If there is no element for the given ID - returns -1
2420 # \n If there is no node for the given index - returns -2
2421 # @return an integer value
2422 # @ingroup l1_meshinfo
2423 def GetElemNode(self, id, index):
2424 return self.mesh.GetElemNode(id, index)
2426 ## Returns the IDs of nodes of the given element
2427 # @return a list of integer values
2428 # @ingroup l1_meshinfo
2429 def GetElemNodes(self, id):
2430 return self.mesh.GetElemNodes(id)
2432 ## Returns true if the given node is the medium node in the given quadratic element
2433 # @ingroup l1_meshinfo
2434 def IsMediumNode(self, elementID, nodeID):
2435 return self.mesh.IsMediumNode(elementID, nodeID)
2437 ## Returns true if the given node is the medium node in one of quadratic elements
2438 # @ingroup l1_meshinfo
2439 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2440 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2442 ## Returns the number of edges for the given element
2443 # @ingroup l1_meshinfo
2444 def ElemNbEdges(self, id):
2445 return self.mesh.ElemNbEdges(id)
2447 ## Returns the number of faces for the given element
2448 # @ingroup l1_meshinfo
2449 def ElemNbFaces(self, id):
2450 return self.mesh.ElemNbFaces(id)
2452 ## Returns nodes of given face (counted from zero) for given volumic element.
2453 # @ingroup l1_meshinfo
2454 def GetElemFaceNodes(self,elemId, faceIndex):
2455 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2457 ## Returns an element based on all given nodes.
2458 # @ingroup l1_meshinfo
2459 def FindElementByNodes(self,nodes):
2460 return self.mesh.FindElementByNodes(nodes)
2462 ## Returns true if the given element is a polygon
2463 # @ingroup l1_meshinfo
2464 def IsPoly(self, id):
2465 return self.mesh.IsPoly(id)
2467 ## Returns true if the given element is quadratic
2468 # @ingroup l1_meshinfo
2469 def IsQuadratic(self, id):
2470 return self.mesh.IsQuadratic(id)
2472 ## Returns XYZ coordinates of the barycenter of the given element
2473 # \n If there is no element for the given ID - returns an empty list
2474 # @return a list of three double values
2475 # @ingroup l1_meshinfo
2476 def BaryCenter(self, id):
2477 return self.mesh.BaryCenter(id)
2480 # Get mesh measurements information:
2481 # ------------------------------------
2483 ## Get minimum distance between two nodes, elements or distance to the origin
2484 # @param id1 first node/element id
2485 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2486 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2487 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2488 # @return minimum distance value
2489 # @sa GetMinDistance()
2490 def MinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2491 aMeasure = self.GetMinDistance(id1, id2, isElem1, isElem2)
2492 return aMeasure.value
2494 ## Get measure structure specifying minimum distance data between two objects
2495 # @param id1 first node/element id
2496 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2497 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2498 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2499 # @return Measure structure
2501 def GetMinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2503 id1 = self.editor.MakeIDSource([id1], SMESH.FACE)
2505 id1 = self.editor.MakeIDSource([id1], SMESH.NODE)
2508 id2 = self.editor.MakeIDSource([id2], SMESH.FACE)
2510 id2 = self.editor.MakeIDSource([id2], SMESH.NODE)
2515 aMeasurements = self.smeshpyD.CreateMeasurements()
2516 aMeasure = aMeasurements.MinDistance(id1, id2)
2517 aMeasurements.UnRegister()
2520 ## Get bounding box of the specified object(s)
2521 # @param objects single source object or list of source objects or list of nodes/elements IDs
2522 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2523 # @c False specifies that @a objects are nodes
2524 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
2525 # @sa GetBoundingBox()
2526 def BoundingBox(self, objects=None, isElem=False):
2527 result = self.GetBoundingBox(objects, isElem)
2531 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
2534 ## Get measure structure specifying bounding box data of the specified object(s)
2535 # @param IDs single source object or list of source objects or list of nodes/elements IDs
2536 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2537 # @c False specifies that @a objects are nodes
2538 # @return Measure structure
2540 def GetBoundingBox(self, IDs=None, isElem=False):
2543 elif isinstance(IDs, tuple):
2545 if not isinstance(IDs, list):
2547 if len(IDs) > 0 and isinstance(IDs[0], int):
2551 if isinstance(o, Mesh):
2552 srclist.append(o.mesh)
2553 elif hasattr(o, "_narrow"):
2554 src = o._narrow(SMESH.SMESH_IDSource)
2555 if src: srclist.append(src)
2557 elif isinstance(o, list):
2559 srclist.append(self.editor.MakeIDSource(o, SMESH.FACE))
2561 srclist.append(self.editor.MakeIDSource(o, SMESH.NODE))
2564 aMeasurements = self.smeshpyD.CreateMeasurements()
2565 aMeasure = aMeasurements.BoundingBox(srclist)
2566 aMeasurements.UnRegister()
2569 # Mesh edition (SMESH_MeshEditor functionality):
2570 # ---------------------------------------------
2572 ## Removes the elements from the mesh by ids
2573 # @param IDsOfElements is a list of ids of elements to remove
2574 # @return True or False
2575 # @ingroup l2_modif_del
2576 def RemoveElements(self, IDsOfElements):
2577 return self.editor.RemoveElements(IDsOfElements)
2579 ## Removes nodes from mesh by ids
2580 # @param IDsOfNodes is a list of ids of nodes to remove
2581 # @return True or False
2582 # @ingroup l2_modif_del
2583 def RemoveNodes(self, IDsOfNodes):
2584 return self.editor.RemoveNodes(IDsOfNodes)
2586 ## Removes all orphan (free) nodes from mesh
2587 # @return number of the removed nodes
2588 # @ingroup l2_modif_del
2589 def RemoveOrphanNodes(self):
2590 return self.editor.RemoveOrphanNodes()
2592 ## Add a node to the mesh by coordinates
2593 # @return Id of the new node
2594 # @ingroup l2_modif_add
2595 def AddNode(self, x, y, z):
2596 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2597 self.mesh.SetParameters(Parameters)
2598 return self.editor.AddNode( x, y, z)
2600 ## Creates a 0D element on a node with given number.
2601 # @param IDOfNode the ID of node for creation of the element.
2602 # @return the Id of the new 0D element
2603 # @ingroup l2_modif_add
2604 def Add0DElement(self, IDOfNode):
2605 return self.editor.Add0DElement(IDOfNode)
2607 ## Creates a linear or quadratic edge (this is determined
2608 # by the number of given nodes).
2609 # @param IDsOfNodes the list of node IDs for creation of the element.
2610 # The order of nodes in this list should correspond to the description
2611 # of MED. \n This description is located by the following link:
2612 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2613 # @return the Id of the new edge
2614 # @ingroup l2_modif_add
2615 def AddEdge(self, IDsOfNodes):
2616 return self.editor.AddEdge(IDsOfNodes)
2618 ## Creates a linear or quadratic face (this is determined
2619 # by the number of given nodes).
2620 # @param IDsOfNodes the list of node IDs for creation of the element.
2621 # The order of nodes in this list should correspond to the description
2622 # of MED. \n This description is located by the following link:
2623 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2624 # @return the Id of the new face
2625 # @ingroup l2_modif_add
2626 def AddFace(self, IDsOfNodes):
2627 return self.editor.AddFace(IDsOfNodes)
2629 ## Adds a polygonal face to the mesh by the list of node IDs
2630 # @param IdsOfNodes the list of node IDs for creation of the element.
2631 # @return the Id of the new face
2632 # @ingroup l2_modif_add
2633 def AddPolygonalFace(self, IdsOfNodes):
2634 return self.editor.AddPolygonalFace(IdsOfNodes)
2636 ## Creates both simple and quadratic volume (this is determined
2637 # by the number of given nodes).
2638 # @param IDsOfNodes the list of node IDs for creation of the element.
2639 # The order of nodes in this list should correspond to the description
2640 # of MED. \n This description is located by the following link:
2641 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2642 # @return the Id of the new volumic element
2643 # @ingroup l2_modif_add
2644 def AddVolume(self, IDsOfNodes):
2645 return self.editor.AddVolume(IDsOfNodes)
2647 ## Creates a volume of many faces, giving nodes for each face.
2648 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2649 # @param Quantities the list of integer values, Quantities[i]
2650 # gives the quantity of nodes in face number i.
2651 # @return the Id of the new volumic element
2652 # @ingroup l2_modif_add
2653 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2654 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2656 ## Creates a volume of many faces, giving the IDs of the existing faces.
2657 # @param IdsOfFaces the list of face IDs for volume creation.
2659 # Note: The created volume will refer only to the nodes
2660 # of the given faces, not to the faces themselves.
2661 # @return the Id of the new volumic element
2662 # @ingroup l2_modif_add
2663 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2664 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2667 ## @brief Binds a node to a vertex
2668 # @param NodeID a node ID
2669 # @param Vertex a vertex or vertex ID
2670 # @return True if succeed else raises an exception
2671 # @ingroup l2_modif_add
2672 def SetNodeOnVertex(self, NodeID, Vertex):
2673 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2674 VertexID = Vertex.GetSubShapeIndices()[0]
2678 self.editor.SetNodeOnVertex(NodeID, VertexID)
2679 except SALOME.SALOME_Exception, inst:
2680 raise ValueError, inst.details.text
2684 ## @brief Stores the node position on an edge
2685 # @param NodeID a node ID
2686 # @param Edge an edge or edge ID
2687 # @param paramOnEdge a parameter on the edge where the node is located
2688 # @return True if succeed else raises an exception
2689 # @ingroup l2_modif_add
2690 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2691 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2692 EdgeID = Edge.GetSubShapeIndices()[0]
2696 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2697 except SALOME.SALOME_Exception, inst:
2698 raise ValueError, inst.details.text
2701 ## @brief Stores node position on a face
2702 # @param NodeID a node ID
2703 # @param Face a face or face ID
2704 # @param u U parameter on the face where the node is located
2705 # @param v V parameter on the face where the node is located
2706 # @return True if succeed else raises an exception
2707 # @ingroup l2_modif_add
2708 def SetNodeOnFace(self, NodeID, Face, u, v):
2709 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2710 FaceID = Face.GetSubShapeIndices()[0]
2714 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2715 except SALOME.SALOME_Exception, inst:
2716 raise ValueError, inst.details.text
2719 ## @brief Binds a node to a solid
2720 # @param NodeID a node ID
2721 # @param Solid a solid or solid ID
2722 # @return True if succeed else raises an exception
2723 # @ingroup l2_modif_add
2724 def SetNodeInVolume(self, NodeID, Solid):
2725 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2726 SolidID = Solid.GetSubShapeIndices()[0]
2730 self.editor.SetNodeInVolume(NodeID, SolidID)
2731 except SALOME.SALOME_Exception, inst:
2732 raise ValueError, inst.details.text
2735 ## @brief Bind an element to a shape
2736 # @param ElementID an element ID
2737 # @param Shape a shape or shape ID
2738 # @return True if succeed else raises an exception
2739 # @ingroup l2_modif_add
2740 def SetMeshElementOnShape(self, ElementID, Shape):
2741 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2742 ShapeID = Shape.GetSubShapeIndices()[0]
2746 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2747 except SALOME.SALOME_Exception, inst:
2748 raise ValueError, inst.details.text
2752 ## Moves the node with the given id
2753 # @param NodeID the id of the node
2754 # @param x a new X coordinate
2755 # @param y a new Y coordinate
2756 # @param z a new Z coordinate
2757 # @return True if succeed else False
2758 # @ingroup l2_modif_movenode
2759 def MoveNode(self, NodeID, x, y, z):
2760 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2761 self.mesh.SetParameters(Parameters)
2762 return self.editor.MoveNode(NodeID, x, y, z)
2764 ## Finds the node closest to a point and moves it to a point location
2765 # @param x the X coordinate of a point
2766 # @param y the Y coordinate of a point
2767 # @param z the Z coordinate of a point
2768 # @param NodeID if specified (>0), the node with this ID is moved,
2769 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2770 # @return the ID of a node
2771 # @ingroup l2_modif_throughp
2772 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2773 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2774 self.mesh.SetParameters(Parameters)
2775 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2777 ## Finds the node closest to a point
2778 # @param x the X coordinate of a point
2779 # @param y the Y coordinate of a point
2780 # @param z the Z coordinate of a point
2781 # @return the ID of a node
2782 # @ingroup l2_modif_throughp
2783 def FindNodeClosestTo(self, x, y, z):
2784 #preview = self.mesh.GetMeshEditPreviewer()
2785 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2786 return self.editor.FindNodeClosestTo(x, y, z)
2788 ## Finds the elements where a point lays IN or ON
2789 # @param x the X coordinate of a point
2790 # @param y the Y coordinate of a point
2791 # @param z the Z coordinate of a point
2792 # @param elementType type of elements to find (SMESH.ALL type
2793 # means elements of any type excluding nodes and 0D elements)
2794 # @param meshPart a part of mesh (group, sub-mesh) to search within
2795 # @return list of IDs of found elements
2796 # @ingroup l2_modif_throughp
2797 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL, meshPart=None):
2799 return self.editor.FindAmongElementsByPoint( meshPart, x, y, z, elementType );
2801 return self.editor.FindElementsByPoint(x, y, z, elementType)
2803 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2804 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2806 def GetPointState(self, x, y, z):
2807 return self.editor.GetPointState(x, y, z)
2809 ## Finds the node closest to a point and moves it to a point location
2810 # @param x the X coordinate of a point
2811 # @param y the Y coordinate of a point
2812 # @param z the Z coordinate of a point
2813 # @return the ID of a moved node
2814 # @ingroup l2_modif_throughp
2815 def MeshToPassThroughAPoint(self, x, y, z):
2816 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2818 ## Replaces two neighbour triangles sharing Node1-Node2 link
2819 # with the triangles built on the same 4 nodes but having other common link.
2820 # @param NodeID1 the ID of the first node
2821 # @param NodeID2 the ID of the second node
2822 # @return false if proper faces were not found
2823 # @ingroup l2_modif_invdiag
2824 def InverseDiag(self, NodeID1, NodeID2):
2825 return self.editor.InverseDiag(NodeID1, NodeID2)
2827 ## Replaces two neighbour triangles sharing Node1-Node2 link
2828 # with a quadrangle built on the same 4 nodes.
2829 # @param NodeID1 the ID of the first node
2830 # @param NodeID2 the ID of the second node
2831 # @return false if proper faces were not found
2832 # @ingroup l2_modif_unitetri
2833 def DeleteDiag(self, NodeID1, NodeID2):
2834 return self.editor.DeleteDiag(NodeID1, NodeID2)
2836 ## Reorients elements by ids
2837 # @param IDsOfElements if undefined reorients all mesh elements
2838 # @return True if succeed else False
2839 # @ingroup l2_modif_changori
2840 def Reorient(self, IDsOfElements=None):
2841 if IDsOfElements == None:
2842 IDsOfElements = self.GetElementsId()
2843 return self.editor.Reorient(IDsOfElements)
2845 ## Reorients all elements of the object
2846 # @param theObject mesh, submesh or group
2847 # @return True if succeed else False
2848 # @ingroup l2_modif_changori
2849 def ReorientObject(self, theObject):
2850 if ( isinstance( theObject, Mesh )):
2851 theObject = theObject.GetMesh()
2852 return self.editor.ReorientObject(theObject)
2854 ## Fuses the neighbouring triangles into quadrangles.
2855 # @param IDsOfElements The triangles to be fused,
2856 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2857 # @param MaxAngle is the maximum angle between element normals at which the fusion
2858 # is still performed; theMaxAngle is mesured in radians.
2859 # Also it could be a name of variable which defines angle in degrees.
2860 # @return TRUE in case of success, FALSE otherwise.
2861 # @ingroup l2_modif_unitetri
2862 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2864 if isinstance(MaxAngle,str):
2866 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2868 MaxAngle = DegreesToRadians(MaxAngle)
2869 if IDsOfElements == []:
2870 IDsOfElements = self.GetElementsId()
2871 self.mesh.SetParameters(Parameters)
2873 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2874 Functor = theCriterion
2876 Functor = self.smeshpyD.GetFunctor(theCriterion)
2877 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2879 ## Fuses the neighbouring triangles of the object into quadrangles
2880 # @param theObject is mesh, submesh or group
2881 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2882 # @param MaxAngle a max angle between element normals at which the fusion
2883 # is still performed; theMaxAngle is mesured in radians.
2884 # @return TRUE in case of success, FALSE otherwise.
2885 # @ingroup l2_modif_unitetri
2886 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2887 if ( isinstance( theObject, Mesh )):
2888 theObject = theObject.GetMesh()
2889 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2891 ## Splits quadrangles into triangles.
2892 # @param IDsOfElements the faces to be splitted.
2893 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2894 # @return TRUE in case of success, FALSE otherwise.
2895 # @ingroup l2_modif_cutquadr
2896 def QuadToTri (self, IDsOfElements, theCriterion):
2897 if IDsOfElements == []:
2898 IDsOfElements = self.GetElementsId()
2899 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2901 ## Splits quadrangles into triangles.
2902 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2903 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2904 # @return TRUE in case of success, FALSE otherwise.
2905 # @ingroup l2_modif_cutquadr
2906 def QuadToTriObject (self, theObject, theCriterion):
2907 if ( isinstance( theObject, Mesh )):
2908 theObject = theObject.GetMesh()
2909 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2911 ## Splits quadrangles into triangles.
2912 # @param IDsOfElements the faces to be splitted
2913 # @param Diag13 is used to choose a diagonal for splitting.
2914 # @return TRUE in case of success, FALSE otherwise.
2915 # @ingroup l2_modif_cutquadr
2916 def SplitQuad (self, IDsOfElements, Diag13):
2917 if IDsOfElements == []:
2918 IDsOfElements = self.GetElementsId()
2919 return self.editor.SplitQuad(IDsOfElements, Diag13)
2921 ## Splits quadrangles into triangles.
2922 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2923 # @param Diag13 is used to choose a diagonal for splitting.
2924 # @return TRUE in case of success, FALSE otherwise.
2925 # @ingroup l2_modif_cutquadr
2926 def SplitQuadObject (self, theObject, Diag13):
2927 if ( isinstance( theObject, Mesh )):
2928 theObject = theObject.GetMesh()
2929 return self.editor.SplitQuadObject(theObject, Diag13)
2931 ## Finds a better splitting of the given quadrangle.
2932 # @param IDOfQuad the ID of the quadrangle to be splitted.
2933 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2934 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2935 # diagonal is better, 0 if error occurs.
2936 # @ingroup l2_modif_cutquadr
2937 def BestSplit (self, IDOfQuad, theCriterion):
2938 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2940 ## Splits volumic elements into tetrahedrons
2941 # @param elemIDs either list of elements or mesh or group or submesh
2942 # @param method flags passing splitting method: Hex_5Tet, Hex_6Tet, Hex_24Tet
2943 # Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc
2944 # @ingroup l2_modif_cutquadr
2945 def SplitVolumesIntoTetra(self, elemIDs, method=Hex_5Tet ):
2946 if isinstance( elemIDs, Mesh ):
2947 elemIDs = elemIDs.GetMesh()
2948 if ( isinstance( elemIDs, list )):
2949 elemIDs = self.editor.MakeIDSource(elemIDs, SMESH.VOLUME)
2950 self.editor.SplitVolumesIntoTetra(elemIDs, method)
2952 ## Splits quadrangle faces near triangular facets of volumes
2954 # @ingroup l1_auxiliary
2955 def SplitQuadsNearTriangularFacets(self):
2956 faces_array = self.GetElementsByType(SMESH.FACE)
2957 for face_id in faces_array:
2958 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2959 quad_nodes = self.mesh.GetElemNodes(face_id)
2960 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2961 isVolumeFound = False
2962 for node1_elem in node1_elems:
2963 if not isVolumeFound:
2964 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2965 nb_nodes = self.GetElemNbNodes(node1_elem)
2966 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2967 volume_elem = node1_elem
2968 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2969 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2970 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2971 isVolumeFound = True
2972 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2973 self.SplitQuad([face_id], False) # diagonal 2-4
2974 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2975 isVolumeFound = True
2976 self.SplitQuad([face_id], True) # diagonal 1-3
2977 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2978 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2979 isVolumeFound = True
2980 self.SplitQuad([face_id], True) # diagonal 1-3
2982 ## @brief Splits hexahedrons into tetrahedrons.
2984 # This operation uses pattern mapping functionality for splitting.
2985 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2986 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2987 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2988 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2989 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2990 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2991 # @return TRUE in case of success, FALSE otherwise.
2992 # @ingroup l1_auxiliary
2993 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2994 # Pattern: 5.---------.6
2999 # (0,0,1) 4.---------.7 * |
3006 # (0,0,0) 0.---------.3
3007 pattern_tetra = "!!! Nb of points: \n 8 \n\
3017 !!! Indices of points of 6 tetras: \n\
3025 pattern = self.smeshpyD.GetPattern()
3026 isDone = pattern.LoadFromFile(pattern_tetra)
3028 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
3031 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
3032 isDone = pattern.MakeMesh(self.mesh, False, False)
3033 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
3035 # split quafrangle faces near triangular facets of volumes
3036 self.SplitQuadsNearTriangularFacets()
3040 ## @brief Split hexahedrons into prisms.
3042 # Uses the pattern mapping functionality for splitting.
3043 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
3044 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
3045 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
3046 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
3047 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
3048 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
3049 # @return TRUE in case of success, FALSE otherwise.
3050 # @ingroup l1_auxiliary
3051 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
3052 # Pattern: 5.---------.6
3057 # (0,0,1) 4.---------.7 |
3064 # (0,0,0) 0.---------.3
3065 pattern_prism = "!!! Nb of points: \n 8 \n\
3075 !!! Indices of points of 2 prisms: \n\
3079 pattern = self.smeshpyD.GetPattern()
3080 isDone = pattern.LoadFromFile(pattern_prism)
3082 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
3085 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
3086 isDone = pattern.MakeMesh(self.mesh, False, False)
3087 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
3089 # Splits quafrangle faces near triangular facets of volumes
3090 self.SplitQuadsNearTriangularFacets()
3094 ## Smoothes elements
3095 # @param IDsOfElements the list if ids of elements to smooth
3096 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3097 # Note that nodes built on edges and boundary nodes are always fixed.
3098 # @param MaxNbOfIterations the maximum number of iterations
3099 # @param MaxAspectRatio varies in range [1.0, inf]
3100 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3101 # @return TRUE in case of success, FALSE otherwise.
3102 # @ingroup l2_modif_smooth
3103 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
3104 MaxNbOfIterations, MaxAspectRatio, Method):
3105 if IDsOfElements == []:
3106 IDsOfElements = self.GetElementsId()
3107 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
3108 self.mesh.SetParameters(Parameters)
3109 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
3110 MaxNbOfIterations, MaxAspectRatio, Method)
3112 ## Smoothes elements which belong to the given object
3113 # @param theObject the object to smooth
3114 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3115 # Note that nodes built on edges and boundary nodes are always fixed.
3116 # @param MaxNbOfIterations the maximum number of iterations
3117 # @param MaxAspectRatio varies in range [1.0, inf]
3118 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3119 # @return TRUE in case of success, FALSE otherwise.
3120 # @ingroup l2_modif_smooth
3121 def SmoothObject(self, theObject, IDsOfFixedNodes,
3122 MaxNbOfIterations, MaxAspectRatio, Method):
3123 if ( isinstance( theObject, Mesh )):
3124 theObject = theObject.GetMesh()
3125 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
3126 MaxNbOfIterations, MaxAspectRatio, Method)
3128 ## Parametrically smoothes the given elements
3129 # @param IDsOfElements the list if ids of elements to smooth
3130 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3131 # Note that nodes built on edges and boundary nodes are always fixed.
3132 # @param MaxNbOfIterations the maximum number of iterations
3133 # @param MaxAspectRatio varies in range [1.0, inf]
3134 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3135 # @return TRUE in case of success, FALSE otherwise.
3136 # @ingroup l2_modif_smooth
3137 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
3138 MaxNbOfIterations, MaxAspectRatio, Method):
3139 if IDsOfElements == []:
3140 IDsOfElements = self.GetElementsId()
3141 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
3142 self.mesh.SetParameters(Parameters)
3143 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
3144 MaxNbOfIterations, MaxAspectRatio, Method)
3146 ## Parametrically smoothes the elements which belong to the given object
3147 # @param theObject the object to smooth
3148 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3149 # Note that nodes built on edges and boundary nodes are always fixed.
3150 # @param MaxNbOfIterations the maximum number of iterations
3151 # @param MaxAspectRatio varies in range [1.0, inf]
3152 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3153 # @return TRUE in case of success, FALSE otherwise.
3154 # @ingroup l2_modif_smooth
3155 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
3156 MaxNbOfIterations, MaxAspectRatio, Method):
3157 if ( isinstance( theObject, Mesh )):
3158 theObject = theObject.GetMesh()
3159 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
3160 MaxNbOfIterations, MaxAspectRatio, Method)
3162 ## Converts the mesh to quadratic, deletes old elements, replacing
3163 # them with quadratic with the same id.
3164 # @param theForce3d new node creation method:
3165 # 0 - the medium node lies at the geometrical entity from which the mesh element is built
3166 # 1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element
3167 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
3168 # @ingroup l2_modif_tofromqu
3169 def ConvertToQuadratic(self, theForce3d, theSubMesh=None):
3171 self.editor.ConvertToQuadraticObject(theForce3d,theSubMesh)
3173 self.editor.ConvertToQuadratic(theForce3d)
3175 ## Converts the mesh from quadratic to ordinary,
3176 # deletes old quadratic elements, \n replacing
3177 # them with ordinary mesh elements with the same id.
3178 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
3179 # @ingroup l2_modif_tofromqu
3180 def ConvertFromQuadratic(self, theSubMesh=None):
3182 self.editor.ConvertFromQuadraticObject(theSubMesh)
3184 return self.editor.ConvertFromQuadratic()
3186 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
3187 # @return TRUE if operation has been completed successfully, FALSE otherwise
3188 # @ingroup l2_modif_edit
3189 def Make2DMeshFrom3D(self):
3190 return self.editor. Make2DMeshFrom3D()
3192 ## Creates missing boundary elements
3193 # @param elements - elements whose boundary is to be checked:
3194 # mesh, group, sub-mesh or list of elements
3195 # if elements is mesh, it must be the mesh whose MakeBoundaryMesh() is called
3196 # @param dimension - defines type of boundary elements to create:
3197 # SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D
3198 # SMESH.BND_1DFROM3D creates mesh edges on all borders of free facets of 3D cells
3199 # @param groupName - a name of group to store created boundary elements in,
3200 # "" means not to create the group
3201 # @param meshName - a name of new mesh to store created boundary elements in,
3202 # "" means not to create the new mesh
3203 # @param toCopyElements - if true, the checked elements will be copied into
3204 # the new mesh else only boundary elements will be copied into the new mesh
3205 # @param toCopyExistingBondary - if true, not only new but also pre-existing
3206 # boundary elements will be copied into the new mesh
3207 # @return tuple (mesh, group) where bondary elements were added to
3208 # @ingroup l2_modif_edit
3209 def MakeBoundaryMesh(self, elements, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3210 toCopyElements=False, toCopyExistingBondary=False):
3211 if isinstance( elements, Mesh ):
3212 elements = elements.GetMesh()
3213 if ( isinstance( elements, list )):
3214 elemType = SMESH.ALL
3215 if elements: elemType = self.GetElementType( elements[0], iselem=True)
3216 elements = self.editor.MakeIDSource(elements, elemType)
3217 mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName,
3218 toCopyElements,toCopyExistingBondary)
3219 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3223 # @brief Creates missing boundary elements around either the whole mesh or
3224 # groups of 2D elements
3225 # @param dimension - defines type of boundary elements to create
3226 # @param groupName - a name of group to store all boundary elements in,
3227 # "" means not to create the group
3228 # @param meshName - a name of a new mesh, which is a copy of the initial
3229 # mesh + created boundary elements; "" means not to create the new mesh
3230 # @param toCopyAll - if true, the whole initial mesh will be copied into
3231 # the new mesh else only boundary elements will be copied into the new mesh
3232 # @param groups - groups of 2D elements to make boundary around
3233 # @retval tuple( long, mesh, groups )
3234 # long - number of added boundary elements
3235 # mesh - the mesh where elements were added to
3236 # group - the group of boundary elements or None
3238 def MakeBoundaryElements(self, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3239 toCopyAll=False, groups=[]):
3240 nb, mesh, group = self.editor.MakeBoundaryElements(dimension,groupName,meshName,
3242 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3243 return nb, mesh, group
3245 ## Renumber mesh nodes
3246 # @ingroup l2_modif_renumber
3247 def RenumberNodes(self):
3248 self.editor.RenumberNodes()
3250 ## Renumber mesh elements
3251 # @ingroup l2_modif_renumber
3252 def RenumberElements(self):
3253 self.editor.RenumberElements()
3255 ## Generates new elements by rotation of the elements around the axis
3256 # @param IDsOfElements the list of ids of elements to sweep
3257 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3258 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
3259 # @param NbOfSteps the number of steps
3260 # @param Tolerance tolerance
3261 # @param MakeGroups forces the generation of new groups from existing ones
3262 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3263 # of all steps, else - size of each step
3264 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3265 # @ingroup l2_modif_extrurev
3266 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
3267 MakeGroups=False, TotalAngle=False):
3269 if isinstance(AngleInRadians,str):
3271 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3273 AngleInRadians = DegreesToRadians(AngleInRadians)
3274 if IDsOfElements == []:
3275 IDsOfElements = self.GetElementsId()
3276 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3277 Axis = self.smeshpyD.GetAxisStruct(Axis)
3278 Axis,AxisParameters = ParseAxisStruct(Axis)
3279 if TotalAngle and NbOfSteps:
3280 AngleInRadians /= NbOfSteps
3281 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3282 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3283 self.mesh.SetParameters(Parameters)
3285 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
3286 AngleInRadians, NbOfSteps, Tolerance)
3287 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
3290 ## Generates new elements by rotation of the elements of object around the axis
3291 # @param theObject object which elements should be sweeped.
3292 # It can be a mesh, a sub mesh or a group.
3293 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3294 # @param AngleInRadians the angle of Rotation
3295 # @param NbOfSteps number of steps
3296 # @param Tolerance tolerance
3297 # @param MakeGroups forces the generation of new groups from existing ones
3298 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3299 # of all steps, else - size of each step
3300 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3301 # @ingroup l2_modif_extrurev
3302 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3303 MakeGroups=False, TotalAngle=False):
3305 if isinstance(AngleInRadians,str):
3307 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3309 AngleInRadians = DegreesToRadians(AngleInRadians)
3310 if ( isinstance( theObject, Mesh )):
3311 theObject = theObject.GetMesh()
3312 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3313 Axis = self.smeshpyD.GetAxisStruct(Axis)
3314 Axis,AxisParameters = ParseAxisStruct(Axis)
3315 if TotalAngle and NbOfSteps:
3316 AngleInRadians /= NbOfSteps
3317 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3318 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3319 self.mesh.SetParameters(Parameters)
3321 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
3322 NbOfSteps, Tolerance)
3323 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3326 ## Generates new elements by rotation of the elements of object around the axis
3327 # @param theObject object which elements should be sweeped.
3328 # It can be a mesh, a sub mesh or a group.
3329 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3330 # @param AngleInRadians the angle of Rotation
3331 # @param NbOfSteps number of steps
3332 # @param Tolerance tolerance
3333 # @param MakeGroups forces the generation of new groups from existing ones
3334 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3335 # of all steps, else - size of each step
3336 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3337 # @ingroup l2_modif_extrurev
3338 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3339 MakeGroups=False, TotalAngle=False):
3341 if isinstance(AngleInRadians,str):
3343 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3345 AngleInRadians = DegreesToRadians(AngleInRadians)
3346 if ( isinstance( theObject, Mesh )):
3347 theObject = theObject.GetMesh()
3348 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3349 Axis = self.smeshpyD.GetAxisStruct(Axis)
3350 Axis,AxisParameters = ParseAxisStruct(Axis)
3351 if TotalAngle and NbOfSteps:
3352 AngleInRadians /= NbOfSteps
3353 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3354 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3355 self.mesh.SetParameters(Parameters)
3357 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
3358 NbOfSteps, Tolerance)
3359 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3362 ## Generates new elements by rotation of the elements of object around the axis
3363 # @param theObject object which elements should be sweeped.
3364 # It can be a mesh, a sub mesh or a group.
3365 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3366 # @param AngleInRadians the angle of Rotation
3367 # @param NbOfSteps number of steps
3368 # @param Tolerance tolerance
3369 # @param MakeGroups forces the generation of new groups from existing ones
3370 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3371 # of all steps, else - size of each step
3372 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3373 # @ingroup l2_modif_extrurev
3374 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3375 MakeGroups=False, TotalAngle=False):
3377 if isinstance(AngleInRadians,str):
3379 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3381 AngleInRadians = DegreesToRadians(AngleInRadians)
3382 if ( isinstance( theObject, Mesh )):
3383 theObject = theObject.GetMesh()
3384 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3385 Axis = self.smeshpyD.GetAxisStruct(Axis)
3386 Axis,AxisParameters = ParseAxisStruct(Axis)
3387 if TotalAngle and NbOfSteps:
3388 AngleInRadians /= NbOfSteps
3389 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3390 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3391 self.mesh.SetParameters(Parameters)
3393 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
3394 NbOfSteps, Tolerance)
3395 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3398 ## Generates new elements by extrusion of the elements with given ids
3399 # @param IDsOfElements the list of elements ids for extrusion
3400 # @param StepVector vector or DirStruct, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3401 # @param NbOfSteps the number of steps
3402 # @param MakeGroups forces the generation of new groups from existing ones
3403 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3404 # @ingroup l2_modif_extrurev
3405 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
3406 if IDsOfElements == []:
3407 IDsOfElements = self.GetElementsId()
3408 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3409 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3410 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3411 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3412 Parameters = StepVectorParameters + var_separator + Parameters
3413 self.mesh.SetParameters(Parameters)
3415 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
3416 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
3419 ## Generates new elements by extrusion of the elements with given ids
3420 # @param IDsOfElements is ids of elements
3421 # @param StepVector vector, defining the direction and value of extrusion
3422 # @param NbOfSteps the number of steps
3423 # @param ExtrFlags sets flags for extrusion
3424 # @param SewTolerance uses for comparing locations of nodes if flag
3425 # EXTRUSION_FLAG_SEW is set
3426 # @param MakeGroups forces the generation of new groups from existing ones
3427 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3428 # @ingroup l2_modif_extrurev
3429 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
3430 ExtrFlags, SewTolerance, MakeGroups=False):
3431 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3432 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3434 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
3435 ExtrFlags, SewTolerance)
3436 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
3437 ExtrFlags, SewTolerance)
3440 ## Generates new elements by extrusion of the elements which belong to the object
3441 # @param theObject the object which elements should be processed.
3442 # It can be a mesh, a sub mesh or a group.
3443 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3444 # @param NbOfSteps the number of steps
3445 # @param MakeGroups forces the generation of new groups from existing ones
3446 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3447 # @ingroup l2_modif_extrurev
3448 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3449 if ( isinstance( theObject, Mesh )):
3450 theObject = theObject.GetMesh()
3451 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3452 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3453 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3454 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3455 Parameters = StepVectorParameters + var_separator + Parameters
3456 self.mesh.SetParameters(Parameters)
3458 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3459 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
3462 ## Generates new elements by extrusion of the elements which belong to the object
3463 # @param theObject object which elements should be processed.
3464 # It can be a mesh, a sub mesh or a group.
3465 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3466 # @param NbOfSteps the number of steps
3467 # @param MakeGroups to generate new groups from existing ones
3468 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3469 # @ingroup l2_modif_extrurev
3470 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3471 if ( isinstance( theObject, Mesh )):
3472 theObject = theObject.GetMesh()
3473 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3474 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3475 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3476 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3477 Parameters = StepVectorParameters + var_separator + Parameters
3478 self.mesh.SetParameters(Parameters)
3480 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3481 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3484 ## Generates new elements by extrusion of the elements which belong to the object
3485 # @param theObject object which elements should be processed.
3486 # It can be a mesh, a sub mesh or a group.
3487 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3488 # @param NbOfSteps the number of steps
3489 # @param MakeGroups forces the generation of new groups from existing ones
3490 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3491 # @ingroup l2_modif_extrurev
3492 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3493 if ( isinstance( theObject, Mesh )):
3494 theObject = theObject.GetMesh()
3495 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3496 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3497 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3498 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3499 Parameters = StepVectorParameters + var_separator + Parameters
3500 self.mesh.SetParameters(Parameters)
3502 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3503 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3508 ## Generates new elements by extrusion of the given elements
3509 # The path of extrusion must be a meshed edge.
3510 # @param Base mesh or group, or submesh, or list of ids of elements for extrusion
3511 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3512 # @param NodeStart the start node from Path. Defines the direction of extrusion
3513 # @param HasAngles allows the shape to be rotated around the path
3514 # to get the resulting mesh in a helical fashion
3515 # @param Angles list of angles in radians
3516 # @param LinearVariation forces the computation of rotation angles as linear
3517 # variation of the given Angles along path steps
3518 # @param HasRefPoint allows using the reference point
3519 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3520 # The User can specify any point as the Reference Point.
3521 # @param MakeGroups forces the generation of new groups from existing ones
3522 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3523 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3524 # only SMESH::Extrusion_Error otherwise
3525 # @ingroup l2_modif_extrurev
3526 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3527 HasAngles, Angles, LinearVariation,
3528 HasRefPoint, RefPoint, MakeGroups, ElemType):
3529 Angles,AnglesParameters = ParseAngles(Angles)
3530 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3531 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3532 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3534 Parameters = AnglesParameters + var_separator + RefPointParameters
3535 self.mesh.SetParameters(Parameters)
3537 if (isinstance(Path, Mesh)): Path = Path.GetMesh()
3539 if isinstance(Base, list):
3541 if Base == []: IDsOfElements = self.GetElementsId()
3542 else: IDsOfElements = Base
3543 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3544 HasAngles, Angles, LinearVariation,
3545 HasRefPoint, RefPoint, MakeGroups, ElemType)
3547 if isinstance(Base, Mesh): Base = Base.GetMesh()
3548 if isinstance(Base, SMESH._objref_SMESH_Mesh) or isinstance(Base, SMESH._objref_SMESH_Group) or isinstance(Base, SMESH._objref_SMESH_subMesh):
3549 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3550 HasAngles, Angles, LinearVariation,
3551 HasRefPoint, RefPoint, MakeGroups, ElemType)
3553 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3556 ## Generates new elements by extrusion of the given elements
3557 # The path of extrusion must be a meshed edge.
3558 # @param IDsOfElements ids of elements
3559 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3560 # @param PathShape shape(edge) defines the sub-mesh for the path
3561 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3562 # @param HasAngles allows the shape to be rotated around the path
3563 # to get the resulting mesh in a helical fashion
3564 # @param Angles list of angles in radians
3565 # @param HasRefPoint allows using the reference point
3566 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3567 # The User can specify any point as the Reference Point.
3568 # @param MakeGroups forces the generation of new groups from existing ones
3569 # @param LinearVariation forces the computation of rotation angles as linear
3570 # variation of the given Angles along path steps
3571 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3572 # only SMESH::Extrusion_Error otherwise
3573 # @ingroup l2_modif_extrurev
3574 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3575 HasAngles, Angles, HasRefPoint, RefPoint,
3576 MakeGroups=False, LinearVariation=False):
3577 Angles,AnglesParameters = ParseAngles(Angles)
3578 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3579 if IDsOfElements == []:
3580 IDsOfElements = self.GetElementsId()
3581 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3582 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3584 if ( isinstance( PathMesh, Mesh )):
3585 PathMesh = PathMesh.GetMesh()
3586 if HasAngles and Angles and LinearVariation:
3587 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3589 Parameters = AnglesParameters + var_separator + RefPointParameters
3590 self.mesh.SetParameters(Parameters)
3592 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3593 PathShape, NodeStart, HasAngles,
3594 Angles, HasRefPoint, RefPoint)
3595 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3596 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3598 ## Generates new elements by extrusion of the elements which belong to the object
3599 # The path of extrusion must be a meshed edge.
3600 # @param theObject the object which elements should be processed.
3601 # It can be a mesh, a sub mesh or a group.
3602 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3603 # @param PathShape shape(edge) defines the sub-mesh for the path
3604 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3605 # @param HasAngles allows the shape to be rotated around the path
3606 # to get the resulting mesh in a helical fashion
3607 # @param Angles list of angles
3608 # @param HasRefPoint allows using the reference point
3609 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3610 # The User can specify any point as the Reference Point.
3611 # @param MakeGroups forces the generation of new groups from existing ones
3612 # @param LinearVariation forces the computation of rotation angles as linear
3613 # variation of the given Angles along path steps
3614 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3615 # only SMESH::Extrusion_Error otherwise
3616 # @ingroup l2_modif_extrurev
3617 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3618 HasAngles, Angles, HasRefPoint, RefPoint,
3619 MakeGroups=False, LinearVariation=False):
3620 Angles,AnglesParameters = ParseAngles(Angles)
3621 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3622 if ( isinstance( theObject, Mesh )):
3623 theObject = theObject.GetMesh()
3624 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3625 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3626 if ( isinstance( PathMesh, Mesh )):
3627 PathMesh = PathMesh.GetMesh()
3628 if HasAngles and Angles and LinearVariation:
3629 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3631 Parameters = AnglesParameters + var_separator + RefPointParameters
3632 self.mesh.SetParameters(Parameters)
3634 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3635 PathShape, NodeStart, HasAngles,
3636 Angles, HasRefPoint, RefPoint)
3637 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3638 NodeStart, HasAngles, Angles, HasRefPoint,
3641 ## Generates new elements by extrusion of the elements which belong to the object
3642 # The path of extrusion must be a meshed edge.
3643 # @param theObject the object which elements should be processed.
3644 # It can be a mesh, a sub mesh or a group.
3645 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3646 # @param PathShape shape(edge) defines the sub-mesh for the path
3647 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3648 # @param HasAngles allows the shape to be rotated around the path
3649 # to get the resulting mesh in a helical fashion
3650 # @param Angles list of angles
3651 # @param HasRefPoint allows using the reference point
3652 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3653 # The User can specify any point as the Reference Point.
3654 # @param MakeGroups forces the generation of new groups from existing ones
3655 # @param LinearVariation forces the computation of rotation angles as linear
3656 # variation of the given Angles along path steps
3657 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3658 # only SMESH::Extrusion_Error otherwise
3659 # @ingroup l2_modif_extrurev
3660 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3661 HasAngles, Angles, HasRefPoint, RefPoint,
3662 MakeGroups=False, LinearVariation=False):
3663 Angles,AnglesParameters = ParseAngles(Angles)
3664 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3665 if ( isinstance( theObject, Mesh )):
3666 theObject = theObject.GetMesh()
3667 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3668 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3669 if ( isinstance( PathMesh, Mesh )):
3670 PathMesh = PathMesh.GetMesh()
3671 if HasAngles and Angles and LinearVariation:
3672 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3674 Parameters = AnglesParameters + var_separator + RefPointParameters
3675 self.mesh.SetParameters(Parameters)
3677 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3678 PathShape, NodeStart, HasAngles,
3679 Angles, HasRefPoint, RefPoint)
3680 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3681 NodeStart, HasAngles, Angles, HasRefPoint,
3684 ## Generates new elements by extrusion of the elements which belong to the object
3685 # The path of extrusion must be a meshed edge.
3686 # @param theObject the object which elements should be processed.
3687 # It can be a mesh, a sub mesh or a group.
3688 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3689 # @param PathShape shape(edge) defines the sub-mesh for the path
3690 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3691 # @param HasAngles allows the shape to be rotated around the path
3692 # to get the resulting mesh in a helical fashion
3693 # @param Angles list of angles
3694 # @param HasRefPoint allows using the reference point
3695 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3696 # The User can specify any point as the Reference Point.
3697 # @param MakeGroups forces the generation of new groups from existing ones
3698 # @param LinearVariation forces the computation of rotation angles as linear
3699 # variation of the given Angles along path steps
3700 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3701 # only SMESH::Extrusion_Error otherwise
3702 # @ingroup l2_modif_extrurev
3703 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3704 HasAngles, Angles, HasRefPoint, RefPoint,
3705 MakeGroups=False, LinearVariation=False):
3706 Angles,AnglesParameters = ParseAngles(Angles)
3707 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3708 if ( isinstance( theObject, Mesh )):
3709 theObject = theObject.GetMesh()
3710 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3711 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3712 if ( isinstance( PathMesh, Mesh )):
3713 PathMesh = PathMesh.GetMesh()
3714 if HasAngles and Angles and LinearVariation:
3715 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3717 Parameters = AnglesParameters + var_separator + RefPointParameters
3718 self.mesh.SetParameters(Parameters)
3720 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3721 PathShape, NodeStart, HasAngles,
3722 Angles, HasRefPoint, RefPoint)
3723 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3724 NodeStart, HasAngles, Angles, HasRefPoint,
3727 ## Creates a symmetrical copy of mesh elements
3728 # @param IDsOfElements list of elements ids
3729 # @param Mirror is AxisStruct or geom object(point, line, plane)
3730 # @param theMirrorType is POINT, AXIS or PLANE
3731 # If the Mirror is a geom object this parameter is unnecessary
3732 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3733 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3734 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3735 # @ingroup l2_modif_trsf
3736 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3737 if IDsOfElements == []:
3738 IDsOfElements = self.GetElementsId()
3739 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3740 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3741 Mirror,Parameters = ParseAxisStruct(Mirror)
3742 self.mesh.SetParameters(Parameters)
3743 if Copy and MakeGroups:
3744 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3745 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3748 ## Creates a new mesh by a symmetrical copy of mesh elements
3749 # @param IDsOfElements the list of elements ids
3750 # @param Mirror is AxisStruct or geom object (point, line, plane)
3751 # @param theMirrorType is POINT, AXIS or PLANE
3752 # If the Mirror is a geom object this parameter is unnecessary
3753 # @param MakeGroups to generate new groups from existing ones
3754 # @param NewMeshName a name of the new mesh to create
3755 # @return instance of Mesh class
3756 # @ingroup l2_modif_trsf
3757 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3758 if IDsOfElements == []:
3759 IDsOfElements = self.GetElementsId()
3760 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3761 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3762 Mirror,Parameters = ParseAxisStruct(Mirror)
3763 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3764 MakeGroups, NewMeshName)
3765 mesh.SetParameters(Parameters)
3766 return Mesh(self.smeshpyD,self.geompyD,mesh)
3768 ## Creates a symmetrical copy of the object
3769 # @param theObject mesh, submesh or group
3770 # @param Mirror AxisStruct or geom object (point, line, plane)
3771 # @param theMirrorType is POINT, AXIS or PLANE
3772 # If the Mirror is a geom object this parameter is unnecessary
3773 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3774 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3775 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3776 # @ingroup l2_modif_trsf
3777 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3778 if ( isinstance( theObject, Mesh )):
3779 theObject = theObject.GetMesh()
3780 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3781 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3782 Mirror,Parameters = ParseAxisStruct(Mirror)
3783 self.mesh.SetParameters(Parameters)
3784 if Copy and MakeGroups:
3785 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3786 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3789 ## Creates a new mesh by a symmetrical copy of the object
3790 # @param theObject mesh, submesh or group
3791 # @param Mirror AxisStruct or geom object (point, line, plane)
3792 # @param theMirrorType POINT, AXIS or PLANE
3793 # If the Mirror is a geom object this parameter is unnecessary
3794 # @param MakeGroups forces the generation of new groups from existing ones
3795 # @param NewMeshName the name of the new mesh to create
3796 # @return instance of Mesh class
3797 # @ingroup l2_modif_trsf
3798 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3799 if ( isinstance( theObject, Mesh )):
3800 theObject = theObject.GetMesh()
3801 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3802 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3803 Mirror,Parameters = ParseAxisStruct(Mirror)
3804 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3805 MakeGroups, NewMeshName)
3806 mesh.SetParameters(Parameters)
3807 return Mesh( self.smeshpyD,self.geompyD,mesh )
3809 ## Translates the elements
3810 # @param IDsOfElements list of elements ids
3811 # @param Vector the direction of translation (DirStruct or vector)
3812 # @param Copy allows copying the translated elements
3813 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3814 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3815 # @ingroup l2_modif_trsf
3816 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3817 if IDsOfElements == []:
3818 IDsOfElements = self.GetElementsId()
3819 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3820 Vector = self.smeshpyD.GetDirStruct(Vector)
3821 Vector,Parameters = ParseDirStruct(Vector)
3822 self.mesh.SetParameters(Parameters)
3823 if Copy and MakeGroups:
3824 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3825 self.editor.Translate(IDsOfElements, Vector, Copy)
3828 ## Creates a new mesh of translated elements
3829 # @param IDsOfElements list of elements ids
3830 # @param Vector the direction of translation (DirStruct or vector)
3831 # @param MakeGroups forces the generation of new groups from existing ones
3832 # @param NewMeshName the name of the newly created mesh
3833 # @return instance of Mesh class
3834 # @ingroup l2_modif_trsf
3835 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3836 if IDsOfElements == []:
3837 IDsOfElements = self.GetElementsId()
3838 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3839 Vector = self.smeshpyD.GetDirStruct(Vector)
3840 Vector,Parameters = ParseDirStruct(Vector)
3841 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3842 mesh.SetParameters(Parameters)
3843 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3845 ## Translates the object
3846 # @param theObject the object to translate (mesh, submesh, or group)
3847 # @param Vector direction of translation (DirStruct or geom vector)
3848 # @param Copy allows copying the translated elements
3849 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3850 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3851 # @ingroup l2_modif_trsf
3852 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3853 if ( isinstance( theObject, Mesh )):
3854 theObject = theObject.GetMesh()
3855 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3856 Vector = self.smeshpyD.GetDirStruct(Vector)
3857 Vector,Parameters = ParseDirStruct(Vector)
3858 self.mesh.SetParameters(Parameters)
3859 if Copy and MakeGroups:
3860 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3861 self.editor.TranslateObject(theObject, Vector, Copy)
3864 ## Creates a new mesh from the translated object
3865 # @param theObject the object to translate (mesh, submesh, or group)
3866 # @param Vector the direction of translation (DirStruct or geom vector)
3867 # @param MakeGroups forces the generation of new groups from existing ones
3868 # @param NewMeshName the name of the newly created mesh
3869 # @return instance of Mesh class
3870 # @ingroup l2_modif_trsf
3871 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3872 if (isinstance(theObject, Mesh)):
3873 theObject = theObject.GetMesh()
3874 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3875 Vector = self.smeshpyD.GetDirStruct(Vector)
3876 Vector,Parameters = ParseDirStruct(Vector)
3877 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3878 mesh.SetParameters(Parameters)
3879 return Mesh( self.smeshpyD, self.geompyD, mesh )
3883 ## Scales the 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 Copy - allows copying the translated elements
3888 # @param MakeGroups - forces the generation of new groups from existing
3890 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3891 # empty list otherwise
3892 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3893 if ( isinstance( theObject, Mesh )):
3894 theObject = theObject.GetMesh()
3895 if ( isinstance( theObject, list )):
3896 theObject = self.GetIDSource(theObject, SMESH.ALL)
3898 thePoint, Parameters = ParsePointStruct(thePoint)
3899 self.mesh.SetParameters(Parameters)
3901 if Copy and MakeGroups:
3902 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3903 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3906 ## Creates a new mesh from the translated object
3907 # @param theObject - the object to translate (mesh, submesh, or group)
3908 # @param thePoint - base point for scale
3909 # @param theScaleFact - list of 1-3 scale factors for axises
3910 # @param MakeGroups - forces the generation of new groups from existing ones
3911 # @param NewMeshName - the name of the newly created mesh
3912 # @return instance of Mesh class
3913 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3914 if (isinstance(theObject, Mesh)):
3915 theObject = theObject.GetMesh()
3916 if ( isinstance( theObject, list )):
3917 theObject = self.GetIDSource(theObject,SMESH.ALL)
3919 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3920 MakeGroups, NewMeshName)
3921 #mesh.SetParameters(Parameters)
3922 return Mesh( self.smeshpyD, self.geompyD, mesh )
3926 ## Rotates the elements
3927 # @param IDsOfElements list of elements ids
3928 # @param Axis the axis of rotation (AxisStruct or geom line)
3929 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3930 # @param Copy allows copying the rotated elements
3931 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3932 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3933 # @ingroup l2_modif_trsf
3934 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3936 if isinstance(AngleInRadians,str):
3938 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3940 AngleInRadians = DegreesToRadians(AngleInRadians)
3941 if IDsOfElements == []:
3942 IDsOfElements = self.GetElementsId()
3943 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3944 Axis = self.smeshpyD.GetAxisStruct(Axis)
3945 Axis,AxisParameters = ParseAxisStruct(Axis)
3946 Parameters = AxisParameters + var_separator + Parameters
3947 self.mesh.SetParameters(Parameters)
3948 if Copy and MakeGroups:
3949 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3950 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3953 ## Creates a new mesh of rotated elements
3954 # @param IDsOfElements list of element ids
3955 # @param Axis the axis of rotation (AxisStruct or geom line)
3956 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3957 # @param MakeGroups forces the generation of new groups from existing ones
3958 # @param NewMeshName the name of the newly created mesh
3959 # @return instance of Mesh class
3960 # @ingroup l2_modif_trsf
3961 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3963 if isinstance(AngleInRadians,str):
3965 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3967 AngleInRadians = DegreesToRadians(AngleInRadians)
3968 if IDsOfElements == []:
3969 IDsOfElements = self.GetElementsId()
3970 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3971 Axis = self.smeshpyD.GetAxisStruct(Axis)
3972 Axis,AxisParameters = ParseAxisStruct(Axis)
3973 Parameters = AxisParameters + var_separator + Parameters
3974 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3975 MakeGroups, NewMeshName)
3976 mesh.SetParameters(Parameters)
3977 return Mesh( self.smeshpyD, self.geompyD, mesh )
3979 ## Rotates the object
3980 # @param theObject the object to rotate( mesh, submesh, or group)
3981 # @param Axis the axis of rotation (AxisStruct or geom line)
3982 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3983 # @param Copy allows copying the rotated elements
3984 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3985 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3986 # @ingroup l2_modif_trsf
3987 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3989 if isinstance(AngleInRadians,str):
3991 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3993 AngleInRadians = DegreesToRadians(AngleInRadians)
3994 if (isinstance(theObject, Mesh)):
3995 theObject = theObject.GetMesh()
3996 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3997 Axis = self.smeshpyD.GetAxisStruct(Axis)
3998 Axis,AxisParameters = ParseAxisStruct(Axis)
3999 Parameters = AxisParameters + ":" + Parameters
4000 self.mesh.SetParameters(Parameters)
4001 if Copy and MakeGroups:
4002 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
4003 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
4006 ## Creates a new mesh from the rotated object
4007 # @param theObject the object to rotate (mesh, submesh, or group)
4008 # @param Axis the axis of rotation (AxisStruct or geom line)
4009 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
4010 # @param MakeGroups forces the generation of new groups from existing ones
4011 # @param NewMeshName the name of the newly created mesh
4012 # @return instance of Mesh class
4013 # @ingroup l2_modif_trsf
4014 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
4016 if isinstance(AngleInRadians,str):
4018 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
4020 AngleInRadians = DegreesToRadians(AngleInRadians)
4021 if (isinstance( theObject, Mesh )):
4022 theObject = theObject.GetMesh()
4023 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
4024 Axis = self.smeshpyD.GetAxisStruct(Axis)
4025 Axis,AxisParameters = ParseAxisStruct(Axis)
4026 Parameters = AxisParameters + ":" + Parameters
4027 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
4028 MakeGroups, NewMeshName)
4029 mesh.SetParameters(Parameters)
4030 return Mesh( self.smeshpyD, self.geompyD, mesh )
4032 ## Finds groups of ajacent nodes within Tolerance.
4033 # @param Tolerance the value of tolerance
4034 # @return the list of groups of nodes
4035 # @ingroup l2_modif_trsf
4036 def FindCoincidentNodes (self, Tolerance):
4037 return self.editor.FindCoincidentNodes(Tolerance)
4039 ## Finds groups of ajacent nodes within Tolerance.
4040 # @param Tolerance the value of tolerance
4041 # @param SubMeshOrGroup SubMesh or Group
4042 # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
4043 # @return the list of groups of nodes
4044 # @ingroup l2_modif_trsf
4045 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
4046 if (isinstance( SubMeshOrGroup, Mesh )):
4047 SubMeshOrGroup = SubMeshOrGroup.GetMesh()
4048 if not isinstance( exceptNodes, list):
4049 exceptNodes = [ exceptNodes ]
4050 if exceptNodes and isinstance( exceptNodes[0], int):
4051 exceptNodes = [ self.GetIDSource( exceptNodes, SMESH.NODE)]
4052 return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes)
4055 # @param GroupsOfNodes the list of groups of nodes
4056 # @ingroup l2_modif_trsf
4057 def MergeNodes (self, GroupsOfNodes):
4058 self.editor.MergeNodes(GroupsOfNodes)
4060 ## Finds the elements built on the same nodes.
4061 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
4062 # @return a list of groups of equal elements
4063 # @ingroup l2_modif_trsf
4064 def FindEqualElements (self, MeshOrSubMeshOrGroup):
4065 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
4066 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
4067 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
4069 ## Merges elements in each given group.
4070 # @param GroupsOfElementsID groups of elements for merging
4071 # @ingroup l2_modif_trsf
4072 def MergeElements(self, GroupsOfElementsID):
4073 self.editor.MergeElements(GroupsOfElementsID)
4075 ## Leaves one element and removes all other elements built on the same nodes.
4076 # @ingroup l2_modif_trsf
4077 def MergeEqualElements(self):
4078 self.editor.MergeEqualElements()
4080 ## Sews free borders
4081 # @return SMESH::Sew_Error
4082 # @ingroup l2_modif_trsf
4083 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
4084 FirstNodeID2, SecondNodeID2, LastNodeID2,
4085 CreatePolygons, CreatePolyedrs):
4086 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
4087 FirstNodeID2, SecondNodeID2, LastNodeID2,
4088 CreatePolygons, CreatePolyedrs)
4090 ## Sews conform free borders
4091 # @return SMESH::Sew_Error
4092 # @ingroup l2_modif_trsf
4093 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
4094 FirstNodeID2, SecondNodeID2):
4095 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
4096 FirstNodeID2, SecondNodeID2)
4098 ## Sews border to side
4099 # @return SMESH::Sew_Error
4100 # @ingroup l2_modif_trsf
4101 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
4102 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
4103 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
4104 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
4106 ## Sews two sides of a mesh. The nodes belonging to Side1 are
4107 # merged with the nodes of elements of Side2.
4108 # The number of elements in theSide1 and in theSide2 must be
4109 # equal and they should have similar nodal connectivity.
4110 # The nodes to merge should belong to side borders and
4111 # the first node should be linked to the second.
4112 # @return SMESH::Sew_Error
4113 # @ingroup l2_modif_trsf
4114 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
4115 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
4116 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
4117 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
4118 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
4119 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
4121 ## Sets new nodes for the given element.
4122 # @param ide the element id
4123 # @param newIDs nodes ids
4124 # @return If the number of nodes does not correspond to the type of element - returns false
4125 # @ingroup l2_modif_edit
4126 def ChangeElemNodes(self, ide, newIDs):
4127 return self.editor.ChangeElemNodes(ide, newIDs)
4129 ## If during the last operation of MeshEditor some nodes were
4130 # created, this method returns the list of their IDs, \n
4131 # if new nodes were not created - returns empty list
4132 # @return the list of integer values (can be empty)
4133 # @ingroup l1_auxiliary
4134 def GetLastCreatedNodes(self):
4135 return self.editor.GetLastCreatedNodes()
4137 ## If during the last operation of MeshEditor some elements were
4138 # created this method returns the list of their IDs, \n
4139 # if new elements were not created - returns empty list
4140 # @return the list of integer values (can be empty)
4141 # @ingroup l1_auxiliary
4142 def GetLastCreatedElems(self):
4143 return self.editor.GetLastCreatedElems()
4145 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4146 # @param theNodes identifiers of nodes to be doubled
4147 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
4148 # nodes. If list of element identifiers is empty then nodes are doubled but
4149 # they not assigned to elements
4150 # @return TRUE if operation has been completed successfully, FALSE otherwise
4151 # @ingroup l2_modif_edit
4152 def DoubleNodes(self, theNodes, theModifiedElems):
4153 return self.editor.DoubleNodes(theNodes, theModifiedElems)
4155 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4156 # This method provided for convenience works as DoubleNodes() described above.
4157 # @param theNodeId identifiers of node to be doubled
4158 # @param theModifiedElems identifiers of elements to be updated
4159 # @return TRUE if operation has been completed successfully, FALSE otherwise
4160 # @ingroup l2_modif_edit
4161 def DoubleNode(self, theNodeId, theModifiedElems):
4162 return self.editor.DoubleNode(theNodeId, theModifiedElems)
4164 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4165 # This method provided for convenience works as DoubleNodes() described above.
4166 # @param theNodes group of nodes to be doubled
4167 # @param theModifiedElems group of elements to be updated.
4168 # @param theMakeGroup forces the generation of a group containing new nodes.
4169 # @return TRUE or a created group if operation has been completed successfully,
4170 # FALSE or None otherwise
4171 # @ingroup l2_modif_edit
4172 def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
4174 return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
4175 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
4177 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4178 # This method provided for convenience works as DoubleNodes() described above.
4179 # @param theNodes list of groups of nodes to be doubled
4180 # @param theModifiedElems list of groups of elements to be updated.
4181 # @param theMakeGroup forces the generation of a group containing new nodes.
4182 # @return TRUE if operation has been completed successfully, FALSE otherwise
4183 # @ingroup l2_modif_edit
4184 def DoubleNodeGroups(self, theNodes, theModifiedElems, theMakeGroup=False):
4186 return self.editor.DoubleNodeGroupsNew(theNodes, theModifiedElems)
4187 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
4189 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4190 # @param theElems - the list of elements (edges or faces) to be replicated
4191 # The nodes for duplication could be found from these elements
4192 # @param theNodesNot - list of nodes to NOT replicate
4193 # @param theAffectedElems - the list of elements (cells and edges) to which the
4194 # replicated nodes should be associated to.
4195 # @return TRUE if operation has been completed successfully, FALSE otherwise
4196 # @ingroup l2_modif_edit
4197 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
4198 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
4200 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4201 # @param theElems - the list of elements (edges or faces) to be replicated
4202 # The nodes for duplication could be found from these elements
4203 # @param theNodesNot - list of nodes to NOT replicate
4204 # @param theShape - shape to detect affected elements (element which geometric center
4205 # located on or inside shape).
4206 # The replicated nodes should be associated to affected elements.
4207 # @return TRUE if operation has been completed successfully, FALSE otherwise
4208 # @ingroup l2_modif_edit
4209 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
4210 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
4212 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4213 # This method provided for convenience works as DoubleNodes() described above.
4214 # @param theElems - group of of elements (edges or faces) to be replicated
4215 # @param theNodesNot - group of nodes not to replicated
4216 # @param theAffectedElems - group of elements to which the replicated nodes
4217 # should be associated to.
4218 # @param theMakeGroup forces the generation of a group containing new elements.
4219 # @return TRUE or a created group if operation has been completed successfully,
4220 # FALSE or None otherwise
4221 # @ingroup l2_modif_edit
4222 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4224 return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
4225 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
4227 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4228 # This method provided for convenience works as DoubleNodes() described above.
4229 # @param theElems - group of of elements (edges or faces) to be replicated
4230 # @param theNodesNot - group of nodes not to replicated
4231 # @param theShape - shape to detect affected elements (element which geometric center
4232 # located on or inside shape).
4233 # The replicated nodes should be associated to affected elements.
4234 # @ingroup l2_modif_edit
4235 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
4236 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
4238 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4239 # This method provided for convenience works as DoubleNodes() described above.
4240 # @param theElems - list of groups of elements (edges or faces) to be replicated
4241 # @param theNodesNot - list of groups of nodes not to replicated
4242 # @param theAffectedElems - group of elements to which the replicated nodes
4243 # should be associated to.
4244 # @param theMakeGroup forces the generation of a group containing new elements.
4245 # @return TRUE or a created group if operation has been completed successfully,
4246 # FALSE or None otherwise
4247 # @ingroup l2_modif_edit
4248 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4250 return self.editor.DoubleNodeElemGroupsNew(theElems, theNodesNot, theAffectedElems)
4251 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
4253 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4254 # This method provided for convenience works as DoubleNodes() described above.
4255 # @param theElems - list of groups of elements (edges or faces) to be replicated
4256 # @param theNodesNot - list of groups of nodes not to replicated
4257 # @param theShape - shape to detect affected elements (element which geometric center
4258 # located on or inside shape).
4259 # The replicated nodes should be associated to affected elements.
4260 # @return TRUE if operation has been completed successfully, FALSE otherwise
4261 # @ingroup l2_modif_edit
4262 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
4263 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
4265 ## Double nodes on shared faces between groups of volumes and create flat elements on demand.
4266 # The list of groups must describe a partition of the mesh volumes.
4267 # The nodes of the internal faces at the boundaries of the groups are doubled.
4268 # In option, the internal faces are replaced by flat elements.
4269 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4270 # @param theDomains - list of groups of volumes
4271 # @param createJointElems - if TRUE, create the elements
4272 # @return TRUE if operation has been completed successfully, FALSE otherwise
4273 def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems ):
4274 return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems )
4276 ## Double nodes on some external faces and create flat elements.
4277 # Flat elements are mainly used by some types of mechanic calculations.
4279 # Each group of the list must be constituted of faces.
4280 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4281 # @param theGroupsOfFaces - list of groups of faces
4282 # @return TRUE if operation has been completed successfully, FALSE otherwise
4283 def CreateFlatElementsOnFacesGroups(self, theGroupsOfFaces ):
4284 return self.editor.CreateFlatElementsOnFacesGroups( theGroupsOfFaces )
4286 def _valueFromFunctor(self, funcType, elemId):
4287 fn = self.smeshpyD.GetFunctor(funcType)
4288 fn.SetMesh(self.mesh)
4289 if fn.GetElementType() == self.GetElementType(elemId, True):
4290 val = fn.GetValue(elemId)
4295 ## Get length of 1D element.
4296 # @param elemId mesh element ID
4297 # @return element's length value
4298 # @ingroup l1_measurements
4299 def GetLength(self, elemId):
4300 return self._valueFromFunctor(SMESH.FT_Length, elemId)
4302 ## Get area of 2D element.
4303 # @param elemId mesh element ID
4304 # @return element's area value
4305 # @ingroup l1_measurements
4306 def GetArea(self, elemId):
4307 return self._valueFromFunctor(SMESH.FT_Area, elemId)
4309 ## Get volume of 3D element.
4310 # @param elemId mesh element ID
4311 # @return element's volume value
4312 # @ingroup l1_measurements
4313 def GetVolume(self, elemId):
4314 return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
4316 ## Get maximum element length.
4317 # @param elemId mesh element ID
4318 # @return element's maximum length value
4319 # @ingroup l1_measurements
4320 def GetMaxElementLength(self, elemId):
4321 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4322 ftype = SMESH.FT_MaxElementLength3D
4324 ftype = SMESH.FT_MaxElementLength2D
4325 return self._valueFromFunctor(ftype, elemId)
4327 ## Get aspect ratio of 2D or 3D element.
4328 # @param elemId mesh element ID
4329 # @return element's aspect ratio value
4330 # @ingroup l1_measurements
4331 def GetAspectRatio(self, elemId):
4332 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4333 ftype = SMESH.FT_AspectRatio3D
4335 ftype = SMESH.FT_AspectRatio
4336 return self._valueFromFunctor(ftype, elemId)
4338 ## Get warping angle of 2D element.
4339 # @param elemId mesh element ID
4340 # @return element's warping angle value
4341 # @ingroup l1_measurements
4342 def GetWarping(self, elemId):
4343 return self._valueFromFunctor(SMESH.FT_Warping, elemId)
4345 ## Get minimum angle of 2D element.
4346 # @param elemId mesh element ID
4347 # @return element's minimum angle value
4348 # @ingroup l1_measurements
4349 def GetMinimumAngle(self, elemId):
4350 return self._valueFromFunctor(SMESH.FT_MinimumAngle, elemId)
4352 ## Get taper of 2D element.
4353 # @param elemId mesh element ID
4354 # @return element's taper value
4355 # @ingroup l1_measurements
4356 def GetTaper(self, elemId):
4357 return self._valueFromFunctor(SMESH.FT_Taper, elemId)
4359 ## Get skew of 2D element.
4360 # @param elemId mesh element ID
4361 # @return element's skew value
4362 # @ingroup l1_measurements
4363 def GetSkew(self, elemId):
4364 return self._valueFromFunctor(SMESH.FT_Skew, elemId)
4366 ## The mother class to define algorithm, it is not recommended to use it directly.
4369 # @ingroup l2_algorithms
4370 class Mesh_Algorithm:
4371 # @class Mesh_Algorithm
4372 # @brief Class Mesh_Algorithm
4374 #def __init__(self,smesh):
4382 ## Finds a hypothesis in the study by its type name and parameters.
4383 # Finds only the hypotheses created in smeshpyD engine.
4384 # @return SMESH.SMESH_Hypothesis
4385 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
4386 study = smeshpyD.GetCurrentStudy()
4387 #to do: find component by smeshpyD object, not by its data type
4388 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4389 if scomp is not None:
4390 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
4391 # Check if the root label of the hypotheses exists
4392 if res and hypRoot is not None:
4393 iter = study.NewChildIterator(hypRoot)
4394 # Check all published hypotheses
4396 hypo_so_i = iter.Value()
4397 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
4398 if attr is not None:
4399 anIOR = attr.Value()
4400 hypo_o_i = salome.orb.string_to_object(anIOR)
4401 if hypo_o_i is not None:
4402 # Check if this is a hypothesis
4403 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
4404 if hypo_i is not None:
4405 # Check if the hypothesis belongs to current engine
4406 if smeshpyD.GetObjectId(hypo_i) > 0:
4407 # Check if this is the required hypothesis
4408 if hypo_i.GetName() == hypname:
4410 if CompareMethod(hypo_i, args):
4424 ## Finds the algorithm in the study by its type name.
4425 # Finds only the algorithms, which have been created in smeshpyD engine.
4426 # @return SMESH.SMESH_Algo
4427 def FindAlgorithm (self, algoname, smeshpyD):
4428 study = smeshpyD.GetCurrentStudy()
4429 #to do: find component by smeshpyD object, not by its data type
4430 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4431 if scomp is not None:
4432 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
4433 # Check if the root label of the algorithms exists
4434 if res and hypRoot is not None:
4435 iter = study.NewChildIterator(hypRoot)
4436 # Check all published algorithms
4438 algo_so_i = iter.Value()
4439 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
4440 if attr is not None:
4441 anIOR = attr.Value()
4442 algo_o_i = salome.orb.string_to_object(anIOR)
4443 if algo_o_i is not None:
4444 # Check if this is an algorithm
4445 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
4446 if algo_i is not None:
4447 # Checks if the algorithm belongs to the current engine
4448 if smeshpyD.GetObjectId(algo_i) > 0:
4449 # Check if this is the required algorithm
4450 if algo_i.GetName() == algoname:
4463 ## If the algorithm is global, returns 0; \n
4464 # else returns the submesh associated to this algorithm.
4465 def GetSubMesh(self):
4468 ## Returns the wrapped mesher.
4469 def GetAlgorithm(self):
4472 ## Gets the list of hypothesis that can be used with this algorithm
4473 def GetCompatibleHypothesis(self):
4476 mylist = self.algo.GetCompatibleHypothesis()
4479 ## Gets the name of the algorithm
4483 ## Sets the name to the algorithm
4484 def SetName(self, name):
4485 self.mesh.smeshpyD.SetName(self.algo, name)
4487 ## Gets the id of the algorithm
4489 return self.algo.GetId()
4492 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
4494 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
4495 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
4497 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
4499 self.Assign(algo, mesh, geom)
4503 def Assign(self, algo, mesh, geom):
4505 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
4509 self.geom = mesh.geom
4512 AssureGeomPublished( mesh, geom )
4514 name = GetName(geom)
4518 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
4520 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
4521 TreatHypoStatus( status, algo.GetName(), name, True )
4524 def CompareHyp (self, hyp, args):
4525 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
4528 def CompareEqualHyp (self, hyp, args):
4532 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
4533 UseExisting=0, CompareMethod=""):
4536 if CompareMethod == "": CompareMethod = self.CompareHyp
4537 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
4540 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
4546 a = a + s + str(args[i])
4550 self.mesh.smeshpyD.SetName(hypo, hyp + a)
4554 geomName = GetName(self.geom)
4555 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
4556 TreatHypoStatus( status, GetName(hypo), geomName, 0 )
4559 ## Returns entry of the shape to mesh in the study
4560 def MainShapeEntry(self):
4562 if not self.mesh or not self.mesh.GetMesh(): return entry
4563 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
4564 study = self.mesh.smeshpyD.GetCurrentStudy()
4565 ior = salome.orb.object_to_string( self.mesh.GetShape() )
4566 sobj = study.FindObjectIOR(ior)
4567 if sobj: entry = sobj.GetID()
4568 if not entry: return ""
4571 ## Defines "ViscousLayers" hypothesis to give parameters of layers of prisms to build
4572 # near mesh boundary. This hypothesis can be used by several 3D algorithms:
4573 # NETGEN 3D, GHS3D, Hexahedron(i,j,k)
4574 # @param thickness total thickness of layers of prisms
4575 # @param numberOfLayers number of layers of prisms
4576 # @param stretchFactor factor (>1.0) of growth of layer thickness towards inside of mesh
4577 # @param ignoreFaces list of geometrical faces (or their ids) not to generate layers on
4578 # @ingroup l3_hypos_additi
4579 def ViscousLayers(self, thickness, numberOfLayers, stretchFactor, ignoreFaces=[]):
4580 if not isinstance(self.algo, SMESH._objref_SMESH_3D_Algo):
4581 raise TypeError, "ViscousLayers are supported by 3D algorithms only"
4582 if not "ViscousLayers" in self.GetCompatibleHypothesis():
4583 raise TypeError, "ViscousLayers are not supported by %s"%self.algo.GetName()
4584 if ignoreFaces and isinstance( ignoreFaces[0], geompyDC.GEOM._objref_GEOM_Object ):
4585 ignoreFaces = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, f) for f in ignoreFaces ]
4586 hyp = self.Hypothesis("ViscousLayers",
4587 [thickness, numberOfLayers, stretchFactor, ignoreFaces])
4588 hyp.SetTotalThickness(thickness)
4589 hyp.SetNumberLayers(numberOfLayers)
4590 hyp.SetStretchFactor(stretchFactor)
4591 hyp.SetIgnoreFaces(ignoreFaces)
4594 ## Transform a list of ether edges or tuples (edge 1st_vertex_of_edge)
4595 # into a list acceptable to SetReversedEdges() of some 1D hypotheses
4596 # @ingroupl3_hypos_1dhyps
4597 def ReversedEdgeIndices(self, reverseList):
4599 geompy = self.mesh.geompyD
4600 for i in reverseList:
4601 if isinstance( i, int ):
4602 s = geompy.SubShapes(self.mesh.geom, [i])[0]
4603 if s.GetShapeType() != geompyDC.GEOM.EDGE:
4604 raise TypeError, "Not EDGE index given"
4606 elif isinstance( i, geompyDC.GEOM._objref_GEOM_Object ):
4607 if i.GetShapeType() != geompyDC.GEOM.EDGE:
4608 raise TypeError, "Not an EDGE given"
4609 resList.append( geompy.GetSubShapeID(self.mesh.geom, i ))
4613 if not isinstance( e, geompyDC.GEOM._objref_GEOM_Object ) or \
4614 not isinstance( v, geompyDC.GEOM._objref_GEOM_Object ):
4615 raise TypeError, "A list item must be a tuple (edge 1st_vertex_of_edge)"
4616 if v.GetShapeType() == geompyDC.GEOM.EDGE and \
4617 e.GetShapeType() == geompyDC.GEOM.VERTEX:
4619 if e.GetShapeType() != geompyDC.GEOM.EDGE or \
4620 v.GetShapeType() != geompyDC.GEOM.VERTEX:
4621 raise TypeError, "A list item must be a tuple (edge 1st_vertex_of_edge)"
4622 vFirst = FirstVertexOnCurve( e )
4623 tol = geompy.Tolerance( vFirst )[-1]
4624 if geompy.MinDistance( v, vFirst ) > 1.5*tol:
4625 resList.append( geompy.GetSubShapeID(self.mesh.geom, e ))
4627 raise TypeError, "Item must be either an edge or tuple (edge 1st_vertex_of_edge)"
4630 # Public class: Mesh_Segment
4631 # --------------------------
4633 ## Class to define a segment 1D algorithm for discretization
4636 # @ingroup l3_algos_basic
4637 class Mesh_Segment(Mesh_Algorithm):
4639 ## Private constructor.
4640 def __init__(self, mesh, geom=0):
4641 Mesh_Algorithm.__init__(self)
4642 self.Create(mesh, geom, "Regular_1D")
4644 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
4645 # @param l for the length of segments that cut an edge
4646 # @param UseExisting if ==true - searches for an existing hypothesis created with
4647 # the same parameters, else (default) - creates a new one
4648 # @param p precision, used for calculation of the number of segments.
4649 # The precision should be a positive, meaningful value within the range [0,1].
4650 # In general, the number of segments is calculated with the formula:
4651 # nb = ceil((edge_length / l) - p)
4652 # Function ceil rounds its argument to the higher integer.
4653 # So, p=0 means rounding of (edge_length / l) to the higher integer,
4654 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
4655 # p=1 means rounding of (edge_length / l) to the lower integer.
4656 # Default value is 1e-07.
4657 # @return an instance of StdMeshers_LocalLength hypothesis
4658 # @ingroup l3_hypos_1dhyps
4659 def LocalLength(self, l, UseExisting=0, p=1e-07):
4660 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
4661 CompareMethod=self.CompareLocalLength)
4667 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
4668 def CompareLocalLength(self, hyp, args):
4669 if IsEqual(hyp.GetLength(), args[0]):
4670 return IsEqual(hyp.GetPrecision(), args[1])
4673 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
4674 # @param length is optional maximal allowed length of segment, if it is omitted
4675 # the preestimated length is used that depends on geometry size
4676 # @param UseExisting if ==true - searches for an existing hypothesis created with
4677 # the same parameters, else (default) - create a new one
4678 # @return an instance of StdMeshers_MaxLength hypothesis
4679 # @ingroup l3_hypos_1dhyps
4680 def MaxSize(self, length=0.0, UseExisting=0):
4681 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
4684 hyp.SetLength(length)
4686 # set preestimated length
4687 gen = self.mesh.smeshpyD
4688 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
4689 self.mesh.GetMesh(), self.mesh.GetShape(),
4691 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
4693 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
4696 hyp.SetUsePreestimatedLength( length == 0.0 )
4699 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
4700 # @param n for the number of segments that cut an edge
4701 # @param s for the scale factor (optional)
4702 # @param reversedEdges is a list of edges to mesh using reversed orientation.
4703 # A list item can also be a tuple (edge 1st_vertex_of_edge)
4704 # @param UseExisting if ==true - searches for an existing hypothesis created with
4705 # the same parameters, else (default) - create a new one
4706 # @return an instance of StdMeshers_NumberOfSegments hypothesis
4707 # @ingroup l3_hypos_1dhyps
4708 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4709 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4710 reversedEdges, UseExisting = [], reversedEdges
4711 entry = self.MainShapeEntry()
4712 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
4714 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdgeInd, entry],
4715 UseExisting=UseExisting,
4716 CompareMethod=self.CompareNumberOfSegments)
4718 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdgeInd, entry],
4719 UseExisting=UseExisting,
4720 CompareMethod=self.CompareNumberOfSegments)
4721 hyp.SetDistrType( 1 )
4722 hyp.SetScaleFactor(s)
4723 hyp.SetNumberOfSegments(n)
4724 hyp.SetReversedEdges( reversedEdgeInd )
4725 hyp.SetObjectEntry( entry )
4729 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4730 def CompareNumberOfSegments(self, hyp, args):
4731 if hyp.GetNumberOfSegments() == args[0]:
4733 if hyp.GetReversedEdges() == args[1]:
4734 if not args[1] or hyp.GetObjectEntry() == args[2]:
4737 if hyp.GetReversedEdges() == args[2]:
4738 if not args[2] or hyp.GetObjectEntry() == args[3]:
4739 if hyp.GetDistrType() == 1:
4740 if IsEqual(hyp.GetScaleFactor(), args[1]):
4744 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4745 # @param start defines the length of the first segment
4746 # @param end defines the length of the last segment
4747 # @param reversedEdges is a list of edges to mesh using reversed orientation.
4748 # A list item can also be a tuple (edge 1st_vertex_of_edge)
4749 # @param UseExisting if ==true - searches for an existing hypothesis created with
4750 # the same parameters, else (default) - creates a new one
4751 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4752 # @ingroup l3_hypos_1dhyps
4753 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4754 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4755 reversedEdges, UseExisting = [], reversedEdges
4756 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
4757 entry = self.MainShapeEntry()
4758 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdgeInd, entry],
4759 UseExisting=UseExisting,
4760 CompareMethod=self.CompareArithmetic1D)
4761 hyp.SetStartLength(start)
4762 hyp.SetEndLength(end)
4763 hyp.SetReversedEdges( reversedEdgeInd )
4764 hyp.SetObjectEntry( entry )
4768 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4769 def CompareArithmetic1D(self, hyp, args):
4770 if IsEqual(hyp.GetLength(1), args[0]):
4771 if IsEqual(hyp.GetLength(0), args[1]):
4772 if hyp.GetReversedEdges() == args[2]:
4773 if not args[2] or hyp.GetObjectEntry() == args[3]:
4778 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4779 # on curve from 0 to 1 (additionally it is neecessary to check
4780 # orientation of edges and create list of reversed edges if it is
4781 # needed) and sets numbers of segments between given points (default
4782 # values are equals 1
4783 # @param points defines the list of parameters on curve
4784 # @param nbSegs defines the list of numbers of segments
4785 # @param reversedEdges is a list of edges to mesh using reversed orientation.
4786 # A list item can also be a tuple (edge 1st_vertex_of_edge)
4787 # @param UseExisting if ==true - searches for an existing hypothesis created with
4788 # the same parameters, else (default) - creates a new one
4789 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4790 # @ingroup l3_hypos_1dhyps
4791 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4792 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4793 reversedEdges, UseExisting = [], reversedEdges
4794 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
4795 entry = self.MainShapeEntry()
4796 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdgeInd, entry],
4797 UseExisting=UseExisting,
4798 CompareMethod=self.CompareFixedPoints1D)
4799 hyp.SetPoints(points)
4800 hyp.SetNbSegments(nbSegs)
4801 hyp.SetReversedEdges(reversedEdgeInd)
4802 hyp.SetObjectEntry(entry)
4806 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4807 ## as the given arguments
4808 def CompareFixedPoints1D(self, hyp, args):
4809 if hyp.GetPoints() == args[0]:
4810 if hyp.GetNbSegments() == args[1]:
4811 if hyp.GetReversedEdges() == args[2]:
4812 if not args[2] or hyp.GetObjectEntry() == args[3]:
4818 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4819 # @param start defines the length of the first segment
4820 # @param end defines the length of the last segment
4821 # @param reversedEdges is a list of edges to mesh using reversed orientation.
4822 # A list item can also be a tuple (edge 1st_vertex_of_edge)
4823 # @param UseExisting if ==true - searches for an existing hypothesis created with
4824 # the same parameters, else (default) - creates a new one
4825 # @return an instance of StdMeshers_StartEndLength hypothesis
4826 # @ingroup l3_hypos_1dhyps
4827 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4828 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4829 reversedEdges, UseExisting = [], reversedEdges
4830 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
4831 entry = self.MainShapeEntry()
4832 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdgeInd, entry],
4833 UseExisting=UseExisting,
4834 CompareMethod=self.CompareStartEndLength)
4835 hyp.SetStartLength(start)
4836 hyp.SetEndLength(end)
4837 hyp.SetReversedEdges( reversedEdgeInd )
4838 hyp.SetObjectEntry( entry )
4841 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4842 def CompareStartEndLength(self, hyp, args):
4843 if IsEqual(hyp.GetLength(1), args[0]):
4844 if IsEqual(hyp.GetLength(0), args[1]):
4845 if hyp.GetReversedEdges() == args[2]:
4846 if not args[2] or hyp.GetObjectEntry() == args[3]:
4850 ## Defines "Deflection1D" hypothesis
4851 # @param d for the deflection
4852 # @param UseExisting if ==true - searches for an existing hypothesis created with
4853 # the same parameters, else (default) - create a new one
4854 # @ingroup l3_hypos_1dhyps
4855 def Deflection1D(self, d, UseExisting=0):
4856 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4857 CompareMethod=self.CompareDeflection1D)
4858 hyp.SetDeflection(d)
4861 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4862 def CompareDeflection1D(self, hyp, args):
4863 return IsEqual(hyp.GetDeflection(), args[0])
4865 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4866 # the opposite side in case of quadrangular faces
4867 # @ingroup l3_hypos_additi
4868 def Propagation(self):
4869 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4871 ## Defines "AutomaticLength" hypothesis
4872 # @param fineness for the fineness [0-1]
4873 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4874 # same parameters, else (default) - create a new one
4875 # @ingroup l3_hypos_1dhyps
4876 def AutomaticLength(self, fineness=0, UseExisting=0):
4877 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4878 CompareMethod=self.CompareAutomaticLength)
4879 hyp.SetFineness( fineness )
4882 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4883 def CompareAutomaticLength(self, hyp, args):
4884 return IsEqual(hyp.GetFineness(), args[0])
4886 ## Defines "SegmentLengthAroundVertex" hypothesis
4887 # @param length for the segment length
4888 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4889 # Any other integer value means that the hypothesis will be set on the
4890 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4891 # @param UseExisting if ==true - searches for an existing hypothesis created with
4892 # the same parameters, else (default) - creates a new one
4893 # @ingroup l3_algos_segmarv
4894 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4896 store_geom = self.geom
4897 if type(vertex) is types.IntType:
4898 if vertex == 0 or vertex == 1:
4899 vertex = self.mesh.geompyD.ExtractShapes(self.geom, geompyDC.ShapeType["VERTEX"],True)[vertex]
4907 if self.geom is None:
4908 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4909 AssureGeomPublished( self.mesh, self.geom )
4910 name = GetName(self.geom)
4912 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4914 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4916 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4917 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4919 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4920 CompareMethod=self.CompareLengthNearVertex)
4921 self.geom = store_geom
4922 hyp.SetLength( length )
4925 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4926 # @ingroup l3_algos_segmarv
4927 def CompareLengthNearVertex(self, hyp, args):
4928 return IsEqual(hyp.GetLength(), args[0])
4930 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4931 # If the 2D mesher sees that all boundary edges are quadratic,
4932 # it generates quadratic faces, else it generates linear faces using
4933 # medium nodes as if they are vertices.
4934 # The 3D mesher generates quadratic volumes only if all boundary faces
4935 # are quadratic, else it fails.
4937 # @ingroup l3_hypos_additi
4938 def QuadraticMesh(self):
4939 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4942 # Public class: Mesh_CompositeSegment
4943 # --------------------------
4945 ## Defines a segment 1D algorithm for discretization
4947 # @ingroup l3_algos_basic
4948 class Mesh_CompositeSegment(Mesh_Segment):
4950 ## Private constructor.
4951 def __init__(self, mesh, geom=0):
4952 self.Create(mesh, geom, "CompositeSegment_1D")
4955 # Public class: Mesh_Segment_Python
4956 # ---------------------------------
4958 ## Defines a segment 1D algorithm for discretization with python function
4960 # @ingroup l3_algos_basic
4961 class Mesh_Segment_Python(Mesh_Segment):
4963 ## Private constructor.
4964 def __init__(self, mesh, geom=0):
4965 import Python1dPlugin
4966 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4968 ## Defines "PythonSplit1D" hypothesis
4969 # @param n for the number of segments that cut an edge
4970 # @param func for the python function that calculates the length of all segments
4971 # @param UseExisting if ==true - searches for the existing hypothesis created with
4972 # the same parameters, else (default) - creates a new one
4973 # @ingroup l3_hypos_1dhyps
4974 def PythonSplit1D(self, n, func, UseExisting=0):
4975 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4976 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4977 hyp.SetNumberOfSegments(n)
4978 hyp.SetPythonLog10RatioFunction(func)
4981 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4982 def ComparePythonSplit1D(self, hyp, args):
4983 #if hyp.GetNumberOfSegments() == args[0]:
4984 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4988 # Public class: Mesh_Triangle
4989 # ---------------------------
4991 ## Defines a triangle 2D algorithm
4993 # @ingroup l3_algos_basic
4994 class Mesh_Triangle(Mesh_Algorithm):
5003 ## Private constructor.
5004 def __init__(self, mesh, algoType, geom=0):
5005 Mesh_Algorithm.__init__(self)
5007 if algoType == MEFISTO:
5008 self.Create(mesh, geom, "MEFISTO_2D")
5010 elif algoType == BLSURF:
5012 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
5013 #self.SetPhysicalMesh() - PAL19680
5014 elif algoType == NETGEN:
5016 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
5018 elif algoType == NETGEN_2D:
5020 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
5023 self.algoType = algoType
5025 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
5026 # @param area for the maximum area of each triangle
5027 # @param UseExisting if ==true - searches for an existing hypothesis created with the
5028 # same parameters, else (default) - creates a new one
5030 # Only for algoType == MEFISTO || NETGEN_2D
5031 # @ingroup l3_hypos_2dhyps
5032 def MaxElementArea(self, area, UseExisting=0):
5033 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
5034 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
5035 CompareMethod=self.CompareMaxElementArea)
5036 elif self.algoType == NETGEN:
5037 hyp = self.Parameters(SIMPLE)
5038 hyp.SetMaxElementArea(area)
5041 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
5042 def CompareMaxElementArea(self, hyp, args):
5043 return IsEqual(hyp.GetMaxElementArea(), args[0])
5045 ## Defines "LengthFromEdges" hypothesis to build triangles
5046 # based on the length of the edges taken from the wire
5048 # Only for algoType == MEFISTO || NETGEN_2D
5049 # @ingroup l3_hypos_2dhyps
5050 def LengthFromEdges(self):
5051 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
5052 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
5054 elif self.algoType == NETGEN:
5055 hyp = self.Parameters(SIMPLE)
5056 hyp.LengthFromEdges()
5059 ## Sets a way to define size of mesh elements to generate.
5060 # @param thePhysicalMesh is: DefaultSize, BLSURF_Custom or SizeMap.
5061 # @ingroup l3_hypos_blsurf
5062 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
5063 if self.Parameters():
5064 # Parameter of BLSURF algo
5065 self.params.SetPhysicalMesh(thePhysicalMesh)
5067 ## Sets size of mesh elements to generate.
5068 # @ingroup l3_hypos_blsurf
5069 def SetPhySize(self, theVal):
5070 if self.Parameters():
5071 # Parameter of BLSURF algo
5072 self.params.SetPhySize(theVal)
5074 ## Sets lower boundary of mesh element size (PhySize).
5075 # @ingroup l3_hypos_blsurf
5076 def SetPhyMin(self, theVal=-1):
5077 if self.Parameters():
5078 # Parameter of BLSURF algo
5079 self.params.SetPhyMin(theVal)
5081 ## Sets upper boundary of mesh element size (PhySize).
5082 # @ingroup l3_hypos_blsurf
5083 def SetPhyMax(self, theVal=-1):
5084 if self.Parameters():
5085 # Parameter of BLSURF algo
5086 self.params.SetPhyMax(theVal)
5088 ## Sets a way to define maximum angular deflection of mesh from CAD model.
5089 # @param theGeometricMesh is: 0 (None) or 1 (Custom)
5090 # @ingroup l3_hypos_blsurf
5091 def SetGeometricMesh(self, theGeometricMesh=0):
5092 if self.Parameters():
5093 # Parameter of BLSURF algo
5094 if self.params.GetPhysicalMesh() == 0: theGeometricMesh = 1
5095 self.params.SetGeometricMesh(theGeometricMesh)
5097 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
5098 # @ingroup l3_hypos_blsurf
5099 def SetAngleMeshS(self, theVal=_angleMeshS):
5100 if self.Parameters():
5101 # Parameter of BLSURF algo
5102 if self.params.GetGeometricMesh() == 0: theVal = self._angleMeshS
5103 self.params.SetAngleMeshS(theVal)
5105 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
5106 # @ingroup l3_hypos_blsurf
5107 def SetAngleMeshC(self, theVal=_angleMeshS):
5108 if self.Parameters():
5109 # Parameter of BLSURF algo
5110 if self.params.GetGeometricMesh() == 0: theVal = self._angleMeshS
5111 self.params.SetAngleMeshC(theVal)
5113 ## Sets lower boundary of mesh element size computed to respect angular deflection.
5114 # @ingroup l3_hypos_blsurf
5115 def SetGeoMin(self, theVal=-1):
5116 if self.Parameters():
5117 # Parameter of BLSURF algo
5118 self.params.SetGeoMin(theVal)
5120 ## Sets upper boundary of mesh element size computed to respect angular deflection.
5121 # @ingroup l3_hypos_blsurf
5122 def SetGeoMax(self, theVal=-1):
5123 if self.Parameters():
5124 # Parameter of BLSURF algo
5125 self.params.SetGeoMax(theVal)
5127 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
5128 # @ingroup l3_hypos_blsurf
5129 def SetGradation(self, theVal=_gradation):
5130 if self.Parameters():
5131 # Parameter of BLSURF algo
5132 if self.params.GetGeometricMesh() == 0: theVal = self._gradation
5133 self.params.SetGradation(theVal)
5135 ## Sets topology usage way.
5136 # @param way defines how mesh conformity is assured <ul>
5137 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
5138 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
5139 # <li>PreCAD - by pre-processing with PreCAD a CAD model</li></ul>
5140 # @ingroup l3_hypos_blsurf
5141 def SetTopology(self, way):
5142 if self.Parameters():
5143 # Parameter of BLSURF algo
5144 self.params.SetTopology(way)
5146 ## To respect geometrical edges or not.
5147 # @ingroup l3_hypos_blsurf
5148 def SetDecimesh(self, toIgnoreEdges=False):
5149 if self.Parameters():
5150 # Parameter of BLSURF algo
5151 self.params.SetDecimesh(toIgnoreEdges)
5153 ## Sets verbosity level in the range 0 to 100.
5154 # @ingroup l3_hypos_blsurf
5155 def SetVerbosity(self, level):
5156 if self.Parameters():
5157 # Parameter of BLSURF algo
5158 self.params.SetVerbosity(level)
5160 ## To optimize merges edges.
5161 # @ingroup l3_hypos_blsurf
5162 def SetPreCADMergeEdges(self, toMergeEdges=False):
5163 if self.Parameters():
5164 # Parameter of BLSURF algo
5165 self.params.SetPreCADMergeEdges(toMergeEdges)
5167 ## To remove nano edges.
5168 # @ingroup l3_hypos_blsurf
5169 def SetPreCADRemoveNanoEdges(self, toRemoveNanoEdges=False):
5170 if self.Parameters():
5171 # Parameter of BLSURF algo
5172 self.params.SetPreCADRemoveNanoEdges(toRemoveNanoEdges)
5174 ## To compute topology from scratch
5175 # @ingroup l3_hypos_blsurf
5176 def SetPreCADDiscardInput(self, toDiscardInput=False):
5177 if self.Parameters():
5178 # Parameter of BLSURF algo
5179 self.params.SetPreCADDiscardInput(toDiscardInput)
5181 ## Sets the length below which an edge is considered as nano
5182 # for the topology processing.
5183 # @ingroup l3_hypos_blsurf
5184 def SetPreCADEpsNano(self, epsNano):
5185 if self.Parameters():
5186 # Parameter of BLSURF algo
5187 self.params.SetPreCADEpsNano(epsNano)
5189 ## Sets advanced option value.
5190 # @ingroup l3_hypos_blsurf
5191 def SetOptionValue(self, optionName, level):
5192 if self.Parameters():
5193 # Parameter of BLSURF algo
5194 self.params.SetOptionValue(optionName,level)
5196 ## Sets advanced PreCAD option value.
5197 # Keyword arguments:
5198 # optionName: name of the option
5199 # optionValue: value of the option
5200 # @ingroup l3_hypos_blsurf
5201 def SetPreCADOptionValue(self, optionName, optionValue):
5202 if self.Parameters():
5203 # Parameter of BLSURF algo
5204 self.params.SetPreCADOptionValue(optionName,optionValue)
5206 ## Sets GMF file for export at computation
5207 # @ingroup l3_hypos_blsurf
5208 def SetGMFFile(self, fileName):
5209 if self.Parameters():
5210 # Parameter of BLSURF algo
5211 self.params.SetGMFFile(fileName)
5213 ## Enforced vertices (BLSURF)
5215 ## To get all the enforced vertices
5216 # @ingroup l3_hypos_blsurf
5217 def GetAllEnforcedVertices(self):
5218 if self.Parameters():
5219 # Parameter of BLSURF algo
5220 return self.params.GetAllEnforcedVertices()
5222 ## To get all the enforced vertices sorted by face (or group, compound)
5223 # @ingroup l3_hypos_blsurf
5224 def GetAllEnforcedVerticesByFace(self):
5225 if self.Parameters():
5226 # Parameter of BLSURF algo
5227 return self.params.GetAllEnforcedVerticesByFace()
5229 ## To get all the enforced vertices sorted by coords of input vertices
5230 # @ingroup l3_hypos_blsurf
5231 def GetAllEnforcedVerticesByCoords(self):
5232 if self.Parameters():
5233 # Parameter of BLSURF algo
5234 return self.params.GetAllEnforcedVerticesByCoords()
5236 ## To get all the coords of input vertices sorted by face (or group, compound)
5237 # @ingroup l3_hypos_blsurf
5238 def GetAllCoordsByFace(self):
5239 if self.Parameters():
5240 # Parameter of BLSURF algo
5241 return self.params.GetAllCoordsByFace()
5243 ## To get all the enforced vertices on a face (or group, compound)
5244 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
5245 # @ingroup l3_hypos_blsurf
5246 def GetEnforcedVertices(self, theFace):
5247 if self.Parameters():
5248 # Parameter of BLSURF algo
5249 AssureGeomPublished( self.mesh, theFace )
5250 return self.params.GetEnforcedVertices(theFace)
5252 ## To clear all the enforced vertices
5253 # @ingroup l3_hypos_blsurf
5254 def ClearAllEnforcedVertices(self):
5255 if self.Parameters():
5256 # Parameter of BLSURF algo
5257 return self.params.ClearAllEnforcedVertices()
5259 ## 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.
5260 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
5261 # @param x : x coordinate
5262 # @param y : y coordinate
5263 # @param z : z coordinate
5264 # @param vertexName : name of the enforced vertex
5265 # @param groupName : name of the group
5266 # @ingroup l3_hypos_blsurf
5267 def SetEnforcedVertex(self, theFace, x, y, z, vertexName = "", groupName = ""):
5268 if self.Parameters():
5269 # Parameter of BLSURF algo
5270 AssureGeomPublished( self.mesh, theFace )
5271 if vertexName == "":
5273 return self.params.SetEnforcedVertex(theFace, x, y, z)
5275 return self.params.SetEnforcedVertexWithGroup(theFace, x, y, z, groupName)
5278 return self.params.SetEnforcedVertexNamed(theFace, x, y, z, vertexName)
5280 return self.params.SetEnforcedVertexNamedWithGroup(theFace, x, y, z, vertexName, groupName)
5282 ## To set an enforced vertex on a face (or group, compound) given a GEOM vertex, group or compound.
5283 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
5284 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
5285 # @param groupName : name of the group
5286 # @ingroup l3_hypos_blsurf
5287 def SetEnforcedVertexGeom(self, theFace, theVertex, groupName = ""):
5288 if self.Parameters():
5289 # Parameter of BLSURF algo
5290 AssureGeomPublished( self.mesh, theFace )
5291 AssureGeomPublished( self.mesh, theVertex )
5293 return self.params.SetEnforcedVertexGeom(theFace, theVertex)
5295 return self.params.SetEnforcedVertexGeomWithGroup(theFace, theVertex,groupName)
5297 ## To remove an enforced vertex on a given GEOM face (or group, compound) given the coordinates.
5298 # @param theFace : GEOM face (or group, compound) on which to remove the enforced vertex
5299 # @param x : x coordinate
5300 # @param y : y coordinate
5301 # @param z : z coordinate
5302 # @ingroup l3_hypos_blsurf
5303 def UnsetEnforcedVertex(self, theFace, x, y, z):
5304 if self.Parameters():
5305 # Parameter of BLSURF algo
5306 AssureGeomPublished( self.mesh, theFace )
5307 return self.params.UnsetEnforcedVertex(theFace, x, y, z)
5309 ## To remove an enforced vertex on a given GEOM face (or group, compound) given a GEOM vertex, group or compound.
5310 # @param theFace : GEOM face (or group, compound) on which to remove the enforced vertex
5311 # @param theVertex : GEOM vertex (or group, compound) to remove.
5312 # @ingroup l3_hypos_blsurf
5313 def UnsetEnforcedVertexGeom(self, theFace, theVertex):
5314 if self.Parameters():
5315 # Parameter of BLSURF algo
5316 AssureGeomPublished( self.mesh, theFace )
5317 AssureGeomPublished( self.mesh, theVertex )
5318 return self.params.UnsetEnforcedVertexGeom(theFace, theVertex)
5320 ## To remove all enforced vertices on a given face.
5321 # @param theFace : face (or group/compound of faces) on which to remove all enforced vertices
5322 # @ingroup l3_hypos_blsurf
5323 def UnsetEnforcedVertices(self, theFace):
5324 if self.Parameters():
5325 # Parameter of BLSURF algo
5326 AssureGeomPublished( self.mesh, theFace )
5327 return self.params.UnsetEnforcedVertices(theFace)
5329 ## Attractors (BLSURF)
5331 ## 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 ]
5332 # @param theFace : face on which the attractor will be defined
5333 # @param theAttractor : geometrical object from which the mesh size "h" decreases exponentially
5334 # @param theStartSize : mesh size on theAttractor
5335 # @param theEndSize : maximum size that will be reached on theFace
5336 # @param theInfluenceDistance : influence of the attractor ( the size grow slower on theFace if it's high)
5337 # @param theConstantSizeDistance : distance until which the mesh size will be kept constant on theFace
5338 # @ingroup l3_hypos_blsurf
5339 def SetAttractorGeom(self, theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance):
5340 if self.Parameters():
5341 # Parameter of BLSURF algo
5342 AssureGeomPublished( self.mesh, theFace )
5343 AssureGeomPublished( self.mesh, theAttractor )
5344 self.params.SetAttractorGeom(theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance)
5346 ## Unsets an attractor on the chosen face.
5347 # @param theFace : face on which the attractor has to be removed
5348 # @ingroup l3_hypos_blsurf
5349 def UnsetAttractorGeom(self, theFace):
5350 if self.Parameters():
5351 # Parameter of BLSURF algo
5352 AssureGeomPublished( self.mesh, theFace )
5353 self.params.SetAttractorGeom(theFace)
5355 ## Size maps (BLSURF)
5357 ## To set a size map on a face, edge or vertex (or group, compound) given Python function.
5358 # If theObject is a face, the function can be: def f(u,v): return u+v
5359 # If theObject is an edge, the function can be: def f(t): return t/2
5360 # If theObject is a vertex, the function can be: def f(): return 10
5361 # @param theObject : GEOM face, edge or vertex (or group, compound) on which to define a size map
5362 # @param theSizeMap : Size map defined as a string
5363 # @ingroup l3_hypos_blsurf
5364 def SetSizeMap(self, theObject, theSizeMap):
5365 if self.Parameters():
5366 # Parameter of BLSURF algo
5367 AssureGeomPublished( self.mesh, theObject )
5368 return self.params.SetSizeMap(theObject, theSizeMap)
5370 ## To remove a size map defined on a face, edge or vertex (or group, compound)
5371 # @param theObject : GEOM face, edge or vertex (or group, compound) on which to define a size map
5372 # @ingroup l3_hypos_blsurf
5373 def UnsetSizeMap(self, theObject):
5374 if self.Parameters():
5375 # Parameter of BLSURF algo
5376 AssureGeomPublished( self.mesh, theObject )
5377 return self.params.UnsetSizeMap(theObject)
5379 ## To remove all the size maps
5380 # @ingroup l3_hypos_blsurf
5381 def ClearSizeMaps(self):
5382 if self.Parameters():
5383 # Parameter of BLSURF algo
5384 return self.params.ClearSizeMaps()
5387 ## Sets QuadAllowed flag.
5388 # Only for algoType == NETGEN(NETGEN_1D2D) || NETGEN_2D || BLSURF
5389 # @ingroup l3_hypos_netgen l3_hypos_blsurf
5390 def SetQuadAllowed(self, toAllow=True):
5391 if self.algoType == NETGEN_2D:
5394 hasSimpleHyps = False
5395 simpleHyps = ["QuadranglePreference","LengthFromEdges","MaxElementArea"]
5396 for hyp in self.mesh.GetHypothesisList( self.geom ):
5397 if hyp.GetName() in simpleHyps:
5398 hasSimpleHyps = True
5399 if hyp.GetName() == "QuadranglePreference":
5400 if not toAllow: # remove QuadranglePreference
5401 self.mesh.RemoveHypothesis( self.geom, hyp )
5407 if toAllow: # add QuadranglePreference
5408 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
5413 if self.Parameters():
5414 self.params.SetQuadAllowed(toAllow)
5417 ## Defines hypothesis having several parameters
5419 # @ingroup l3_hypos_netgen
5420 def Parameters(self, which=SOLE):
5422 if self.algoType == NETGEN:
5424 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
5425 "libNETGENEngine.so", UseExisting=0)
5427 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
5428 "libNETGENEngine.so", UseExisting=0)
5429 elif self.algoType == MEFISTO:
5430 print "Mefisto algo support no multi-parameter hypothesis"
5431 elif self.algoType == NETGEN_2D:
5432 self.params = self.Hypothesis("NETGEN_Parameters_2D_ONLY", [],
5433 "libNETGENEngine.so", UseExisting=0)
5434 elif self.algoType == BLSURF:
5435 self.params = self.Hypothesis("BLSURF_Parameters", [],
5436 "libBLSURFEngine.so", UseExisting=0)
5438 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
5443 # Only for algoType == NETGEN
5444 # @ingroup l3_hypos_netgen
5445 def SetMaxSize(self, theSize):
5446 if self.Parameters():
5447 self.params.SetMaxSize(theSize)
5449 ## Sets SecondOrder flag
5451 # Only for algoType == NETGEN
5452 # @ingroup l3_hypos_netgen
5453 def SetSecondOrder(self, theVal):
5454 if self.Parameters():
5455 self.params.SetSecondOrder(theVal)
5457 ## Sets Optimize flag
5459 # Only for algoType == NETGEN
5460 # @ingroup l3_hypos_netgen
5461 def SetOptimize(self, theVal):
5462 if self.Parameters():
5463 self.params.SetOptimize(theVal)
5466 # @param theFineness is:
5467 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5469 # Only for algoType == NETGEN
5470 # @ingroup l3_hypos_netgen
5471 def SetFineness(self, theFineness):
5472 if self.Parameters():
5473 self.params.SetFineness(theFineness)
5477 # Only for algoType == NETGEN
5478 # @ingroup l3_hypos_netgen
5479 def SetGrowthRate(self, theRate):
5480 if self.Parameters():
5481 self.params.SetGrowthRate(theRate)
5483 ## Sets NbSegPerEdge
5485 # Only for algoType == NETGEN
5486 # @ingroup l3_hypos_netgen
5487 def SetNbSegPerEdge(self, theVal):
5488 if self.Parameters():
5489 self.params.SetNbSegPerEdge(theVal)
5491 ## Sets NbSegPerRadius
5493 # Only for algoType == NETGEN
5494 # @ingroup l3_hypos_netgen
5495 def SetNbSegPerRadius(self, theVal):
5496 if self.Parameters():
5497 self.params.SetNbSegPerRadius(theVal)
5499 ## Sets number of segments overriding value set by SetLocalLength()
5501 # Only for algoType == NETGEN
5502 # @ingroup l3_hypos_netgen
5503 def SetNumberOfSegments(self, theVal):
5504 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5506 ## Sets number of segments overriding value set by SetNumberOfSegments()
5508 # Only for algoType == NETGEN
5509 # @ingroup l3_hypos_netgen
5510 def SetLocalLength(self, theVal):
5511 self.Parameters(SIMPLE).SetLocalLength(theVal)
5516 # Public class: Mesh_Quadrangle
5517 # -----------------------------
5519 ## Defines a quadrangle 2D algorithm
5521 # @ingroup l3_algos_basic
5522 class Mesh_Quadrangle(Mesh_Algorithm):
5526 ## Private constructor.
5527 def __init__(self, mesh, geom=0):
5528 Mesh_Algorithm.__init__(self)
5529 self.Create(mesh, geom, "Quadrangle_2D")
5532 ## Defines "QuadrangleParameters" hypothesis
5533 # @param quadType defines the algorithm of transition between differently descretized
5534 # sides of a geometrical face:
5535 # - QUAD_STANDARD - both triangles and quadrangles are possible in the transition
5536 # area along the finer meshed sides.
5537 # - QUAD_TRIANGLE_PREF - only triangles are built in the transition area along the
5538 # finer meshed sides.
5539 # - QUAD_QUADRANGLE_PREF - only quadrangles are built in the transition area along
5540 # the finer meshed sides, iff the total quantity of segments on
5541 # all four sides of the face is even (divisible by 2).
5542 # - QUAD_QUADRANGLE_PREF_REVERSED - same as QUAD_QUADRANGLE_PREF but the transition
5543 # area is located along the coarser meshed sides.
5544 # - QUAD_REDUCED - only quadrangles are built and the transition between the sides
5545 # is made gradually, layer by layer. This type has a limitation on
5546 # the number of segments: one pair of opposite sides must have the
5547 # same number of segments, the other pair must have an even difference
5548 # between the numbers of segments on the sides.
5549 # @param triangleVertex: vertex of a trilateral geometrical face, around which triangles
5550 # will be created while other elements will be quadrangles.
5551 # Vertex can be either a GEOM_Object or a vertex ID within the
5553 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5554 # the same parameters, else (default) - creates a new one
5555 # @ingroup l3_hypos_quad
5556 def QuadrangleParameters(self, quadType=StdMeshers.QUAD_STANDARD, triangleVertex=0, UseExisting=0):
5557 vertexID = triangleVertex
5558 if isinstance( triangleVertex, geompyDC.GEOM._objref_GEOM_Object ):
5559 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, triangleVertex )
5561 compFun = lambda hyp,args: \
5562 hyp.GetQuadType() == args[0] and \
5563 ( hyp.GetTriaVertex()==args[1] or ( hyp.GetTriaVertex()<1 and args[1]<1))
5564 self.params = self.Hypothesis("QuadrangleParams", [quadType,vertexID],
5565 UseExisting = UseExisting, CompareMethod=compFun)
5567 if self.params.GetQuadType() != quadType:
5568 self.params.SetQuadType(quadType)
5570 self.params.SetTriaVertex( vertexID )
5573 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5574 # quadrangles are built in the transition area along the finer meshed sides,
5575 # iff the total quantity of segments on all four sides of the face is even.
5576 # @param reversed if True, transition area is located along the coarser meshed sides.
5577 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5578 # the same parameters, else (default) - creates a new one
5579 # @ingroup l3_hypos_quad
5580 def QuadranglePreference(self, reversed=False, UseExisting=0):
5582 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF_REVERSED,UseExisting=UseExisting)
5583 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF,UseExisting=UseExisting)
5585 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5586 # triangles are built in the transition area along the finer meshed sides.
5587 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5588 # the same parameters, else (default) - creates a new one
5589 # @ingroup l3_hypos_quad
5590 def TrianglePreference(self, UseExisting=0):
5591 return self.QuadrangleParameters(QUAD_TRIANGLE_PREF,UseExisting=UseExisting)
5593 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5594 # quadrangles are built and the transition between the sides is made gradually,
5595 # layer by layer. This type has a limitation on the number of segments: one pair
5596 # of opposite sides must have the same number of segments, the other pair must
5597 # have an even difference between the numbers of segments on the sides.
5598 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5599 # the same parameters, else (default) - creates a new one
5600 # @ingroup l3_hypos_quad
5601 def Reduced(self, UseExisting=0):
5602 return self.QuadrangleParameters(QUAD_REDUCED,UseExisting=UseExisting)
5604 ## Defines "QuadrangleParams" hypothesis with QUAD_STANDARD type of quadrangulation
5605 # @param vertex: vertex of a trilateral geometrical face, around which triangles
5606 # will be created while other elements will be quadrangles.
5607 # Vertex can be either a GEOM_Object or a vertex ID within the
5609 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5610 # the same parameters, else (default) - creates a new one
5611 # @ingroup l3_hypos_quad
5612 def TriangleVertex(self, vertex, UseExisting=0):
5613 return self.QuadrangleParameters(QUAD_STANDARD,vertex,UseExisting)
5616 # Public class: Mesh_Tetrahedron
5617 # ------------------------------
5619 ## Defines a tetrahedron 3D algorithm
5621 # @ingroup l3_algos_basic
5622 class Mesh_Tetrahedron(Mesh_Algorithm):
5627 ## Private constructor.
5628 def __init__(self, mesh, algoType, geom=0):
5629 Mesh_Algorithm.__init__(self)
5631 if algoType == NETGEN:
5633 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
5636 elif algoType == FULL_NETGEN:
5638 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5641 elif algoType == GHS3D:
5643 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
5646 elif algoType == GHS3DPRL:
5647 CheckPlugin(GHS3DPRL)
5648 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
5651 self.algoType = algoType
5653 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
5654 # @param vol for the maximum volume of each tetrahedron
5655 # @param UseExisting if ==true - searches for the existing hypothesis created with
5656 # the same parameters, else (default) - creates a new one
5657 # @ingroup l3_hypos_maxvol
5658 def MaxElementVolume(self, vol, UseExisting=0):
5659 if self.algoType == NETGEN:
5660 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
5661 CompareMethod=self.CompareMaxElementVolume)
5662 hyp.SetMaxElementVolume(vol)
5664 elif self.algoType == FULL_NETGEN:
5665 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
5668 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
5669 def CompareMaxElementVolume(self, hyp, args):
5670 return IsEqual(hyp.GetMaxElementVolume(), args[0])
5672 ## Defines hypothesis having several parameters
5674 # @ingroup l3_hypos_netgen
5675 def Parameters(self, which=SOLE):
5678 if self.algoType == FULL_NETGEN:
5680 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
5681 "libNETGENEngine.so", UseExisting=0)
5683 self.params = self.Hypothesis("NETGEN_Parameters", [],
5684 "libNETGENEngine.so", UseExisting=0)
5686 elif self.algoType == NETGEN:
5687 self.params = self.Hypothesis("NETGEN_Parameters_3D", [],
5688 "libNETGENEngine.so", UseExisting=0)
5690 elif self.algoType == GHS3D:
5691 self.params = self.Hypothesis("GHS3D_Parameters", [],
5692 "libGHS3DEngine.so", UseExisting=0)
5694 elif self.algoType == GHS3DPRL:
5695 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
5696 "libGHS3DPRLEngine.so", UseExisting=0)
5698 print "Warning: %s supports no multi-parameter hypothesis"%self.algo.GetName()
5703 # Parameter of FULL_NETGEN and NETGEN
5704 # @ingroup l3_hypos_netgen
5705 def SetMaxSize(self, theSize):
5706 self.Parameters().SetMaxSize(theSize)
5708 ## Sets SecondOrder flag
5709 # Parameter of FULL_NETGEN
5710 # @ingroup l3_hypos_netgen
5711 def SetSecondOrder(self, theVal):
5712 self.Parameters().SetSecondOrder(theVal)
5714 ## Sets Optimize flag
5715 # Parameter of FULL_NETGEN and NETGEN
5716 # @ingroup l3_hypos_netgen
5717 def SetOptimize(self, theVal):
5718 self.Parameters().SetOptimize(theVal)
5721 # @param theFineness is:
5722 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5723 # Parameter of FULL_NETGEN
5724 # @ingroup l3_hypos_netgen
5725 def SetFineness(self, theFineness):
5726 self.Parameters().SetFineness(theFineness)
5729 # Parameter of FULL_NETGEN
5730 # @ingroup l3_hypos_netgen
5731 def SetGrowthRate(self, theRate):
5732 self.Parameters().SetGrowthRate(theRate)
5734 ## Sets NbSegPerEdge
5735 # Parameter of FULL_NETGEN
5736 # @ingroup l3_hypos_netgen
5737 def SetNbSegPerEdge(self, theVal):
5738 self.Parameters().SetNbSegPerEdge(theVal)
5740 ## Sets NbSegPerRadius
5741 # Parameter of FULL_NETGEN
5742 # @ingroup l3_hypos_netgen
5743 def SetNbSegPerRadius(self, theVal):
5744 self.Parameters().SetNbSegPerRadius(theVal)
5746 ## Sets number of segments overriding value set by SetLocalLength()
5747 # Only for algoType == NETGEN_FULL
5748 # @ingroup l3_hypos_netgen
5749 def SetNumberOfSegments(self, theVal):
5750 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5752 ## Sets number of segments overriding value set by SetNumberOfSegments()
5753 # Only for algoType == NETGEN_FULL
5754 # @ingroup l3_hypos_netgen
5755 def SetLocalLength(self, theVal):
5756 self.Parameters(SIMPLE).SetLocalLength(theVal)
5758 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
5759 # Overrides value set by LengthFromEdges()
5760 # Only for algoType == NETGEN_FULL
5761 # @ingroup l3_hypos_netgen
5762 def MaxElementArea(self, area):
5763 self.Parameters(SIMPLE).SetMaxElementArea(area)
5765 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
5766 # Overrides value set by MaxElementArea()
5767 # Only for algoType == NETGEN_FULL
5768 # @ingroup l3_hypos_netgen
5769 def LengthFromEdges(self):
5770 self.Parameters(SIMPLE).LengthFromEdges()
5772 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
5773 # Overrides value set by MaxElementVolume()
5774 # Only for algoType == NETGEN_FULL
5775 # @ingroup l3_hypos_netgen
5776 def LengthFromFaces(self):
5777 self.Parameters(SIMPLE).LengthFromFaces()
5779 ## To mesh "holes" in a solid or not. Default is to mesh.
5780 # @ingroup l3_hypos_ghs3dh
5781 def SetToMeshHoles(self, toMesh):
5782 # Parameter of GHS3D
5783 if self.Parameters():
5784 self.params.SetToMeshHoles(toMesh)
5786 ## Set Optimization level:
5787 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
5788 # Strong_Optimization.
5789 # Default is Standard_Optimization
5790 # @ingroup l3_hypos_ghs3dh
5791 def SetOptimizationLevel(self, level):
5792 # Parameter of GHS3D
5793 if self.Parameters():
5794 self.params.SetOptimizationLevel(level)
5796 ## Maximal size of memory to be used by the algorithm (in Megabytes).
5797 # @ingroup l3_hypos_ghs3dh
5798 def SetMaximumMemory(self, MB):
5799 # Advanced parameter of GHS3D
5800 if self.Parameters():
5801 self.params.SetMaximumMemory(MB)
5803 ## Initial size of memory to be used by the algorithm (in Megabytes) in
5804 # automatic memory adjustment mode.
5805 # @ingroup l3_hypos_ghs3dh
5806 def SetInitialMemory(self, MB):
5807 # Advanced parameter of GHS3D
5808 if self.Parameters():
5809 self.params.SetInitialMemory(MB)
5811 ## Path to working directory.
5812 # @ingroup l3_hypos_ghs3dh
5813 def SetWorkingDirectory(self, path):
5814 # Advanced parameter of GHS3D
5815 if self.Parameters():
5816 self.params.SetWorkingDirectory(path)
5818 ## To keep working files or remove them. Log file remains in case of errors anyway.
5819 # @ingroup l3_hypos_ghs3dh
5820 def SetKeepFiles(self, toKeep):
5821 # Advanced parameter of GHS3D and GHS3DPRL
5822 if self.Parameters():
5823 self.params.SetKeepFiles(toKeep)
5825 ## To set verbose level [0-10]. <ul>
5826 #<li> 0 - no standard output,
5827 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
5828 # indicates when the final mesh is being saved. In addition the software
5829 # gives indication regarding the CPU time.
5830 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
5831 # histogram of the skin mesh, quality statistics histogram together with
5832 # the characteristics of the final mesh.</ul>
5833 # @ingroup l3_hypos_ghs3dh
5834 def SetVerboseLevel(self, level):
5835 # Advanced parameter of GHS3D
5836 if self.Parameters():
5837 self.params.SetVerboseLevel(level)
5839 ## To create new nodes.
5840 # @ingroup l3_hypos_ghs3dh
5841 def SetToCreateNewNodes(self, toCreate):
5842 # Advanced parameter of GHS3D
5843 if self.Parameters():
5844 self.params.SetToCreateNewNodes(toCreate)
5846 ## To use boundary recovery version which tries to create mesh on a very poor
5847 # quality surface mesh.
5848 # @ingroup l3_hypos_ghs3dh
5849 def SetToUseBoundaryRecoveryVersion(self, toUse):
5850 # Advanced parameter of GHS3D
5851 if self.Parameters():
5852 self.params.SetToUseBoundaryRecoveryVersion(toUse)
5854 ## Applies finite-element correction by replacing overconstrained elements where
5855 # it is possible. The process is cutting first the overconstrained edges and
5856 # second the overconstrained facets. This insure that no edges have two boundary
5857 # vertices and that no facets have three boundary vertices.
5858 # @ingroup l3_hypos_ghs3dh
5859 def SetFEMCorrection(self, toUseFem):
5860 # Advanced parameter of GHS3D
5861 if self.Parameters():
5862 self.params.SetFEMCorrection(toUseFem)
5864 ## To removes initial central point.
5865 # @ingroup l3_hypos_ghs3dh
5866 def SetToRemoveCentralPoint(self, toRemove):
5867 # Advanced parameter of GHS3D
5868 if self.Parameters():
5869 self.params.SetToRemoveCentralPoint(toRemove)
5871 ## To set an enforced vertex.
5872 # @param x : x coordinate
5873 # @param y : y coordinate
5874 # @param z : z coordinate
5875 # @param size : size of 1D element around enforced vertex
5876 # @param vertexName : name of the enforced vertex
5877 # @param groupName : name of the group
5878 # @ingroup l3_hypos_ghs3dh
5879 def SetEnforcedVertex(self, x, y, z, size, vertexName = "", groupName = ""):
5880 # Advanced parameter of GHS3D
5881 if self.Parameters():
5882 if vertexName == "":
5884 return self.params.SetEnforcedVertex(x, y, z, size)
5886 return self.params.SetEnforcedVertexWithGroup(x, y, z, size, groupName)
5889 return self.params.SetEnforcedVertexNamed(x, y, z, size, vertexName)
5891 return self.params.SetEnforcedVertexNamedWithGroup(x, y, z, size, vertexName, groupName)
5893 ## To set an enforced vertex given a GEOM vertex, group or compound.
5894 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
5895 # @param size : size of 1D element around enforced vertex
5896 # @param groupName : name of the group
5897 # @ingroup l3_hypos_ghs3dh
5898 def SetEnforcedVertexGeom(self, theVertex, size, groupName = ""):
5899 AssureGeomPublished( self.mesh, theVertex )
5900 # Advanced parameter of GHS3D
5901 if self.Parameters():
5903 return self.params.SetEnforcedVertexGeom(theVertex, size)
5905 return self.params.SetEnforcedVertexGeomWithGroup(theVertex, size, groupName)
5907 ## To remove an enforced vertex.
5908 # @param x : x coordinate
5909 # @param y : y coordinate
5910 # @param z : z coordinate
5911 # @ingroup l3_hypos_ghs3dh
5912 def RemoveEnforcedVertex(self, x, y, z):
5913 # Advanced parameter of GHS3D
5914 if self.Parameters():
5915 return self.params.RemoveEnforcedVertex(x, y, z)
5917 ## To remove an enforced vertex given a GEOM vertex, group or compound.
5918 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
5919 # @ingroup l3_hypos_ghs3dh
5920 def RemoveEnforcedVertexGeom(self, theVertex):
5921 AssureGeomPublished( self.mesh, theVertex )
5922 # Advanced parameter of GHS3D
5923 if self.Parameters():
5924 return self.params.RemoveEnforcedVertexGeom(theVertex)
5926 ## To set an enforced mesh with given size and add the enforced elements in the group "groupName".
5927 # @param theSource : source mesh which provides constraint elements/nodes
5928 # @param elementType : SMESH.ElementType (NODE, EDGE or FACE)
5929 # @param size : size of elements around enforced elements. Unused if -1.
5930 # @param groupName : group in which enforced elements will be added. Unused if "".
5931 # @ingroup l3_hypos_ghs3dh
5932 def SetEnforcedMesh(self, theSource, elementType, size = -1, groupName = ""):
5933 # Advanced parameter of GHS3D
5934 if self.Parameters():
5937 return self.params.SetEnforcedMesh(theSource, elementType)
5939 return self.params.SetEnforcedMeshWithGroup(theSource, elementType, groupName)
5942 return self.params.SetEnforcedMeshSize(theSource, elementType, size)
5944 return self.params.SetEnforcedMeshSizeWithGroup(theSource, elementType, size, groupName)
5946 ## Sets command line option as text.
5947 # @ingroup l3_hypos_ghs3dh
5948 def SetTextOption(self, option):
5949 # Advanced parameter of GHS3D
5950 if self.Parameters():
5951 self.params.SetTextOption(option)
5953 ## Sets MED files name and path.
5954 def SetMEDName(self, value):
5955 if self.Parameters():
5956 self.params.SetMEDName(value)
5958 ## Sets the number of partition of the initial mesh
5959 def SetNbPart(self, value):
5960 if self.Parameters():
5961 self.params.SetNbPart(value)
5963 ## When big mesh, start tepal in background
5964 def SetBackground(self, value):
5965 if self.Parameters():
5966 self.params.SetBackground(value)
5968 # Public class: Mesh_Hexahedron
5969 # ------------------------------
5971 ## Defines a hexahedron 3D algorithm
5973 # @ingroup l3_algos_basic
5974 class Mesh_Hexahedron(Mesh_Algorithm):
5979 ## Private constructor.
5980 def __init__(self, mesh, algoType=Hexa, geom=0):
5981 Mesh_Algorithm.__init__(self)
5983 self.algoType = algoType
5985 if algoType == Hexa:
5986 self.Create(mesh, geom, "Hexa_3D")
5989 elif algoType == Hexotic:
5990 CheckPlugin(Hexotic)
5991 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
5994 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
5995 # @ingroup l3_hypos_hexotic
5996 def MinMaxQuad(self, min=3, max=8, quad=True):
5997 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
5999 self.params.SetHexesMinLevel(min)
6000 self.params.SetHexesMaxLevel(max)
6001 self.params.SetHexoticQuadrangles(quad)
6004 # Deprecated, only for compatibility!
6005 # Public class: Mesh_Netgen
6006 # ------------------------------
6008 ## Defines a NETGEN-based 2D or 3D algorithm
6009 # that needs no discrete boundary (i.e. independent)
6011 # This class is deprecated, only for compatibility!
6014 # @ingroup l3_algos_basic
6015 class Mesh_Netgen(Mesh_Algorithm):
6019 ## Private constructor.
6020 def __init__(self, mesh, is3D, geom=0):
6021 Mesh_Algorithm.__init__(self)
6027 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
6031 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
6034 ## Defines the hypothesis containing parameters of the algorithm
6035 def Parameters(self):
6037 hyp = self.Hypothesis("NETGEN_Parameters", [],
6038 "libNETGENEngine.so", UseExisting=0)
6040 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
6041 "libNETGENEngine.so", UseExisting=0)
6044 # Public class: Mesh_Projection1D
6045 # ------------------------------
6047 ## Defines a projection 1D algorithm
6048 # @ingroup l3_algos_proj
6050 class Mesh_Projection1D(Mesh_Algorithm):
6052 ## Private constructor.
6053 def __init__(self, mesh, geom=0):
6054 Mesh_Algorithm.__init__(self)
6055 self.Create(mesh, geom, "Projection_1D")
6057 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
6058 # a mesh pattern is taken, and, optionally, the association of vertices
6059 # between the source edge and a target edge (to which a hypothesis is assigned)
6060 # @param edge from which nodes distribution is taken
6061 # @param mesh from which nodes distribution is taken (optional)
6062 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
6063 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
6064 # to associate with \a srcV (optional)
6065 # @param UseExisting if ==true - searches for the existing hypothesis created with
6066 # the same parameters, else (default) - creates a new one
6067 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
6068 AssureGeomPublished( self.mesh, edge )
6069 AssureGeomPublished( self.mesh, srcV )
6070 AssureGeomPublished( self.mesh, tgtV )
6071 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
6073 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
6074 hyp.SetSourceEdge( edge )
6075 if not mesh is None and isinstance(mesh, Mesh):
6076 mesh = mesh.GetMesh()
6077 hyp.SetSourceMesh( mesh )
6078 hyp.SetVertexAssociation( srcV, tgtV )
6081 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
6082 #def CompareSourceEdge(self, hyp, args):
6083 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
6087 # Public class: Mesh_Projection2D
6088 # ------------------------------
6090 ## Defines a projection 2D algorithm
6091 # @ingroup l3_algos_proj
6093 class Mesh_Projection2D(Mesh_Algorithm):
6095 ## Private constructor.
6096 def __init__(self, mesh, geom=0):
6097 Mesh_Algorithm.__init__(self)
6098 self.Create(mesh, geom, "Projection_2D")
6100 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
6101 # a mesh pattern is taken, and, optionally, the association of vertices
6102 # between the source face and the target face (to which a hypothesis is assigned)
6103 # @param face from which the mesh pattern is taken
6104 # @param mesh from which the mesh pattern is taken (optional)
6105 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
6106 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
6107 # to associate with \a srcV1 (optional)
6108 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
6109 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
6110 # to associate with \a srcV2 (optional)
6111 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
6112 # the same parameters, else (default) - forces the creation a new one
6114 # Note: all association vertices must belong to one edge of a face
6115 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
6116 srcV2=None, tgtV2=None, UseExisting=0):
6117 for geom in [ face, srcV1, tgtV1, srcV2, tgtV2 ]:
6118 AssureGeomPublished( self.mesh, geom )
6119 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
6121 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
6122 hyp.SetSourceFace( face )
6123 if isinstance(mesh, Mesh):
6124 mesh = mesh.GetMesh()
6125 hyp.SetSourceMesh( mesh )
6126 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
6129 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
6130 #def CompareSourceFace(self, hyp, args):
6131 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
6134 # Public class: Mesh_Projection3D
6135 # ------------------------------
6137 ## Defines a projection 3D algorithm
6138 # @ingroup l3_algos_proj
6140 class Mesh_Projection3D(Mesh_Algorithm):
6142 ## Private constructor.
6143 def __init__(self, mesh, geom=0):
6144 Mesh_Algorithm.__init__(self)
6145 self.Create(mesh, geom, "Projection_3D")
6147 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
6148 # the mesh pattern is taken, and, optionally, the association of vertices
6149 # between the source and the target solid (to which a hipothesis is assigned)
6150 # @param solid from where the mesh pattern is taken
6151 # @param mesh from where the mesh pattern is taken (optional)
6152 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
6153 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
6154 # to associate with \a srcV1 (optional)
6155 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
6156 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
6157 # to associate with \a srcV2 (optional)
6158 # @param UseExisting - if ==true - searches for the existing hypothesis created with
6159 # the same parameters, else (default) - creates a new one
6161 # Note: association vertices must belong to one edge of a solid
6162 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
6163 srcV2=0, tgtV2=0, UseExisting=0):
6164 for geom in [ solid, srcV1, tgtV1, srcV2, tgtV2 ]:
6165 AssureGeomPublished( self.mesh, geom )
6166 hyp = self.Hypothesis("ProjectionSource3D",
6167 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
6169 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
6170 hyp.SetSource3DShape( solid )
6171 if not mesh is None and isinstance(mesh, Mesh):
6172 mesh = mesh.GetMesh()
6173 hyp.SetSourceMesh( mesh )
6174 if srcV1 and srcV2 and tgtV1 and tgtV2:
6175 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
6176 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
6179 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
6180 #def CompareSourceShape3D(self, hyp, args):
6181 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
6185 # Public class: Mesh_Prism
6186 # ------------------------
6188 ## Defines a 3D extrusion algorithm
6189 # @ingroup l3_algos_3dextr
6191 class Mesh_Prism3D(Mesh_Algorithm):
6193 ## Private constructor.
6194 def __init__(self, mesh, geom=0):
6195 Mesh_Algorithm.__init__(self)
6196 self.Create(mesh, geom, "Prism_3D")
6198 # Public class: Mesh_RadialPrism
6199 # -------------------------------
6201 ## Defines a Radial Prism 3D algorithm
6202 # @ingroup l3_algos_radialp
6204 class Mesh_RadialPrism3D(Mesh_Algorithm):
6206 ## Private constructor.
6207 def __init__(self, mesh, geom=0):
6208 Mesh_Algorithm.__init__(self)
6209 self.Create(mesh, geom, "RadialPrism_3D")
6211 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
6212 self.nbLayers = None
6214 ## Return 3D hypothesis holding the 1D one
6215 def Get3DHypothesis(self):
6216 return self.distribHyp
6218 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
6219 # hypothesis. Returns the created hypothesis
6220 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
6221 #print "OwnHypothesis",hypType
6222 if not self.nbLayers is None:
6223 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
6224 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
6225 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
6226 self.mesh.smeshpyD.SetCurrentStudy( None )
6227 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
6228 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
6229 self.distribHyp.SetLayerDistribution( hyp )
6232 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
6233 # prisms to build between the inner and outer shells
6234 # @param n number of layers
6235 # @param UseExisting if ==true - searches for the existing hypothesis created with
6236 # the same parameters, else (default) - creates a new one
6237 def NumberOfLayers(self, n, UseExisting=0):
6238 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
6239 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
6240 CompareMethod=self.CompareNumberOfLayers)
6241 self.nbLayers.SetNumberOfLayers( n )
6242 return self.nbLayers
6244 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
6245 def CompareNumberOfLayers(self, hyp, args):
6246 return IsEqual(hyp.GetNumberOfLayers(), args[0])
6248 ## Defines "LocalLength" hypothesis, specifying the segment length
6249 # to build between the inner and the outer shells
6250 # @param l the length of segments
6251 # @param p the precision of rounding
6252 def LocalLength(self, l, p=1e-07):
6253 hyp = self.OwnHypothesis("LocalLength", [l,p])
6258 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
6259 # prisms to build between the inner and the outer shells.
6260 # @param n the number of layers
6261 # @param s the scale factor (optional)
6262 def NumberOfSegments(self, n, s=[]):
6264 hyp = self.OwnHypothesis("NumberOfSegments", [n])
6266 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
6267 hyp.SetDistrType( 1 )
6268 hyp.SetScaleFactor(s)
6269 hyp.SetNumberOfSegments(n)
6272 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
6273 # to build between the inner and the outer shells with a length that changes in arithmetic progression
6274 # @param start the length of the first segment
6275 # @param end the length of the last segment
6276 def Arithmetic1D(self, start, end ):
6277 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
6278 hyp.SetLength(start, 1)
6279 hyp.SetLength(end , 0)
6282 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
6283 # to build between the inner and the outer shells as geometric length increasing
6284 # @param start for the length of the first segment
6285 # @param end for the length of the last segment
6286 def StartEndLength(self, start, end):
6287 hyp = self.OwnHypothesis("StartEndLength", [start, end])
6288 hyp.SetLength(start, 1)
6289 hyp.SetLength(end , 0)
6292 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
6293 # to build between the inner and outer shells
6294 # @param fineness defines the quality of the mesh within the range [0-1]
6295 def AutomaticLength(self, fineness=0):
6296 hyp = self.OwnHypothesis("AutomaticLength")
6297 hyp.SetFineness( fineness )
6300 # Public class: Mesh_RadialQuadrangle1D2D
6301 # -------------------------------
6303 ## Defines a Radial Quadrangle 1D2D algorithm
6304 # @ingroup l2_algos_radialq
6306 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
6308 ## Private constructor.
6309 def __init__(self, mesh, geom=0):
6310 Mesh_Algorithm.__init__(self)
6311 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
6313 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
6314 self.nbLayers = None
6316 ## Return 2D hypothesis holding the 1D one
6317 def Get2DHypothesis(self):
6318 return self.distribHyp
6320 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
6321 # hypothesis. Returns the created hypothesis
6322 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
6323 #print "OwnHypothesis",hypType
6325 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
6326 if self.distribHyp is None:
6327 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
6329 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
6330 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
6331 self.mesh.smeshpyD.SetCurrentStudy( None )
6332 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
6333 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
6334 self.distribHyp.SetLayerDistribution( hyp )
6337 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
6338 # @param n number of layers
6339 # @param UseExisting if ==true - searches for the existing hypothesis created with
6340 # the same parameters, else (default) - creates a new one
6341 def NumberOfLayers(self, n, UseExisting=0):
6343 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
6344 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
6345 CompareMethod=self.CompareNumberOfLayers)
6346 self.nbLayers.SetNumberOfLayers( n )
6347 return self.nbLayers
6349 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
6350 def CompareNumberOfLayers(self, hyp, args):
6351 return IsEqual(hyp.GetNumberOfLayers(), args[0])
6353 ## Defines "LocalLength" hypothesis, specifying the segment length
6354 # @param l the length of segments
6355 # @param p the precision of rounding
6356 def LocalLength(self, l, p=1e-07):
6357 hyp = self.OwnHypothesis("LocalLength", [l,p])
6362 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
6363 # @param n the number of layers
6364 # @param s the scale factor (optional)
6365 def NumberOfSegments(self, n, s=[]):
6367 hyp = self.OwnHypothesis("NumberOfSegments", [n])
6369 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
6370 hyp.SetDistrType( 1 )
6371 hyp.SetScaleFactor(s)
6372 hyp.SetNumberOfSegments(n)
6375 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
6376 # with a length that changes in arithmetic progression
6377 # @param start the length of the first segment
6378 # @param end the length of the last segment
6379 def Arithmetic1D(self, start, end ):
6380 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
6381 hyp.SetLength(start, 1)
6382 hyp.SetLength(end , 0)
6385 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
6386 # as geometric length increasing
6387 # @param start for the length of the first segment
6388 # @param end for the length of the last segment
6389 def StartEndLength(self, start, end):
6390 hyp = self.OwnHypothesis("StartEndLength", [start, end])
6391 hyp.SetLength(start, 1)
6392 hyp.SetLength(end , 0)
6395 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
6396 # @param fineness defines the quality of the mesh within the range [0-1]
6397 def AutomaticLength(self, fineness=0):
6398 hyp = self.OwnHypothesis("AutomaticLength")
6399 hyp.SetFineness( fineness )
6403 # Public class: Mesh_UseExistingElements
6404 # --------------------------------------
6405 ## Defines a Radial Quadrangle 1D2D algorithm
6406 # @ingroup l3_algos_basic
6408 class Mesh_UseExistingElements(Mesh_Algorithm):
6410 def __init__(self, dim, mesh, geom=0):
6412 self.Create(mesh, geom, "Import_1D")
6414 self.Create(mesh, geom, "Import_1D2D")
6417 ## Defines "Source edges" hypothesis, specifying groups of edges to import
6418 # @param groups list of groups of edges
6419 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
6420 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
6421 # @param UseExisting if ==true - searches for the existing hypothesis created with
6422 # the same parameters, else (default) - creates a new one
6423 def SourceEdges(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
6424 if self.algo.GetName() != "Import_1D":
6425 raise ValueError, "algoritm dimension mismatch"
6426 for group in groups:
6427 AssureGeomPublished( self.mesh, group )
6428 hyp = self.Hypothesis("ImportSource1D", [groups, toCopyMesh, toCopyGroups],
6429 UseExisting=UseExisting, CompareMethod=self._compareHyp)
6430 hyp.SetSourceEdges(groups)
6431 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
6434 ## Defines "Source faces" hypothesis, specifying groups of faces to import
6435 # @param groups list of groups of faces
6436 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
6437 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
6438 # @param UseExisting if ==true - searches for the existing hypothesis created with
6439 # the same parameters, else (default) - creates a new one
6440 def SourceFaces(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
6441 if self.algo.GetName() == "Import_1D":
6442 raise ValueError, "algoritm dimension mismatch"
6443 for group in groups:
6444 AssureGeomPublished( self.mesh, group )
6445 hyp = self.Hypothesis("ImportSource2D", [groups, toCopyMesh, toCopyGroups],
6446 UseExisting=UseExisting, CompareMethod=self._compareHyp)
6447 hyp.SetSourceFaces(groups)
6448 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
6451 def _compareHyp(self,hyp,args):
6452 if hasattr( hyp, "GetSourceEdges"):
6453 entries = hyp.GetSourceEdges()
6455 entries = hyp.GetSourceFaces()
6457 toCopyMesh,toCopyGroups = hyp.GetCopySourceMesh()
6458 if len(entries)==len(groups) and toCopyMesh==args[1] and toCopyGroups==args[2]:
6460 study = self.mesh.smeshpyD.GetCurrentStudy()
6463 ior = salome.orb.object_to_string(g)
6464 sobj = study.FindObjectIOR(ior)
6465 if sobj: entries2.append( sobj.GetID() )
6470 return entries == entries2
6474 # Private class: Mesh_UseExisting
6475 # -------------------------------
6476 class Mesh_UseExisting(Mesh_Algorithm):
6478 def __init__(self, dim, mesh, geom=0):
6480 self.Create(mesh, geom, "UseExisting_1D")
6482 self.Create(mesh, geom, "UseExisting_2D")
6485 import salome_notebook
6486 notebook = salome_notebook.notebook
6488 ##Return values of the notebook variables
6489 def ParseParameters(last, nbParams,nbParam, value):
6493 listSize = len(last)
6494 for n in range(0,nbParams):
6496 if counter < listSize:
6497 strResult = strResult + last[counter]
6499 strResult = strResult + ""
6501 if isinstance(value, str):
6502 if notebook.isVariable(value):
6503 result = notebook.get(value)
6504 strResult=strResult+value
6506 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
6508 strResult=strResult+str(value)
6510 if nbParams - 1 != counter:
6511 strResult=strResult+var_separator #":"
6513 return result, strResult
6515 #Wrapper class for StdMeshers_LocalLength hypothesis
6516 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
6518 ## Set Length parameter value
6519 # @param length numerical value or name of variable from notebook
6520 def SetLength(self, length):
6521 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
6522 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6523 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
6525 ## Set Precision parameter value
6526 # @param precision numerical value or name of variable from notebook
6527 def SetPrecision(self, precision):
6528 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
6529 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6530 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
6532 #Registering the new proxy for LocalLength
6533 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
6536 #Wrapper class for StdMeshers_LayerDistribution hypothesis
6537 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
6539 def SetLayerDistribution(self, hypo):
6540 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
6541 hypo.ClearParameters();
6542 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
6544 #Registering the new proxy for LayerDistribution
6545 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
6547 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
6548 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
6550 ## Set Length parameter value
6551 # @param length numerical value or name of variable from notebook
6552 def SetLength(self, length):
6553 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
6554 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
6555 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
6557 #Registering the new proxy for SegmentLengthAroundVertex
6558 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
6561 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
6562 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
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_Arithmetic1D.GetLastParameters(self),2,nb,length)
6572 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
6573 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
6575 #Registering the new proxy for Arithmetic1D
6576 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
6578 #Wrapper class for StdMeshers_Deflection1D hypothesis
6579 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
6581 ## Set Deflection parameter value
6582 # @param deflection numerical value or name of variable from notebook
6583 def SetDeflection(self, deflection):
6584 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
6585 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
6586 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
6588 #Registering the new proxy for Deflection1D
6589 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
6591 #Wrapper class for StdMeshers_StartEndLength hypothesis
6592 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
6594 ## Set Length parameter value
6595 # @param length numerical value or name of variable from notebook
6596 # @param isStart true is length is Start Length, otherwise false
6597 def SetLength(self, length, isStart):
6601 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
6602 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
6603 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
6605 #Registering the new proxy for StartEndLength
6606 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
6608 #Wrapper class for StdMeshers_MaxElementArea hypothesis
6609 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
6611 ## Set Max Element Area parameter value
6612 # @param area numerical value or name of variable from notebook
6613 def SetMaxElementArea(self, area):
6614 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
6615 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
6616 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
6618 #Registering the new proxy for MaxElementArea
6619 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
6622 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
6623 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
6625 ## Set Max Element Volume parameter value
6626 # @param volume numerical value or name of variable from notebook
6627 def SetMaxElementVolume(self, volume):
6628 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
6629 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
6630 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
6632 #Registering the new proxy for MaxElementVolume
6633 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
6636 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
6637 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
6639 ## Set Number Of Layers parameter value
6640 # @param nbLayers numerical value or name of variable from notebook
6641 def SetNumberOfLayers(self, nbLayers):
6642 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
6643 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
6644 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
6646 #Registering the new proxy for NumberOfLayers
6647 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
6649 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
6650 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
6652 ## Set Number Of Segments parameter value
6653 # @param nbSeg numerical value or name of variable from notebook
6654 def SetNumberOfSegments(self, nbSeg):
6655 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
6656 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
6657 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6658 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
6660 ## Set Scale Factor parameter value
6661 # @param factor numerical value or name of variable from notebook
6662 def SetScaleFactor(self, factor):
6663 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
6664 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6665 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
6667 #Registering the new proxy for NumberOfSegments
6668 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
6670 if not noNETGENPlugin:
6671 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
6672 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
6674 ## Set Max Size parameter value
6675 # @param maxsize numerical value or name of variable from notebook
6676 def SetMaxSize(self, maxsize):
6677 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6678 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
6679 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6680 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
6682 ## Set Growth Rate parameter value
6683 # @param value numerical value or name of variable from notebook
6684 def SetGrowthRate(self, value):
6685 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6686 value, parameters = ParseParameters(lastParameters,4,2,value)
6687 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6688 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
6690 ## Set Number of Segments per Edge parameter value
6691 # @param value numerical value or name of variable from notebook
6692 def SetNbSegPerEdge(self, value):
6693 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6694 value, parameters = ParseParameters(lastParameters,4,3,value)
6695 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6696 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
6698 ## Set Number of Segments per Radius parameter value
6699 # @param value numerical value or name of variable from notebook
6700 def SetNbSegPerRadius(self, value):
6701 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6702 value, parameters = ParseParameters(lastParameters,4,4,value)
6703 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6704 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
6706 #Registering the new proxy for NETGENPlugin_Hypothesis
6707 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
6710 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
6711 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
6714 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
6715 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
6717 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
6718 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
6720 ## Set Number of Segments parameter value
6721 # @param nbSeg numerical value or name of variable from notebook
6722 def SetNumberOfSegments(self, nbSeg):
6723 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6724 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
6725 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6726 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
6728 ## Set Local Length parameter value
6729 # @param length numerical value or name of variable from notebook
6730 def SetLocalLength(self, length):
6731 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6732 length, parameters = ParseParameters(lastParameters,2,1,length)
6733 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6734 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
6736 ## Set Max Element Area parameter value
6737 # @param area numerical value or name of variable from notebook
6738 def SetMaxElementArea(self, area):
6739 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6740 area, parameters = ParseParameters(lastParameters,2,2,area)
6741 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6742 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
6744 def LengthFromEdges(self):
6745 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6747 value, parameters = ParseParameters(lastParameters,2,2,value)
6748 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6749 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
6751 #Registering the new proxy for NETGEN_SimpleParameters_2D
6752 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
6755 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
6756 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
6757 ## Set Max Element Volume parameter value
6758 # @param volume numerical value or name of variable from notebook
6759 def SetMaxElementVolume(self, volume):
6760 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6761 volume, parameters = ParseParameters(lastParameters,3,3,volume)
6762 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6763 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
6765 def LengthFromFaces(self):
6766 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6768 value, parameters = ParseParameters(lastParameters,3,3,value)
6769 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6770 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
6772 #Registering the new proxy for NETGEN_SimpleParameters_3D
6773 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
6775 pass # if not noNETGENPlugin:
6777 class Pattern(SMESH._objref_SMESH_Pattern):
6779 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
6781 if isinstance(theNodeIndexOnKeyPoint1,str):
6783 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
6785 theNodeIndexOnKeyPoint1 -= 1
6786 theMesh.SetParameters(Parameters)
6787 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
6789 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
6792 if isinstance(theNode000Index,str):
6794 if isinstance(theNode001Index,str):
6796 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
6798 theNode000Index -= 1
6800 theNode001Index -= 1
6801 theMesh.SetParameters(Parameters)
6802 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
6804 #Registering the new proxy for Pattern
6805 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)