1 # Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 # Author : Francis KLOSS, OCC
28 ## @defgroup l1_auxiliary Auxiliary methods and structures
29 ## @defgroup l1_creating Creating meshes
31 ## @defgroup l2_impexp Importing and exporting meshes
32 ## @defgroup l2_construct Constructing meshes
33 ## @defgroup l2_algorithms Defining Algorithms
35 ## @defgroup l3_algos_basic Basic meshing algorithms
36 ## @defgroup l3_algos_proj Projection Algorithms
37 ## @defgroup l3_algos_radialp Radial Prism
38 ## @defgroup l3_algos_segmarv Segments around Vertex
39 ## @defgroup l3_algos_3dextr 3D extrusion meshing algorithm
42 ## @defgroup l2_hypotheses Defining hypotheses
44 ## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
45 ## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
46 ## @defgroup l3_hypos_maxvol Max Element Volume hypothesis
47 ## @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
48 ## @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
49 ## @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
50 ## @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
51 ## @defgroup l3_hypos_quad Quadrangle Parameters hypothesis
52 ## @defgroup l3_hypos_additi Additional Hypotheses
55 ## @defgroup l2_submeshes Constructing submeshes
56 ## @defgroup l2_compounds Building Compounds
57 ## @defgroup l2_editing Editing Meshes
60 ## @defgroup l1_meshinfo Mesh Information
61 ## @defgroup l1_controls Quality controls and Filtering
62 ## @defgroup l1_grouping Grouping elements
64 ## @defgroup l2_grps_create Creating groups
65 ## @defgroup l2_grps_edit Editing groups
66 ## @defgroup l2_grps_operon Using operations on groups
67 ## @defgroup l2_grps_delete Deleting Groups
70 ## @defgroup l1_modifying Modifying meshes
72 ## @defgroup l2_modif_add Adding nodes and elements
73 ## @defgroup l2_modif_del Removing nodes and elements
74 ## @defgroup l2_modif_edit Modifying nodes and elements
75 ## @defgroup l2_modif_renumber Renumbering nodes and elements
76 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
77 ## @defgroup l2_modif_movenode Moving nodes
78 ## @defgroup l2_modif_throughp Mesh through point
79 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
80 ## @defgroup l2_modif_unitetri Uniting triangles
81 ## @defgroup l2_modif_changori Changing orientation of elements
82 ## @defgroup l2_modif_cutquadr Cutting quadrangles
83 ## @defgroup l2_modif_smooth Smoothing
84 ## @defgroup l2_modif_extrurev Extrusion and Revolution
85 ## @defgroup l2_modif_patterns Pattern mapping
86 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
89 ## @defgroup l1_measurements Measurements
94 import SMESH # This is necessary for back compatibility
102 # import NETGENPlugin module if possible
110 # import GHS3DPlugin module if possible
118 # import GHS3DPRLPlugin module if possible
121 import GHS3DPRLPlugin
126 # import HexoticPlugin module if possible
134 # import BLSURFPlugin module if possible
142 ## @addtogroup l1_auxiliary
145 # Types of algorithms
158 NETGEN_1D2D3D = FULL_NETGEN
159 NETGEN_FULL = FULL_NETGEN
167 # MirrorType enumeration
168 POINT = SMESH_MeshEditor.POINT
169 AXIS = SMESH_MeshEditor.AXIS
170 PLANE = SMESH_MeshEditor.PLANE
172 # Smooth_Method enumeration
173 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
174 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
176 # Fineness enumeration (for NETGEN)
184 # Optimization level of GHS3D
186 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
187 # V4.1 (partialy redefines V3.1). Issue 0020574
188 None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization, Strong_Optimization = 0,1,2,3,4
190 # Topology treatment way of BLSURF
191 FromCAD, PreProcess, PreProcessPlus = 0,1,2
193 # Element size flag of BLSURF
194 DefaultSize, DefaultGeom, Custom = 0,0,1
196 PrecisionConfusion = 1e-07
198 # TopAbs_State enumeration
199 [TopAbs_IN, TopAbs_OUT, TopAbs_ON, TopAbs_UNKNOWN] = range(4)
201 # Methods of splitting a hexahedron into tetrahedra
202 Hex_5Tet, Hex_6Tet, Hex_24Tet = 1, 2, 3
204 # import items of enum QuadType
205 for e in StdMeshers.QuadType._items: exec('%s = StdMeshers.%s'%(e,e))
207 ## Converts an angle from degrees to radians
208 def DegreesToRadians(AngleInDegrees):
210 return AngleInDegrees * pi / 180.0
212 # Salome notebook variable separator
215 # Parametrized substitute for PointStruct
216 class PointStructStr:
225 def __init__(self, xStr, yStr, zStr):
229 if isinstance(xStr, str) and notebook.isVariable(xStr):
230 self.x = notebook.get(xStr)
233 if isinstance(yStr, str) and notebook.isVariable(yStr):
234 self.y = notebook.get(yStr)
237 if isinstance(zStr, str) and notebook.isVariable(zStr):
238 self.z = notebook.get(zStr)
242 # Parametrized substitute for PointStruct (with 6 parameters)
243 class PointStructStr6:
258 def __init__(self, x1Str, x2Str, y1Str, y2Str, z1Str, z2Str):
265 if isinstance(x1Str, str) and notebook.isVariable(x1Str):
266 self.x1 = notebook.get(x1Str)
269 if isinstance(x2Str, str) and notebook.isVariable(x2Str):
270 self.x2 = notebook.get(x2Str)
273 if isinstance(y1Str, str) and notebook.isVariable(y1Str):
274 self.y1 = notebook.get(y1Str)
277 if isinstance(y2Str, str) and notebook.isVariable(y2Str):
278 self.y2 = notebook.get(y2Str)
281 if isinstance(z1Str, str) and notebook.isVariable(z1Str):
282 self.z1 = notebook.get(z1Str)
285 if isinstance(z2Str, str) and notebook.isVariable(z2Str):
286 self.z2 = notebook.get(z2Str)
290 # Parametrized substitute for AxisStruct
306 def __init__(self, xStr, yStr, zStr, dxStr, dyStr, dzStr):
313 if isinstance(xStr, str) and notebook.isVariable(xStr):
314 self.x = notebook.get(xStr)
317 if isinstance(yStr, str) and notebook.isVariable(yStr):
318 self.y = notebook.get(yStr)
321 if isinstance(zStr, str) and notebook.isVariable(zStr):
322 self.z = notebook.get(zStr)
325 if isinstance(dxStr, str) and notebook.isVariable(dxStr):
326 self.dx = notebook.get(dxStr)
329 if isinstance(dyStr, str) and notebook.isVariable(dyStr):
330 self.dy = notebook.get(dyStr)
333 if isinstance(dzStr, str) and notebook.isVariable(dzStr):
334 self.dz = notebook.get(dzStr)
338 # Parametrized substitute for DirStruct
341 def __init__(self, pointStruct):
342 self.pointStruct = pointStruct
344 # Returns list of variable values from salome notebook
345 def ParsePointStruct(Point):
346 Parameters = 2*var_separator
347 if isinstance(Point, PointStructStr):
348 Parameters = str(Point.xStr) + var_separator + str(Point.yStr) + var_separator + str(Point.zStr)
349 Point = PointStruct(Point.x, Point.y, Point.z)
350 return Point, Parameters
352 # Returns list of variable values from salome notebook
353 def ParseDirStruct(Dir):
354 Parameters = 2*var_separator
355 if isinstance(Dir, DirStructStr):
356 pntStr = Dir.pointStruct
357 if isinstance(pntStr, PointStructStr6):
358 Parameters = str(pntStr.x1Str) + var_separator + str(pntStr.x2Str) + var_separator
359 Parameters += str(pntStr.y1Str) + var_separator + str(pntStr.y2Str) + var_separator
360 Parameters += str(pntStr.z1Str) + var_separator + str(pntStr.z2Str)
361 Point = PointStruct(pntStr.x2 - pntStr.x1, pntStr.y2 - pntStr.y1, pntStr.z2 - pntStr.z1)
363 Parameters = str(pntStr.xStr) + var_separator + str(pntStr.yStr) + var_separator + str(pntStr.zStr)
364 Point = PointStruct(pntStr.x, pntStr.y, pntStr.z)
365 Dir = DirStruct(Point)
366 return Dir, Parameters
368 # Returns list of variable values from salome notebook
369 def ParseAxisStruct(Axis):
370 Parameters = 5*var_separator
371 if isinstance(Axis, AxisStructStr):
372 Parameters = str(Axis.xStr) + var_separator + str(Axis.yStr) + var_separator + str(Axis.zStr) + var_separator
373 Parameters += str(Axis.dxStr) + var_separator + str(Axis.dyStr) + var_separator + str(Axis.dzStr)
374 Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz)
375 return Axis, Parameters
377 ## Return list of variable values from salome notebook
378 def ParseAngles(list):
381 for parameter in list:
382 if isinstance(parameter,str) and notebook.isVariable(parameter):
383 Result.append(DegreesToRadians(notebook.get(parameter)))
386 Result.append(parameter)
389 Parameters = Parameters + str(parameter)
390 Parameters = Parameters + var_separator
392 Parameters = Parameters[:len(Parameters)-1]
393 return Result, Parameters
395 def IsEqual(val1, val2, tol=PrecisionConfusion):
396 if abs(val1 - val2) < tol:
406 if isinstance(obj, SALOMEDS._objref_SObject):
409 ior = salome.orb.object_to_string(obj)
412 studies = salome.myStudyManager.GetOpenStudies()
413 for sname in studies:
414 s = salome.myStudyManager.GetStudyByName(sname)
416 sobj = s.FindObjectIOR(ior)
417 if not sobj: continue
418 return sobj.GetName()
419 if hasattr(obj, "GetName"):
420 # unknown CORBA object, having GetName() method
423 # unknown CORBA object, no GetName() method
426 if hasattr(obj, "GetName"):
427 # unknown non-CORBA object, having GetName() method
430 raise RuntimeError, "Null or invalid object"
432 ## Prints error message if a hypothesis was not assigned.
433 def TreatHypoStatus(status, hypName, geomName, isAlgo):
435 hypType = "algorithm"
437 hypType = "hypothesis"
439 if status == HYP_UNKNOWN_FATAL :
440 reason = "for unknown reason"
441 elif status == HYP_INCOMPATIBLE :
442 reason = "this hypothesis mismatches the algorithm"
443 elif status == HYP_NOTCONFORM :
444 reason = "a non-conform mesh would be built"
445 elif status == HYP_ALREADY_EXIST :
446 if isAlgo: return # it does not influence anything
447 reason = hypType + " of the same dimension is already assigned to this shape"
448 elif status == HYP_BAD_DIM :
449 reason = hypType + " mismatches the shape"
450 elif status == HYP_CONCURENT :
451 reason = "there are concurrent hypotheses on sub-shapes"
452 elif status == HYP_BAD_SUBSHAPE :
453 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
454 elif status == HYP_BAD_GEOMETRY:
455 reason = "geometry mismatches the expectation of the algorithm"
456 elif status == HYP_HIDDEN_ALGO:
457 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
458 elif status == HYP_HIDING_ALGO:
459 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
460 elif status == HYP_NEED_SHAPE:
461 reason = "Algorithm can't work without shape"
464 hypName = '"' + hypName + '"'
465 geomName= '"' + geomName+ '"'
466 if status < HYP_UNKNOWN_FATAL and not geomName =='""':
467 print hypName, "was assigned to", geomName,"but", reason
468 elif not geomName == '""':
469 print hypName, "was not assigned to",geomName,":", reason
471 print hypName, "was not assigned:", reason
474 ## Check meshing plugin availability
475 def CheckPlugin(plugin):
476 if plugin == NETGEN and noNETGENPlugin:
477 print "Warning: NETGENPlugin module unavailable"
479 elif plugin == GHS3D and noGHS3DPlugin:
480 print "Warning: GHS3DPlugin module unavailable"
482 elif plugin == GHS3DPRL and noGHS3DPRLPlugin:
483 print "Warning: GHS3DPRLPlugin module unavailable"
485 elif plugin == Hexotic and noHexoticPlugin:
486 print "Warning: HexoticPlugin module unavailable"
488 elif plugin == BLSURF and noBLSURFPlugin:
489 print "Warning: BLSURFPlugin module unavailable"
493 # end of l1_auxiliary
496 # All methods of this class are accessible directly from the smesh.py package.
497 class smeshDC(SMESH._objref_SMESH_Gen):
499 ## Dump component to the Python script
500 # This method overrides IDL function to allow default values for the parameters.
501 def DumpPython(self, theStudy, theIsPublished=True, theIsMultiFile=True):
502 return SMESH._objref_SMESH_Gen.DumpPython(self, theStudy, theIsPublished, theIsMultiFile)
504 ## Sets the current study and Geometry component
505 # @ingroup l1_auxiliary
506 def init_smesh(self,theStudy,geompyD):
507 self.SetCurrentStudy(theStudy,geompyD)
509 ## Creates an empty Mesh. This mesh can have an underlying geometry.
510 # @param obj the Geometrical object on which the mesh is built. If not defined,
511 # the mesh will have no underlying geometry.
512 # @param name the name for the new mesh.
513 # @return an instance of Mesh class.
514 # @ingroup l2_construct
515 def Mesh(self, obj=0, name=0):
516 if isinstance(obj,str):
518 return Mesh(self,self.geompyD,obj,name)
520 ## Returns a long value from enumeration
521 # Should be used for SMESH.FunctorType enumeration
522 # @ingroup l1_controls
523 def EnumToLong(self,theItem):
526 ## Returns a string representation of the color.
527 # To be used with filters.
528 # @param c color value (SALOMEDS.Color)
529 # @ingroup l1_controls
530 def ColorToString(self,c):
532 if isinstance(c, SALOMEDS.Color):
533 val = "%s;%s;%s" % (c.R, c.G, c.B)
534 elif isinstance(c, str):
537 raise ValueError, "Color value should be of string or SALOMEDS.Color type"
540 ## Gets PointStruct from vertex
541 # @param theVertex a GEOM object(vertex)
542 # @return SMESH.PointStruct
543 # @ingroup l1_auxiliary
544 def GetPointStruct(self,theVertex):
545 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
546 return PointStruct(x,y,z)
548 ## Gets DirStruct from vector
549 # @param theVector a GEOM object(vector)
550 # @return SMESH.DirStruct
551 # @ingroup l1_auxiliary
552 def GetDirStruct(self,theVector):
553 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
554 if(len(vertices) != 2):
555 print "Error: vector object is incorrect."
557 p1 = self.geompyD.PointCoordinates(vertices[0])
558 p2 = self.geompyD.PointCoordinates(vertices[1])
559 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
560 dirst = DirStruct(pnt)
563 ## Makes DirStruct from a triplet
564 # @param x,y,z vector components
565 # @return SMESH.DirStruct
566 # @ingroup l1_auxiliary
567 def MakeDirStruct(self,x,y,z):
568 pnt = PointStruct(x,y,z)
569 return DirStruct(pnt)
571 ## Get AxisStruct from object
572 # @param theObj a GEOM object (line or plane)
573 # @return SMESH.AxisStruct
574 # @ingroup l1_auxiliary
575 def GetAxisStruct(self,theObj):
576 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
578 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
579 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
580 vertex1 = self.geompyD.PointCoordinates(vertex1)
581 vertex2 = self.geompyD.PointCoordinates(vertex2)
582 vertex3 = self.geompyD.PointCoordinates(vertex3)
583 vertex4 = self.geompyD.PointCoordinates(vertex4)
584 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
585 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
586 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] ]
587 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
589 elif len(edges) == 1:
590 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
591 p1 = self.geompyD.PointCoordinates( vertex1 )
592 p2 = self.geompyD.PointCoordinates( vertex2 )
593 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
597 # From SMESH_Gen interface:
598 # ------------------------
600 ## Sets the given name to the object
601 # @param obj the object to rename
602 # @param name a new object name
603 # @ingroup l1_auxiliary
604 def SetName(self, obj, name):
605 if isinstance( obj, Mesh ):
607 elif isinstance( obj, Mesh_Algorithm ):
608 obj = obj.GetAlgorithm()
609 ior = salome.orb.object_to_string(obj)
610 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
612 ## Sets the current mode
613 # @ingroup l1_auxiliary
614 def SetEmbeddedMode( self,theMode ):
615 #self.SetEmbeddedMode(theMode)
616 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
618 ## Gets the current mode
619 # @ingroup l1_auxiliary
620 def IsEmbeddedMode(self):
621 #return self.IsEmbeddedMode()
622 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
624 ## Sets the current study
625 # @ingroup l1_auxiliary
626 def SetCurrentStudy( self, theStudy, geompyD = None ):
627 #self.SetCurrentStudy(theStudy)
630 geompyD = geompy.geom
633 self.SetGeomEngine(geompyD)
634 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
636 ## Gets the current study
637 # @ingroup l1_auxiliary
638 def GetCurrentStudy(self):
639 #return self.GetCurrentStudy()
640 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
642 ## Creates a Mesh object importing data from the given UNV file
643 # @return an instance of Mesh class
645 def CreateMeshesFromUNV( self,theFileName ):
646 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
647 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
650 ## Creates a Mesh object(s) importing data from the given MED file
651 # @return a list of Mesh class instances
653 def CreateMeshesFromMED( self,theFileName ):
654 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
656 for iMesh in range(len(aSmeshMeshes)) :
657 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
658 aMeshes.append(aMesh)
659 return aMeshes, aStatus
661 ## Creates a Mesh object importing data from the given STL file
662 # @return an instance of Mesh class
664 def CreateMeshesFromSTL( self, theFileName ):
665 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
666 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
669 ## Concatenate the given meshes into one mesh.
670 # @return an instance of Mesh class
671 # @param meshes the meshes to combine into one mesh
672 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
673 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
674 # @param mergeTolerance tolerance for merging nodes
675 # @param allGroups forces creation of groups of all elements
676 def Concatenate( self, meshes, uniteIdenticalGroups,
677 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
678 mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
679 for i,m in enumerate(meshes):
680 if isinstance(m, Mesh):
681 meshes[i] = m.GetMesh()
683 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
684 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
686 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
687 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
688 aSmeshMesh.SetParameters(Parameters)
689 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
692 ## Create a mesh by copying a part of another mesh.
693 # @param meshPart a part of mesh to copy, either a Mesh, a sub-mesh or a group;
694 # to copy nodes or elements not contained in any mesh object,
695 # pass result of Mesh.GetIDSource( list_of_ids, type ) as meshPart
696 # @param meshName a name of the new mesh
697 # @param toCopyGroups to create in the new mesh groups the copied elements belongs to
698 # @param toKeepIDs to preserve IDs of the copied elements or not
699 # @return an instance of Mesh class
700 def CopyMesh( self, meshPart, meshName, toCopyGroups=False, toKeepIDs=False):
701 if (isinstance( meshPart, Mesh )):
702 meshPart = meshPart.GetMesh()
703 mesh = SMESH._objref_SMESH_Gen.CopyMesh( self,meshPart,meshName,toCopyGroups,toKeepIDs )
704 return Mesh(self, self.geompyD, mesh)
706 ## From SMESH_Gen interface
707 # @return the list of integer values
708 # @ingroup l1_auxiliary
709 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
710 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
712 ## From SMESH_Gen interface. Creates a pattern
713 # @return an instance of SMESH_Pattern
715 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
716 # @ingroup l2_modif_patterns
717 def GetPattern(self):
718 return SMESH._objref_SMESH_Gen.GetPattern(self)
720 ## Sets number of segments per diagonal of boundary box of geometry by which
721 # default segment length of appropriate 1D hypotheses is defined.
722 # Default value is 10
723 # @ingroup l1_auxiliary
724 def SetBoundaryBoxSegmentation(self, nbSegments):
725 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
727 # Filtering. Auxiliary functions:
728 # ------------------------------
730 ## Creates an empty criterion
731 # @return SMESH.Filter.Criterion
732 # @ingroup l1_controls
733 def GetEmptyCriterion(self):
734 Type = self.EnumToLong(FT_Undefined)
735 Compare = self.EnumToLong(FT_Undefined)
739 UnaryOp = self.EnumToLong(FT_Undefined)
740 BinaryOp = self.EnumToLong(FT_Undefined)
743 Precision = -1 ##@1e-07
744 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
745 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
747 ## Creates a criterion by the given parameters
748 # \n Criterion structures allow to define complex filters by combining them with logical operations (AND / OR) (see example below)
749 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
750 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
751 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
752 # @param Treshold the threshold value (range of ids as string, shape, numeric)
753 # @param UnaryOp FT_LogicalNOT or FT_Undefined
754 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
755 # FT_Undefined (must be for the last criterion of all criteria)
756 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
757 # FT_LyingOnGeom, FT_CoplanarFaces criteria
758 # @return SMESH.Filter.Criterion
760 # <a href="../tui_filters_page.html#combining_filters">Example of Criteria usage</a>
761 # @ingroup l1_controls
762 def GetCriterion(self,elementType,
764 Compare = FT_EqualTo,
766 UnaryOp=FT_Undefined,
767 BinaryOp=FT_Undefined,
769 aCriterion = self.GetEmptyCriterion()
770 aCriterion.TypeOfElement = elementType
771 aCriterion.Type = self.EnumToLong(CritType)
772 aCriterion.Tolerance = Tolerance
776 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
777 aCriterion.Compare = self.EnumToLong(Compare)
778 elif Compare == "=" or Compare == "==":
779 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
781 aCriterion.Compare = self.EnumToLong(FT_LessThan)
783 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
784 elif Compare != FT_Undefined:
785 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
788 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
789 FT_BelongToCylinder, FT_LyingOnGeom]:
790 # Checks the treshold
791 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
792 aCriterion.ThresholdStr = GetName(aTreshold)
793 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
795 print "Error: The treshold should be a shape."
797 if isinstance(UnaryOp,float):
798 aCriterion.Tolerance = UnaryOp
799 UnaryOp = FT_Undefined
801 elif CritType == FT_RangeOfIds:
802 # Checks the treshold
803 if isinstance(aTreshold, str):
804 aCriterion.ThresholdStr = aTreshold
806 print "Error: The treshold should be a string."
808 elif CritType == FT_CoplanarFaces:
809 # Checks the treshold
810 if isinstance(aTreshold, int):
811 aCriterion.ThresholdID = "%s"%aTreshold
812 elif isinstance(aTreshold, str):
815 raise ValueError, "Invalid ID of mesh face: '%s'"%aTreshold
816 aCriterion.ThresholdID = aTreshold
819 "The treshold should be an ID of mesh face and not '%s'"%aTreshold
820 elif CritType == FT_ElemGeomType:
821 # Checks the treshold
823 aCriterion.Threshold = self.EnumToLong(aTreshold)
825 if isinstance(aTreshold, int):
826 aCriterion.Threshold = aTreshold
828 print "Error: The treshold should be an integer or SMESH.GeometryType."
832 elif CritType == FT_GroupColor:
833 # Checks the treshold
835 aCriterion.ThresholdStr = self.ColorToString(aTreshold)
837 print "Error: The threshold value should be of SALOMEDS.Color type"
840 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
841 FT_FreeFaces, FT_LinearOrQuadratic,
842 FT_BareBorderFace, FT_BareBorderVolume,
843 FT_OverConstrainedFace, FT_OverConstrainedVolume]:
844 # At this point the treshold is unnecessary
845 if aTreshold == FT_LogicalNOT:
846 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
847 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
848 aCriterion.BinaryOp = aTreshold
852 aTreshold = float(aTreshold)
853 aCriterion.Threshold = aTreshold
855 print "Error: The treshold should be a number."
858 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
859 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
861 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
862 aCriterion.BinaryOp = self.EnumToLong(Treshold)
864 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
865 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
867 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
868 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
872 ## Creates a filter with the given parameters
873 # @param elementType the type of elements in the group
874 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
875 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
876 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
877 # @param UnaryOp FT_LogicalNOT or FT_Undefined
878 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
879 # FT_LyingOnGeom, FT_CoplanarFaces criteria
880 # @return SMESH_Filter
882 # <a href="../tui_filters_page.html#tui_filters">Example of Filters usage</a>
883 # @ingroup l1_controls
884 def GetFilter(self,elementType,
885 CritType=FT_Undefined,
888 UnaryOp=FT_Undefined,
890 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined,Tolerance)
891 aFilterMgr = self.CreateFilterManager()
892 aFilter = aFilterMgr.CreateFilter()
894 aCriteria.append(aCriterion)
895 aFilter.SetCriteria(aCriteria)
896 aFilterMgr.UnRegister()
899 ## Creates a filter from criteria
900 # @param criteria a list of criteria
901 # @return SMESH_Filter
903 # <a href="../tui_filters_page.html#tui_filters">Example of Filters usage</a>
904 # @ingroup l1_controls
905 def GetFilterFromCriteria(self,criteria):
906 aFilterMgr = self.CreateFilterManager()
907 aFilter = aFilterMgr.CreateFilter()
908 aFilter.SetCriteria(criteria)
909 aFilterMgr.UnRegister()
912 ## Creates a numerical functor by its type
913 # @param theCriterion FT_...; functor type
914 # @return SMESH_NumericalFunctor
915 # @ingroup l1_controls
916 def GetFunctor(self,theCriterion):
917 aFilterMgr = self.CreateFilterManager()
918 if theCriterion == FT_AspectRatio:
919 return aFilterMgr.CreateAspectRatio()
920 elif theCriterion == FT_AspectRatio3D:
921 return aFilterMgr.CreateAspectRatio3D()
922 elif theCriterion == FT_Warping:
923 return aFilterMgr.CreateWarping()
924 elif theCriterion == FT_MinimumAngle:
925 return aFilterMgr.CreateMinimumAngle()
926 elif theCriterion == FT_Taper:
927 return aFilterMgr.CreateTaper()
928 elif theCriterion == FT_Skew:
929 return aFilterMgr.CreateSkew()
930 elif theCriterion == FT_Area:
931 return aFilterMgr.CreateArea()
932 elif theCriterion == FT_Volume3D:
933 return aFilterMgr.CreateVolume3D()
934 elif theCriterion == FT_MaxElementLength2D:
935 return aFilterMgr.CreateMaxElementLength2D()
936 elif theCriterion == FT_MaxElementLength3D:
937 return aFilterMgr.CreateMaxElementLength3D()
938 elif theCriterion == FT_MultiConnection:
939 return aFilterMgr.CreateMultiConnection()
940 elif theCriterion == FT_MultiConnection2D:
941 return aFilterMgr.CreateMultiConnection2D()
942 elif theCriterion == FT_Length:
943 return aFilterMgr.CreateLength()
944 elif theCriterion == FT_Length2D:
945 return aFilterMgr.CreateLength2D()
947 print "Error: given parameter is not numerucal functor type."
949 ## Creates hypothesis
950 # @param theHType mesh hypothesis type (string)
951 # @param theLibName mesh plug-in library name
952 # @return created hypothesis instance
953 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
954 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
956 ## Gets the mesh statistic
957 # @return dictionary <element type> - <count of elements>
958 # @ingroup l1_meshinfo
959 def GetMeshInfo(self, obj):
960 if isinstance( obj, Mesh ):
963 if hasattr(obj, "GetMeshInfo"):
964 values = obj.GetMeshInfo()
965 for i in range(SMESH.Entity_Last._v):
966 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
970 ## Get minimum distance between two objects
972 # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
973 # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
975 # @param src1 first source object
976 # @param src2 second source object
977 # @param id1 node/element id from the first source
978 # @param id2 node/element id from the second (or first) source
979 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
980 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
981 # @return minimum distance value
982 # @sa GetMinDistance()
983 # @ingroup l1_measurements
984 def MinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
985 result = self.GetMinDistance(src1, src2, id1, id2, isElem1, isElem2)
989 result = result.value
992 ## Get measure structure specifying minimum distance data between two objects
994 # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
995 # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
997 # @param src1 first source object
998 # @param src2 second source object
999 # @param id1 node/element id from the first source
1000 # @param id2 node/element id from the second (or first) source
1001 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
1002 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
1003 # @return Measure structure or None if input data is invalid
1005 # @ingroup l1_measurements
1006 def GetMinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
1007 if isinstance(src1, Mesh): src1 = src1.mesh
1008 if isinstance(src2, Mesh): src2 = src2.mesh
1009 if src2 is None and id2 != 0: src2 = src1
1010 if not hasattr(src1, "_narrow"): return None
1011 src1 = src1._narrow(SMESH.SMESH_IDSource)
1012 if not src1: return None
1015 e = m.GetMeshEditor()
1017 src1 = e.MakeIDSource([id1], SMESH.FACE)
1019 src1 = e.MakeIDSource([id1], SMESH.NODE)
1021 if hasattr(src2, "_narrow"):
1022 src2 = src2._narrow(SMESH.SMESH_IDSource)
1023 if src2 and id2 != 0:
1025 e = m.GetMeshEditor()
1027 src2 = e.MakeIDSource([id2], SMESH.FACE)
1029 src2 = e.MakeIDSource([id2], SMESH.NODE)
1032 aMeasurements = self.CreateMeasurements()
1033 result = aMeasurements.MinDistance(src1, src2)
1034 aMeasurements.UnRegister()
1037 ## Get bounding box of the specified object(s)
1038 # @param objects single source object or list of source objects
1039 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
1040 # @sa GetBoundingBox()
1041 # @ingroup l1_measurements
1042 def BoundingBox(self, objects):
1043 result = self.GetBoundingBox(objects)
1047 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
1050 ## Get measure structure specifying bounding box data of the specified object(s)
1051 # @param objects single source object or list of source objects
1052 # @return Measure structure
1054 # @ingroup l1_measurements
1055 def GetBoundingBox(self, objects):
1056 if isinstance(objects, tuple):
1057 objects = list(objects)
1058 if not isinstance(objects, list):
1062 if isinstance(o, Mesh):
1063 srclist.append(o.mesh)
1064 elif hasattr(o, "_narrow"):
1065 src = o._narrow(SMESH.SMESH_IDSource)
1066 if src: srclist.append(src)
1069 aMeasurements = self.CreateMeasurements()
1070 result = aMeasurements.BoundingBox(srclist)
1071 aMeasurements.UnRegister()
1075 #Registering the new proxy for SMESH_Gen
1076 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
1079 # Public class: Mesh
1080 # ==================
1082 ## This class allows defining and managing a mesh.
1083 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
1084 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
1085 # new nodes and elements and by changing the existing entities), to get information
1086 # about a mesh and to export a mesh into different formats.
1095 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
1096 # sets the GUI name of this mesh to \a name.
1097 # @param smeshpyD an instance of smeshDC class
1098 # @param geompyD an instance of geompyDC class
1099 # @param obj Shape to be meshed or SMESH_Mesh object
1100 # @param name Study name of the mesh
1101 # @ingroup l2_construct
1102 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
1103 self.smeshpyD=smeshpyD
1104 self.geompyD=geompyD
1108 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
1110 # publish geom of mesh (issue 0021122)
1111 if not self.geom.GetStudyEntry():
1112 studyID = smeshpyD.GetCurrentStudy()._get_StudyId()
1113 if studyID != geompyD.myStudyId:
1114 geompyD.init_geom( smeshpyD.GetCurrentStudy())
1116 geo_name = "%s_%s"%(self.geom.GetShapeType(), id(self.geom)%100)
1117 geompyD.addToStudy( self.geom, geo_name )
1118 self.mesh = self.smeshpyD.CreateMesh(self.geom)
1120 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
1123 self.mesh = self.smeshpyD.CreateEmptyMesh()
1125 self.smeshpyD.SetName(self.mesh, name)
1127 self.smeshpyD.SetName(self.mesh, GetName(obj))
1130 self.geom = self.mesh.GetShapeToMesh()
1132 self.editor = self.mesh.GetMeshEditor()
1134 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
1135 # @param theMesh a SMESH_Mesh object
1136 # @ingroup l2_construct
1137 def SetMesh(self, theMesh):
1139 self.geom = self.mesh.GetShapeToMesh()
1141 ## Returns the mesh, that is an instance of SMESH_Mesh interface
1142 # @return a SMESH_Mesh object
1143 # @ingroup l2_construct
1147 ## Gets the name of the mesh
1148 # @return the name of the mesh as a string
1149 # @ingroup l2_construct
1151 name = GetName(self.GetMesh())
1154 ## Sets a name to the mesh
1155 # @param name a new name of the mesh
1156 # @ingroup l2_construct
1157 def SetName(self, name):
1158 self.smeshpyD.SetName(self.GetMesh(), name)
1160 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
1161 # The subMesh object gives access to the IDs of nodes and elements.
1162 # @param geom a geometrical object (shape)
1163 # @param name a name for the submesh
1164 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
1165 # @ingroup l2_submeshes
1166 def GetSubMesh(self, geom, name):
1167 if not geom.IsSame( self.geom ) and not geom.GetStudyEntry():
1169 studyID = self.smeshpyD.GetCurrentStudy()._get_StudyId()
1170 if studyID != self.geompyD.myStudyId:
1171 self.geompyD.init_geom( self.smeshpyD.GetCurrentStudy())
1173 if not name and geom.GetShapeType() != geompyDC.GEOM.COMPOUND:
1174 # for all groups SubShapeName() returns "Compound_-1"
1175 name = self.geompyD.SubShapeName(geom, self.geom)
1177 name = "%s_%s"%(geom.GetShapeType(), id(geom)%10000)
1179 self.geompyD.addToStudyInFather( self.geom, geom, name )
1180 submesh = self.mesh.GetSubMesh( geom, name )
1183 ## Returns the shape associated to the mesh
1184 # @return a GEOM_Object
1185 # @ingroup l2_construct
1189 ## Associates the given shape to the mesh (entails the recreation of the mesh)
1190 # @param geom the shape to be meshed (GEOM_Object)
1191 # @ingroup l2_construct
1192 def SetShape(self, geom):
1193 self.mesh = self.smeshpyD.CreateMesh(geom)
1195 ## Returns true if the hypotheses are defined well
1196 # @param theSubObject a subshape of a mesh shape
1197 # @return True or False
1198 # @ingroup l2_construct
1199 def IsReadyToCompute(self, theSubObject):
1200 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
1202 ## Returns errors of hypotheses definition.
1203 # The list of errors is empty if everything is OK.
1204 # @param theSubObject a subshape of a mesh shape
1205 # @return a list of errors
1206 # @ingroup l2_construct
1207 def GetAlgoState(self, theSubObject):
1208 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
1210 ## Returns a geometrical object on which the given element was built.
1211 # The returned geometrical object, if not nil, is either found in the
1212 # study or published by this method with the given name
1213 # @param theElementID the id of the mesh element
1214 # @param theGeomName the user-defined name of the geometrical object
1215 # @return GEOM::GEOM_Object instance
1216 # @ingroup l2_construct
1217 def GetGeometryByMeshElement(self, theElementID, theGeomName):
1218 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
1220 ## Returns the mesh dimension depending on the dimension of the underlying shape
1221 # @return mesh dimension as an integer value [0,3]
1222 # @ingroup l1_auxiliary
1223 def MeshDimension(self):
1224 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
1225 if len( shells ) > 0 :
1227 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
1229 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
1235 ## Creates a segment discretization 1D algorithm.
1236 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
1237 # \n If the optional \a geom parameter is not set, this algorithm is global.
1238 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1239 # @param algo the type of the required algorithm. Possible values are:
1241 # - smesh.PYTHON for discretization via a python function,
1242 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
1243 # @param geom If defined is the subshape to be meshed
1244 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
1245 # @ingroup l3_algos_basic
1246 def Segment(self, algo=REGULAR, geom=0):
1247 ## if Segment(geom) is called by mistake
1248 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
1249 algo, geom = geom, algo
1250 if not algo: algo = REGULAR
1253 return Mesh_Segment(self, geom)
1254 elif algo == PYTHON:
1255 return Mesh_Segment_Python(self, geom)
1256 elif algo == COMPOSITE:
1257 return Mesh_CompositeSegment(self, geom)
1259 return Mesh_Segment(self, geom)
1261 ## Creates 1D algorithm importing segments conatined in groups of other mesh.
1262 # If the optional \a geom parameter is not set, this algorithm is global.
1263 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1264 # @param geom If defined the subshape is to be meshed
1265 # @return an instance of Mesh_UseExistingElements class
1266 # @ingroup l3_algos_basic
1267 def UseExisting1DElements(self, geom=0):
1268 return Mesh_UseExistingElements(1,self, geom)
1270 ## Creates 2D algorithm importing faces conatined in groups of other mesh.
1271 # If the optional \a geom parameter is not set, this algorithm is global.
1272 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1273 # @param geom If defined the subshape is to be meshed
1274 # @return an instance of Mesh_UseExistingElements class
1275 # @ingroup l3_algos_basic
1276 def UseExisting2DElements(self, geom=0):
1277 return Mesh_UseExistingElements(2,self, geom)
1279 ## Enables creation of nodes and segments usable by 2D algoritms.
1280 # The added nodes and segments must be bound to edges and vertices by
1281 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
1282 # If the optional \a geom parameter is not set, this algorithm is global.
1283 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1284 # @param geom the subshape to be manually meshed
1285 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
1286 # @ingroup l3_algos_basic
1287 def UseExistingSegments(self, geom=0):
1288 algo = Mesh_UseExisting(1,self,geom)
1289 return algo.GetAlgorithm()
1291 ## Enables creation of nodes and faces usable by 3D algoritms.
1292 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
1293 # and SetMeshElementOnShape()
1294 # If the optional \a geom parameter is not set, this algorithm is global.
1295 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1296 # @param geom the subshape to be manually meshed
1297 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1298 # @ingroup l3_algos_basic
1299 def UseExistingFaces(self, geom=0):
1300 algo = Mesh_UseExisting(2,self,geom)
1301 return algo.GetAlgorithm()
1303 ## Creates a triangle 2D algorithm for faces.
1304 # If the optional \a geom parameter is not set, this algorithm is global.
1305 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1306 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1307 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1308 # @return an instance of Mesh_Triangle algorithm
1309 # @ingroup l3_algos_basic
1310 def Triangle(self, algo=MEFISTO, geom=0):
1311 ## if Triangle(geom) is called by mistake
1312 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1315 return Mesh_Triangle(self, algo, geom)
1317 ## Creates a quadrangle 2D algorithm for faces.
1318 # If the optional \a geom parameter is not set, this algorithm is global.
1319 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1320 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1321 # @param algo values are: smesh.QUADRANGLE || smesh.RADIAL_QUAD
1322 # @return an instance of Mesh_Quadrangle algorithm
1323 # @ingroup l3_algos_basic
1324 def Quadrangle(self, geom=0, algo=QUADRANGLE):
1325 if algo==RADIAL_QUAD:
1326 return Mesh_RadialQuadrangle1D2D(self,geom)
1328 return Mesh_Quadrangle(self, geom)
1330 ## Creates a tetrahedron 3D algorithm for solids.
1331 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1332 # If the optional \a geom parameter is not set, this algorithm is global.
1333 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1334 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1335 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1336 # @return an instance of Mesh_Tetrahedron algorithm
1337 # @ingroup l3_algos_basic
1338 def Tetrahedron(self, algo=NETGEN, geom=0):
1339 ## if Tetrahedron(geom) is called by mistake
1340 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1341 algo, geom = geom, algo
1342 if not algo: algo = NETGEN
1344 return Mesh_Tetrahedron(self, algo, geom)
1346 ## Creates a hexahedron 3D algorithm for solids.
1347 # If the optional \a geom parameter is not set, this algorithm is global.
1348 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1349 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1350 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1351 # @return an instance of Mesh_Hexahedron algorithm
1352 # @ingroup l3_algos_basic
1353 def Hexahedron(self, algo=Hexa, geom=0):
1354 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1355 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1356 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1357 elif geom == 0: algo, geom = Hexa, algo
1358 return Mesh_Hexahedron(self, algo, geom)
1360 ## Deprecated, used only for compatibility!
1361 # @return an instance of Mesh_Netgen algorithm
1362 # @ingroup l3_algos_basic
1363 def Netgen(self, is3D, geom=0):
1364 return Mesh_Netgen(self, is3D, geom)
1366 ## Creates a projection 1D algorithm for edges.
1367 # If the optional \a geom parameter is not set, this algorithm is global.
1368 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1369 # @param geom If defined, the subshape to be meshed
1370 # @return an instance of Mesh_Projection1D algorithm
1371 # @ingroup l3_algos_proj
1372 def Projection1D(self, geom=0):
1373 return Mesh_Projection1D(self, geom)
1375 ## Creates a projection 2D algorithm for faces.
1376 # If the optional \a geom parameter is not set, this algorithm is global.
1377 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1378 # @param geom If defined, the subshape to be meshed
1379 # @return an instance of Mesh_Projection2D algorithm
1380 # @ingroup l3_algos_proj
1381 def Projection2D(self, geom=0):
1382 return Mesh_Projection2D(self, geom)
1384 ## Creates a projection 3D algorithm for solids.
1385 # If the optional \a geom parameter is not set, this algorithm is global.
1386 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1387 # @param geom If defined, the subshape to be meshed
1388 # @return an instance of Mesh_Projection3D algorithm
1389 # @ingroup l3_algos_proj
1390 def Projection3D(self, geom=0):
1391 return Mesh_Projection3D(self, geom)
1393 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1394 # If the optional \a geom parameter is not set, this algorithm is global.
1395 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1396 # @param geom If defined, the subshape to be meshed
1397 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1398 # @ingroup l3_algos_radialp l3_algos_3dextr
1399 def Prism(self, geom=0):
1403 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1404 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1405 if nbSolids == 0 or nbSolids == nbShells:
1406 return Mesh_Prism3D(self, geom)
1407 return Mesh_RadialPrism3D(self, geom)
1409 ## Evaluates size of prospective mesh on a shape
1410 # @return a list where i-th element is a number of elements of i-th SMESH.EntityType
1411 # To know predicted number of e.g. edges, inquire it this way
1412 # Evaluate()[ EnumToLong( Entity_Edge )]
1413 def Evaluate(self, geom=0):
1414 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1416 geom = self.mesh.GetShapeToMesh()
1419 return self.smeshpyD.Evaluate(self.mesh, geom)
1422 ## Computes the mesh and returns the status of the computation
1423 # @param geom geomtrical shape on which mesh data should be computed
1424 # @param discardModifs if True and the mesh has been edited since
1425 # a last total re-compute and that may prevent successful partial re-compute,
1426 # then the mesh is cleaned before Compute()
1427 # @return True or False
1428 # @ingroup l2_construct
1429 def Compute(self, geom=0, discardModifs=False):
1430 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1432 geom = self.mesh.GetShapeToMesh()
1437 if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693
1439 ok = self.smeshpyD.Compute(self.mesh, geom)
1440 except SALOME.SALOME_Exception, ex:
1441 print "Mesh computation failed, exception caught:"
1442 print " ", ex.details.text
1445 print "Mesh computation failed, exception caught:"
1446 traceback.print_exc()
1450 # Treat compute errors
1451 computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
1452 for err in computeErrors:
1454 if self.mesh.HasShapeToMesh():
1456 mainIOR = salome.orb.object_to_string(geom)
1457 for sname in salome.myStudyManager.GetOpenStudies():
1458 s = salome.myStudyManager.GetStudyByName(sname)
1460 mainSO = s.FindObjectIOR(mainIOR)
1461 if not mainSO: continue
1462 if err.subShapeID == 1:
1463 shapeText = ' on "%s"' % mainSO.GetName()
1464 subIt = s.NewChildIterator(mainSO)
1466 subSO = subIt.Value()
1468 obj = subSO.GetObject()
1469 if not obj: continue
1470 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
1472 ids = go.GetSubShapeIndices()
1473 if len(ids) == 1 and ids[0] == err.subShapeID:
1474 shapeText = ' on "%s"' % subSO.GetName()
1477 shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
1479 shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID)
1481 shapeText = " on subshape #%s" % (err.subShapeID)
1483 shapeText = " on subshape #%s" % (err.subShapeID)
1485 stdErrors = ["OK", #COMPERR_OK
1486 "Invalid input mesh", #COMPERR_BAD_INPUT_MESH
1487 "std::exception", #COMPERR_STD_EXCEPTION
1488 "OCC exception", #COMPERR_OCC_EXCEPTION
1489 "SALOME exception", #COMPERR_SLM_EXCEPTION
1490 "Unknown exception", #COMPERR_EXCEPTION
1491 "Memory allocation problem", #COMPERR_MEMORY_PB
1492 "Algorithm failed", #COMPERR_ALGO_FAILED
1493 "Unexpected geometry"]#COMPERR_BAD_SHAPE
1495 if err.code < len(stdErrors): errText = stdErrors[err.code]
1497 errText = "code %s" % -err.code
1498 if errText: errText += ". "
1499 errText += err.comment
1500 if allReasons != "":allReasons += "\n"
1501 allReasons += '"%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
1505 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1507 if err.isGlobalAlgo:
1515 reason = '%s %sD algorithm is missing' % (glob, dim)
1516 elif err.state == HYP_MISSING:
1517 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1518 % (glob, dim, name, dim))
1519 elif err.state == HYP_NOTCONFORM:
1520 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1521 elif err.state == HYP_BAD_PARAMETER:
1522 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1523 % ( glob, dim, name ))
1524 elif err.state == HYP_BAD_GEOMETRY:
1525 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1526 'geometry' % ( glob, dim, name ))
1528 reason = "For unknown reason."+\
1529 " Revise Mesh.Compute() implementation in smeshDC.py!"
1531 if allReasons != "":allReasons += "\n"
1532 allReasons += reason
1534 if allReasons != "":
1535 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1539 print '"' + GetName(self.mesh) + '"',"has not been computed."
1542 if salome.sg.hasDesktop():
1543 smeshgui = salome.ImportComponentGUI("SMESH")
1544 smeshgui.Init(self.mesh.GetStudyId())
1545 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1546 salome.sg.updateObjBrowser(1)
1550 ## Return submesh objects list in meshing order
1551 # @return list of list of submesh objects
1552 # @ingroup l2_construct
1553 def GetMeshOrder(self):
1554 return self.mesh.GetMeshOrder()
1556 ## Return submesh objects list in meshing order
1557 # @return list of list of submesh objects
1558 # @ingroup l2_construct
1559 def SetMeshOrder(self, submeshes):
1560 return self.mesh.SetMeshOrder(submeshes)
1562 ## Removes all nodes and elements
1563 # @ingroup l2_construct
1566 if salome.sg.hasDesktop():
1567 smeshgui = salome.ImportComponentGUI("SMESH")
1568 smeshgui.Init(self.mesh.GetStudyId())
1569 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1570 salome.sg.updateObjBrowser(1)
1572 ## Removes all nodes and elements of indicated shape
1573 # @ingroup l2_construct
1574 def ClearSubMesh(self, geomId):
1575 self.mesh.ClearSubMesh(geomId)
1576 if salome.sg.hasDesktop():
1577 smeshgui = salome.ImportComponentGUI("SMESH")
1578 smeshgui.Init(self.mesh.GetStudyId())
1579 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1580 salome.sg.updateObjBrowser(1)
1582 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1583 # @param fineness [0,-1] defines mesh fineness
1584 # @return True or False
1585 # @ingroup l3_algos_basic
1586 def AutomaticTetrahedralization(self, fineness=0):
1587 dim = self.MeshDimension()
1589 self.RemoveGlobalHypotheses()
1590 self.Segment().AutomaticLength(fineness)
1592 self.Triangle().LengthFromEdges()
1595 self.Tetrahedron(NETGEN)
1597 return self.Compute()
1599 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1600 # @param fineness [0,-1] defines mesh fineness
1601 # @return True or False
1602 # @ingroup l3_algos_basic
1603 def AutomaticHexahedralization(self, fineness=0):
1604 dim = self.MeshDimension()
1605 # assign the hypotheses
1606 self.RemoveGlobalHypotheses()
1607 self.Segment().AutomaticLength(fineness)
1614 return self.Compute()
1616 ## Assigns a hypothesis
1617 # @param hyp a hypothesis to assign
1618 # @param geom a subhape of mesh geometry
1619 # @return SMESH.Hypothesis_Status
1620 # @ingroup l2_hypotheses
1621 def AddHypothesis(self, hyp, geom=0):
1622 if isinstance( hyp, Mesh_Algorithm ):
1623 hyp = hyp.GetAlgorithm()
1628 geom = self.mesh.GetShapeToMesh()
1630 status = self.mesh.AddHypothesis(geom, hyp)
1631 isAlgo = hyp._narrow( SMESH_Algo )
1632 hyp_name = GetName( hyp )
1635 geom_name = GetName( geom )
1636 TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1639 ## Unassigns a hypothesis
1640 # @param hyp a hypothesis to unassign
1641 # @param geom a subshape of mesh geometry
1642 # @return SMESH.Hypothesis_Status
1643 # @ingroup l2_hypotheses
1644 def RemoveHypothesis(self, hyp, geom=0):
1645 if isinstance( hyp, Mesh_Algorithm ):
1646 hyp = hyp.GetAlgorithm()
1651 status = self.mesh.RemoveHypothesis(geom, hyp)
1654 ## Gets the list of hypotheses added on a geometry
1655 # @param geom a subshape of mesh geometry
1656 # @return the sequence of SMESH_Hypothesis
1657 # @ingroup l2_hypotheses
1658 def GetHypothesisList(self, geom):
1659 return self.mesh.GetHypothesisList( geom )
1661 ## Removes all global hypotheses
1662 # @ingroup l2_hypotheses
1663 def RemoveGlobalHypotheses(self):
1664 current_hyps = self.mesh.GetHypothesisList( self.geom )
1665 for hyp in current_hyps:
1666 self.mesh.RemoveHypothesis( self.geom, hyp )
1670 ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
1671 ## Exports the mesh in a file in MED format and chooses the \a version of MED format
1672 ## allowing to overwrite the file if it exists or add the exported data to its contents
1673 # @param f the file name
1674 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1675 # @param opt boolean parameter for creating/not creating
1676 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1677 # @param overwrite boolean parameter for overwriting/not overwriting the file
1678 # @ingroup l2_impexp
1679 def ExportToMED(self, f, version, opt=0, overwrite=1):
1680 self.mesh.ExportToMEDX(f, opt, version, overwrite)
1682 ## Exports the mesh in a file in MED format and chooses the \a version of MED format
1683 ## allowing to overwrite the file if it exists or add the exported data to its contents
1684 # @param f is the file name
1685 # @param auto_groups boolean parameter for creating/not creating
1686 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1687 # the typical use is auto_groups=false.
1688 # @param version MED format version(MED_V2_1 or MED_V2_2)
1689 # @param overwrite boolean parameter for overwriting/not overwriting the file
1690 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1691 # @ingroup l2_impexp
1692 def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1, meshPart=None):
1694 if isinstance( meshPart, list ):
1695 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1696 self.mesh.ExportPartToMED( meshPart, f, auto_groups, version, overwrite )
1698 self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
1700 ## Exports the mesh in a file in DAT format
1701 # @param f the file name
1702 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1703 # @ingroup l2_impexp
1704 def ExportDAT(self, f, meshPart=None):
1706 if isinstance( meshPart, list ):
1707 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1708 self.mesh.ExportPartToDAT( meshPart, f )
1710 self.mesh.ExportDAT(f)
1712 ## Exports the mesh in a file in UNV format
1713 # @param f the file name
1714 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1715 # @ingroup l2_impexp
1716 def ExportUNV(self, f, meshPart=None):
1718 if isinstance( meshPart, list ):
1719 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1720 self.mesh.ExportPartToUNV( meshPart, f )
1722 self.mesh.ExportUNV(f)
1724 ## Export the mesh in a file in STL format
1725 # @param f the file name
1726 # @param ascii defines the file encoding
1727 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1728 # @ingroup l2_impexp
1729 def ExportSTL(self, f, ascii=1, meshPart=None):
1731 if isinstance( meshPart, list ):
1732 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1733 self.mesh.ExportPartToSTL( meshPart, f, ascii )
1735 self.mesh.ExportSTL(f, ascii)
1738 # Operations with groups:
1739 # ----------------------
1741 ## Creates an empty mesh group
1742 # @param elementType the type of elements in the group
1743 # @param name the name of the mesh group
1744 # @return SMESH_Group
1745 # @ingroup l2_grps_create
1746 def CreateEmptyGroup(self, elementType, name):
1747 return self.mesh.CreateGroup(elementType, name)
1749 ## Creates a mesh group based on the geometric object \a grp
1750 # and gives a \a name, \n if this parameter is not defined
1751 # the name is the same as the geometric group name \n
1752 # Note: Works like GroupOnGeom().
1753 # @param grp a geometric group, a vertex, an edge, a face or a solid
1754 # @param name the name of the mesh group
1755 # @return SMESH_GroupOnGeom
1756 # @ingroup l2_grps_create
1757 def Group(self, grp, name=""):
1758 return self.GroupOnGeom(grp, name)
1760 ## Creates a mesh group based on the geometrical object \a grp
1761 # and gives a \a name, \n if this parameter is not defined
1762 # the name is the same as the geometrical group name
1763 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1764 # @param name the name of the mesh group
1765 # @param typ the type of elements in the group. If not set, it is
1766 # automatically detected by the type of the geometry
1767 # @return SMESH_GroupOnGeom
1768 # @ingroup l2_grps_create
1769 def GroupOnGeom(self, grp, name="", typ=None):
1771 name = grp.GetName()
1774 tgeo = str(grp.GetShapeType())
1775 if tgeo == "VERTEX":
1777 elif tgeo == "EDGE":
1779 elif tgeo == "FACE":
1781 elif tgeo == "SOLID":
1783 elif tgeo == "SHELL":
1785 elif tgeo == "COMPOUND":
1786 try: # it raises on a compound of compounds
1787 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1788 print "Mesh.Group: empty geometric group", GetName( grp )
1793 if grp.GetType() == 37: # GEOMImpl_Types.hxx: #define GEOM_GROUP 37
1795 tgeo = self.geompyD.GetType(grp)
1796 if tgeo == geompyDC.ShapeType["VERTEX"]:
1798 elif tgeo == geompyDC.ShapeType["EDGE"]:
1800 elif tgeo == geompyDC.ShapeType["FACE"]:
1802 elif tgeo == geompyDC.ShapeType["SOLID"]:
1808 for elemType, shapeType in [[VOLUME,"SOLID"],[FACE,"FACE"],
1809 [EDGE,"EDGE"],[NODE,"VERTEX"]]:
1810 if self.geompyD.SubShapeAll(grp,geompyDC.ShapeType[shapeType]):
1818 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1821 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1823 ## Creates a mesh group with given \a name based on the \a filter which
1824 ## is a special type of group dynamically updating it's contents during
1825 ## mesh modification
1826 # @param typ the type of elements in the group
1827 # @param name the name of the mesh group
1828 # @param filter the filter defining group contents
1829 # @return SMESH_GroupOnFilter
1830 # @ingroup l2_grps_create
1831 def GroupOnFilter(self, typ, name, filter):
1832 return self.mesh.CreateGroupFromFilter(typ, name, filter)
1834 ## Creates a mesh group by the given ids of elements
1835 # @param groupName the name of the mesh group
1836 # @param elementType the type of elements in the group
1837 # @param elemIDs the list of ids
1838 # @return SMESH_Group
1839 # @ingroup l2_grps_create
1840 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1841 group = self.mesh.CreateGroup(elementType, groupName)
1845 ## Creates a mesh group by the given conditions
1846 # @param groupName the name of the mesh group
1847 # @param elementType the type of elements in the group
1848 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1849 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1850 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1851 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1852 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
1853 # FT_LyingOnGeom, FT_CoplanarFaces criteria
1854 # @return SMESH_Group
1855 # @ingroup l2_grps_create
1859 CritType=FT_Undefined,
1862 UnaryOp=FT_Undefined,
1864 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined,Tolerance)
1865 group = self.MakeGroupByCriterion(groupName, aCriterion)
1868 ## Creates a mesh group by the given criterion
1869 # @param groupName the name of the mesh group
1870 # @param Criterion the instance of Criterion class
1871 # @return SMESH_Group
1872 # @ingroup l2_grps_create
1873 def MakeGroupByCriterion(self, groupName, Criterion):
1874 aFilterMgr = self.smeshpyD.CreateFilterManager()
1875 aFilter = aFilterMgr.CreateFilter()
1877 aCriteria.append(Criterion)
1878 aFilter.SetCriteria(aCriteria)
1879 group = self.MakeGroupByFilter(groupName, aFilter)
1880 aFilterMgr.UnRegister()
1883 ## Creates a mesh group by the given criteria (list of criteria)
1884 # @param groupName the name of the mesh group
1885 # @param theCriteria the list of criteria
1886 # @return SMESH_Group
1887 # @ingroup l2_grps_create
1888 def MakeGroupByCriteria(self, groupName, theCriteria):
1889 aFilterMgr = self.smeshpyD.CreateFilterManager()
1890 aFilter = aFilterMgr.CreateFilter()
1891 aFilter.SetCriteria(theCriteria)
1892 group = self.MakeGroupByFilter(groupName, aFilter)
1893 aFilterMgr.UnRegister()
1896 ## Creates a mesh group by the given filter
1897 # @param groupName the name of the mesh group
1898 # @param theFilter the instance of Filter class
1899 # @return SMESH_Group
1900 # @ingroup l2_grps_create
1901 def MakeGroupByFilter(self, groupName, theFilter):
1902 group = self.CreateEmptyGroup(theFilter.GetElementType(), groupName)
1903 theFilter.SetMesh( self.mesh )
1904 group.AddFrom( theFilter )
1907 ## Passes mesh elements through the given filter and return IDs of fitting elements
1908 # @param theFilter SMESH_Filter
1909 # @return a list of ids
1910 # @ingroup l1_controls
1911 def GetIdsFromFilter(self, theFilter):
1912 theFilter.SetMesh( self.mesh )
1913 return theFilter.GetIDs()
1915 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1916 # Returns a list of special structures (borders).
1917 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1918 # @ingroup l1_controls
1919 def GetFreeBorders(self):
1920 aFilterMgr = self.smeshpyD.CreateFilterManager()
1921 aPredicate = aFilterMgr.CreateFreeEdges()
1922 aPredicate.SetMesh(self.mesh)
1923 aBorders = aPredicate.GetBorders()
1924 aFilterMgr.UnRegister()
1928 # @ingroup l2_grps_delete
1929 def RemoveGroup(self, group):
1930 self.mesh.RemoveGroup(group)
1932 ## Removes a group with its contents
1933 # @ingroup l2_grps_delete
1934 def RemoveGroupWithContents(self, group):
1935 self.mesh.RemoveGroupWithContents(group)
1937 ## Gets the list of groups existing in the mesh
1938 # @return a sequence of SMESH_GroupBase
1939 # @ingroup l2_grps_create
1940 def GetGroups(self):
1941 return self.mesh.GetGroups()
1943 ## Gets the number of groups existing in the mesh
1944 # @return the quantity of groups as an integer value
1945 # @ingroup l2_grps_create
1947 return self.mesh.NbGroups()
1949 ## Gets the list of names of groups existing in the mesh
1950 # @return list of strings
1951 # @ingroup l2_grps_create
1952 def GetGroupNames(self):
1953 groups = self.GetGroups()
1955 for group in groups:
1956 names.append(group.GetName())
1959 ## Produces a union of two groups
1960 # A new group is created. All mesh elements that are
1961 # present in the initial groups are added to the new one
1962 # @return an instance of SMESH_Group
1963 # @ingroup l2_grps_operon
1964 def UnionGroups(self, group1, group2, name):
1965 return self.mesh.UnionGroups(group1, group2, name)
1967 ## Produces a union list of groups
1968 # New group is created. All mesh elements that are present in
1969 # initial groups are added to the new one
1970 # @return an instance of SMESH_Group
1971 # @ingroup l2_grps_operon
1972 def UnionListOfGroups(self, groups, name):
1973 return self.mesh.UnionListOfGroups(groups, name)
1975 ## Prodices an intersection of two groups
1976 # A new group is created. All mesh elements that are common
1977 # for the two initial groups are added to the new one.
1978 # @return an instance of SMESH_Group
1979 # @ingroup l2_grps_operon
1980 def IntersectGroups(self, group1, group2, name):
1981 return self.mesh.IntersectGroups(group1, group2, name)
1983 ## Produces an intersection of groups
1984 # New group is created. All mesh elements that are present in all
1985 # initial groups simultaneously are added to the new one
1986 # @return an instance of SMESH_Group
1987 # @ingroup l2_grps_operon
1988 def IntersectListOfGroups(self, groups, name):
1989 return self.mesh.IntersectListOfGroups(groups, name)
1991 ## Produces a cut of two groups
1992 # A new group is created. All mesh elements that are present in
1993 # the main group but are not present in the tool group are added to the new one
1994 # @return an instance of SMESH_Group
1995 # @ingroup l2_grps_operon
1996 def CutGroups(self, main_group, tool_group, name):
1997 return self.mesh.CutGroups(main_group, tool_group, name)
1999 ## Produces a cut of groups
2000 # A new group is created. All mesh elements that are present in main groups
2001 # but do not present in tool groups are added to the new one
2002 # @return an instance of SMESH_Group
2003 # @ingroup l2_grps_operon
2004 def CutListOfGroups(self, main_groups, tool_groups, name):
2005 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
2007 ## Produces a group of elements of specified type using list of existing groups
2008 # A new group is created. System
2009 # 1) extracts all nodes on which groups elements are built
2010 # 2) combines all elements of specified dimension laying on these nodes
2011 # @return an instance of SMESH_Group
2012 # @ingroup l2_grps_operon
2013 def CreateDimGroup(self, groups, elem_type, name):
2014 return self.mesh.CreateDimGroup(groups, elem_type, name)
2017 ## Convert group on geom into standalone group
2018 # @ingroup l2_grps_delete
2019 def ConvertToStandalone(self, group):
2020 return self.mesh.ConvertToStandalone(group)
2022 # Get some info about mesh:
2023 # ------------------------
2025 ## Returns the log of nodes and elements added or removed
2026 # since the previous clear of the log.
2027 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
2028 # @return list of log_block structures:
2033 # @ingroup l1_auxiliary
2034 def GetLog(self, clearAfterGet):
2035 return self.mesh.GetLog(clearAfterGet)
2037 ## Clears the log of nodes and elements added or removed since the previous
2038 # clear. Must be used immediately after GetLog if clearAfterGet is false.
2039 # @ingroup l1_auxiliary
2041 self.mesh.ClearLog()
2043 ## Toggles auto color mode on the object.
2044 # @param theAutoColor the flag which toggles auto color mode.
2045 # @ingroup l1_auxiliary
2046 def SetAutoColor(self, theAutoColor):
2047 self.mesh.SetAutoColor(theAutoColor)
2049 ## Gets flag of object auto color mode.
2050 # @return True or False
2051 # @ingroup l1_auxiliary
2052 def GetAutoColor(self):
2053 return self.mesh.GetAutoColor()
2055 ## Gets the internal ID
2056 # @return integer value, which is the internal Id of the mesh
2057 # @ingroup l1_auxiliary
2059 return self.mesh.GetId()
2062 # @return integer value, which is the study Id of the mesh
2063 # @ingroup l1_auxiliary
2064 def GetStudyId(self):
2065 return self.mesh.GetStudyId()
2067 ## Checks the group names for duplications.
2068 # Consider the maximum group name length stored in MED file.
2069 # @return True or False
2070 # @ingroup l1_auxiliary
2071 def HasDuplicatedGroupNamesMED(self):
2072 return self.mesh.HasDuplicatedGroupNamesMED()
2074 ## Obtains the mesh editor tool
2075 # @return an instance of SMESH_MeshEditor
2076 # @ingroup l1_modifying
2077 def GetMeshEditor(self):
2078 return self.mesh.GetMeshEditor()
2080 ## Wrap a list of IDs of elements or nodes into SMESH_IDSource which
2081 # can be passed as argument to accepting mesh, group or sub-mesh
2082 # @return an instance of SMESH_IDSource
2083 # @ingroup l1_auxiliary
2084 def GetIDSource(self, ids, elemType):
2085 return self.GetMeshEditor().MakeIDSource(ids, elemType)
2088 # @return an instance of SALOME_MED::MESH
2089 # @ingroup l1_auxiliary
2090 def GetMEDMesh(self):
2091 return self.mesh.GetMEDMesh()
2094 # Get informations about mesh contents:
2095 # ------------------------------------
2097 ## Gets the mesh stattistic
2098 # @return dictionary type element - count of elements
2099 # @ingroup l1_meshinfo
2100 def GetMeshInfo(self, obj = None):
2101 if not obj: obj = self.mesh
2102 return self.smeshpyD.GetMeshInfo(obj)
2104 ## Returns the number of nodes in the mesh
2105 # @return an integer value
2106 # @ingroup l1_meshinfo
2108 return self.mesh.NbNodes()
2110 ## Returns the number of elements in the mesh
2111 # @return an integer value
2112 # @ingroup l1_meshinfo
2113 def NbElements(self):
2114 return self.mesh.NbElements()
2116 ## Returns the number of 0d elements in the mesh
2117 # @return an integer value
2118 # @ingroup l1_meshinfo
2119 def Nb0DElements(self):
2120 return self.mesh.Nb0DElements()
2122 ## Returns the number of edges in the mesh
2123 # @return an integer value
2124 # @ingroup l1_meshinfo
2126 return self.mesh.NbEdges()
2128 ## Returns the number of edges with the given order in the mesh
2129 # @param elementOrder the order of elements:
2130 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2131 # @return an integer value
2132 # @ingroup l1_meshinfo
2133 def NbEdgesOfOrder(self, elementOrder):
2134 return self.mesh.NbEdgesOfOrder(elementOrder)
2136 ## Returns the number of faces in the mesh
2137 # @return an integer value
2138 # @ingroup l1_meshinfo
2140 return self.mesh.NbFaces()
2142 ## Returns the number of faces with the given order in the mesh
2143 # @param elementOrder the order of elements:
2144 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2145 # @return an integer value
2146 # @ingroup l1_meshinfo
2147 def NbFacesOfOrder(self, elementOrder):
2148 return self.mesh.NbFacesOfOrder(elementOrder)
2150 ## Returns the number of triangles in the mesh
2151 # @return an integer value
2152 # @ingroup l1_meshinfo
2153 def NbTriangles(self):
2154 return self.mesh.NbTriangles()
2156 ## Returns the number of triangles with the given order in the mesh
2157 # @param elementOrder is the order of elements:
2158 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2159 # @return an integer value
2160 # @ingroup l1_meshinfo
2161 def NbTrianglesOfOrder(self, elementOrder):
2162 return self.mesh.NbTrianglesOfOrder(elementOrder)
2164 ## Returns the number of quadrangles in the mesh
2165 # @return an integer value
2166 # @ingroup l1_meshinfo
2167 def NbQuadrangles(self):
2168 return self.mesh.NbQuadrangles()
2170 ## Returns the number of quadrangles with the given order in the mesh
2171 # @param elementOrder the order of elements:
2172 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2173 # @return an integer value
2174 # @ingroup l1_meshinfo
2175 def NbQuadranglesOfOrder(self, elementOrder):
2176 return self.mesh.NbQuadranglesOfOrder(elementOrder)
2178 ## Returns the number of polygons in the mesh
2179 # @return an integer value
2180 # @ingroup l1_meshinfo
2181 def NbPolygons(self):
2182 return self.mesh.NbPolygons()
2184 ## Returns the number of volumes in the mesh
2185 # @return an integer value
2186 # @ingroup l1_meshinfo
2187 def NbVolumes(self):
2188 return self.mesh.NbVolumes()
2190 ## Returns the number of volumes with the given order in the mesh
2191 # @param elementOrder the order of elements:
2192 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2193 # @return an integer value
2194 # @ingroup l1_meshinfo
2195 def NbVolumesOfOrder(self, elementOrder):
2196 return self.mesh.NbVolumesOfOrder(elementOrder)
2198 ## Returns the number of tetrahedrons in the mesh
2199 # @return an integer value
2200 # @ingroup l1_meshinfo
2202 return self.mesh.NbTetras()
2204 ## Returns the number of tetrahedrons with the given order in the mesh
2205 # @param elementOrder the order of elements:
2206 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2207 # @return an integer value
2208 # @ingroup l1_meshinfo
2209 def NbTetrasOfOrder(self, elementOrder):
2210 return self.mesh.NbTetrasOfOrder(elementOrder)
2212 ## Returns the number of hexahedrons in the mesh
2213 # @return an integer value
2214 # @ingroup l1_meshinfo
2216 return self.mesh.NbHexas()
2218 ## Returns the number of hexahedrons with the given order in the mesh
2219 # @param elementOrder the order of elements:
2220 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2221 # @return an integer value
2222 # @ingroup l1_meshinfo
2223 def NbHexasOfOrder(self, elementOrder):
2224 return self.mesh.NbHexasOfOrder(elementOrder)
2226 ## Returns the number of pyramids in the mesh
2227 # @return an integer value
2228 # @ingroup l1_meshinfo
2229 def NbPyramids(self):
2230 return self.mesh.NbPyramids()
2232 ## Returns the number of pyramids with the given order in the mesh
2233 # @param elementOrder the order of elements:
2234 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2235 # @return an integer value
2236 # @ingroup l1_meshinfo
2237 def NbPyramidsOfOrder(self, elementOrder):
2238 return self.mesh.NbPyramidsOfOrder(elementOrder)
2240 ## Returns the number of prisms in the mesh
2241 # @return an integer value
2242 # @ingroup l1_meshinfo
2244 return self.mesh.NbPrisms()
2246 ## Returns the number of prisms with the given order in the mesh
2247 # @param elementOrder the order of elements:
2248 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2249 # @return an integer value
2250 # @ingroup l1_meshinfo
2251 def NbPrismsOfOrder(self, elementOrder):
2252 return self.mesh.NbPrismsOfOrder(elementOrder)
2254 ## Returns the number of polyhedrons in the mesh
2255 # @return an integer value
2256 # @ingroup l1_meshinfo
2257 def NbPolyhedrons(self):
2258 return self.mesh.NbPolyhedrons()
2260 ## Returns the number of submeshes in the mesh
2261 # @return an integer value
2262 # @ingroup l1_meshinfo
2263 def NbSubMesh(self):
2264 return self.mesh.NbSubMesh()
2266 ## Returns the list of mesh elements IDs
2267 # @return the list of integer values
2268 # @ingroup l1_meshinfo
2269 def GetElementsId(self):
2270 return self.mesh.GetElementsId()
2272 ## Returns the list of IDs of mesh elements with the given type
2273 # @param elementType the required type of elements (SMESH.NODE, SMESH.EDGE, SMESH.FACE or SMESH.VOLUME)
2274 # @return list of integer values
2275 # @ingroup l1_meshinfo
2276 def GetElementsByType(self, elementType):
2277 return self.mesh.GetElementsByType(elementType)
2279 ## Returns the list of mesh nodes IDs
2280 # @return the list of integer values
2281 # @ingroup l1_meshinfo
2282 def GetNodesId(self):
2283 return self.mesh.GetNodesId()
2285 # Get the information about mesh elements:
2286 # ------------------------------------
2288 ## Returns the type of mesh element
2289 # @return the value from SMESH::ElementType enumeration
2290 # @ingroup l1_meshinfo
2291 def GetElementType(self, id, iselem):
2292 return self.mesh.GetElementType(id, iselem)
2294 ## Returns the geometric type of mesh element
2295 # @return the value from SMESH::EntityType enumeration
2296 # @ingroup l1_meshinfo
2297 def GetElementGeomType(self, id):
2298 return self.mesh.GetElementGeomType(id)
2300 ## Returns the list of submesh elements IDs
2301 # @param Shape a geom object(subshape) IOR
2302 # Shape must be the subshape of a ShapeToMesh()
2303 # @return the list of integer values
2304 # @ingroup l1_meshinfo
2305 def GetSubMeshElementsId(self, Shape):
2306 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2307 ShapeID = Shape.GetSubShapeIndices()[0]
2310 return self.mesh.GetSubMeshElementsId(ShapeID)
2312 ## Returns the list of submesh nodes IDs
2313 # @param Shape a geom object(subshape) IOR
2314 # Shape must be the subshape of a ShapeToMesh()
2315 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
2316 # @return the list of integer values
2317 # @ingroup l1_meshinfo
2318 def GetSubMeshNodesId(self, Shape, all):
2319 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2320 ShapeID = Shape.GetSubShapeIndices()[0]
2323 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2325 ## Returns type of elements on given shape
2326 # @param Shape a geom object(subshape) IOR
2327 # Shape must be a subshape of a ShapeToMesh()
2328 # @return element type
2329 # @ingroup l1_meshinfo
2330 def GetSubMeshElementType(self, Shape):
2331 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2332 ShapeID = Shape.GetSubShapeIndices()[0]
2335 return self.mesh.GetSubMeshElementType(ShapeID)
2337 ## Gets the mesh description
2338 # @return string value
2339 # @ingroup l1_meshinfo
2341 return self.mesh.Dump()
2344 # Get the information about nodes and elements of a mesh by its IDs:
2345 # -----------------------------------------------------------
2347 ## Gets XYZ coordinates of a node
2348 # \n If there is no nodes for the given ID - returns an empty list
2349 # @return a list of double precision values
2350 # @ingroup l1_meshinfo
2351 def GetNodeXYZ(self, id):
2352 return self.mesh.GetNodeXYZ(id)
2354 ## Returns list of IDs of inverse elements for the given node
2355 # \n If there is no node for the given ID - returns an empty list
2356 # @return a list of integer values
2357 # @ingroup l1_meshinfo
2358 def GetNodeInverseElements(self, id):
2359 return self.mesh.GetNodeInverseElements(id)
2361 ## @brief Returns the position of a node on the shape
2362 # @return SMESH::NodePosition
2363 # @ingroup l1_meshinfo
2364 def GetNodePosition(self,NodeID):
2365 return self.mesh.GetNodePosition(NodeID)
2367 ## If the given element is a node, returns the ID of shape
2368 # \n If there is no node for the given ID - returns -1
2369 # @return an integer value
2370 # @ingroup l1_meshinfo
2371 def GetShapeID(self, id):
2372 return self.mesh.GetShapeID(id)
2374 ## Returns the ID of the result shape after
2375 # FindShape() from SMESH_MeshEditor for the given element
2376 # \n If there is no element for the given ID - returns -1
2377 # @return an integer value
2378 # @ingroup l1_meshinfo
2379 def GetShapeIDForElem(self,id):
2380 return self.mesh.GetShapeIDForElem(id)
2382 ## Returns the number of nodes for the given element
2383 # \n If there is no element for the given ID - returns -1
2384 # @return an integer value
2385 # @ingroup l1_meshinfo
2386 def GetElemNbNodes(self, id):
2387 return self.mesh.GetElemNbNodes(id)
2389 ## Returns the node ID the given index for the given element
2390 # \n If there is no element for the given ID - returns -1
2391 # \n If there is no node for the given index - returns -2
2392 # @return an integer value
2393 # @ingroup l1_meshinfo
2394 def GetElemNode(self, id, index):
2395 return self.mesh.GetElemNode(id, index)
2397 ## Returns the IDs of nodes of the given element
2398 # @return a list of integer values
2399 # @ingroup l1_meshinfo
2400 def GetElemNodes(self, id):
2401 return self.mesh.GetElemNodes(id)
2403 ## Returns true if the given node is the medium node in the given quadratic element
2404 # @ingroup l1_meshinfo
2405 def IsMediumNode(self, elementID, nodeID):
2406 return self.mesh.IsMediumNode(elementID, nodeID)
2408 ## Returns true if the given node is the medium node in one of quadratic elements
2409 # @ingroup l1_meshinfo
2410 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2411 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2413 ## Returns the number of edges for the given element
2414 # @ingroup l1_meshinfo
2415 def ElemNbEdges(self, id):
2416 return self.mesh.ElemNbEdges(id)
2418 ## Returns the number of faces for the given element
2419 # @ingroup l1_meshinfo
2420 def ElemNbFaces(self, id):
2421 return self.mesh.ElemNbFaces(id)
2423 ## Returns nodes of given face (counted from zero) for given volumic element.
2424 # @ingroup l1_meshinfo
2425 def GetElemFaceNodes(self,elemId, faceIndex):
2426 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2428 ## Returns an element based on all given nodes.
2429 # @ingroup l1_meshinfo
2430 def FindElementByNodes(self,nodes):
2431 return self.mesh.FindElementByNodes(nodes)
2433 ## Returns true if the given element is a polygon
2434 # @ingroup l1_meshinfo
2435 def IsPoly(self, id):
2436 return self.mesh.IsPoly(id)
2438 ## Returns true if the given element is quadratic
2439 # @ingroup l1_meshinfo
2440 def IsQuadratic(self, id):
2441 return self.mesh.IsQuadratic(id)
2443 ## Returns XYZ coordinates of the barycenter of the given element
2444 # \n If there is no element for the given ID - returns an empty list
2445 # @return a list of three double values
2446 # @ingroup l1_meshinfo
2447 def BaryCenter(self, id):
2448 return self.mesh.BaryCenter(id)
2451 # Get mesh measurements information:
2452 # ------------------------------------
2454 ## Get minimum distance between two nodes, elements or distance to the origin
2455 # @param id1 first node/element id
2456 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2457 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2458 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2459 # @return minimum distance value
2460 # @sa GetMinDistance()
2461 def MinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2462 aMeasure = self.GetMinDistance(id1, id2, isElem1, isElem2)
2463 return aMeasure.value
2465 ## Get measure structure specifying minimum distance data between two objects
2466 # @param id1 first node/element id
2467 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2468 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2469 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2470 # @return Measure structure
2472 def GetMinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2474 id1 = self.editor.MakeIDSource([id1], SMESH.FACE)
2476 id1 = self.editor.MakeIDSource([id1], SMESH.NODE)
2479 id2 = self.editor.MakeIDSource([id2], SMESH.FACE)
2481 id2 = self.editor.MakeIDSource([id2], SMESH.NODE)
2486 aMeasurements = self.smeshpyD.CreateMeasurements()
2487 aMeasure = aMeasurements.MinDistance(id1, id2)
2488 aMeasurements.UnRegister()
2491 ## Get bounding box of the specified object(s)
2492 # @param objects single source object or list of source objects or list of nodes/elements IDs
2493 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2494 # @c False specifies that @a objects are nodes
2495 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
2496 # @sa GetBoundingBox()
2497 def BoundingBox(self, objects=None, isElem=False):
2498 result = self.GetBoundingBox(objects, isElem)
2502 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
2505 ## Get measure structure specifying bounding box data of the specified object(s)
2506 # @param objects single source object or list of source objects or list of nodes/elements IDs
2507 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2508 # @c False specifies that @a objects are nodes
2509 # @return Measure structure
2511 def GetBoundingBox(self, IDs=None, isElem=False):
2514 elif isinstance(IDs, tuple):
2516 if not isinstance(IDs, list):
2518 if len(IDs) > 0 and isinstance(IDs[0], int):
2522 if isinstance(o, Mesh):
2523 srclist.append(o.mesh)
2524 elif hasattr(o, "_narrow"):
2525 src = o._narrow(SMESH.SMESH_IDSource)
2526 if src: srclist.append(src)
2528 elif isinstance(o, list):
2530 srclist.append(self.editor.MakeIDSource(o, SMESH.FACE))
2532 srclist.append(self.editor.MakeIDSource(o, SMESH.NODE))
2535 aMeasurements = self.smeshpyD.CreateMeasurements()
2536 aMeasure = aMeasurements.BoundingBox(srclist)
2537 aMeasurements.UnRegister()
2540 # Mesh edition (SMESH_MeshEditor functionality):
2541 # ---------------------------------------------
2543 ## Removes the elements from the mesh by ids
2544 # @param IDsOfElements is a list of ids of elements to remove
2545 # @return True or False
2546 # @ingroup l2_modif_del
2547 def RemoveElements(self, IDsOfElements):
2548 return self.editor.RemoveElements(IDsOfElements)
2550 ## Removes nodes from mesh by ids
2551 # @param IDsOfNodes is a list of ids of nodes to remove
2552 # @return True or False
2553 # @ingroup l2_modif_del
2554 def RemoveNodes(self, IDsOfNodes):
2555 return self.editor.RemoveNodes(IDsOfNodes)
2557 ## Removes all orphan (free) nodes from mesh
2558 # @return number of the removed nodes
2559 # @ingroup l2_modif_del
2560 def RemoveOrphanNodes(self):
2561 return self.editor.RemoveOrphanNodes()
2563 ## Add a node to the mesh by coordinates
2564 # @return Id of the new node
2565 # @ingroup l2_modif_add
2566 def AddNode(self, x, y, z):
2567 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2568 self.mesh.SetParameters(Parameters)
2569 return self.editor.AddNode( x, y, z)
2571 ## Creates a 0D element on a node with given number.
2572 # @param IDOfNode the ID of node for creation of the element.
2573 # @return the Id of the new 0D element
2574 # @ingroup l2_modif_add
2575 def Add0DElement(self, IDOfNode):
2576 return self.editor.Add0DElement(IDOfNode)
2578 ## Creates a linear or quadratic edge (this is determined
2579 # by the number of given nodes).
2580 # @param IDsOfNodes the list of node IDs for creation of the element.
2581 # The order of nodes in this list should correspond to the description
2582 # of MED. \n This description is located by the following link:
2583 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2584 # @return the Id of the new edge
2585 # @ingroup l2_modif_add
2586 def AddEdge(self, IDsOfNodes):
2587 return self.editor.AddEdge(IDsOfNodes)
2589 ## Creates a linear or quadratic face (this is determined
2590 # by the number of given nodes).
2591 # @param IDsOfNodes the list of node IDs for creation of the element.
2592 # The order of nodes in this list should correspond to the description
2593 # of MED. \n This description is located by the following link:
2594 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2595 # @return the Id of the new face
2596 # @ingroup l2_modif_add
2597 def AddFace(self, IDsOfNodes):
2598 return self.editor.AddFace(IDsOfNodes)
2600 ## Adds a polygonal face to the mesh by the list of node IDs
2601 # @param IdsOfNodes the list of node IDs for creation of the element.
2602 # @return the Id of the new face
2603 # @ingroup l2_modif_add
2604 def AddPolygonalFace(self, IdsOfNodes):
2605 return self.editor.AddPolygonalFace(IdsOfNodes)
2607 ## Creates both simple and quadratic volume (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 volumic element
2614 # @ingroup l2_modif_add
2615 def AddVolume(self, IDsOfNodes):
2616 return self.editor.AddVolume(IDsOfNodes)
2618 ## Creates a volume of many faces, giving nodes for each face.
2619 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2620 # @param Quantities the list of integer values, Quantities[i]
2621 # gives the quantity of nodes in face number i.
2622 # @return the Id of the new volumic element
2623 # @ingroup l2_modif_add
2624 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2625 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2627 ## Creates a volume of many faces, giving the IDs of the existing faces.
2628 # @param IdsOfFaces the list of face IDs for volume creation.
2630 # Note: The created volume will refer only to the nodes
2631 # of the given faces, not to the faces themselves.
2632 # @return the Id of the new volumic element
2633 # @ingroup l2_modif_add
2634 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2635 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2638 ## @brief Binds a node to a vertex
2639 # @param NodeID a node ID
2640 # @param Vertex a vertex or vertex ID
2641 # @return True if succeed else raises an exception
2642 # @ingroup l2_modif_add
2643 def SetNodeOnVertex(self, NodeID, Vertex):
2644 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2645 VertexID = Vertex.GetSubShapeIndices()[0]
2649 self.editor.SetNodeOnVertex(NodeID, VertexID)
2650 except SALOME.SALOME_Exception, inst:
2651 raise ValueError, inst.details.text
2655 ## @brief Stores the node position on an edge
2656 # @param NodeID a node ID
2657 # @param Edge an edge or edge ID
2658 # @param paramOnEdge a parameter on the edge where the node is located
2659 # @return True if succeed else raises an exception
2660 # @ingroup l2_modif_add
2661 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2662 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2663 EdgeID = Edge.GetSubShapeIndices()[0]
2667 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2668 except SALOME.SALOME_Exception, inst:
2669 raise ValueError, inst.details.text
2672 ## @brief Stores node position on a face
2673 # @param NodeID a node ID
2674 # @param Face a face or face ID
2675 # @param u U parameter on the face where the node is located
2676 # @param v V parameter on the face where the node is located
2677 # @return True if succeed else raises an exception
2678 # @ingroup l2_modif_add
2679 def SetNodeOnFace(self, NodeID, Face, u, v):
2680 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2681 FaceID = Face.GetSubShapeIndices()[0]
2685 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2686 except SALOME.SALOME_Exception, inst:
2687 raise ValueError, inst.details.text
2690 ## @brief Binds a node to a solid
2691 # @param NodeID a node ID
2692 # @param Solid a solid or solid ID
2693 # @return True if succeed else raises an exception
2694 # @ingroup l2_modif_add
2695 def SetNodeInVolume(self, NodeID, Solid):
2696 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2697 SolidID = Solid.GetSubShapeIndices()[0]
2701 self.editor.SetNodeInVolume(NodeID, SolidID)
2702 except SALOME.SALOME_Exception, inst:
2703 raise ValueError, inst.details.text
2706 ## @brief Bind an element to a shape
2707 # @param ElementID an element ID
2708 # @param Shape a shape or shape ID
2709 # @return True if succeed else raises an exception
2710 # @ingroup l2_modif_add
2711 def SetMeshElementOnShape(self, ElementID, Shape):
2712 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2713 ShapeID = Shape.GetSubShapeIndices()[0]
2717 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2718 except SALOME.SALOME_Exception, inst:
2719 raise ValueError, inst.details.text
2723 ## Moves the node with the given id
2724 # @param NodeID the id of the node
2725 # @param x a new X coordinate
2726 # @param y a new Y coordinate
2727 # @param z a new Z coordinate
2728 # @return True if succeed else False
2729 # @ingroup l2_modif_movenode
2730 def MoveNode(self, NodeID, x, y, z):
2731 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2732 self.mesh.SetParameters(Parameters)
2733 return self.editor.MoveNode(NodeID, x, y, z)
2735 ## Finds the node closest to a point and moves it to a point location
2736 # @param x the X coordinate of a point
2737 # @param y the Y coordinate of a point
2738 # @param z the Z coordinate of a point
2739 # @param NodeID if specified (>0), the node with this ID is moved,
2740 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2741 # @return the ID of a node
2742 # @ingroup l2_modif_throughp
2743 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2744 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2745 self.mesh.SetParameters(Parameters)
2746 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2748 ## Finds the node closest to a point
2749 # @param x the X coordinate of a point
2750 # @param y the Y coordinate of a point
2751 # @param z the Z coordinate of a point
2752 # @return the ID of a node
2753 # @ingroup l2_modif_throughp
2754 def FindNodeClosestTo(self, x, y, z):
2755 #preview = self.mesh.GetMeshEditPreviewer()
2756 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2757 return self.editor.FindNodeClosestTo(x, y, z)
2759 ## Finds the elements where a point lays IN or ON
2760 # @param x the X coordinate of a point
2761 # @param y the Y coordinate of a point
2762 # @param z the Z coordinate of a point
2763 # @param elementType type of elements to find (SMESH.ALL type
2764 # means elements of any type excluding nodes and 0D elements)
2765 # @param meshPart a part of mesh (group, sub-mesh) to search within
2766 # @return list of IDs of found elements
2767 # @ingroup l2_modif_throughp
2768 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL, meshPart=None):
2770 return self.editor.FindAmongElementsByPoint( meshPart, x, y, z, elementType );
2772 return self.editor.FindElementsByPoint(x, y, z, elementType)
2774 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2775 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2777 def GetPointState(self, x, y, z):
2778 return self.editor.GetPointState(x, y, z)
2780 ## Finds the node closest to a point and moves it to a point location
2781 # @param x the X coordinate of a point
2782 # @param y the Y coordinate of a point
2783 # @param z the Z coordinate of a point
2784 # @return the ID of a moved node
2785 # @ingroup l2_modif_throughp
2786 def MeshToPassThroughAPoint(self, x, y, z):
2787 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2789 ## Replaces two neighbour triangles sharing Node1-Node2 link
2790 # with the triangles built on the same 4 nodes but having other common link.
2791 # @param NodeID1 the ID of the first node
2792 # @param NodeID2 the ID of the second node
2793 # @return false if proper faces were not found
2794 # @ingroup l2_modif_invdiag
2795 def InverseDiag(self, NodeID1, NodeID2):
2796 return self.editor.InverseDiag(NodeID1, NodeID2)
2798 ## Replaces two neighbour triangles sharing Node1-Node2 link
2799 # with a quadrangle built on the same 4 nodes.
2800 # @param NodeID1 the ID of the first node
2801 # @param NodeID2 the ID of the second node
2802 # @return false if proper faces were not found
2803 # @ingroup l2_modif_unitetri
2804 def DeleteDiag(self, NodeID1, NodeID2):
2805 return self.editor.DeleteDiag(NodeID1, NodeID2)
2807 ## Reorients elements by ids
2808 # @param IDsOfElements if undefined reorients all mesh elements
2809 # @return True if succeed else False
2810 # @ingroup l2_modif_changori
2811 def Reorient(self, IDsOfElements=None):
2812 if IDsOfElements == None:
2813 IDsOfElements = self.GetElementsId()
2814 return self.editor.Reorient(IDsOfElements)
2816 ## Reorients all elements of the object
2817 # @param theObject mesh, submesh or group
2818 # @return True if succeed else False
2819 # @ingroup l2_modif_changori
2820 def ReorientObject(self, theObject):
2821 if ( isinstance( theObject, Mesh )):
2822 theObject = theObject.GetMesh()
2823 return self.editor.ReorientObject(theObject)
2825 ## Fuses the neighbouring triangles into quadrangles.
2826 # @param IDsOfElements The triangles to be fused,
2827 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2828 # @param MaxAngle is the maximum angle between element normals at which the fusion
2829 # is still performed; theMaxAngle is mesured in radians.
2830 # Also it could be a name of variable which defines angle in degrees.
2831 # @return TRUE in case of success, FALSE otherwise.
2832 # @ingroup l2_modif_unitetri
2833 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2835 if isinstance(MaxAngle,str):
2837 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2839 MaxAngle = DegreesToRadians(MaxAngle)
2840 if IDsOfElements == []:
2841 IDsOfElements = self.GetElementsId()
2842 self.mesh.SetParameters(Parameters)
2844 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2845 Functor = theCriterion
2847 Functor = self.smeshpyD.GetFunctor(theCriterion)
2848 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2850 ## Fuses the neighbouring triangles of the object into quadrangles
2851 # @param theObject is mesh, submesh or group
2852 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2853 # @param MaxAngle a max angle between element normals at which the fusion
2854 # is still performed; theMaxAngle is mesured in radians.
2855 # @return TRUE in case of success, FALSE otherwise.
2856 # @ingroup l2_modif_unitetri
2857 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2858 if ( isinstance( theObject, Mesh )):
2859 theObject = theObject.GetMesh()
2860 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2862 ## Splits quadrangles into triangles.
2863 # @param IDsOfElements the faces to be splitted.
2864 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2865 # @return TRUE in case of success, FALSE otherwise.
2866 # @ingroup l2_modif_cutquadr
2867 def QuadToTri (self, IDsOfElements, theCriterion):
2868 if IDsOfElements == []:
2869 IDsOfElements = self.GetElementsId()
2870 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2872 ## Splits quadrangles into triangles.
2873 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2874 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2875 # @return TRUE in case of success, FALSE otherwise.
2876 # @ingroup l2_modif_cutquadr
2877 def QuadToTriObject (self, theObject, theCriterion):
2878 if ( isinstance( theObject, Mesh )):
2879 theObject = theObject.GetMesh()
2880 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2882 ## Splits quadrangles into triangles.
2883 # @param IDsOfElements the faces to be splitted
2884 # @param Diag13 is used to choose a diagonal for splitting.
2885 # @return TRUE in case of success, FALSE otherwise.
2886 # @ingroup l2_modif_cutquadr
2887 def SplitQuad (self, IDsOfElements, Diag13):
2888 if IDsOfElements == []:
2889 IDsOfElements = self.GetElementsId()
2890 return self.editor.SplitQuad(IDsOfElements, Diag13)
2892 ## Splits quadrangles into triangles.
2893 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2894 # @param Diag13 is used to choose a diagonal for splitting.
2895 # @return TRUE in case of success, FALSE otherwise.
2896 # @ingroup l2_modif_cutquadr
2897 def SplitQuadObject (self, theObject, Diag13):
2898 if ( isinstance( theObject, Mesh )):
2899 theObject = theObject.GetMesh()
2900 return self.editor.SplitQuadObject(theObject, Diag13)
2902 ## Finds a better splitting of the given quadrangle.
2903 # @param IDOfQuad the ID of the quadrangle to be splitted.
2904 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2905 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2906 # diagonal is better, 0 if error occurs.
2907 # @ingroup l2_modif_cutquadr
2908 def BestSplit (self, IDOfQuad, theCriterion):
2909 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2911 ## Splits volumic elements into tetrahedrons
2912 # @param elemIDs either list of elements or mesh or group or submesh
2913 # @param method flags passing splitting method: Hex_5Tet, Hex_6Tet, Hex_24Tet
2914 # Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc
2915 # @ingroup l2_modif_cutquadr
2916 def SplitVolumesIntoTetra(self, elemIDs, method=Hex_5Tet ):
2917 if isinstance( elemIDs, Mesh ):
2918 elemIDs = elemIDs.GetMesh()
2919 if ( isinstance( elemIDs, list )):
2920 elemIDs = self.editor.MakeIDSource(elemIDs, SMESH.VOLUME)
2921 self.editor.SplitVolumesIntoTetra(elemIDs, method)
2923 ## Splits quadrangle faces near triangular facets of volumes
2925 # @ingroup l1_auxiliary
2926 def SplitQuadsNearTriangularFacets(self):
2927 faces_array = self.GetElementsByType(SMESH.FACE)
2928 for face_id in faces_array:
2929 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2930 quad_nodes = self.mesh.GetElemNodes(face_id)
2931 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2932 isVolumeFound = False
2933 for node1_elem in node1_elems:
2934 if not isVolumeFound:
2935 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2936 nb_nodes = self.GetElemNbNodes(node1_elem)
2937 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2938 volume_elem = node1_elem
2939 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2940 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2941 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2942 isVolumeFound = True
2943 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2944 self.SplitQuad([face_id], False) # diagonal 2-4
2945 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2946 isVolumeFound = True
2947 self.SplitQuad([face_id], True) # diagonal 1-3
2948 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2949 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2950 isVolumeFound = True
2951 self.SplitQuad([face_id], True) # diagonal 1-3
2953 ## @brief Splits hexahedrons into tetrahedrons.
2955 # This operation uses pattern mapping functionality for splitting.
2956 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2957 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2958 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2959 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2960 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2961 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2962 # @return TRUE in case of success, FALSE otherwise.
2963 # @ingroup l1_auxiliary
2964 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2965 # Pattern: 5.---------.6
2970 # (0,0,1) 4.---------.7 * |
2977 # (0,0,0) 0.---------.3
2978 pattern_tetra = "!!! Nb of points: \n 8 \n\
2988 !!! Indices of points of 6 tetras: \n\
2996 pattern = self.smeshpyD.GetPattern()
2997 isDone = pattern.LoadFromFile(pattern_tetra)
2999 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
3002 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
3003 isDone = pattern.MakeMesh(self.mesh, False, False)
3004 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
3006 # split quafrangle faces near triangular facets of volumes
3007 self.SplitQuadsNearTriangularFacets()
3011 ## @brief Split hexahedrons into prisms.
3013 # Uses the pattern mapping functionality for splitting.
3014 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
3015 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
3016 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
3017 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
3018 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
3019 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
3020 # @return TRUE in case of success, FALSE otherwise.
3021 # @ingroup l1_auxiliary
3022 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
3023 # Pattern: 5.---------.6
3028 # (0,0,1) 4.---------.7 |
3035 # (0,0,0) 0.---------.3
3036 pattern_prism = "!!! Nb of points: \n 8 \n\
3046 !!! Indices of points of 2 prisms: \n\
3050 pattern = self.smeshpyD.GetPattern()
3051 isDone = pattern.LoadFromFile(pattern_prism)
3053 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
3056 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
3057 isDone = pattern.MakeMesh(self.mesh, False, False)
3058 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
3060 # Splits quafrangle faces near triangular facets of volumes
3061 self.SplitQuadsNearTriangularFacets()
3065 ## Smoothes elements
3066 # @param IDsOfElements the list if ids of elements to smooth
3067 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3068 # Note that nodes built on edges and boundary nodes are always fixed.
3069 # @param MaxNbOfIterations the maximum number of iterations
3070 # @param MaxAspectRatio varies in range [1.0, inf]
3071 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3072 # @return TRUE in case of success, FALSE otherwise.
3073 # @ingroup l2_modif_smooth
3074 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
3075 MaxNbOfIterations, MaxAspectRatio, Method):
3076 if IDsOfElements == []:
3077 IDsOfElements = self.GetElementsId()
3078 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
3079 self.mesh.SetParameters(Parameters)
3080 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
3081 MaxNbOfIterations, MaxAspectRatio, Method)
3083 ## Smoothes elements which belong to the given object
3084 # @param theObject the object to smooth
3085 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3086 # Note that nodes built on edges and boundary nodes are always fixed.
3087 # @param MaxNbOfIterations the maximum number of iterations
3088 # @param MaxAspectRatio varies in range [1.0, inf]
3089 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3090 # @return TRUE in case of success, FALSE otherwise.
3091 # @ingroup l2_modif_smooth
3092 def SmoothObject(self, theObject, IDsOfFixedNodes,
3093 MaxNbOfIterations, MaxAspectRatio, Method):
3094 if ( isinstance( theObject, Mesh )):
3095 theObject = theObject.GetMesh()
3096 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
3097 MaxNbOfIterations, MaxAspectRatio, Method)
3099 ## Parametrically smoothes the given elements
3100 # @param IDsOfElements the list if ids of elements to smooth
3101 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3102 # Note that nodes built on edges and boundary nodes are always fixed.
3103 # @param MaxNbOfIterations the maximum number of iterations
3104 # @param MaxAspectRatio varies in range [1.0, inf]
3105 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3106 # @return TRUE in case of success, FALSE otherwise.
3107 # @ingroup l2_modif_smooth
3108 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
3109 MaxNbOfIterations, MaxAspectRatio, Method):
3110 if IDsOfElements == []:
3111 IDsOfElements = self.GetElementsId()
3112 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
3113 self.mesh.SetParameters(Parameters)
3114 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
3115 MaxNbOfIterations, MaxAspectRatio, Method)
3117 ## Parametrically smoothes the elements which belong to the given object
3118 # @param theObject the object to smooth
3119 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3120 # Note that nodes built on edges and boundary nodes are always fixed.
3121 # @param MaxNbOfIterations the maximum number of iterations
3122 # @param MaxAspectRatio varies in range [1.0, inf]
3123 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3124 # @return TRUE in case of success, FALSE otherwise.
3125 # @ingroup l2_modif_smooth
3126 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
3127 MaxNbOfIterations, MaxAspectRatio, Method):
3128 if ( isinstance( theObject, Mesh )):
3129 theObject = theObject.GetMesh()
3130 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
3131 MaxNbOfIterations, MaxAspectRatio, Method)
3133 ## Converts the mesh to quadratic, deletes old elements, replacing
3134 # them with quadratic with the same id.
3135 # @param theForce3d new node creation method:
3136 # 0 - the medium node lies at the geometrical entity from which the mesh element is built
3137 # 1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element
3138 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
3139 # @ingroup l2_modif_tofromqu
3140 def ConvertToQuadratic(self, theForce3d, theSubMesh=None):
3142 self.editor.ConvertToQuadraticObject(theForce3d,theSubMesh)
3144 self.editor.ConvertToQuadratic(theForce3d)
3146 ## Converts the mesh from quadratic to ordinary,
3147 # deletes old quadratic elements, \n replacing
3148 # them with ordinary mesh elements with the same id.
3149 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
3150 # @ingroup l2_modif_tofromqu
3151 def ConvertFromQuadratic(self, theSubMesh=None):
3153 self.editor.ConvertFromQuadraticObject(theSubMesh)
3155 return self.editor.ConvertFromQuadratic()
3157 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
3158 # @return TRUE if operation has been completed successfully, FALSE otherwise
3159 # @ingroup l2_modif_edit
3160 def Make2DMeshFrom3D(self):
3161 return self.editor. Make2DMeshFrom3D()
3163 ## Creates missing boundary elements
3164 # @param elements - elements whose boundary is to be checked:
3165 # mesh, group, sub-mesh or list of elements
3166 # if elements is mesh, it must be the mesh whose MakeBoundaryMesh() is called
3167 # @param dimension - defines type of boundary elements to create:
3168 # SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D
3169 # SMESH.BND_1DFROM3D creates mesh edges on all borders of free facets of 3D cells
3170 # @param groupName - a name of group to store created boundary elements in,
3171 # "" means not to create the group
3172 # @param meshName - a name of new mesh to store created boundary elements in,
3173 # "" means not to create the new mesh
3174 # @param toCopyElements - if true, the checked elements will be copied into
3175 # the new mesh else only boundary elements will be copied into the new mesh
3176 # @param toCopyExistingBondary - if true, not only new but also pre-existing
3177 # boundary elements will be copied into the new mesh
3178 # @return tuple (mesh, group) where bondary elements were added to
3179 # @ingroup l2_modif_edit
3180 def MakeBoundaryMesh(self, elements, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3181 toCopyElements=False, toCopyExistingBondary=False):
3182 if isinstance( elements, Mesh ):
3183 elements = elements.GetMesh()
3184 if ( isinstance( elements, list )):
3185 elemType = SMESH.ALL
3186 if elements: elemType = self.GetElementType( elements[0], iselem=True)
3187 elements = self.editor.MakeIDSource(elements, elemType)
3188 mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName,
3189 toCopyElements,toCopyExistingBondary)
3190 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3194 # @brief Creates missing boundary elements around either the whole mesh or
3195 # groups of 2D elements
3196 # @param dimension - defines type of boundary elements to create
3197 # @param groupName - a name of group to store all boundary elements in,
3198 # "" means not to create the group
3199 # @param meshName - a name of a new mesh, which is a copy of the initial
3200 # mesh + created boundary elements; "" means not to create the new mesh
3201 # @param toCopyAll - if true, the whole initial mesh will be copied into
3202 # the new mesh else only boundary elements will be copied into the new mesh
3203 # @param groups - groups of 2D elements to make boundary around
3204 # @retval tuple( long, mesh, groups )
3205 # long - number of added boundary elements
3206 # mesh - the mesh where elements were added to
3207 # group - the group of boundary elements or None
3209 def MakeBoundaryElements(self, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3210 toCopyAll=False, groups=[]):
3211 nb, mesh, group = self.editor.MakeBoundaryElements(dimension,groupName,meshName,
3213 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3214 return nb, mesh, group
3216 ## Renumber mesh nodes
3217 # @ingroup l2_modif_renumber
3218 def RenumberNodes(self):
3219 self.editor.RenumberNodes()
3221 ## Renumber mesh elements
3222 # @ingroup l2_modif_renumber
3223 def RenumberElements(self):
3224 self.editor.RenumberElements()
3226 ## Generates new elements by rotation of the elements around the axis
3227 # @param IDsOfElements the list of ids of elements to sweep
3228 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3229 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
3230 # @param NbOfSteps the number of steps
3231 # @param Tolerance tolerance
3232 # @param MakeGroups forces the generation of new groups from existing ones
3233 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3234 # of all steps, else - size of each step
3235 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3236 # @ingroup l2_modif_extrurev
3237 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
3238 MakeGroups=False, TotalAngle=False):
3240 if isinstance(AngleInRadians,str):
3242 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3244 AngleInRadians = DegreesToRadians(AngleInRadians)
3245 if IDsOfElements == []:
3246 IDsOfElements = self.GetElementsId()
3247 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3248 Axis = self.smeshpyD.GetAxisStruct(Axis)
3249 Axis,AxisParameters = ParseAxisStruct(Axis)
3250 if TotalAngle and NbOfSteps:
3251 AngleInRadians /= NbOfSteps
3252 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3253 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3254 self.mesh.SetParameters(Parameters)
3256 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
3257 AngleInRadians, NbOfSteps, Tolerance)
3258 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
3261 ## Generates new elements by rotation of the elements of object around the axis
3262 # @param theObject object which elements should be sweeped.
3263 # It can be a mesh, a sub mesh or a group.
3264 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3265 # @param AngleInRadians the angle of Rotation
3266 # @param NbOfSteps number of steps
3267 # @param Tolerance tolerance
3268 # @param MakeGroups forces the generation of new groups from existing ones
3269 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3270 # of all steps, else - size of each step
3271 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3272 # @ingroup l2_modif_extrurev
3273 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3274 MakeGroups=False, TotalAngle=False):
3276 if isinstance(AngleInRadians,str):
3278 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3280 AngleInRadians = DegreesToRadians(AngleInRadians)
3281 if ( isinstance( theObject, Mesh )):
3282 theObject = theObject.GetMesh()
3283 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3284 Axis = self.smeshpyD.GetAxisStruct(Axis)
3285 Axis,AxisParameters = ParseAxisStruct(Axis)
3286 if TotalAngle and NbOfSteps:
3287 AngleInRadians /= NbOfSteps
3288 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3289 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3290 self.mesh.SetParameters(Parameters)
3292 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
3293 NbOfSteps, Tolerance)
3294 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3297 ## Generates new elements by rotation of the elements of object around the axis
3298 # @param theObject object which elements should be sweeped.
3299 # It can be a mesh, a sub mesh or a group.
3300 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3301 # @param AngleInRadians the angle of Rotation
3302 # @param NbOfSteps number of steps
3303 # @param Tolerance tolerance
3304 # @param MakeGroups forces the generation of new groups from existing ones
3305 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3306 # of all steps, else - size of each step
3307 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3308 # @ingroup l2_modif_extrurev
3309 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3310 MakeGroups=False, TotalAngle=False):
3312 if isinstance(AngleInRadians,str):
3314 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3316 AngleInRadians = DegreesToRadians(AngleInRadians)
3317 if ( isinstance( theObject, Mesh )):
3318 theObject = theObject.GetMesh()
3319 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3320 Axis = self.smeshpyD.GetAxisStruct(Axis)
3321 Axis,AxisParameters = ParseAxisStruct(Axis)
3322 if TotalAngle and NbOfSteps:
3323 AngleInRadians /= NbOfSteps
3324 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3325 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3326 self.mesh.SetParameters(Parameters)
3328 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
3329 NbOfSteps, Tolerance)
3330 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3333 ## Generates new elements by rotation of the elements of object around the axis
3334 # @param theObject object which elements should be sweeped.
3335 # It can be a mesh, a sub mesh or a group.
3336 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3337 # @param AngleInRadians the angle of Rotation
3338 # @param NbOfSteps number of steps
3339 # @param Tolerance tolerance
3340 # @param MakeGroups forces the generation of new groups from existing ones
3341 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3342 # of all steps, else - size of each step
3343 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3344 # @ingroup l2_modif_extrurev
3345 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3346 MakeGroups=False, TotalAngle=False):
3348 if isinstance(AngleInRadians,str):
3350 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3352 AngleInRadians = DegreesToRadians(AngleInRadians)
3353 if ( isinstance( theObject, Mesh )):
3354 theObject = theObject.GetMesh()
3355 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3356 Axis = self.smeshpyD.GetAxisStruct(Axis)
3357 Axis,AxisParameters = ParseAxisStruct(Axis)
3358 if TotalAngle and NbOfSteps:
3359 AngleInRadians /= NbOfSteps
3360 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3361 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3362 self.mesh.SetParameters(Parameters)
3364 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
3365 NbOfSteps, Tolerance)
3366 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3369 ## Generates new elements by extrusion of the elements with given ids
3370 # @param IDsOfElements the list of elements ids for extrusion
3371 # @param StepVector vector or DirStruct, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3372 # @param NbOfSteps the number of steps
3373 # @param MakeGroups forces the generation of new groups from existing ones
3374 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3375 # @ingroup l2_modif_extrurev
3376 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
3377 if IDsOfElements == []:
3378 IDsOfElements = self.GetElementsId()
3379 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3380 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3381 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3382 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3383 Parameters = StepVectorParameters + var_separator + Parameters
3384 self.mesh.SetParameters(Parameters)
3386 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
3387 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
3390 ## Generates new elements by extrusion of the elements with given ids
3391 # @param IDsOfElements is ids of elements
3392 # @param StepVector vector, defining the direction and value of extrusion
3393 # @param NbOfSteps the number of steps
3394 # @param ExtrFlags sets flags for extrusion
3395 # @param SewTolerance uses for comparing locations of nodes if flag
3396 # EXTRUSION_FLAG_SEW is set
3397 # @param MakeGroups forces the generation of new groups from existing ones
3398 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3399 # @ingroup l2_modif_extrurev
3400 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
3401 ExtrFlags, SewTolerance, MakeGroups=False):
3402 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3403 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3405 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
3406 ExtrFlags, SewTolerance)
3407 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
3408 ExtrFlags, SewTolerance)
3411 ## Generates new elements by extrusion of the elements which belong to the object
3412 # @param theObject the object which elements should be processed.
3413 # It can be a mesh, a sub mesh or a group.
3414 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3415 # @param NbOfSteps the number of steps
3416 # @param MakeGroups forces the generation of new groups from existing ones
3417 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3418 # @ingroup l2_modif_extrurev
3419 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3420 if ( isinstance( theObject, Mesh )):
3421 theObject = theObject.GetMesh()
3422 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3423 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3424 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3425 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3426 Parameters = StepVectorParameters + var_separator + Parameters
3427 self.mesh.SetParameters(Parameters)
3429 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3430 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
3433 ## Generates new elements by extrusion of the elements which belong to the object
3434 # @param theObject object which elements should be processed.
3435 # It can be a mesh, a sub mesh or a group.
3436 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3437 # @param NbOfSteps the number of steps
3438 # @param MakeGroups to generate new groups from existing ones
3439 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3440 # @ingroup l2_modif_extrurev
3441 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3442 if ( isinstance( theObject, Mesh )):
3443 theObject = theObject.GetMesh()
3444 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3445 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3446 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3447 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3448 Parameters = StepVectorParameters + var_separator + Parameters
3449 self.mesh.SetParameters(Parameters)
3451 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3452 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3455 ## Generates new elements by extrusion of the elements which belong to the object
3456 # @param theObject object which elements should be processed.
3457 # It can be a mesh, a sub mesh or a group.
3458 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3459 # @param NbOfSteps the number of steps
3460 # @param MakeGroups forces the generation of new groups from existing ones
3461 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3462 # @ingroup l2_modif_extrurev
3463 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3464 if ( isinstance( theObject, Mesh )):
3465 theObject = theObject.GetMesh()
3466 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3467 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3468 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3469 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3470 Parameters = StepVectorParameters + var_separator + Parameters
3471 self.mesh.SetParameters(Parameters)
3473 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3474 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3479 ## Generates new elements by extrusion of the given elements
3480 # The path of extrusion must be a meshed edge.
3481 # @param Base mesh or group, or submesh, or list of ids of elements for extrusion
3482 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3483 # @param NodeStart the start node from Path. Defines the direction of extrusion
3484 # @param HasAngles allows the shape to be rotated around the path
3485 # to get the resulting mesh in a helical fashion
3486 # @param Angles list of angles in radians
3487 # @param LinearVariation forces the computation of rotation angles as linear
3488 # variation of the given Angles along path steps
3489 # @param HasRefPoint allows using the reference point
3490 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3491 # The User can specify any point as the Reference Point.
3492 # @param MakeGroups forces the generation of new groups from existing ones
3493 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3494 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3495 # only SMESH::Extrusion_Error otherwise
3496 # @ingroup l2_modif_extrurev
3497 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3498 HasAngles, Angles, LinearVariation,
3499 HasRefPoint, RefPoint, MakeGroups, ElemType):
3500 Angles,AnglesParameters = ParseAngles(Angles)
3501 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3502 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3503 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3505 Parameters = AnglesParameters + var_separator + RefPointParameters
3506 self.mesh.SetParameters(Parameters)
3508 if (isinstance(Path, Mesh)): Path = Path.GetMesh()
3510 if isinstance(Base, list):
3512 if Base == []: IDsOfElements = self.GetElementsId()
3513 else: IDsOfElements = Base
3514 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3515 HasAngles, Angles, LinearVariation,
3516 HasRefPoint, RefPoint, MakeGroups, ElemType)
3518 if isinstance(Base, Mesh): Base = Base.GetMesh()
3519 if isinstance(Base, SMESH._objref_SMESH_Mesh) or isinstance(Base, SMESH._objref_SMESH_Group) or isinstance(Base, SMESH._objref_SMESH_subMesh):
3520 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3521 HasAngles, Angles, LinearVariation,
3522 HasRefPoint, RefPoint, MakeGroups, ElemType)
3524 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3527 ## Generates new elements by extrusion of the given elements
3528 # The path of extrusion must be a meshed edge.
3529 # @param IDsOfElements ids of elements
3530 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3531 # @param PathShape shape(edge) defines the sub-mesh for the path
3532 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3533 # @param HasAngles allows the shape to be rotated around the path
3534 # to get the resulting mesh in a helical fashion
3535 # @param Angles list of angles in radians
3536 # @param HasRefPoint allows using the reference point
3537 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3538 # The User can specify any point as the Reference Point.
3539 # @param MakeGroups forces the generation of new groups from existing ones
3540 # @param LinearVariation forces the computation of rotation angles as linear
3541 # variation of the given Angles along path steps
3542 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3543 # only SMESH::Extrusion_Error otherwise
3544 # @ingroup l2_modif_extrurev
3545 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3546 HasAngles, Angles, HasRefPoint, RefPoint,
3547 MakeGroups=False, LinearVariation=False):
3548 Angles,AnglesParameters = ParseAngles(Angles)
3549 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3550 if IDsOfElements == []:
3551 IDsOfElements = self.GetElementsId()
3552 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3553 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3555 if ( isinstance( PathMesh, Mesh )):
3556 PathMesh = PathMesh.GetMesh()
3557 if HasAngles and Angles and LinearVariation:
3558 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3560 Parameters = AnglesParameters + var_separator + RefPointParameters
3561 self.mesh.SetParameters(Parameters)
3563 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3564 PathShape, NodeStart, HasAngles,
3565 Angles, HasRefPoint, RefPoint)
3566 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3567 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3569 ## Generates new elements by extrusion of the elements which belong to the object
3570 # The path of extrusion must be a meshed edge.
3571 # @param theObject the object which elements should be processed.
3572 # It can be a mesh, a sub mesh or a group.
3573 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3574 # @param PathShape shape(edge) defines the sub-mesh for the path
3575 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3576 # @param HasAngles allows the shape to be rotated around the path
3577 # to get the resulting mesh in a helical fashion
3578 # @param Angles list of angles
3579 # @param HasRefPoint allows using the reference point
3580 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3581 # The User can specify any point as the Reference Point.
3582 # @param MakeGroups forces the generation of new groups from existing ones
3583 # @param LinearVariation forces the computation of rotation angles as linear
3584 # variation of the given Angles along path steps
3585 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3586 # only SMESH::Extrusion_Error otherwise
3587 # @ingroup l2_modif_extrurev
3588 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3589 HasAngles, Angles, HasRefPoint, RefPoint,
3590 MakeGroups=False, LinearVariation=False):
3591 Angles,AnglesParameters = ParseAngles(Angles)
3592 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3593 if ( isinstance( theObject, Mesh )):
3594 theObject = theObject.GetMesh()
3595 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3596 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3597 if ( isinstance( PathMesh, Mesh )):
3598 PathMesh = PathMesh.GetMesh()
3599 if HasAngles and Angles and LinearVariation:
3600 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3602 Parameters = AnglesParameters + var_separator + RefPointParameters
3603 self.mesh.SetParameters(Parameters)
3605 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3606 PathShape, NodeStart, HasAngles,
3607 Angles, HasRefPoint, RefPoint)
3608 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3609 NodeStart, HasAngles, Angles, HasRefPoint,
3612 ## Generates new elements by extrusion of the elements which belong to the object
3613 # The path of extrusion must be a meshed edge.
3614 # @param theObject the object which elements should be processed.
3615 # It can be a mesh, a sub mesh or a group.
3616 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3617 # @param PathShape shape(edge) defines the sub-mesh for the path
3618 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3619 # @param HasAngles allows the shape to be rotated around the path
3620 # to get the resulting mesh in a helical fashion
3621 # @param Angles list of angles
3622 # @param HasRefPoint allows using the reference point
3623 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3624 # The User can specify any point as the Reference Point.
3625 # @param MakeGroups forces the generation of new groups from existing ones
3626 # @param LinearVariation forces the computation of rotation angles as linear
3627 # variation of the given Angles along path steps
3628 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3629 # only SMESH::Extrusion_Error otherwise
3630 # @ingroup l2_modif_extrurev
3631 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3632 HasAngles, Angles, HasRefPoint, RefPoint,
3633 MakeGroups=False, LinearVariation=False):
3634 Angles,AnglesParameters = ParseAngles(Angles)
3635 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3636 if ( isinstance( theObject, Mesh )):
3637 theObject = theObject.GetMesh()
3638 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3639 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3640 if ( isinstance( PathMesh, Mesh )):
3641 PathMesh = PathMesh.GetMesh()
3642 if HasAngles and Angles and LinearVariation:
3643 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3645 Parameters = AnglesParameters + var_separator + RefPointParameters
3646 self.mesh.SetParameters(Parameters)
3648 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3649 PathShape, NodeStart, HasAngles,
3650 Angles, HasRefPoint, RefPoint)
3651 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3652 NodeStart, HasAngles, Angles, HasRefPoint,
3655 ## Generates new elements by extrusion of the elements which belong to the object
3656 # The path of extrusion must be a meshed edge.
3657 # @param theObject the object which elements should be processed.
3658 # It can be a mesh, a sub mesh or a group.
3659 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3660 # @param PathShape shape(edge) defines the sub-mesh for the path
3661 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3662 # @param HasAngles allows the shape to be rotated around the path
3663 # to get the resulting mesh in a helical fashion
3664 # @param Angles list of angles
3665 # @param HasRefPoint allows using the reference point
3666 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3667 # The User can specify any point as the Reference Point.
3668 # @param MakeGroups forces the generation of new groups from existing ones
3669 # @param LinearVariation forces the computation of rotation angles as linear
3670 # variation of the given Angles along path steps
3671 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3672 # only SMESH::Extrusion_Error otherwise
3673 # @ingroup l2_modif_extrurev
3674 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3675 HasAngles, Angles, HasRefPoint, RefPoint,
3676 MakeGroups=False, LinearVariation=False):
3677 Angles,AnglesParameters = ParseAngles(Angles)
3678 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3679 if ( isinstance( theObject, Mesh )):
3680 theObject = theObject.GetMesh()
3681 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3682 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3683 if ( isinstance( PathMesh, Mesh )):
3684 PathMesh = PathMesh.GetMesh()
3685 if HasAngles and Angles and LinearVariation:
3686 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3688 Parameters = AnglesParameters + var_separator + RefPointParameters
3689 self.mesh.SetParameters(Parameters)
3691 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3692 PathShape, NodeStart, HasAngles,
3693 Angles, HasRefPoint, RefPoint)
3694 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3695 NodeStart, HasAngles, Angles, HasRefPoint,
3698 ## Creates a symmetrical copy of mesh elements
3699 # @param IDsOfElements list of elements ids
3700 # @param Mirror is AxisStruct or geom object(point, line, plane)
3701 # @param theMirrorType is POINT, AXIS or PLANE
3702 # If the Mirror is a geom object this parameter is unnecessary
3703 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3704 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3705 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3706 # @ingroup l2_modif_trsf
3707 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3708 if IDsOfElements == []:
3709 IDsOfElements = self.GetElementsId()
3710 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3711 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3712 Mirror,Parameters = ParseAxisStruct(Mirror)
3713 self.mesh.SetParameters(Parameters)
3714 if Copy and MakeGroups:
3715 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3716 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3719 ## Creates a new mesh by a symmetrical copy of mesh elements
3720 # @param IDsOfElements the list of elements ids
3721 # @param Mirror is AxisStruct or geom object (point, line, plane)
3722 # @param theMirrorType is POINT, AXIS or PLANE
3723 # If the Mirror is a geom object this parameter is unnecessary
3724 # @param MakeGroups to generate new groups from existing ones
3725 # @param NewMeshName a name of the new mesh to create
3726 # @return instance of Mesh class
3727 # @ingroup l2_modif_trsf
3728 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3729 if IDsOfElements == []:
3730 IDsOfElements = self.GetElementsId()
3731 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3732 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3733 Mirror,Parameters = ParseAxisStruct(Mirror)
3734 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3735 MakeGroups, NewMeshName)
3736 mesh.SetParameters(Parameters)
3737 return Mesh(self.smeshpyD,self.geompyD,mesh)
3739 ## Creates a symmetrical copy of the object
3740 # @param theObject mesh, submesh or group
3741 # @param Mirror AxisStruct or geom object (point, line, plane)
3742 # @param theMirrorType is POINT, AXIS or PLANE
3743 # If the Mirror is a geom object this parameter is unnecessary
3744 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3745 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3746 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3747 # @ingroup l2_modif_trsf
3748 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3749 if ( isinstance( theObject, Mesh )):
3750 theObject = theObject.GetMesh()
3751 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3752 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3753 Mirror,Parameters = ParseAxisStruct(Mirror)
3754 self.mesh.SetParameters(Parameters)
3755 if Copy and MakeGroups:
3756 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3757 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3760 ## Creates a new mesh by a symmetrical copy of the object
3761 # @param theObject mesh, submesh or group
3762 # @param Mirror AxisStruct or geom object (point, line, plane)
3763 # @param theMirrorType POINT, AXIS or PLANE
3764 # If the Mirror is a geom object this parameter is unnecessary
3765 # @param MakeGroups forces the generation of new groups from existing ones
3766 # @param NewMeshName the name of the new mesh to create
3767 # @return instance of Mesh class
3768 # @ingroup l2_modif_trsf
3769 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3770 if ( isinstance( theObject, Mesh )):
3771 theObject = theObject.GetMesh()
3772 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3773 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3774 Mirror,Parameters = ParseAxisStruct(Mirror)
3775 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3776 MakeGroups, NewMeshName)
3777 mesh.SetParameters(Parameters)
3778 return Mesh( self.smeshpyD,self.geompyD,mesh )
3780 ## Translates the elements
3781 # @param IDsOfElements list of elements ids
3782 # @param Vector the direction of translation (DirStruct or vector)
3783 # @param Copy allows copying the translated elements
3784 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3785 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3786 # @ingroup l2_modif_trsf
3787 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3788 if IDsOfElements == []:
3789 IDsOfElements = self.GetElementsId()
3790 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3791 Vector = self.smeshpyD.GetDirStruct(Vector)
3792 Vector,Parameters = ParseDirStruct(Vector)
3793 self.mesh.SetParameters(Parameters)
3794 if Copy and MakeGroups:
3795 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3796 self.editor.Translate(IDsOfElements, Vector, Copy)
3799 ## Creates a new mesh of translated elements
3800 # @param IDsOfElements list of elements ids
3801 # @param Vector the direction of translation (DirStruct or vector)
3802 # @param MakeGroups forces the generation of new groups from existing ones
3803 # @param NewMeshName the name of the newly created mesh
3804 # @return instance of Mesh class
3805 # @ingroup l2_modif_trsf
3806 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3807 if IDsOfElements == []:
3808 IDsOfElements = self.GetElementsId()
3809 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3810 Vector = self.smeshpyD.GetDirStruct(Vector)
3811 Vector,Parameters = ParseDirStruct(Vector)
3812 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3813 mesh.SetParameters(Parameters)
3814 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3816 ## Translates the object
3817 # @param theObject the object to translate (mesh, submesh, or group)
3818 # @param Vector direction of translation (DirStruct or geom vector)
3819 # @param Copy allows copying the translated elements
3820 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3821 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3822 # @ingroup l2_modif_trsf
3823 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3824 if ( isinstance( theObject, Mesh )):
3825 theObject = theObject.GetMesh()
3826 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3827 Vector = self.smeshpyD.GetDirStruct(Vector)
3828 Vector,Parameters = ParseDirStruct(Vector)
3829 self.mesh.SetParameters(Parameters)
3830 if Copy and MakeGroups:
3831 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3832 self.editor.TranslateObject(theObject, Vector, Copy)
3835 ## Creates a new mesh from the translated object
3836 # @param theObject the object to translate (mesh, submesh, or group)
3837 # @param Vector the direction of translation (DirStruct or geom vector)
3838 # @param MakeGroups forces the generation of new groups from existing ones
3839 # @param NewMeshName the name of the newly created mesh
3840 # @return instance of Mesh class
3841 # @ingroup l2_modif_trsf
3842 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3843 if (isinstance(theObject, Mesh)):
3844 theObject = theObject.GetMesh()
3845 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3846 Vector = self.smeshpyD.GetDirStruct(Vector)
3847 Vector,Parameters = ParseDirStruct(Vector)
3848 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3849 mesh.SetParameters(Parameters)
3850 return Mesh( self.smeshpyD, self.geompyD, mesh )
3854 ## Scales the object
3855 # @param theObject - the object to translate (mesh, submesh, or group)
3856 # @param thePoint - base point for scale
3857 # @param theScaleFact - list of 1-3 scale factors for axises
3858 # @param Copy - allows copying the translated elements
3859 # @param MakeGroups - forces the generation of new groups from existing
3861 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3862 # empty list otherwise
3863 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3864 if ( isinstance( theObject, Mesh )):
3865 theObject = theObject.GetMesh()
3866 if ( isinstance( theObject, list )):
3867 theObject = self.GetIDSource(theObject, SMESH.ALL)
3869 thePoint, Parameters = ParsePointStruct(thePoint)
3870 self.mesh.SetParameters(Parameters)
3872 if Copy and MakeGroups:
3873 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3874 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3877 ## Creates a new mesh from the translated object
3878 # @param theObject - the object to translate (mesh, submesh, or group)
3879 # @param thePoint - base point for scale
3880 # @param theScaleFact - list of 1-3 scale factors for axises
3881 # @param MakeGroups - forces the generation of new groups from existing ones
3882 # @param NewMeshName - the name of the newly created mesh
3883 # @return instance of Mesh class
3884 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3885 if (isinstance(theObject, Mesh)):
3886 theObject = theObject.GetMesh()
3887 if ( isinstance( theObject, list )):
3888 theObject = self.GetIDSource(theObject,SMESH.ALL)
3890 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3891 MakeGroups, NewMeshName)
3892 #mesh.SetParameters(Parameters)
3893 return Mesh( self.smeshpyD, self.geompyD, mesh )
3897 ## Rotates the elements
3898 # @param IDsOfElements list of elements ids
3899 # @param Axis the axis of rotation (AxisStruct or geom line)
3900 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3901 # @param Copy allows copying the rotated elements
3902 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3903 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3904 # @ingroup l2_modif_trsf
3905 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3907 if isinstance(AngleInRadians,str):
3909 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3911 AngleInRadians = DegreesToRadians(AngleInRadians)
3912 if IDsOfElements == []:
3913 IDsOfElements = self.GetElementsId()
3914 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3915 Axis = self.smeshpyD.GetAxisStruct(Axis)
3916 Axis,AxisParameters = ParseAxisStruct(Axis)
3917 Parameters = AxisParameters + var_separator + Parameters
3918 self.mesh.SetParameters(Parameters)
3919 if Copy and MakeGroups:
3920 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3921 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3924 ## Creates a new mesh of rotated elements
3925 # @param IDsOfElements list of element ids
3926 # @param Axis the axis of rotation (AxisStruct or geom line)
3927 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3928 # @param MakeGroups forces the generation of new groups from existing ones
3929 # @param NewMeshName the name of the newly created mesh
3930 # @return instance of Mesh class
3931 # @ingroup l2_modif_trsf
3932 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3934 if isinstance(AngleInRadians,str):
3936 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3938 AngleInRadians = DegreesToRadians(AngleInRadians)
3939 if IDsOfElements == []:
3940 IDsOfElements = self.GetElementsId()
3941 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3942 Axis = self.smeshpyD.GetAxisStruct(Axis)
3943 Axis,AxisParameters = ParseAxisStruct(Axis)
3944 Parameters = AxisParameters + var_separator + Parameters
3945 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3946 MakeGroups, NewMeshName)
3947 mesh.SetParameters(Parameters)
3948 return Mesh( self.smeshpyD, self.geompyD, mesh )
3950 ## Rotates the object
3951 # @param theObject the object to rotate( mesh, submesh, or group)
3952 # @param Axis the axis of rotation (AxisStruct or geom line)
3953 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3954 # @param Copy allows copying the rotated elements
3955 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3956 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3957 # @ingroup l2_modif_trsf
3958 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3960 if isinstance(AngleInRadians,str):
3962 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3964 AngleInRadians = DegreesToRadians(AngleInRadians)
3965 if (isinstance(theObject, Mesh)):
3966 theObject = theObject.GetMesh()
3967 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3968 Axis = self.smeshpyD.GetAxisStruct(Axis)
3969 Axis,AxisParameters = ParseAxisStruct(Axis)
3970 Parameters = AxisParameters + ":" + Parameters
3971 self.mesh.SetParameters(Parameters)
3972 if Copy and MakeGroups:
3973 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3974 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3977 ## Creates a new mesh from the rotated object
3978 # @param theObject the object to rotate (mesh, submesh, or group)
3979 # @param Axis the axis of rotation (AxisStruct or geom line)
3980 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3981 # @param MakeGroups forces the generation of new groups from existing ones
3982 # @param NewMeshName the name of the newly created mesh
3983 # @return instance of Mesh class
3984 # @ingroup l2_modif_trsf
3985 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3987 if isinstance(AngleInRadians,str):
3989 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3991 AngleInRadians = DegreesToRadians(AngleInRadians)
3992 if (isinstance( theObject, Mesh )):
3993 theObject = theObject.GetMesh()
3994 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3995 Axis = self.smeshpyD.GetAxisStruct(Axis)
3996 Axis,AxisParameters = ParseAxisStruct(Axis)
3997 Parameters = AxisParameters + ":" + Parameters
3998 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3999 MakeGroups, NewMeshName)
4000 mesh.SetParameters(Parameters)
4001 return Mesh( self.smeshpyD, self.geompyD, mesh )
4003 ## Finds groups of ajacent nodes within Tolerance.
4004 # @param Tolerance the value of tolerance
4005 # @return the list of groups of nodes
4006 # @ingroup l2_modif_trsf
4007 def FindCoincidentNodes (self, Tolerance):
4008 return self.editor.FindCoincidentNodes(Tolerance)
4010 ## Finds groups of ajacent nodes within Tolerance.
4011 # @param Tolerance the value of tolerance
4012 # @param SubMeshOrGroup SubMesh or Group
4013 # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
4014 # @return the list of groups of nodes
4015 # @ingroup l2_modif_trsf
4016 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
4017 if (isinstance( SubMeshOrGroup, Mesh )):
4018 SubMeshOrGroup = SubMeshOrGroup.GetMesh()
4019 if not isinstance( exceptNodes, list):
4020 exceptNodes = [ exceptNodes ]
4021 if exceptNodes and isinstance( exceptNodes[0], int):
4022 exceptNodes = [ self.GetIDSource( exceptNodes, SMESH.NODE)]
4023 return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes)
4026 # @param GroupsOfNodes the list of groups of nodes
4027 # @ingroup l2_modif_trsf
4028 def MergeNodes (self, GroupsOfNodes):
4029 self.editor.MergeNodes(GroupsOfNodes)
4031 ## Finds the elements built on the same nodes.
4032 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
4033 # @return a list of groups of equal elements
4034 # @ingroup l2_modif_trsf
4035 def FindEqualElements (self, MeshOrSubMeshOrGroup):
4036 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
4037 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
4038 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
4040 ## Merges elements in each given group.
4041 # @param GroupsOfElementsID groups of elements for merging
4042 # @ingroup l2_modif_trsf
4043 def MergeElements(self, GroupsOfElementsID):
4044 self.editor.MergeElements(GroupsOfElementsID)
4046 ## Leaves one element and removes all other elements built on the same nodes.
4047 # @ingroup l2_modif_trsf
4048 def MergeEqualElements(self):
4049 self.editor.MergeEqualElements()
4051 ## Sews free borders
4052 # @return SMESH::Sew_Error
4053 # @ingroup l2_modif_trsf
4054 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
4055 FirstNodeID2, SecondNodeID2, LastNodeID2,
4056 CreatePolygons, CreatePolyedrs):
4057 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
4058 FirstNodeID2, SecondNodeID2, LastNodeID2,
4059 CreatePolygons, CreatePolyedrs)
4061 ## Sews conform free borders
4062 # @return SMESH::Sew_Error
4063 # @ingroup l2_modif_trsf
4064 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
4065 FirstNodeID2, SecondNodeID2):
4066 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
4067 FirstNodeID2, SecondNodeID2)
4069 ## Sews border to side
4070 # @return SMESH::Sew_Error
4071 # @ingroup l2_modif_trsf
4072 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
4073 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
4074 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
4075 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
4077 ## Sews two sides of a mesh. The nodes belonging to Side1 are
4078 # merged with the nodes of elements of Side2.
4079 # The number of elements in theSide1 and in theSide2 must be
4080 # equal and they should have similar nodal connectivity.
4081 # The nodes to merge should belong to side borders and
4082 # the first node should be linked to the second.
4083 # @return SMESH::Sew_Error
4084 # @ingroup l2_modif_trsf
4085 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
4086 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
4087 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
4088 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
4089 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
4090 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
4092 ## Sets new nodes for the given element.
4093 # @param ide the element id
4094 # @param newIDs nodes ids
4095 # @return If the number of nodes does not correspond to the type of element - returns false
4096 # @ingroup l2_modif_edit
4097 def ChangeElemNodes(self, ide, newIDs):
4098 return self.editor.ChangeElemNodes(ide, newIDs)
4100 ## If during the last operation of MeshEditor some nodes were
4101 # created, this method returns the list of their IDs, \n
4102 # if new nodes were not created - returns empty list
4103 # @return the list of integer values (can be empty)
4104 # @ingroup l1_auxiliary
4105 def GetLastCreatedNodes(self):
4106 return self.editor.GetLastCreatedNodes()
4108 ## If during the last operation of MeshEditor some elements were
4109 # created this method returns the list of their IDs, \n
4110 # if new elements were not created - returns empty list
4111 # @return the list of integer values (can be empty)
4112 # @ingroup l1_auxiliary
4113 def GetLastCreatedElems(self):
4114 return self.editor.GetLastCreatedElems()
4116 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4117 # @param theNodes identifiers of nodes to be doubled
4118 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
4119 # nodes. If list of element identifiers is empty then nodes are doubled but
4120 # they not assigned to elements
4121 # @return TRUE if operation has been completed successfully, FALSE otherwise
4122 # @ingroup l2_modif_edit
4123 def DoubleNodes(self, theNodes, theModifiedElems):
4124 return self.editor.DoubleNodes(theNodes, theModifiedElems)
4126 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4127 # This method provided for convenience works as DoubleNodes() described above.
4128 # @param theNodeId identifiers of node to be doubled
4129 # @param theModifiedElems identifiers of elements to be updated
4130 # @return TRUE if operation has been completed successfully, FALSE otherwise
4131 # @ingroup l2_modif_edit
4132 def DoubleNode(self, theNodeId, theModifiedElems):
4133 return self.editor.DoubleNode(theNodeId, theModifiedElems)
4135 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4136 # This method provided for convenience works as DoubleNodes() described above.
4137 # @param theNodes group of nodes to be doubled
4138 # @param theModifiedElems group of elements to be updated.
4139 # @param theMakeGroup forces the generation of a group containing new nodes.
4140 # @return TRUE or a created group if operation has been completed successfully,
4141 # FALSE or None otherwise
4142 # @ingroup l2_modif_edit
4143 def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
4145 return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
4146 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
4148 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4149 # This method provided for convenience works as DoubleNodes() described above.
4150 # @param theNodes list of groups of nodes to be doubled
4151 # @param theModifiedElems list of groups of elements to be updated.
4152 # @return TRUE if operation has been completed successfully, FALSE otherwise
4153 # @ingroup l2_modif_edit
4154 def DoubleNodeGroups(self, theNodes, theModifiedElems, theMakeGroup=False):
4156 return self.editor.DoubleNodeGroupsNew(theNodes, theModifiedElems)
4157 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
4159 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4160 # @param theElems - the list of elements (edges or faces) to be replicated
4161 # The nodes for duplication could be found from these elements
4162 # @param theNodesNot - list of nodes to NOT replicate
4163 # @param theAffectedElems - the list of elements (cells and edges) to which the
4164 # replicated nodes should be associated to.
4165 # @return TRUE if operation has been completed successfully, FALSE otherwise
4166 # @ingroup l2_modif_edit
4167 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
4168 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
4170 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4171 # @param theElems - the list of elements (edges or faces) to be replicated
4172 # The nodes for duplication could be found from these elements
4173 # @param theNodesNot - list of nodes to NOT replicate
4174 # @param theShape - shape to detect affected elements (element which geometric center
4175 # located on or inside shape).
4176 # The replicated nodes should be associated to affected elements.
4177 # @return TRUE if operation has been completed successfully, FALSE otherwise
4178 # @ingroup l2_modif_edit
4179 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
4180 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
4182 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4183 # This method provided for convenience works as DoubleNodes() described above.
4184 # @param theElems - group of of elements (edges or faces) to be replicated
4185 # @param theNodesNot - group of nodes not to replicated
4186 # @param theAffectedElems - group of elements to which the replicated nodes
4187 # should be associated to.
4188 # @param theMakeGroup forces the generation of a group containing new elements.
4189 # @return TRUE or a created group if operation has been completed successfully,
4190 # FALSE or None otherwise
4191 # @ingroup l2_modif_edit
4192 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4194 return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
4195 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
4197 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4198 # This method provided for convenience works as DoubleNodes() described above.
4199 # @param theElems - group of of elements (edges or faces) to be replicated
4200 # @param theNodesNot - group of nodes not to replicated
4201 # @param theShape - shape to detect affected elements (element which geometric center
4202 # located on or inside shape).
4203 # The replicated nodes should be associated to affected elements.
4204 # @ingroup l2_modif_edit
4205 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
4206 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
4208 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4209 # This method provided for convenience works as DoubleNodes() described above.
4210 # @param theElems - list of groups of elements (edges or faces) to be replicated
4211 # @param theNodesNot - list of groups of nodes not to replicated
4212 # @param theAffectedElems - group of elements to which the replicated nodes
4213 # should be associated to.
4214 # @param theMakeGroup forces the generation of a group containing new elements.
4215 # @return TRUE or a created group if operation has been completed successfully,
4216 # FALSE or None otherwise
4217 # @ingroup l2_modif_edit
4218 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4220 return self.editor.DoubleNodeElemGroupsNew(theElems, theNodesNot, theAffectedElems)
4221 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
4223 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4224 # This method provided for convenience works as DoubleNodes() described above.
4225 # @param theElems - list of groups of elements (edges or faces) to be replicated
4226 # @param theNodesNot - list of groups of nodes not to replicated
4227 # @param theShape - shape to detect affected elements (element which geometric center
4228 # located on or inside shape).
4229 # The replicated nodes should be associated to affected elements.
4230 # @return TRUE if operation has been completed successfully, FALSE otherwise
4231 # @ingroup l2_modif_edit
4232 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
4233 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
4235 ## Double nodes on shared faces between groups of volumes and create flat elements on demand.
4236 # The list of groups must describe a partition of the mesh volumes.
4237 # The nodes of the internal faces at the boundaries of the groups are doubled.
4238 # In option, the internal faces are replaced by flat elements.
4239 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4240 # @param theDomains - list of groups of volumes
4241 # @param createJointElems - if TRUE, create the elements
4242 # @return TRUE if operation has been completed successfully, FALSE otherwise
4243 def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems ):
4244 return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems )
4246 ## Double nodes on some external faces and create flat elements.
4247 # Flat elements are mainly used by some types of mechanic calculations.
4249 # Each group of the list must be constituted of faces.
4250 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4251 # @param theGroupsOfFaces - list of groups of faces
4252 # @return TRUE if operation has been completed successfully, FALSE otherwise
4253 def CreateFlatElementsOnFacesGroups(self, theGroupsOfFaces ):
4254 return self.editor.CreateFlatElementsOnFacesGroups( theGroupsOfFaces )
4256 def _valueFromFunctor(self, funcType, elemId):
4257 fn = self.smeshpyD.GetFunctor(funcType)
4258 fn.SetMesh(self.mesh)
4259 if fn.GetElementType() == self.GetElementType(elemId, True):
4260 val = fn.GetValue(elemId)
4265 ## Get length of 1D element.
4266 # @param elemId mesh element ID
4267 # @return element's length value
4268 # @ingroup l1_measurements
4269 def GetLength(self, elemId):
4270 return self._valueFromFunctor(SMESH.FT_Length, elemId)
4272 ## Get area of 2D element.
4273 # @param elemId mesh element ID
4274 # @return element's area value
4275 # @ingroup l1_measurements
4276 def GetArea(self, elemId):
4277 return self._valueFromFunctor(SMESH.FT_Area, elemId)
4279 ## Get volume of 3D element.
4280 # @param elemId mesh element ID
4281 # @return element's volume value
4282 # @ingroup l1_measurements
4283 def GetVolume(self, elemId):
4284 return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
4286 ## Get maximum element length.
4287 # @param elemId mesh element ID
4288 # @return element's maximum length value
4289 # @ingroup l1_measurements
4290 def GetMaxElementLength(self, elemId):
4291 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4292 ftype = SMESH.FT_MaxElementLength3D
4294 ftype = SMESH.FT_MaxElementLength2D
4295 return self._valueFromFunctor(ftype, elemId)
4297 ## Get aspect ratio of 2D or 3D element.
4298 # @param elemId mesh element ID
4299 # @return element's aspect ratio value
4300 # @ingroup l1_measurements
4301 def GetAspectRatio(self, elemId):
4302 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4303 ftype = SMESH.FT_AspectRatio3D
4305 ftype = SMESH.FT_AspectRatio
4306 return self._valueFromFunctor(ftype, elemId)
4308 ## Get warping angle of 2D element.
4309 # @param elemId mesh element ID
4310 # @return element's warping angle value
4311 # @ingroup l1_measurements
4312 def GetWarping(self, elemId):
4313 return self._valueFromFunctor(SMESH.FT_Warping, elemId)
4315 ## Get minimum angle of 2D element.
4316 # @param elemId mesh element ID
4317 # @return element's minimum angle value
4318 # @ingroup l1_measurements
4319 def GetMinimumAngle(self, elemId):
4320 return self._valueFromFunctor(SMESH.FT_MinimumAngle, elemId)
4322 ## Get taper of 2D element.
4323 # @param elemId mesh element ID
4324 # @return element's taper value
4325 # @ingroup l1_measurements
4326 def GetTaper(self, elemId):
4327 return self._valueFromFunctor(SMESH.FT_Taper, elemId)
4329 ## Get skew of 2D element.
4330 # @param elemId mesh element ID
4331 # @return element's skew value
4332 # @ingroup l1_measurements
4333 def GetSkew(self, elemId):
4334 return self._valueFromFunctor(SMESH.FT_Skew, elemId)
4336 ## The mother class to define algorithm, it is not recommended to use it directly.
4339 # @ingroup l2_algorithms
4340 class Mesh_Algorithm:
4341 # @class Mesh_Algorithm
4342 # @brief Class Mesh_Algorithm
4344 #def __init__(self,smesh):
4352 ## Finds a hypothesis in the study by its type name and parameters.
4353 # Finds only the hypotheses created in smeshpyD engine.
4354 # @return SMESH.SMESH_Hypothesis
4355 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
4356 study = smeshpyD.GetCurrentStudy()
4357 #to do: find component by smeshpyD object, not by its data type
4358 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4359 if scomp is not None:
4360 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
4361 # Check if the root label of the hypotheses exists
4362 if res and hypRoot is not None:
4363 iter = study.NewChildIterator(hypRoot)
4364 # Check all published hypotheses
4366 hypo_so_i = iter.Value()
4367 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
4368 if attr is not None:
4369 anIOR = attr.Value()
4370 hypo_o_i = salome.orb.string_to_object(anIOR)
4371 if hypo_o_i is not None:
4372 # Check if this is a hypothesis
4373 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
4374 if hypo_i is not None:
4375 # Check if the hypothesis belongs to current engine
4376 if smeshpyD.GetObjectId(hypo_i) > 0:
4377 # Check if this is the required hypothesis
4378 if hypo_i.GetName() == hypname:
4380 if CompareMethod(hypo_i, args):
4394 ## Finds the algorithm in the study by its type name.
4395 # Finds only the algorithms, which have been created in smeshpyD engine.
4396 # @return SMESH.SMESH_Algo
4397 def FindAlgorithm (self, algoname, smeshpyD):
4398 study = smeshpyD.GetCurrentStudy()
4399 #to do: find component by smeshpyD object, not by its data type
4400 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4401 if scomp is not None:
4402 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
4403 # Check if the root label of the algorithms exists
4404 if res and hypRoot is not None:
4405 iter = study.NewChildIterator(hypRoot)
4406 # Check all published algorithms
4408 algo_so_i = iter.Value()
4409 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
4410 if attr is not None:
4411 anIOR = attr.Value()
4412 algo_o_i = salome.orb.string_to_object(anIOR)
4413 if algo_o_i is not None:
4414 # Check if this is an algorithm
4415 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
4416 if algo_i is not None:
4417 # Checks if the algorithm belongs to the current engine
4418 if smeshpyD.GetObjectId(algo_i) > 0:
4419 # Check if this is the required algorithm
4420 if algo_i.GetName() == algoname:
4433 ## If the algorithm is global, returns 0; \n
4434 # else returns the submesh associated to this algorithm.
4435 def GetSubMesh(self):
4438 ## Returns the wrapped mesher.
4439 def GetAlgorithm(self):
4442 ## Gets the list of hypothesis that can be used with this algorithm
4443 def GetCompatibleHypothesis(self):
4446 mylist = self.algo.GetCompatibleHypothesis()
4449 ## Gets the name of the algorithm
4453 ## Sets the name to the algorithm
4454 def SetName(self, name):
4455 self.mesh.smeshpyD.SetName(self.algo, name)
4457 ## Gets the id of the algorithm
4459 return self.algo.GetId()
4462 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
4464 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
4465 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
4467 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
4469 self.Assign(algo, mesh, geom)
4473 def Assign(self, algo, mesh, geom):
4475 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
4479 self.geom = mesh.geom
4482 self.AssureGeomPublished( geom )
4484 name = GetName(geom)
4488 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
4490 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
4491 TreatHypoStatus( status, algo.GetName(), name, True )
4494 ## Private method. Add geom into the study if not yet there
4495 def AssureGeomPublished(self, geom, name=''):
4496 if not isinstance( geom, geompyDC.GEOM._objref_GEOM_Object ):
4498 if not geom.IsSame( self.mesh.geom ) and not geom.GetStudyEntry():
4500 studyID = self.mesh.smeshpyD.GetCurrentStudy()._get_StudyId()
4501 if studyID != self.mesh.geompyD.myStudyId:
4502 self.mesh.geompyD.init_geom( self.mesh.smeshpyD.GetCurrentStudy())
4504 if not name and geom.GetShapeType() != geompyDC.GEOM.COMPOUND:
4505 # for all groups SubShapeName() returns "Compound_-1"
4506 name = self.mesh.geompyD.SubShapeName(geom, self.mesh.geom)
4508 name = "%s_%s"%(geom.GetShapeType(), id(geom)%10000)
4510 self.mesh.geompyD.addToStudyInFather( self.mesh.geom, geom, name )
4513 def CompareHyp (self, hyp, args):
4514 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
4517 def CompareEqualHyp (self, hyp, args):
4521 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
4522 UseExisting=0, CompareMethod=""):
4525 if CompareMethod == "": CompareMethod = self.CompareHyp
4526 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
4529 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
4535 a = a + s + str(args[i])
4539 self.mesh.smeshpyD.SetName(hypo, hyp + a)
4543 geomName = GetName(self.geom)
4544 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
4545 TreatHypoStatus( status, GetName(hypo), geomName, 0 )
4548 ## Returns entry of the shape to mesh in the study
4549 def MainShapeEntry(self):
4551 if not self.mesh or not self.mesh.GetMesh(): return entry
4552 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
4553 study = self.mesh.smeshpyD.GetCurrentStudy()
4554 ior = salome.orb.object_to_string( self.mesh.GetShape() )
4555 sobj = study.FindObjectIOR(ior)
4556 if sobj: entry = sobj.GetID()
4557 if not entry: return ""
4560 ## Defines "ViscousLayers" hypothesis to give parameters of layers of prisms to build
4561 # near mesh boundary. This hypothesis can be used by several 3D algorithms:
4562 # NETGEN 3D, GHS3D, Hexahedron(i,j,k)
4563 # @param thickness total thickness of layers of prisms
4564 # @param numberOfLayers number of layers of prisms
4565 # @param stretchFactor factor (>1.0) of growth of layer thickness towards inside of mesh
4566 # @param ignoreFaces list of geometrical faces (or their ids) not to generate layers on
4567 # @ingroup l3_hypos_additi
4568 def ViscousLayers(self, thickness, numberOfLayers, stretchFactor, ignoreFaces=[]):
4569 if not isinstance(self.algo, SMESH._objref_SMESH_3D_Algo):
4570 raise TypeError, "ViscousLayers are supported by 3D algorithms only"
4571 if not "ViscousLayers" in self.GetCompatibleHypothesis():
4572 raise TypeError, "ViscousLayers are not supported by %s"%self.algo.GetName()
4573 if ignoreFaces and isinstance( ignoreFaces[0], geompyDC.GEOM._objref_GEOM_Object ):
4574 ignoreFaces = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, f) for f in ignoreFaces ]
4575 hyp = self.Hypothesis("ViscousLayers",
4576 [thickness, numberOfLayers, stretchFactor, ignoreFaces])
4577 hyp.SetTotalThickness(thickness)
4578 hyp.SetNumberLayers(numberOfLayers)
4579 hyp.SetStretchFactor(stretchFactor)
4580 hyp.SetIgnoreFaces(ignoreFaces)
4583 # Public class: Mesh_Segment
4584 # --------------------------
4586 ## Class to define a segment 1D algorithm for discretization
4589 # @ingroup l3_algos_basic
4590 class Mesh_Segment(Mesh_Algorithm):
4592 ## Private constructor.
4593 def __init__(self, mesh, geom=0):
4594 Mesh_Algorithm.__init__(self)
4595 self.Create(mesh, geom, "Regular_1D")
4597 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
4598 # @param l for the length of segments that cut an edge
4599 # @param UseExisting if ==true - searches for an existing hypothesis created with
4600 # the same parameters, else (default) - creates a new one
4601 # @param p precision, used for calculation of the number of segments.
4602 # The precision should be a positive, meaningful value within the range [0,1].
4603 # In general, the number of segments is calculated with the formula:
4604 # nb = ceil((edge_length / l) - p)
4605 # Function ceil rounds its argument to the higher integer.
4606 # So, p=0 means rounding of (edge_length / l) to the higher integer,
4607 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
4608 # p=1 means rounding of (edge_length / l) to the lower integer.
4609 # Default value is 1e-07.
4610 # @return an instance of StdMeshers_LocalLength hypothesis
4611 # @ingroup l3_hypos_1dhyps
4612 def LocalLength(self, l, UseExisting=0, p=1e-07):
4613 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
4614 CompareMethod=self.CompareLocalLength)
4620 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
4621 def CompareLocalLength(self, hyp, args):
4622 if IsEqual(hyp.GetLength(), args[0]):
4623 return IsEqual(hyp.GetPrecision(), args[1])
4626 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
4627 # @param length is optional maximal allowed length of segment, if it is omitted
4628 # the preestimated length is used that depends on geometry size
4629 # @param UseExisting if ==true - searches for an existing hypothesis created with
4630 # the same parameters, else (default) - create a new one
4631 # @return an instance of StdMeshers_MaxLength hypothesis
4632 # @ingroup l3_hypos_1dhyps
4633 def MaxSize(self, length=0.0, UseExisting=0):
4634 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
4637 hyp.SetLength(length)
4639 # set preestimated length
4640 gen = self.mesh.smeshpyD
4641 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
4642 self.mesh.GetMesh(), self.mesh.GetShape(),
4644 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
4646 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
4649 hyp.SetUsePreestimatedLength( length == 0.0 )
4652 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
4653 # @param n for the number of segments that cut an edge
4654 # @param s for the scale factor (optional)
4655 # @param reversedEdges is a list of edges to mesh using reversed orientation
4656 # @param UseExisting if ==true - searches for an existing hypothesis created with
4657 # the same parameters, else (default) - create a new one
4658 # @return an instance of StdMeshers_NumberOfSegments hypothesis
4659 # @ingroup l3_hypos_1dhyps
4660 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4661 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4662 reversedEdges, UseExisting = [], reversedEdges
4663 entry = self.MainShapeEntry()
4664 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4665 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4667 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
4668 UseExisting=UseExisting,
4669 CompareMethod=self.CompareNumberOfSegments)
4671 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
4672 UseExisting=UseExisting,
4673 CompareMethod=self.CompareNumberOfSegments)
4674 hyp.SetDistrType( 1 )
4675 hyp.SetScaleFactor(s)
4676 hyp.SetNumberOfSegments(n)
4677 hyp.SetReversedEdges( reversedEdges )
4678 hyp.SetObjectEntry( entry )
4682 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4683 def CompareNumberOfSegments(self, hyp, args):
4684 if hyp.GetNumberOfSegments() == args[0]:
4686 if hyp.GetReversedEdges() == args[1]:
4687 if not args[1] or hyp.GetObjectEntry() == args[2]:
4690 if hyp.GetReversedEdges() == args[2]:
4691 if not args[2] or hyp.GetObjectEntry() == args[3]:
4692 if hyp.GetDistrType() == 1:
4693 if IsEqual(hyp.GetScaleFactor(), args[1]):
4697 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4698 # @param start defines the length of the first segment
4699 # @param end defines the length of the last segment
4700 # @param reversedEdges is a list of edges to mesh using reversed orientation
4701 # @param UseExisting if ==true - searches for an existing hypothesis created with
4702 # the same parameters, else (default) - creates a new one
4703 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4704 # @ingroup l3_hypos_1dhyps
4705 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4706 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4707 reversedEdges, UseExisting = [], reversedEdges
4708 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4709 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4710 entry = self.MainShapeEntry()
4711 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
4712 UseExisting=UseExisting,
4713 CompareMethod=self.CompareArithmetic1D)
4714 hyp.SetStartLength(start)
4715 hyp.SetEndLength(end)
4716 hyp.SetReversedEdges( reversedEdges )
4717 hyp.SetObjectEntry( entry )
4721 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4722 def CompareArithmetic1D(self, hyp, args):
4723 if IsEqual(hyp.GetLength(1), args[0]):
4724 if IsEqual(hyp.GetLength(0), args[1]):
4725 if hyp.GetReversedEdges() == args[2]:
4726 if not args[2] or hyp.GetObjectEntry() == args[3]:
4731 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4732 # on curve from 0 to 1 (additionally it is neecessary to check
4733 # orientation of edges and create list of reversed edges if it is
4734 # needed) and sets numbers of segments between given points (default
4735 # values are equals 1
4736 # @param points defines the list of parameters on curve
4737 # @param nbSegs defines the list of numbers of segments
4738 # @param reversedEdges is a list of edges to mesh using reversed orientation
4739 # @param UseExisting if ==true - searches for an existing hypothesis created with
4740 # the same parameters, else (default) - creates a new one
4741 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4742 # @ingroup l3_hypos_1dhyps
4743 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4744 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4745 reversedEdges, UseExisting = [], reversedEdges
4746 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4747 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4748 entry = self.MainShapeEntry()
4749 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
4750 UseExisting=UseExisting,
4751 CompareMethod=self.CompareFixedPoints1D)
4752 hyp.SetPoints(points)
4753 hyp.SetNbSegments(nbSegs)
4754 hyp.SetReversedEdges(reversedEdges)
4755 hyp.SetObjectEntry(entry)
4759 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4760 ## as the given arguments
4761 def CompareFixedPoints1D(self, hyp, args):
4762 if hyp.GetPoints() == args[0]:
4763 if hyp.GetNbSegments() == args[1]:
4764 if hyp.GetReversedEdges() == args[2]:
4765 if not args[2] or hyp.GetObjectEntry() == args[3]:
4771 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4772 # @param start defines the length of the first segment
4773 # @param end defines the length of the last segment
4774 # @param reversedEdges is a list of edges to mesh using reversed orientation
4775 # @param UseExisting if ==true - searches for an existing hypothesis created with
4776 # the same parameters, else (default) - creates a new one
4777 # @return an instance of StdMeshers_StartEndLength hypothesis
4778 # @ingroup l3_hypos_1dhyps
4779 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4780 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4781 reversedEdges, UseExisting = [], reversedEdges
4782 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4783 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4784 entry = self.MainShapeEntry()
4785 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
4786 UseExisting=UseExisting,
4787 CompareMethod=self.CompareStartEndLength)
4788 hyp.SetStartLength(start)
4789 hyp.SetEndLength(end)
4790 hyp.SetReversedEdges( reversedEdges )
4791 hyp.SetObjectEntry( entry )
4794 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4795 def CompareStartEndLength(self, hyp, args):
4796 if IsEqual(hyp.GetLength(1), args[0]):
4797 if IsEqual(hyp.GetLength(0), args[1]):
4798 if hyp.GetReversedEdges() == args[2]:
4799 if not args[2] or hyp.GetObjectEntry() == args[3]:
4803 ## Defines "Deflection1D" hypothesis
4804 # @param d for the deflection
4805 # @param UseExisting if ==true - searches for an existing hypothesis created with
4806 # the same parameters, else (default) - create a new one
4807 # @ingroup l3_hypos_1dhyps
4808 def Deflection1D(self, d, UseExisting=0):
4809 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4810 CompareMethod=self.CompareDeflection1D)
4811 hyp.SetDeflection(d)
4814 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4815 def CompareDeflection1D(self, hyp, args):
4816 return IsEqual(hyp.GetDeflection(), args[0])
4818 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4819 # the opposite side in case of quadrangular faces
4820 # @ingroup l3_hypos_additi
4821 def Propagation(self):
4822 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4824 ## Defines "AutomaticLength" hypothesis
4825 # @param fineness for the fineness [0-1]
4826 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4827 # same parameters, else (default) - create a new one
4828 # @ingroup l3_hypos_1dhyps
4829 def AutomaticLength(self, fineness=0, UseExisting=0):
4830 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4831 CompareMethod=self.CompareAutomaticLength)
4832 hyp.SetFineness( fineness )
4835 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4836 def CompareAutomaticLength(self, hyp, args):
4837 return IsEqual(hyp.GetFineness(), args[0])
4839 ## Defines "SegmentLengthAroundVertex" hypothesis
4840 # @param length for the segment length
4841 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4842 # Any other integer value means that the hypothesis will be set on the
4843 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4844 # @param UseExisting if ==true - searches for an existing hypothesis created with
4845 # the same parameters, else (default) - creates a new one
4846 # @ingroup l3_algos_segmarv
4847 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4849 store_geom = self.geom
4850 if type(vertex) is types.IntType:
4851 if vertex == 0 or vertex == 1:
4852 vertex = self.mesh.geompyD.ExtractShapes(self.geom, geompyDC.ShapeType["VERTEX"],True)[vertex]
4860 if self.geom is None:
4861 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4862 self.AssureGeomPublished( self.geom )
4863 name = GetName(self.geom)
4865 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4867 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4869 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4870 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4872 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4873 CompareMethod=self.CompareLengthNearVertex)
4874 self.geom = store_geom
4875 hyp.SetLength( length )
4878 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4879 # @ingroup l3_algos_segmarv
4880 def CompareLengthNearVertex(self, hyp, args):
4881 return IsEqual(hyp.GetLength(), args[0])
4883 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4884 # If the 2D mesher sees that all boundary edges are quadratic,
4885 # it generates quadratic faces, else it generates linear faces using
4886 # medium nodes as if they are vertices.
4887 # The 3D mesher generates quadratic volumes only if all boundary faces
4888 # are quadratic, else it fails.
4890 # @ingroup l3_hypos_additi
4891 def QuadraticMesh(self):
4892 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4895 # Public class: Mesh_CompositeSegment
4896 # --------------------------
4898 ## Defines a segment 1D algorithm for discretization
4900 # @ingroup l3_algos_basic
4901 class Mesh_CompositeSegment(Mesh_Segment):
4903 ## Private constructor.
4904 def __init__(self, mesh, geom=0):
4905 self.Create(mesh, geom, "CompositeSegment_1D")
4908 # Public class: Mesh_Segment_Python
4909 # ---------------------------------
4911 ## Defines a segment 1D algorithm for discretization with python function
4913 # @ingroup l3_algos_basic
4914 class Mesh_Segment_Python(Mesh_Segment):
4916 ## Private constructor.
4917 def __init__(self, mesh, geom=0):
4918 import Python1dPlugin
4919 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4921 ## Defines "PythonSplit1D" hypothesis
4922 # @param n for the number of segments that cut an edge
4923 # @param func for the python function that calculates the length of all segments
4924 # @param UseExisting if ==true - searches for the existing hypothesis created with
4925 # the same parameters, else (default) - creates a new one
4926 # @ingroup l3_hypos_1dhyps
4927 def PythonSplit1D(self, n, func, UseExisting=0):
4928 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4929 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4930 hyp.SetNumberOfSegments(n)
4931 hyp.SetPythonLog10RatioFunction(func)
4934 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4935 def ComparePythonSplit1D(self, hyp, args):
4936 #if hyp.GetNumberOfSegments() == args[0]:
4937 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4941 # Public class: Mesh_Triangle
4942 # ---------------------------
4944 ## Defines a triangle 2D algorithm
4946 # @ingroup l3_algos_basic
4947 class Mesh_Triangle(Mesh_Algorithm):
4956 ## Private constructor.
4957 def __init__(self, mesh, algoType, geom=0):
4958 Mesh_Algorithm.__init__(self)
4960 self.algoType = algoType
4961 if algoType == MEFISTO:
4962 self.Create(mesh, geom, "MEFISTO_2D")
4964 elif algoType == BLSURF:
4966 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4967 #self.SetPhysicalMesh() - PAL19680
4968 elif algoType == NETGEN:
4970 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4972 elif algoType == NETGEN_2D:
4974 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4977 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4978 # @param area for the maximum area of each triangle
4979 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4980 # same parameters, else (default) - creates a new one
4982 # Only for algoType == MEFISTO || NETGEN_2D
4983 # @ingroup l3_hypos_2dhyps
4984 def MaxElementArea(self, area, UseExisting=0):
4985 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4986 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4987 CompareMethod=self.CompareMaxElementArea)
4988 elif self.algoType == NETGEN:
4989 hyp = self.Parameters(SIMPLE)
4990 hyp.SetMaxElementArea(area)
4993 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4994 def CompareMaxElementArea(self, hyp, args):
4995 return IsEqual(hyp.GetMaxElementArea(), args[0])
4997 ## Defines "LengthFromEdges" hypothesis to build triangles
4998 # based on the length of the edges taken from the wire
5000 # Only for algoType == MEFISTO || NETGEN_2D
5001 # @ingroup l3_hypos_2dhyps
5002 def LengthFromEdges(self):
5003 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
5004 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
5006 elif self.algoType == NETGEN:
5007 hyp = self.Parameters(SIMPLE)
5008 hyp.LengthFromEdges()
5011 ## Sets a way to define size of mesh elements to generate.
5012 # @param thePhysicalMesh is: DefaultSize or Custom.
5013 # @ingroup l3_hypos_blsurf
5014 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
5015 # Parameter of BLSURF algo
5016 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
5018 ## Sets size of mesh elements to generate.
5019 # @ingroup l3_hypos_blsurf
5020 def SetPhySize(self, theVal):
5021 # Parameter of BLSURF algo
5022 self.SetPhysicalMesh(1) #Custom - else why to set the size?
5023 self.Parameters().SetPhySize(theVal)
5025 ## Sets lower boundary of mesh element size (PhySize).
5026 # @ingroup l3_hypos_blsurf
5027 def SetPhyMin(self, theVal=-1):
5028 # Parameter of BLSURF algo
5029 self.Parameters().SetPhyMin(theVal)
5031 ## Sets upper boundary of mesh element size (PhySize).
5032 # @ingroup l3_hypos_blsurf
5033 def SetPhyMax(self, theVal=-1):
5034 # Parameter of BLSURF algo
5035 self.Parameters().SetPhyMax(theVal)
5037 ## Sets a way to define maximum angular deflection of mesh from CAD model.
5038 # @param theGeometricMesh is: 0 (None) or 1 (Custom)
5039 # @ingroup l3_hypos_blsurf
5040 def SetGeometricMesh(self, theGeometricMesh=0):
5041 # Parameter of BLSURF algo
5042 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
5043 self.params.SetGeometricMesh(theGeometricMesh)
5045 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
5046 # @ingroup l3_hypos_blsurf
5047 def SetAngleMeshS(self, theVal=_angleMeshS):
5048 # Parameter of BLSURF algo
5049 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
5050 self.params.SetAngleMeshS(theVal)
5052 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
5053 # @ingroup l3_hypos_blsurf
5054 def SetAngleMeshC(self, theVal=_angleMeshS):
5055 # Parameter of BLSURF algo
5056 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
5057 self.params.SetAngleMeshC(theVal)
5059 ## Sets lower boundary of mesh element size computed to respect angular deflection.
5060 # @ingroup l3_hypos_blsurf
5061 def SetGeoMin(self, theVal=-1):
5062 # Parameter of BLSURF algo
5063 self.Parameters().SetGeoMin(theVal)
5065 ## Sets upper boundary of mesh element size computed to respect angular deflection.
5066 # @ingroup l3_hypos_blsurf
5067 def SetGeoMax(self, theVal=-1):
5068 # Parameter of BLSURF algo
5069 self.Parameters().SetGeoMax(theVal)
5071 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
5072 # @ingroup l3_hypos_blsurf
5073 def SetGradation(self, theVal=_gradation):
5074 # Parameter of BLSURF algo
5075 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
5076 self.params.SetGradation(theVal)
5078 ## Sets topology usage way.
5079 # @param way defines how mesh conformity is assured <ul>
5080 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
5081 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
5082 # @ingroup l3_hypos_blsurf
5083 def SetTopology(self, way):
5084 # Parameter of BLSURF algo
5085 self.Parameters().SetTopology(way)
5087 ## To respect geometrical edges or not.
5088 # @ingroup l3_hypos_blsurf
5089 def SetDecimesh(self, toIgnoreEdges=False):
5090 # Parameter of BLSURF algo
5091 self.Parameters().SetDecimesh(toIgnoreEdges)
5093 ## Sets verbosity level in the range 0 to 100.
5094 # @ingroup l3_hypos_blsurf
5095 def SetVerbosity(self, level):
5096 # Parameter of BLSURF algo
5097 self.Parameters().SetVerbosity(level)
5099 ## Sets advanced option value.
5100 # @ingroup l3_hypos_blsurf
5101 def SetOptionValue(self, optionName, level):
5102 # Parameter of BLSURF algo
5103 self.Parameters().SetOptionValue(optionName,level)
5105 ## 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 ]
5106 # @param theFace : face on which the attractor will be defined
5107 # @param theAttractor : geometrical object from which the mesh size "h" decreases exponentially
5108 # @param theStartSize : mesh size on theAttractor
5109 # @param theEndSize : maximum size that will be reached on theFace
5110 # @param theInfluenceDistance : influence of the attractor ( the size grow slower on theFace if it's high)
5111 # @param theConstantSizeDistance : distance until which the mesh size will be kept constant on theFace
5112 # @ingroup l3_hypos_blsurf
5113 def SetAttractorGeom(self, theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance):
5114 self.AssureGeomPublished( theFace )
5115 self.AssureGeomPublished( theAttractor )
5116 # Parameter of BLSURF algo
5117 self.Parameters().SetAttractorGeom(theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance)
5119 ## Unsets an attractor on the chosen face.
5120 # @param theFace : face on which the attractor has to be removed
5121 # @ingroup l3_hypos_blsurf
5122 def UnsetAttractorGeom(self, theFace):
5123 self.AssureGeomPublished( theFace )
5124 # Parameter of BLSURF algo
5125 self.Parameters().SetAttractorGeom(theFace)
5127 ## Sets QuadAllowed flag.
5128 # Only for algoType == NETGEN(NETGEN_1D2D) || NETGEN_2D || BLSURF
5129 # @ingroup l3_hypos_netgen l3_hypos_blsurf
5130 def SetQuadAllowed(self, toAllow=True):
5131 if self.algoType == NETGEN_2D:
5134 hasSimpleHyps = False
5135 simpleHyps = ["QuadranglePreference","LengthFromEdges","MaxElementArea"]
5136 for hyp in self.mesh.GetHypothesisList( self.geom ):
5137 if hyp.GetName() in simpleHyps:
5138 hasSimpleHyps = True
5139 if hyp.GetName() == "QuadranglePreference":
5140 if not toAllow: # remove QuadranglePreference
5141 self.mesh.RemoveHypothesis( self.geom, hyp )
5147 if toAllow: # add QuadranglePreference
5148 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
5153 if self.Parameters():
5154 self.params.SetQuadAllowed(toAllow)
5157 ## Defines hypothesis having several parameters
5159 # @ingroup l3_hypos_netgen
5160 def Parameters(self, which=SOLE):
5162 if self.algoType == NETGEN:
5164 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
5165 "libNETGENEngine.so", UseExisting=0)
5167 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
5168 "libNETGENEngine.so", UseExisting=0)
5169 elif self.algoType == MEFISTO:
5170 print "Mefisto algo support no multi-parameter hypothesis"
5171 elif self.algoType == NETGEN_2D:
5172 self.params = self.Hypothesis("NETGEN_Parameters_2D_ONLY", [],
5173 "libNETGENEngine.so", UseExisting=0)
5174 elif self.algoType == BLSURF:
5175 self.params = self.Hypothesis("BLSURF_Parameters", [],
5176 "libBLSURFEngine.so", UseExisting=0)
5178 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
5183 # Only for algoType == NETGEN
5184 # @ingroup l3_hypos_netgen
5185 def SetMaxSize(self, theSize):
5186 if self.Parameters():
5187 self.params.SetMaxSize(theSize)
5189 ## Sets SecondOrder flag
5191 # Only for algoType == NETGEN
5192 # @ingroup l3_hypos_netgen
5193 def SetSecondOrder(self, theVal):
5194 if self.Parameters():
5195 self.params.SetSecondOrder(theVal)
5197 ## Sets Optimize flag
5199 # Only for algoType == NETGEN
5200 # @ingroup l3_hypos_netgen
5201 def SetOptimize(self, theVal):
5202 if self.Parameters():
5203 self.params.SetOptimize(theVal)
5206 # @param theFineness is:
5207 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5209 # Only for algoType == NETGEN
5210 # @ingroup l3_hypos_netgen
5211 def SetFineness(self, theFineness):
5212 if self.Parameters():
5213 self.params.SetFineness(theFineness)
5217 # Only for algoType == NETGEN
5218 # @ingroup l3_hypos_netgen
5219 def SetGrowthRate(self, theRate):
5220 if self.Parameters():
5221 self.params.SetGrowthRate(theRate)
5223 ## Sets NbSegPerEdge
5225 # Only for algoType == NETGEN
5226 # @ingroup l3_hypos_netgen
5227 def SetNbSegPerEdge(self, theVal):
5228 if self.Parameters():
5229 self.params.SetNbSegPerEdge(theVal)
5231 ## Sets NbSegPerRadius
5233 # Only for algoType == NETGEN
5234 # @ingroup l3_hypos_netgen
5235 def SetNbSegPerRadius(self, theVal):
5236 if self.Parameters():
5237 self.params.SetNbSegPerRadius(theVal)
5239 ## Sets number of segments overriding value set by SetLocalLength()
5241 # Only for algoType == NETGEN
5242 # @ingroup l3_hypos_netgen
5243 def SetNumberOfSegments(self, theVal):
5244 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5246 ## Sets number of segments overriding value set by SetNumberOfSegments()
5248 # Only for algoType == NETGEN
5249 # @ingroup l3_hypos_netgen
5250 def SetLocalLength(self, theVal):
5251 self.Parameters(SIMPLE).SetLocalLength(theVal)
5256 # Public class: Mesh_Quadrangle
5257 # -----------------------------
5259 ## Defines a quadrangle 2D algorithm
5261 # @ingroup l3_algos_basic
5262 class Mesh_Quadrangle(Mesh_Algorithm):
5266 ## Private constructor.
5267 def __init__(self, mesh, geom=0):
5268 Mesh_Algorithm.__init__(self)
5269 self.Create(mesh, geom, "Quadrangle_2D")
5272 ## Defines "QuadrangleParameters" hypothesis
5273 # @param quadType defines the algorithm of transition between differently descretized
5274 # sides of a geometrical face:
5275 # - QUAD_STANDARD - both triangles and quadrangles are possible in the transition
5276 # area along the finer meshed sides.
5277 # - QUAD_TRIANGLE_PREF - only triangles are built in the transition area along the
5278 # finer meshed sides.
5279 # - QUAD_QUADRANGLE_PREF - only quadrangles are built in the transition area along
5280 # the finer meshed sides, iff the total quantity of segments on
5281 # all four sides of the face is even (divisible by 2).
5282 # - QUAD_QUADRANGLE_PREF_REVERSED - same as QUAD_QUADRANGLE_PREF but the transition
5283 # area is located along the coarser meshed sides.
5284 # - QUAD_REDUCED - only quadrangles are built and the transition between the sides
5285 # is made gradually, layer by layer. This type has a limitation on
5286 # the number of segments: one pair of opposite sides must have the
5287 # same number of segments, the other pair must have an even difference
5288 # between the numbers of segments on the sides.
5289 # @param triangleVertex: vertex of a trilateral geometrical face, around which triangles
5290 # will be created while other elements will be quadrangles.
5291 # Vertex can be either a GEOM_Object or a vertex ID within the
5293 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5294 # the same parameters, else (default) - creates a new one
5295 # @ingroup l3_hypos_quad
5296 def QuadrangleParameters(self, quadType=StdMeshers.QUAD_STANDARD, triangleVertex=0, UseExisting=0):
5297 vertexID = triangleVertex
5298 if isinstance( triangleVertex, geompyDC.GEOM._objref_GEOM_Object ):
5299 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, triangleVertex )
5301 compFun = lambda hyp,args: \
5302 hyp.GetQuadType() == args[0] and \
5303 ( hyp.GetTriaVertex()==args[1] or ( hyp.GetTriaVertex()<1 and args[1]<1))
5304 self.params = self.Hypothesis("QuadrangleParams", [quadType,vertexID],
5305 UseExisting = UseExisting, CompareMethod=compFun)
5307 if self.params.GetQuadType() != quadType:
5308 self.params.SetQuadType(quadType)
5310 self.params.SetTriaVertex( vertexID )
5313 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5314 # quadrangles are built in the transition area along the finer meshed sides,
5315 # iff the total quantity of segments on all four sides of the face is even.
5316 # @param reversed if True, transition area is located along the coarser meshed sides.
5317 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5318 # the same parameters, else (default) - creates a new one
5319 # @ingroup l3_hypos_quad
5320 def QuadranglePreference(self, reversed=False, UseExisting=0):
5322 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF_REVERSED,UseExisting=UseExisting)
5323 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF,UseExisting=UseExisting)
5325 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5326 # triangles are built in the transition area along the finer meshed sides.
5327 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5328 # the same parameters, else (default) - creates a new one
5329 # @ingroup l3_hypos_quad
5330 def TrianglePreference(self, UseExisting=0):
5331 return self.QuadrangleParameters(QUAD_TRIANGLE_PREF,UseExisting=UseExisting)
5333 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5334 # quadrangles are built and the transition between the sides is made gradually,
5335 # layer by layer. This type has a limitation on the number of segments: one pair
5336 # of opposite sides must have the same number of segments, the other pair must
5337 # have an even difference between the numbers of segments on the sides.
5338 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5339 # the same parameters, else (default) - creates a new one
5340 # @ingroup l3_hypos_quad
5341 def Reduced(self, UseExisting=0):
5342 return self.QuadrangleParameters(QUAD_REDUCED,UseExisting=UseExisting)
5344 ## Defines "QuadrangleParams" hypothesis with QUAD_STANDARD type of quadrangulation
5345 # @param vertex: vertex of a trilateral geometrical face, around which triangles
5346 # will be created while other elements will be quadrangles.
5347 # Vertex can be either a GEOM_Object or a vertex ID within the
5349 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5350 # the same parameters, else (default) - creates a new one
5351 # @ingroup l3_hypos_quad
5352 def TriangleVertex(self, vertex, UseExisting=0):
5353 return self.QuadrangleParameters(QUAD_STANDARD,vertex,UseExisting)
5356 # Public class: Mesh_Tetrahedron
5357 # ------------------------------
5359 ## Defines a tetrahedron 3D algorithm
5361 # @ingroup l3_algos_basic
5362 class Mesh_Tetrahedron(Mesh_Algorithm):
5367 ## Private constructor.
5368 def __init__(self, mesh, algoType, geom=0):
5369 Mesh_Algorithm.__init__(self)
5371 if algoType == NETGEN:
5373 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
5376 elif algoType == FULL_NETGEN:
5378 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5381 elif algoType == GHS3D:
5383 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
5386 elif algoType == GHS3DPRL:
5387 CheckPlugin(GHS3DPRL)
5388 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
5391 self.algoType = algoType
5393 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
5394 # @param vol for the maximum volume of each tetrahedron
5395 # @param UseExisting if ==true - searches for the existing hypothesis created with
5396 # the same parameters, else (default) - creates a new one
5397 # @ingroup l3_hypos_maxvol
5398 def MaxElementVolume(self, vol, UseExisting=0):
5399 if self.algoType == NETGEN:
5400 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
5401 CompareMethod=self.CompareMaxElementVolume)
5402 hyp.SetMaxElementVolume(vol)
5404 elif self.algoType == FULL_NETGEN:
5405 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
5408 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
5409 def CompareMaxElementVolume(self, hyp, args):
5410 return IsEqual(hyp.GetMaxElementVolume(), args[0])
5412 ## Defines hypothesis having several parameters
5414 # @ingroup l3_hypos_netgen
5415 def Parameters(self, which=SOLE):
5418 if self.algoType == FULL_NETGEN:
5420 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
5421 "libNETGENEngine.so", UseExisting=0)
5423 self.params = self.Hypothesis("NETGEN_Parameters", [],
5424 "libNETGENEngine.so", UseExisting=0)
5426 elif self.algoType == NETGEN:
5427 self.params = self.Hypothesis("NETGEN_Parameters_3D", [],
5428 "libNETGENEngine.so", UseExisting=0)
5430 elif self.algoType == GHS3D:
5431 self.params = self.Hypothesis("GHS3D_Parameters", [],
5432 "libGHS3DEngine.so", UseExisting=0)
5434 elif self.algoType == GHS3DPRL:
5435 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
5436 "libGHS3DPRLEngine.so", UseExisting=0)
5438 print "Warning: %s supports no multi-parameter hypothesis"%self.algo.GetName()
5443 # Parameter of FULL_NETGEN and NETGEN
5444 # @ingroup l3_hypos_netgen
5445 def SetMaxSize(self, theSize):
5446 self.Parameters().SetMaxSize(theSize)
5448 ## Sets SecondOrder flag
5449 # Parameter of FULL_NETGEN
5450 # @ingroup l3_hypos_netgen
5451 def SetSecondOrder(self, theVal):
5452 self.Parameters().SetSecondOrder(theVal)
5454 ## Sets Optimize flag
5455 # Parameter of FULL_NETGEN and NETGEN
5456 # @ingroup l3_hypos_netgen
5457 def SetOptimize(self, theVal):
5458 self.Parameters().SetOptimize(theVal)
5461 # @param theFineness is:
5462 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5463 # Parameter of FULL_NETGEN
5464 # @ingroup l3_hypos_netgen
5465 def SetFineness(self, theFineness):
5466 self.Parameters().SetFineness(theFineness)
5469 # Parameter of FULL_NETGEN
5470 # @ingroup l3_hypos_netgen
5471 def SetGrowthRate(self, theRate):
5472 self.Parameters().SetGrowthRate(theRate)
5474 ## Sets NbSegPerEdge
5475 # Parameter of FULL_NETGEN
5476 # @ingroup l3_hypos_netgen
5477 def SetNbSegPerEdge(self, theVal):
5478 self.Parameters().SetNbSegPerEdge(theVal)
5480 ## Sets NbSegPerRadius
5481 # Parameter of FULL_NETGEN
5482 # @ingroup l3_hypos_netgen
5483 def SetNbSegPerRadius(self, theVal):
5484 self.Parameters().SetNbSegPerRadius(theVal)
5486 ## Sets number of segments overriding value set by SetLocalLength()
5487 # Only for algoType == NETGEN_FULL
5488 # @ingroup l3_hypos_netgen
5489 def SetNumberOfSegments(self, theVal):
5490 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5492 ## Sets number of segments overriding value set by SetNumberOfSegments()
5493 # Only for algoType == NETGEN_FULL
5494 # @ingroup l3_hypos_netgen
5495 def SetLocalLength(self, theVal):
5496 self.Parameters(SIMPLE).SetLocalLength(theVal)
5498 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
5499 # Overrides value set by LengthFromEdges()
5500 # Only for algoType == NETGEN_FULL
5501 # @ingroup l3_hypos_netgen
5502 def MaxElementArea(self, area):
5503 self.Parameters(SIMPLE).SetMaxElementArea(area)
5505 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
5506 # Overrides value set by MaxElementArea()
5507 # Only for algoType == NETGEN_FULL
5508 # @ingroup l3_hypos_netgen
5509 def LengthFromEdges(self):
5510 self.Parameters(SIMPLE).LengthFromEdges()
5512 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
5513 # Overrides value set by MaxElementVolume()
5514 # Only for algoType == NETGEN_FULL
5515 # @ingroup l3_hypos_netgen
5516 def LengthFromFaces(self):
5517 self.Parameters(SIMPLE).LengthFromFaces()
5519 ## To mesh "holes" in a solid or not. Default is to mesh.
5520 # @ingroup l3_hypos_ghs3dh
5521 def SetToMeshHoles(self, toMesh):
5522 # Parameter of GHS3D
5523 self.Parameters().SetToMeshHoles(toMesh)
5525 ## Set Optimization level:
5526 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
5527 # Strong_Optimization.
5528 # Default is Standard_Optimization
5529 # @ingroup l3_hypos_ghs3dh
5530 def SetOptimizationLevel(self, level):
5531 # Parameter of GHS3D
5532 self.Parameters().SetOptimizationLevel(level)
5534 ## Maximal size of memory to be used by the algorithm (in Megabytes).
5535 # @ingroup l3_hypos_ghs3dh
5536 def SetMaximumMemory(self, MB):
5537 # Advanced parameter of GHS3D
5538 self.Parameters().SetMaximumMemory(MB)
5540 ## Initial size of memory to be used by the algorithm (in Megabytes) in
5541 # automatic memory adjustment mode.
5542 # @ingroup l3_hypos_ghs3dh
5543 def SetInitialMemory(self, MB):
5544 # Advanced parameter of GHS3D
5545 self.Parameters().SetInitialMemory(MB)
5547 ## Path to working directory.
5548 # @ingroup l3_hypos_ghs3dh
5549 def SetWorkingDirectory(self, path):
5550 # Advanced parameter of GHS3D
5551 self.Parameters().SetWorkingDirectory(path)
5553 ## To keep working files or remove them. Log file remains in case of errors anyway.
5554 # @ingroup l3_hypos_ghs3dh
5555 def SetKeepFiles(self, toKeep):
5556 # Advanced parameter of GHS3D and GHS3DPRL
5557 self.Parameters().SetKeepFiles(toKeep)
5559 ## To set verbose level [0-10]. <ul>
5560 #<li> 0 - no standard output,
5561 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
5562 # indicates when the final mesh is being saved. In addition the software
5563 # gives indication regarding the CPU time.
5564 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
5565 # histogram of the skin mesh, quality statistics histogram together with
5566 # the characteristics of the final mesh.</ul>
5567 # @ingroup l3_hypos_ghs3dh
5568 def SetVerboseLevel(self, level):
5569 # Advanced parameter of GHS3D
5570 self.Parameters().SetVerboseLevel(level)
5572 ## To create new nodes.
5573 # @ingroup l3_hypos_ghs3dh
5574 def SetToCreateNewNodes(self, toCreate):
5575 # Advanced parameter of GHS3D
5576 self.Parameters().SetToCreateNewNodes(toCreate)
5578 ## To use boundary recovery version which tries to create mesh on a very poor
5579 # quality surface mesh.
5580 # @ingroup l3_hypos_ghs3dh
5581 def SetToUseBoundaryRecoveryVersion(self, toUse):
5582 # Advanced parameter of GHS3D
5583 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
5585 ## Applies finite-element correction by replacing overconstrained elements where
5586 # it is possible. The process is cutting first the overconstrained edges and
5587 # second the overconstrained facets. This insure that no edges have two boundary
5588 # vertices and that no facets have three boundary vertices.
5589 # @ingroup l3_hypos_ghs3dh
5590 def SetFEMCorrection(self, toUseFem):
5591 # Advanced parameter of GHS3D
5592 self.Parameters().SetFEMCorrection(toUseFem)
5594 ## To removes initial central point.
5595 # @ingroup l3_hypos_ghs3dh
5596 def SetToRemoveCentralPoint(self, toRemove):
5597 # Advanced parameter of GHS3D
5598 self.Parameters().SetToRemoveCentralPoint(toRemove)
5600 ## To set an enforced vertex.
5601 # @ingroup l3_hypos_ghs3dh
5602 def SetEnforcedVertex(self, x, y, z, size):
5603 # Advanced parameter of GHS3D
5604 return self.Parameters().SetEnforcedVertex(x, y, z, size)
5606 ## To set an enforced vertex and add it in the group "groupName".
5607 # Only on meshes w/o geometry
5608 # @ingroup l3_hypos_ghs3dh
5609 def SetEnforcedVertexWithGroup(self, x, y, z, size, groupName):
5610 # Advanced parameter of GHS3D
5611 return self.Parameters().SetEnforcedVertex(x, y, z, size,groupName)
5613 ## To remove an enforced vertex.
5614 # @ingroup l3_hypos_ghs3dh
5615 def RemoveEnforcedVertex(self, x, y, z):
5616 # Advanced parameter of GHS3D
5617 return self.Parameters().RemoveEnforcedVertex(x, y, z)
5619 ## To set an enforced vertex given a GEOM vertex, group or compound.
5620 # @ingroup l3_hypos_ghs3dh
5621 def SetEnforcedVertexGeom(self, theVertex, size):
5622 self.AssureGeomPublished( theVertex )
5623 # Advanced parameter of GHS3D
5624 return self.Parameters().SetEnforcedVertexGeom(theVertex, size)
5626 ## To set an enforced vertex given a GEOM vertex, group or compound
5627 # and add it in the group "groupName".
5628 # Only on meshes w/o geometry
5629 # @ingroup l3_hypos_ghs3dh
5630 def SetEnforcedVertexGeomWithGroup(self, theVertex, size, groupName):
5631 self.AssureGeomPublished( theVertex )
5632 # Advanced parameter of GHS3D
5633 return self.Parameters().SetEnforcedVertexGeomWithGroup(theVertex, size,groupName)
5635 ## To remove an enforced vertex given a GEOM vertex, group or compound.
5636 # @ingroup l3_hypos_ghs3dh
5637 def RemoveEnforcedVertexGeom(self, theVertex):
5638 self.AssureGeomPublished( theVertex )
5639 # Advanced parameter of GHS3D
5640 return self.Parameters().RemoveEnforcedVertexGeom(theVertex)
5642 ## To set an enforced mesh.
5643 # @ingroup l3_hypos_ghs3dh
5644 def SetEnforcedMesh(self, theSource, elementType):
5645 # Advanced parameter of GHS3D
5646 return self.Parameters().SetEnforcedMesh(theSource, elementType)
5648 ## To set an enforced mesh and add the enforced elements in the group "groupName".
5649 # @ingroup l3_hypos_ghs3dh
5650 def SetEnforcedMeshWithGroup(self, theSource, elementType, groupName):
5651 # Advanced parameter of GHS3D
5652 return self.Parameters().SetEnforcedMeshWithGroup(theSource, elementType, groupName)
5654 ## To set an enforced mesh with given size.
5655 # @ingroup l3_hypos_ghs3dh
5656 def SetEnforcedMeshSize(self, theSource, elementType, size):
5657 # Advanced parameter of GHS3D
5658 return self.Parameters().SetEnforcedMeshSize(theSource, elementType, size)
5660 ## To set an enforced mesh with given size and add the enforced elements in the group "groupName".
5661 # @ingroup l3_hypos_ghs3dh
5662 def SetEnforcedMeshSizeWithGroup(self, theSource, elementType, size, groupName):
5663 # Advanced parameter of GHS3D
5664 return self.Parameters().SetEnforcedMeshSizeWithGroup(theSource, elementType, size, groupName)
5666 ## Sets command line option as text.
5667 # @ingroup l3_hypos_ghs3dh
5668 def SetTextOption(self, option):
5669 # Advanced parameter of GHS3D
5670 self.Parameters().SetTextOption(option)
5672 ## Sets MED files name and path.
5673 def SetMEDName(self, value):
5674 self.Parameters().SetMEDName(value)
5676 ## Sets the number of partition of the initial mesh
5677 def SetNbPart(self, value):
5678 self.Parameters().SetNbPart(value)
5680 ## When big mesh, start tepal in background
5681 def SetBackground(self, value):
5682 self.Parameters().SetBackground(value)
5684 # Public class: Mesh_Hexahedron
5685 # ------------------------------
5687 ## Defines a hexahedron 3D algorithm
5689 # @ingroup l3_algos_basic
5690 class Mesh_Hexahedron(Mesh_Algorithm):
5695 ## Private constructor.
5696 def __init__(self, mesh, algoType=Hexa, geom=0):
5697 Mesh_Algorithm.__init__(self)
5699 self.algoType = algoType
5701 if algoType == Hexa:
5702 self.Create(mesh, geom, "Hexa_3D")
5705 elif algoType == Hexotic:
5706 CheckPlugin(Hexotic)
5707 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
5710 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
5711 # @ingroup l3_hypos_hexotic
5712 def MinMaxQuad(self, min=3, max=8, quad=True):
5713 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
5715 self.params.SetHexesMinLevel(min)
5716 self.params.SetHexesMaxLevel(max)
5717 self.params.SetHexoticQuadrangles(quad)
5720 # Deprecated, only for compatibility!
5721 # Public class: Mesh_Netgen
5722 # ------------------------------
5724 ## Defines a NETGEN-based 2D or 3D algorithm
5725 # that needs no discrete boundary (i.e. independent)
5727 # This class is deprecated, only for compatibility!
5730 # @ingroup l3_algos_basic
5731 class Mesh_Netgen(Mesh_Algorithm):
5735 ## Private constructor.
5736 def __init__(self, mesh, is3D, geom=0):
5737 Mesh_Algorithm.__init__(self)
5743 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5747 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
5750 ## Defines the hypothesis containing parameters of the algorithm
5751 def Parameters(self):
5753 hyp = self.Hypothesis("NETGEN_Parameters", [],
5754 "libNETGENEngine.so", UseExisting=0)
5756 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
5757 "libNETGENEngine.so", UseExisting=0)
5760 # Public class: Mesh_Projection1D
5761 # ------------------------------
5763 ## Defines a projection 1D algorithm
5764 # @ingroup l3_algos_proj
5766 class Mesh_Projection1D(Mesh_Algorithm):
5768 ## Private constructor.
5769 def __init__(self, mesh, geom=0):
5770 Mesh_Algorithm.__init__(self)
5771 self.Create(mesh, geom, "Projection_1D")
5773 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
5774 # a mesh pattern is taken, and, optionally, the association of vertices
5775 # between the source edge and a target edge (to which a hypothesis is assigned)
5776 # @param edge from which nodes distribution is taken
5777 # @param mesh from which nodes distribution is taken (optional)
5778 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
5779 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
5780 # to associate with \a srcV (optional)
5781 # @param UseExisting if ==true - searches for the existing hypothesis created with
5782 # the same parameters, else (default) - creates a new one
5783 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
5784 self.AssureGeomPublished( edge )
5785 self.AssureGeomPublished( srcV )
5786 self.AssureGeomPublished( tgtV )
5787 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
5789 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
5790 hyp.SetSourceEdge( edge )
5791 if not mesh is None and isinstance(mesh, Mesh):
5792 mesh = mesh.GetMesh()
5793 hyp.SetSourceMesh( mesh )
5794 hyp.SetVertexAssociation( srcV, tgtV )
5797 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
5798 #def CompareSourceEdge(self, hyp, args):
5799 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
5803 # Public class: Mesh_Projection2D
5804 # ------------------------------
5806 ## Defines a projection 2D algorithm
5807 # @ingroup l3_algos_proj
5809 class Mesh_Projection2D(Mesh_Algorithm):
5811 ## Private constructor.
5812 def __init__(self, mesh, geom=0):
5813 Mesh_Algorithm.__init__(self)
5814 self.Create(mesh, geom, "Projection_2D")
5816 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
5817 # a mesh pattern is taken, and, optionally, the association of vertices
5818 # between the source face and the target face (to which a hypothesis is assigned)
5819 # @param face from which the mesh pattern is taken
5820 # @param mesh from which the mesh pattern is taken (optional)
5821 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
5822 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
5823 # to associate with \a srcV1 (optional)
5824 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
5825 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
5826 # to associate with \a srcV2 (optional)
5827 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
5828 # the same parameters, else (default) - forces the creation a new one
5830 # Note: all association vertices must belong to one edge of a face
5831 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
5832 srcV2=None, tgtV2=None, UseExisting=0):
5833 for geom in [ face, srcV1, tgtV1, srcV2, tgtV2 ]:
5834 self.AssureGeomPublished( geom )
5835 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
5837 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
5838 hyp.SetSourceFace( face )
5839 if isinstance(mesh, Mesh):
5840 mesh = mesh.GetMesh()
5841 hyp.SetSourceMesh( mesh )
5842 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5845 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
5846 #def CompareSourceFace(self, hyp, args):
5847 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
5850 # Public class: Mesh_Projection3D
5851 # ------------------------------
5853 ## Defines a projection 3D algorithm
5854 # @ingroup l3_algos_proj
5856 class Mesh_Projection3D(Mesh_Algorithm):
5858 ## Private constructor.
5859 def __init__(self, mesh, geom=0):
5860 Mesh_Algorithm.__init__(self)
5861 self.Create(mesh, geom, "Projection_3D")
5863 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
5864 # the mesh pattern is taken, and, optionally, the association of vertices
5865 # between the source and the target solid (to which a hipothesis is assigned)
5866 # @param solid from where the mesh pattern is taken
5867 # @param mesh from where the mesh pattern is taken (optional)
5868 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
5869 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
5870 # to associate with \a srcV1 (optional)
5871 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
5872 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
5873 # to associate with \a srcV2 (optional)
5874 # @param UseExisting - if ==true - searches for the existing hypothesis created with
5875 # the same parameters, else (default) - creates a new one
5877 # Note: association vertices must belong to one edge of a solid
5878 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
5879 srcV2=0, tgtV2=0, UseExisting=0):
5880 for geom in [ solid, srcV1, tgtV1, srcV2, tgtV2 ]:
5881 self.AssureGeomPublished( geom )
5882 hyp = self.Hypothesis("ProjectionSource3D",
5883 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
5885 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
5886 hyp.SetSource3DShape( solid )
5887 if not mesh is None and isinstance(mesh, Mesh):
5888 mesh = mesh.GetMesh()
5889 hyp.SetSourceMesh( mesh )
5890 if srcV1 and srcV2 and tgtV1 and tgtV2:
5891 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5892 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
5895 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
5896 #def CompareSourceShape3D(self, hyp, args):
5897 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
5901 # Public class: Mesh_Prism
5902 # ------------------------
5904 ## Defines a 3D extrusion algorithm
5905 # @ingroup l3_algos_3dextr
5907 class Mesh_Prism3D(Mesh_Algorithm):
5909 ## Private constructor.
5910 def __init__(self, mesh, geom=0):
5911 Mesh_Algorithm.__init__(self)
5912 self.Create(mesh, geom, "Prism_3D")
5914 # Public class: Mesh_RadialPrism
5915 # -------------------------------
5917 ## Defines a Radial Prism 3D algorithm
5918 # @ingroup l3_algos_radialp
5920 class Mesh_RadialPrism3D(Mesh_Algorithm):
5922 ## Private constructor.
5923 def __init__(self, mesh, geom=0):
5924 Mesh_Algorithm.__init__(self)
5925 self.Create(mesh, geom, "RadialPrism_3D")
5927 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
5928 self.nbLayers = None
5930 ## Return 3D hypothesis holding the 1D one
5931 def Get3DHypothesis(self):
5932 return self.distribHyp
5934 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5935 # hypothesis. Returns the created hypothesis
5936 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5937 #print "OwnHypothesis",hypType
5938 if not self.nbLayers is None:
5939 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5940 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5941 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5942 self.mesh.smeshpyD.SetCurrentStudy( None )
5943 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5944 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5945 self.distribHyp.SetLayerDistribution( hyp )
5948 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
5949 # prisms to build between the inner and outer shells
5950 # @param n number of layers
5951 # @param UseExisting if ==true - searches for the existing hypothesis created with
5952 # the same parameters, else (default) - creates a new one
5953 def NumberOfLayers(self, n, UseExisting=0):
5954 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5955 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
5956 CompareMethod=self.CompareNumberOfLayers)
5957 self.nbLayers.SetNumberOfLayers( n )
5958 return self.nbLayers
5960 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5961 def CompareNumberOfLayers(self, hyp, args):
5962 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5964 ## Defines "LocalLength" hypothesis, specifying the segment length
5965 # to build between the inner and the outer shells
5966 # @param l the length of segments
5967 # @param p the precision of rounding
5968 def LocalLength(self, l, p=1e-07):
5969 hyp = self.OwnHypothesis("LocalLength", [l,p])
5974 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
5975 # prisms to build between the inner and the outer shells.
5976 # @param n the number of layers
5977 # @param s the scale factor (optional)
5978 def NumberOfSegments(self, n, s=[]):
5980 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5982 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5983 hyp.SetDistrType( 1 )
5984 hyp.SetScaleFactor(s)
5985 hyp.SetNumberOfSegments(n)
5988 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5989 # to build between the inner and the outer shells with a length that changes in arithmetic progression
5990 # @param start the length of the first segment
5991 # @param end the length of the last segment
5992 def Arithmetic1D(self, start, end ):
5993 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5994 hyp.SetLength(start, 1)
5995 hyp.SetLength(end , 0)
5998 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5999 # to build between the inner and the outer shells as geometric length increasing
6000 # @param start for the length of the first segment
6001 # @param end for the length of the last segment
6002 def StartEndLength(self, start, end):
6003 hyp = self.OwnHypothesis("StartEndLength", [start, end])
6004 hyp.SetLength(start, 1)
6005 hyp.SetLength(end , 0)
6008 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
6009 # to build between the inner and outer shells
6010 # @param fineness defines the quality of the mesh within the range [0-1]
6011 def AutomaticLength(self, fineness=0):
6012 hyp = self.OwnHypothesis("AutomaticLength")
6013 hyp.SetFineness( fineness )
6016 # Public class: Mesh_RadialQuadrangle1D2D
6017 # -------------------------------
6019 ## Defines a Radial Quadrangle 1D2D algorithm
6020 # @ingroup l2_algos_radialq
6022 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
6024 ## Private constructor.
6025 def __init__(self, mesh, geom=0):
6026 Mesh_Algorithm.__init__(self)
6027 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
6029 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
6030 self.nbLayers = None
6032 ## Return 2D hypothesis holding the 1D one
6033 def Get2DHypothesis(self):
6034 return self.distribHyp
6036 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
6037 # hypothesis. Returns the created hypothesis
6038 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
6039 #print "OwnHypothesis",hypType
6041 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
6042 if self.distribHyp is None:
6043 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
6045 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
6046 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
6047 self.mesh.smeshpyD.SetCurrentStudy( None )
6048 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
6049 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
6050 self.distribHyp.SetLayerDistribution( hyp )
6053 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
6054 # @param n number of layers
6055 # @param UseExisting if ==true - searches for the existing hypothesis created with
6056 # the same parameters, else (default) - creates a new one
6057 def NumberOfLayers(self, n, UseExisting=0):
6059 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
6060 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
6061 CompareMethod=self.CompareNumberOfLayers)
6062 self.nbLayers.SetNumberOfLayers( n )
6063 return self.nbLayers
6065 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
6066 def CompareNumberOfLayers(self, hyp, args):
6067 return IsEqual(hyp.GetNumberOfLayers(), args[0])
6069 ## Defines "LocalLength" hypothesis, specifying the segment length
6070 # @param l the length of segments
6071 # @param p the precision of rounding
6072 def LocalLength(self, l, p=1e-07):
6073 hyp = self.OwnHypothesis("LocalLength", [l,p])
6078 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
6079 # @param n the number of layers
6080 # @param s the scale factor (optional)
6081 def NumberOfSegments(self, n, s=[]):
6083 hyp = self.OwnHypothesis("NumberOfSegments", [n])
6085 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
6086 hyp.SetDistrType( 1 )
6087 hyp.SetScaleFactor(s)
6088 hyp.SetNumberOfSegments(n)
6091 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
6092 # with a length that changes in arithmetic progression
6093 # @param start the length of the first segment
6094 # @param end the length of the last segment
6095 def Arithmetic1D(self, start, end ):
6096 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
6097 hyp.SetLength(start, 1)
6098 hyp.SetLength(end , 0)
6101 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
6102 # as geometric length increasing
6103 # @param start for the length of the first segment
6104 # @param end for the length of the last segment
6105 def StartEndLength(self, start, end):
6106 hyp = self.OwnHypothesis("StartEndLength", [start, end])
6107 hyp.SetLength(start, 1)
6108 hyp.SetLength(end , 0)
6111 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
6112 # @param fineness defines the quality of the mesh within the range [0-1]
6113 def AutomaticLength(self, fineness=0):
6114 hyp = self.OwnHypothesis("AutomaticLength")
6115 hyp.SetFineness( fineness )
6119 # Public class: Mesh_UseExistingElements
6120 # --------------------------------------
6121 ## Defines a Radial Quadrangle 1D2D algorithm
6122 # @ingroup l3_algos_basic
6124 class Mesh_UseExistingElements(Mesh_Algorithm):
6126 def __init__(self, dim, mesh, geom=0):
6128 self.Create(mesh, geom, "Import_1D")
6130 self.Create(mesh, geom, "Import_1D2D")
6133 ## Defines "Source edges" hypothesis, specifying groups of edges to import
6134 # @param groups list of groups of edges
6135 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
6136 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
6137 # @param UseExisting if ==true - searches for the existing hypothesis created with
6138 # the same parameters, else (default) - creates a new one
6139 def SourceEdges(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
6140 if self.algo.GetName() == "Import_2D":
6141 raise ValueError, "algoritm dimension mismatch"
6142 for group in groups:
6143 self.AssureGeomPublished( group )
6144 hyp = self.Hypothesis("ImportSource1D", [groups, toCopyMesh, toCopyGroups],
6145 UseExisting=UseExisting, CompareMethod=self._compareHyp)
6146 hyp.SetSourceEdges(groups)
6147 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
6150 ## Defines "Source faces" hypothesis, specifying groups of faces to import
6151 # @param groups list of groups of faces
6152 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
6153 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
6154 # @param UseExisting if ==true - searches for the existing hypothesis created with
6155 # the same parameters, else (default) - creates a new one
6156 def SourceFaces(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
6157 if self.algo.GetName() == "Import_1D":
6158 raise ValueError, "algoritm dimension mismatch"
6159 for group in groups:
6160 self.AssureGeomPublished( group )
6161 hyp = self.Hypothesis("ImportSource2D", [groups, toCopyMesh, toCopyGroups],
6162 UseExisting=UseExisting, CompareMethod=self._compareHyp)
6163 hyp.SetSourceFaces(groups)
6164 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
6167 def _compareHyp(self,hyp,args):
6168 if hasattr( hyp, "GetSourceEdges"):
6169 entries = hyp.GetSourceEdges()
6171 entries = hyp.GetSourceFaces()
6173 toCopyMesh,toCopyGroups = hyp.GetCopySourceMesh()
6174 if len(entries)==len(groups) and toCopyMesh==args[1] and toCopyGroups==args[2]:
6176 study = self.mesh.smeshpyD.GetCurrentStudy()
6179 ior = salome.orb.object_to_string(g)
6180 sobj = study.FindObjectIOR(ior)
6181 if sobj: entries2.append( sobj.GetID() )
6186 return entries == entries2
6190 # Private class: Mesh_UseExisting
6191 # -------------------------------
6192 class Mesh_UseExisting(Mesh_Algorithm):
6194 def __init__(self, dim, mesh, geom=0):
6196 self.Create(mesh, geom, "UseExisting_1D")
6198 self.Create(mesh, geom, "UseExisting_2D")
6201 import salome_notebook
6202 notebook = salome_notebook.notebook
6204 ##Return values of the notebook variables
6205 def ParseParameters(last, nbParams,nbParam, value):
6209 listSize = len(last)
6210 for n in range(0,nbParams):
6212 if counter < listSize:
6213 strResult = strResult + last[counter]
6215 strResult = strResult + ""
6217 if isinstance(value, str):
6218 if notebook.isVariable(value):
6219 result = notebook.get(value)
6220 strResult=strResult+value
6222 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
6224 strResult=strResult+str(value)
6226 if nbParams - 1 != counter:
6227 strResult=strResult+var_separator #":"
6229 return result, strResult
6231 #Wrapper class for StdMeshers_LocalLength hypothesis
6232 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
6234 ## Set Length parameter value
6235 # @param length numerical value or name of variable from notebook
6236 def SetLength(self, length):
6237 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
6238 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6239 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
6241 ## Set Precision parameter value
6242 # @param precision numerical value or name of variable from notebook
6243 def SetPrecision(self, precision):
6244 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
6245 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6246 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
6248 #Registering the new proxy for LocalLength
6249 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
6252 #Wrapper class for StdMeshers_LayerDistribution hypothesis
6253 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
6255 def SetLayerDistribution(self, hypo):
6256 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
6257 hypo.ClearParameters();
6258 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
6260 #Registering the new proxy for LayerDistribution
6261 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
6263 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
6264 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
6266 ## Set Length parameter value
6267 # @param length numerical value or name of variable from notebook
6268 def SetLength(self, length):
6269 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
6270 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
6271 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
6273 #Registering the new proxy for SegmentLengthAroundVertex
6274 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
6277 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
6278 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
6280 ## Set Length parameter value
6281 # @param length numerical value or name of variable from notebook
6282 # @param isStart true is length is Start Length, otherwise false
6283 def SetLength(self, length, isStart):
6287 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
6288 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
6289 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
6291 #Registering the new proxy for Arithmetic1D
6292 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
6294 #Wrapper class for StdMeshers_Deflection1D hypothesis
6295 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
6297 ## Set Deflection parameter value
6298 # @param deflection numerical value or name of variable from notebook
6299 def SetDeflection(self, deflection):
6300 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
6301 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
6302 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
6304 #Registering the new proxy for Deflection1D
6305 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
6307 #Wrapper class for StdMeshers_StartEndLength hypothesis
6308 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
6310 ## Set Length parameter value
6311 # @param length numerical value or name of variable from notebook
6312 # @param isStart true is length is Start Length, otherwise false
6313 def SetLength(self, length, isStart):
6317 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
6318 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
6319 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
6321 #Registering the new proxy for StartEndLength
6322 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
6324 #Wrapper class for StdMeshers_MaxElementArea hypothesis
6325 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
6327 ## Set Max Element Area parameter value
6328 # @param area numerical value or name of variable from notebook
6329 def SetMaxElementArea(self, area):
6330 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
6331 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
6332 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
6334 #Registering the new proxy for MaxElementArea
6335 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
6338 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
6339 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
6341 ## Set Max Element Volume parameter value
6342 # @param volume numerical value or name of variable from notebook
6343 def SetMaxElementVolume(self, volume):
6344 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
6345 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
6346 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
6348 #Registering the new proxy for MaxElementVolume
6349 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
6352 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
6353 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
6355 ## Set Number Of Layers parameter value
6356 # @param nbLayers numerical value or name of variable from notebook
6357 def SetNumberOfLayers(self, nbLayers):
6358 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
6359 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
6360 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
6362 #Registering the new proxy for NumberOfLayers
6363 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
6365 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
6366 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
6368 ## Set Number Of Segments parameter value
6369 # @param nbSeg numerical value or name of variable from notebook
6370 def SetNumberOfSegments(self, nbSeg):
6371 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
6372 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
6373 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6374 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
6376 ## Set Scale Factor parameter value
6377 # @param factor numerical value or name of variable from notebook
6378 def SetScaleFactor(self, factor):
6379 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
6380 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6381 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
6383 #Registering the new proxy for NumberOfSegments
6384 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
6386 if not noNETGENPlugin:
6387 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
6388 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
6390 ## Set Max Size parameter value
6391 # @param maxsize numerical value or name of variable from notebook
6392 def SetMaxSize(self, maxsize):
6393 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6394 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
6395 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6396 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
6398 ## Set Growth Rate parameter value
6399 # @param value numerical value or name of variable from notebook
6400 def SetGrowthRate(self, value):
6401 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6402 value, parameters = ParseParameters(lastParameters,4,2,value)
6403 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6404 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
6406 ## Set Number of Segments per Edge parameter value
6407 # @param value numerical value or name of variable from notebook
6408 def SetNbSegPerEdge(self, value):
6409 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6410 value, parameters = ParseParameters(lastParameters,4,3,value)
6411 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6412 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
6414 ## Set Number of Segments per Radius parameter value
6415 # @param value numerical value or name of variable from notebook
6416 def SetNbSegPerRadius(self, value):
6417 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6418 value, parameters = ParseParameters(lastParameters,4,4,value)
6419 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6420 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
6422 #Registering the new proxy for NETGENPlugin_Hypothesis
6423 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
6426 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
6427 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
6430 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
6431 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
6433 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
6434 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
6436 ## Set Number of Segments parameter value
6437 # @param nbSeg numerical value or name of variable from notebook
6438 def SetNumberOfSegments(self, nbSeg):
6439 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6440 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
6441 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6442 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
6444 ## Set Local Length parameter value
6445 # @param length numerical value or name of variable from notebook
6446 def SetLocalLength(self, length):
6447 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6448 length, parameters = ParseParameters(lastParameters,2,1,length)
6449 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6450 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
6452 ## Set Max Element Area parameter value
6453 # @param area numerical value or name of variable from notebook
6454 def SetMaxElementArea(self, area):
6455 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6456 area, parameters = ParseParameters(lastParameters,2,2,area)
6457 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6458 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
6460 def LengthFromEdges(self):
6461 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6463 value, parameters = ParseParameters(lastParameters,2,2,value)
6464 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6465 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
6467 #Registering the new proxy for NETGEN_SimpleParameters_2D
6468 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
6471 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
6472 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
6473 ## Set Max Element Volume parameter value
6474 # @param volume numerical value or name of variable from notebook
6475 def SetMaxElementVolume(self, volume):
6476 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6477 volume, parameters = ParseParameters(lastParameters,3,3,volume)
6478 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6479 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
6481 def LengthFromFaces(self):
6482 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6484 value, parameters = ParseParameters(lastParameters,3,3,value)
6485 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6486 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
6488 #Registering the new proxy for NETGEN_SimpleParameters_3D
6489 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
6491 pass # if not noNETGENPlugin:
6493 class Pattern(SMESH._objref_SMESH_Pattern):
6495 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
6497 if isinstance(theNodeIndexOnKeyPoint1,str):
6499 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
6501 theNodeIndexOnKeyPoint1 -= 1
6502 theMesh.SetParameters(Parameters)
6503 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
6505 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
6508 if isinstance(theNode000Index,str):
6510 if isinstance(theNode001Index,str):
6512 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
6514 theNode000Index -= 1
6516 theNode001Index -= 1
6517 theMesh.SetParameters(Parameters)
6518 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
6520 #Registering the new proxy for Pattern
6521 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)