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)
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 numerical functor by its type
900 # @param theCriterion FT_...; functor type
901 # @return SMESH_NumericalFunctor
902 # @ingroup l1_controls
903 def GetFunctor(self,theCriterion):
904 aFilterMgr = self.CreateFilterManager()
905 if theCriterion == FT_AspectRatio:
906 return aFilterMgr.CreateAspectRatio()
907 elif theCriterion == FT_AspectRatio3D:
908 return aFilterMgr.CreateAspectRatio3D()
909 elif theCriterion == FT_Warping:
910 return aFilterMgr.CreateWarping()
911 elif theCriterion == FT_MinimumAngle:
912 return aFilterMgr.CreateMinimumAngle()
913 elif theCriterion == FT_Taper:
914 return aFilterMgr.CreateTaper()
915 elif theCriterion == FT_Skew:
916 return aFilterMgr.CreateSkew()
917 elif theCriterion == FT_Area:
918 return aFilterMgr.CreateArea()
919 elif theCriterion == FT_Volume3D:
920 return aFilterMgr.CreateVolume3D()
921 elif theCriterion == FT_MaxElementLength2D:
922 return aFilterMgr.CreateMaxElementLength2D()
923 elif theCriterion == FT_MaxElementLength3D:
924 return aFilterMgr.CreateMaxElementLength3D()
925 elif theCriterion == FT_MultiConnection:
926 return aFilterMgr.CreateMultiConnection()
927 elif theCriterion == FT_MultiConnection2D:
928 return aFilterMgr.CreateMultiConnection2D()
929 elif theCriterion == FT_Length:
930 return aFilterMgr.CreateLength()
931 elif theCriterion == FT_Length2D:
932 return aFilterMgr.CreateLength2D()
934 print "Error: given parameter is not numerucal functor type."
936 ## Creates hypothesis
937 # @param theHType mesh hypothesis type (string)
938 # @param theLibName mesh plug-in library name
939 # @return created hypothesis instance
940 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
941 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
943 ## Gets the mesh stattistic
944 # @return dictionary type element - count of elements
945 # @ingroup l1_meshinfo
946 def GetMeshInfo(self, obj):
947 if isinstance( obj, Mesh ):
950 if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource):
951 values = obj.GetMeshInfo()
952 for i in range(SMESH.Entity_Last._v):
953 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
957 ## Get minimum distance between two objects
959 # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
960 # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
962 # @param src1 first source object
963 # @param src2 second source object
964 # @param id1 node/element id from the first source
965 # @param id2 node/element id from the second (or first) source
966 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
967 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
968 # @return minimum distance value
969 # @sa GetMinDistance()
970 # @ingroup l1_measurements
971 def MinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
972 result = self.GetMinDistance(src1, src2, id1, id2, isElem1, isElem2)
976 result = result.value
979 ## Get measure structure specifying minimum distance data between two objects
981 # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
982 # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
984 # @param src1 first source object
985 # @param src2 second source object
986 # @param id1 node/element id from the first source
987 # @param id2 node/element id from the second (or first) source
988 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
989 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
990 # @return Measure structure or None if input data is invalid
992 # @ingroup l1_measurements
993 def GetMinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
994 if isinstance(src1, Mesh): src1 = src1.mesh
995 if isinstance(src2, Mesh): src2 = src2.mesh
996 if src2 is None and id2 != 0: src2 = src1
997 if not hasattr(src1, "_narrow"): return None
998 src1 = src1._narrow(SMESH.SMESH_IDSource)
999 if not src1: return None
1002 e = m.GetMeshEditor()
1004 src1 = e.MakeIDSource([id1], SMESH.FACE)
1006 src1 = e.MakeIDSource([id1], SMESH.NODE)
1008 if hasattr(src2, "_narrow"):
1009 src2 = src2._narrow(SMESH.SMESH_IDSource)
1010 if src2 and id2 != 0:
1012 e = m.GetMeshEditor()
1014 src2 = e.MakeIDSource([id2], SMESH.FACE)
1016 src2 = e.MakeIDSource([id2], SMESH.NODE)
1019 aMeasurements = self.CreateMeasurements()
1020 result = aMeasurements.MinDistance(src1, src2)
1021 aMeasurements.UnRegister()
1024 ## Get bounding box of the specified object(s)
1025 # @param objects single source object or list of source objects
1026 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
1027 # @sa GetBoundingBox()
1028 # @ingroup l1_measurements
1029 def BoundingBox(self, objects):
1030 result = self.GetBoundingBox(objects)
1034 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
1037 ## Get measure structure specifying bounding box data of the specified object(s)
1038 # @param objects single source object or list of source objects
1039 # @return Measure structure
1041 # @ingroup l1_measurements
1042 def GetBoundingBox(self, objects):
1043 if isinstance(objects, tuple):
1044 objects = list(objects)
1045 if not isinstance(objects, list):
1049 if isinstance(o, Mesh):
1050 srclist.append(o.mesh)
1051 elif hasattr(o, "_narrow"):
1052 src = o._narrow(SMESH.SMESH_IDSource)
1053 if src: srclist.append(src)
1056 aMeasurements = self.CreateMeasurements()
1057 result = aMeasurements.BoundingBox(srclist)
1058 aMeasurements.UnRegister()
1062 #Registering the new proxy for SMESH_Gen
1063 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
1066 # Public class: Mesh
1067 # ==================
1069 ## This class allows defining and managing a mesh.
1070 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
1071 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
1072 # new nodes and elements and by changing the existing entities), to get information
1073 # about a mesh and to export a mesh into different formats.
1082 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
1083 # sets the GUI name of this mesh to \a name.
1084 # @param smeshpyD an instance of smeshDC class
1085 # @param geompyD an instance of geompyDC class
1086 # @param obj Shape to be meshed or SMESH_Mesh object
1087 # @param name Study name of the mesh
1088 # @ingroup l2_construct
1089 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
1090 self.smeshpyD=smeshpyD
1091 self.geompyD=geompyD
1095 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
1097 # publish geom of mesh (issue 0021122)
1098 if not self.geom.GetStudyEntry():
1099 studyID = smeshpyD.GetCurrentStudy()._get_StudyId()
1100 if studyID != geompyD.myStudyId:
1101 geompyD.init_geom( smeshpyD.GetCurrentStudy())
1103 geo_name = "%s_%s"%(self.geom.GetShapeType(), id(self.geom)%100)
1104 geompyD.addToStudy( self.geom, geo_name )
1105 self.mesh = self.smeshpyD.CreateMesh(self.geom)
1107 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
1110 self.mesh = self.smeshpyD.CreateEmptyMesh()
1112 self.smeshpyD.SetName(self.mesh, name)
1114 self.smeshpyD.SetName(self.mesh, GetName(obj))
1117 self.geom = self.mesh.GetShapeToMesh()
1119 self.editor = self.mesh.GetMeshEditor()
1121 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
1122 # @param theMesh a SMESH_Mesh object
1123 # @ingroup l2_construct
1124 def SetMesh(self, theMesh):
1126 self.geom = self.mesh.GetShapeToMesh()
1128 ## Returns the mesh, that is an instance of SMESH_Mesh interface
1129 # @return a SMESH_Mesh object
1130 # @ingroup l2_construct
1134 ## Gets the name of the mesh
1135 # @return the name of the mesh as a string
1136 # @ingroup l2_construct
1138 name = GetName(self.GetMesh())
1141 ## Sets a name to the mesh
1142 # @param name a new name of the mesh
1143 # @ingroup l2_construct
1144 def SetName(self, name):
1145 self.smeshpyD.SetName(self.GetMesh(), name)
1147 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
1148 # The subMesh object gives access to the IDs of nodes and elements.
1149 # @param geom a geometrical object (shape)
1150 # @param name a name for the submesh
1151 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
1152 # @ingroup l2_submeshes
1153 def GetSubMesh(self, geom, name):
1154 if not geom.IsSame( self.geom ) and not geom.GetStudyEntry():
1156 studyID = self.smeshpyD.GetCurrentStudy()._get_StudyId()
1157 if studyID != self.geompyD.myStudyId:
1158 self.geompyD.init_geom( self.smeshpyD.GetCurrentStudy())
1160 if not name and geom.GetShapeType() != geompyDC.GEOM.COMPOUND:
1161 # for all groups SubShapeName() returns "Compound_-1"
1162 name = self.geompyD.SubShapeName(geom, self.geom)
1164 name = "%s_%s"%(geom.GetShapeType(), id(geom)%10000)
1166 self.geompyD.addToStudyInFather( self.geom, geom, name )
1167 submesh = self.mesh.GetSubMesh( geom, name )
1170 ## Returns the shape associated to the mesh
1171 # @return a GEOM_Object
1172 # @ingroup l2_construct
1176 ## Associates the given shape to the mesh (entails the recreation of the mesh)
1177 # @param geom the shape to be meshed (GEOM_Object)
1178 # @ingroup l2_construct
1179 def SetShape(self, geom):
1180 self.mesh = self.smeshpyD.CreateMesh(geom)
1182 ## Returns true if the hypotheses are defined well
1183 # @param theSubObject a subshape of a mesh shape
1184 # @return True or False
1185 # @ingroup l2_construct
1186 def IsReadyToCompute(self, theSubObject):
1187 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
1189 ## Returns errors of hypotheses definition.
1190 # The list of errors is empty if everything is OK.
1191 # @param theSubObject a subshape of a mesh shape
1192 # @return a list of errors
1193 # @ingroup l2_construct
1194 def GetAlgoState(self, theSubObject):
1195 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
1197 ## Returns a geometrical object on which the given element was built.
1198 # The returned geometrical object, if not nil, is either found in the
1199 # study or published by this method with the given name
1200 # @param theElementID the id of the mesh element
1201 # @param theGeomName the user-defined name of the geometrical object
1202 # @return GEOM::GEOM_Object instance
1203 # @ingroup l2_construct
1204 def GetGeometryByMeshElement(self, theElementID, theGeomName):
1205 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
1207 ## Returns the mesh dimension depending on the dimension of the underlying shape
1208 # @return mesh dimension as an integer value [0,3]
1209 # @ingroup l1_auxiliary
1210 def MeshDimension(self):
1211 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
1212 if len( shells ) > 0 :
1214 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
1216 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
1222 ## Creates a segment discretization 1D algorithm.
1223 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
1224 # \n If the optional \a geom parameter is not set, this algorithm is global.
1225 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1226 # @param algo the type of the required algorithm. Possible values are:
1228 # - smesh.PYTHON for discretization via a python function,
1229 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
1230 # @param geom If defined is the subshape to be meshed
1231 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
1232 # @ingroup l3_algos_basic
1233 def Segment(self, algo=REGULAR, geom=0):
1234 ## if Segment(geom) is called by mistake
1235 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
1236 algo, geom = geom, algo
1237 if not algo: algo = REGULAR
1240 return Mesh_Segment(self, geom)
1241 elif algo == PYTHON:
1242 return Mesh_Segment_Python(self, geom)
1243 elif algo == COMPOSITE:
1244 return Mesh_CompositeSegment(self, geom)
1246 return Mesh_Segment(self, geom)
1248 ## Creates 1D algorithm importing segments conatined in groups of other mesh.
1249 # If the optional \a geom parameter is not set, this algorithm is global.
1250 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1251 # @param geom If defined the subshape is to be meshed
1252 # @return an instance of Mesh_UseExistingElements class
1253 # @ingroup l3_algos_basic
1254 def UseExisting1DElements(self, geom=0):
1255 return Mesh_UseExistingElements(1,self, geom)
1257 ## Creates 2D algorithm importing faces conatined in groups of other mesh.
1258 # If the optional \a geom parameter is not set, this algorithm is global.
1259 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1260 # @param geom If defined the subshape is to be meshed
1261 # @return an instance of Mesh_UseExistingElements class
1262 # @ingroup l3_algos_basic
1263 def UseExisting2DElements(self, geom=0):
1264 return Mesh_UseExistingElements(2,self, geom)
1266 ## Enables creation of nodes and segments usable by 2D algoritms.
1267 # The added nodes and segments must be bound to edges and vertices by
1268 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
1269 # If the optional \a geom parameter is not set, this algorithm is global.
1270 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1271 # @param geom the subshape to be manually meshed
1272 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
1273 # @ingroup l3_algos_basic
1274 def UseExistingSegments(self, geom=0):
1275 algo = Mesh_UseExisting(1,self,geom)
1276 return algo.GetAlgorithm()
1278 ## Enables creation of nodes and faces usable by 3D algoritms.
1279 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
1280 # and SetMeshElementOnShape()
1281 # If the optional \a geom parameter is not set, this algorithm is global.
1282 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1283 # @param geom the subshape to be manually meshed
1284 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1285 # @ingroup l3_algos_basic
1286 def UseExistingFaces(self, geom=0):
1287 algo = Mesh_UseExisting(2,self,geom)
1288 return algo.GetAlgorithm()
1290 ## Creates a triangle 2D algorithm for faces.
1291 # If the optional \a geom parameter is not set, this algorithm is global.
1292 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1293 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1294 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1295 # @return an instance of Mesh_Triangle algorithm
1296 # @ingroup l3_algos_basic
1297 def Triangle(self, algo=MEFISTO, geom=0):
1298 ## if Triangle(geom) is called by mistake
1299 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1302 return Mesh_Triangle(self, algo, geom)
1304 ## Creates a quadrangle 2D algorithm for faces.
1305 # If the optional \a geom parameter is not set, this algorithm is global.
1306 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1307 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1308 # @param algo values are: smesh.QUADRANGLE || smesh.RADIAL_QUAD
1309 # @return an instance of Mesh_Quadrangle algorithm
1310 # @ingroup l3_algos_basic
1311 def Quadrangle(self, geom=0, algo=QUADRANGLE):
1312 if algo==RADIAL_QUAD:
1313 return Mesh_RadialQuadrangle1D2D(self,geom)
1315 return Mesh_Quadrangle(self, geom)
1317 ## Creates a tetrahedron 3D algorithm for solids.
1318 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1319 # If the optional \a geom parameter is not set, this algorithm is global.
1320 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1321 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1322 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1323 # @return an instance of Mesh_Tetrahedron algorithm
1324 # @ingroup l3_algos_basic
1325 def Tetrahedron(self, algo=NETGEN, geom=0):
1326 ## if Tetrahedron(geom) is called by mistake
1327 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1328 algo, geom = geom, algo
1329 if not algo: algo = NETGEN
1331 return Mesh_Tetrahedron(self, algo, geom)
1333 ## Creates a hexahedron 3D algorithm for solids.
1334 # If the optional \a geom parameter is not set, this algorithm is global.
1335 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1336 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1337 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1338 # @return an instance of Mesh_Hexahedron algorithm
1339 # @ingroup l3_algos_basic
1340 def Hexahedron(self, algo=Hexa, geom=0):
1341 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1342 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1343 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1344 elif geom == 0: algo, geom = Hexa, algo
1345 return Mesh_Hexahedron(self, algo, geom)
1347 ## Deprecated, used only for compatibility!
1348 # @return an instance of Mesh_Netgen algorithm
1349 # @ingroup l3_algos_basic
1350 def Netgen(self, is3D, geom=0):
1351 return Mesh_Netgen(self, is3D, geom)
1353 ## Creates a projection 1D algorithm for edges.
1354 # If the optional \a geom parameter is not set, this algorithm is global.
1355 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1356 # @param geom If defined, the subshape to be meshed
1357 # @return an instance of Mesh_Projection1D algorithm
1358 # @ingroup l3_algos_proj
1359 def Projection1D(self, geom=0):
1360 return Mesh_Projection1D(self, geom)
1362 ## Creates a projection 2D algorithm for faces.
1363 # If the optional \a geom parameter is not set, this algorithm is global.
1364 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1365 # @param geom If defined, the subshape to be meshed
1366 # @return an instance of Mesh_Projection2D algorithm
1367 # @ingroup l3_algos_proj
1368 def Projection2D(self, geom=0):
1369 return Mesh_Projection2D(self, geom)
1371 ## Creates a projection 3D algorithm for solids.
1372 # If the optional \a geom parameter is not set, this algorithm is global.
1373 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1374 # @param geom If defined, the subshape to be meshed
1375 # @return an instance of Mesh_Projection3D algorithm
1376 # @ingroup l3_algos_proj
1377 def Projection3D(self, geom=0):
1378 return Mesh_Projection3D(self, geom)
1380 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1381 # If the optional \a geom parameter is not set, this algorithm is global.
1382 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1383 # @param geom If defined, the subshape to be meshed
1384 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1385 # @ingroup l3_algos_radialp l3_algos_3dextr
1386 def Prism(self, geom=0):
1390 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1391 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1392 if nbSolids == 0 or nbSolids == nbShells:
1393 return Mesh_Prism3D(self, geom)
1394 return Mesh_RadialPrism3D(self, geom)
1396 ## Evaluates size of prospective mesh on a shape
1397 # @return a list where i-th element is a number of elements of i-th SMESH.EntityType
1398 # To know predicted number of e.g. edges, inquire it this way
1399 # Evaluate()[ EnumToLong( Entity_Edge )]
1400 def Evaluate(self, geom=0):
1401 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1403 geom = self.mesh.GetShapeToMesh()
1406 return self.smeshpyD.Evaluate(self.mesh, geom)
1409 ## Computes the mesh and returns the status of the computation
1410 # @param geom geomtrical shape on which mesh data should be computed
1411 # @param discardModifs if True and the mesh has been edited since
1412 # a last total re-compute and that may prevent successful partial re-compute,
1413 # then the mesh is cleaned before Compute()
1414 # @return True or False
1415 # @ingroup l2_construct
1416 def Compute(self, geom=0, discardModifs=False):
1417 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1419 geom = self.mesh.GetShapeToMesh()
1424 if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693
1426 ok = self.smeshpyD.Compute(self.mesh, geom)
1427 except SALOME.SALOME_Exception, ex:
1428 print "Mesh computation failed, exception caught:"
1429 print " ", ex.details.text
1432 print "Mesh computation failed, exception caught:"
1433 traceback.print_exc()
1437 # Treat compute errors
1438 computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
1439 for err in computeErrors:
1441 if self.mesh.HasShapeToMesh():
1443 mainIOR = salome.orb.object_to_string(geom)
1444 for sname in salome.myStudyManager.GetOpenStudies():
1445 s = salome.myStudyManager.GetStudyByName(sname)
1447 mainSO = s.FindObjectIOR(mainIOR)
1448 if not mainSO: continue
1449 if err.subShapeID == 1:
1450 shapeText = ' on "%s"' % mainSO.GetName()
1451 subIt = s.NewChildIterator(mainSO)
1453 subSO = subIt.Value()
1455 obj = subSO.GetObject()
1456 if not obj: continue
1457 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
1459 ids = go.GetSubShapeIndices()
1460 if len(ids) == 1 and ids[0] == err.subShapeID:
1461 shapeText = ' on "%s"' % subSO.GetName()
1464 shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
1466 shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID)
1468 shapeText = " on subshape #%s" % (err.subShapeID)
1470 shapeText = " on subshape #%s" % (err.subShapeID)
1472 stdErrors = ["OK", #COMPERR_OK
1473 "Invalid input mesh", #COMPERR_BAD_INPUT_MESH
1474 "std::exception", #COMPERR_STD_EXCEPTION
1475 "OCC exception", #COMPERR_OCC_EXCEPTION
1476 "SALOME exception", #COMPERR_SLM_EXCEPTION
1477 "Unknown exception", #COMPERR_EXCEPTION
1478 "Memory allocation problem", #COMPERR_MEMORY_PB
1479 "Algorithm failed", #COMPERR_ALGO_FAILED
1480 "Unexpected geometry"]#COMPERR_BAD_SHAPE
1482 if err.code < len(stdErrors): errText = stdErrors[err.code]
1484 errText = "code %s" % -err.code
1485 if errText: errText += ". "
1486 errText += err.comment
1487 if allReasons != "":allReasons += "\n"
1488 allReasons += '"%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
1492 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1494 if err.isGlobalAlgo:
1502 reason = '%s %sD algorithm is missing' % (glob, dim)
1503 elif err.state == HYP_MISSING:
1504 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1505 % (glob, dim, name, dim))
1506 elif err.state == HYP_NOTCONFORM:
1507 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1508 elif err.state == HYP_BAD_PARAMETER:
1509 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1510 % ( glob, dim, name ))
1511 elif err.state == HYP_BAD_GEOMETRY:
1512 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1513 'geometry' % ( glob, dim, name ))
1515 reason = "For unknown reason."+\
1516 " Revise Mesh.Compute() implementation in smeshDC.py!"
1518 if allReasons != "":allReasons += "\n"
1519 allReasons += reason
1521 if allReasons != "":
1522 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1526 print '"' + GetName(self.mesh) + '"',"has not been computed."
1529 if salome.sg.hasDesktop():
1530 smeshgui = salome.ImportComponentGUI("SMESH")
1531 smeshgui.Init(self.mesh.GetStudyId())
1532 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1533 salome.sg.updateObjBrowser(1)
1537 ## Return submesh objects list in meshing order
1538 # @return list of list of submesh objects
1539 # @ingroup l2_construct
1540 def GetMeshOrder(self):
1541 return self.mesh.GetMeshOrder()
1543 ## Return submesh objects list in meshing order
1544 # @return list of list of submesh objects
1545 # @ingroup l2_construct
1546 def SetMeshOrder(self, submeshes):
1547 return self.mesh.SetMeshOrder(submeshes)
1549 ## Removes all nodes and elements
1550 # @ingroup l2_construct
1553 if salome.sg.hasDesktop():
1554 smeshgui = salome.ImportComponentGUI("SMESH")
1555 smeshgui.Init(self.mesh.GetStudyId())
1556 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1557 salome.sg.updateObjBrowser(1)
1559 ## Removes all nodes and elements of indicated shape
1560 # @ingroup l2_construct
1561 def ClearSubMesh(self, geomId):
1562 self.mesh.ClearSubMesh(geomId)
1563 if salome.sg.hasDesktop():
1564 smeshgui = salome.ImportComponentGUI("SMESH")
1565 smeshgui.Init(self.mesh.GetStudyId())
1566 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1567 salome.sg.updateObjBrowser(1)
1569 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1570 # @param fineness [0,-1] defines mesh fineness
1571 # @return True or False
1572 # @ingroup l3_algos_basic
1573 def AutomaticTetrahedralization(self, fineness=0):
1574 dim = self.MeshDimension()
1576 self.RemoveGlobalHypotheses()
1577 self.Segment().AutomaticLength(fineness)
1579 self.Triangle().LengthFromEdges()
1582 self.Tetrahedron(NETGEN)
1584 return self.Compute()
1586 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1587 # @param fineness [0,-1] defines mesh fineness
1588 # @return True or False
1589 # @ingroup l3_algos_basic
1590 def AutomaticHexahedralization(self, fineness=0):
1591 dim = self.MeshDimension()
1592 # assign the hypotheses
1593 self.RemoveGlobalHypotheses()
1594 self.Segment().AutomaticLength(fineness)
1601 return self.Compute()
1603 ## Assigns a hypothesis
1604 # @param hyp a hypothesis to assign
1605 # @param geom a subhape of mesh geometry
1606 # @return SMESH.Hypothesis_Status
1607 # @ingroup l2_hypotheses
1608 def AddHypothesis(self, hyp, geom=0):
1609 if isinstance( hyp, Mesh_Algorithm ):
1610 hyp = hyp.GetAlgorithm()
1615 geom = self.mesh.GetShapeToMesh()
1617 status = self.mesh.AddHypothesis(geom, hyp)
1618 isAlgo = hyp._narrow( SMESH_Algo )
1619 hyp_name = GetName( hyp )
1622 geom_name = GetName( geom )
1623 TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1626 ## Unassigns a hypothesis
1627 # @param hyp a hypothesis to unassign
1628 # @param geom a subshape of mesh geometry
1629 # @return SMESH.Hypothesis_Status
1630 # @ingroup l2_hypotheses
1631 def RemoveHypothesis(self, hyp, geom=0):
1632 if isinstance( hyp, Mesh_Algorithm ):
1633 hyp = hyp.GetAlgorithm()
1638 status = self.mesh.RemoveHypothesis(geom, hyp)
1641 ## Gets the list of hypotheses added on a geometry
1642 # @param geom a subshape of mesh geometry
1643 # @return the sequence of SMESH_Hypothesis
1644 # @ingroup l2_hypotheses
1645 def GetHypothesisList(self, geom):
1646 return self.mesh.GetHypothesisList( geom )
1648 ## Removes all global hypotheses
1649 # @ingroup l2_hypotheses
1650 def RemoveGlobalHypotheses(self):
1651 current_hyps = self.mesh.GetHypothesisList( self.geom )
1652 for hyp in current_hyps:
1653 self.mesh.RemoveHypothesis( self.geom, hyp )
1657 ## Creates a mesh group based on the geometric object \a grp
1658 # and gives a \a name, \n if this parameter is not defined
1659 # the name is the same as the geometric group name \n
1660 # Note: Works like GroupOnGeom().
1661 # @param grp a geometric group, a vertex, an edge, a face or a solid
1662 # @param name the name of the mesh group
1663 # @return SMESH_GroupOnGeom
1664 # @ingroup l2_grps_create
1665 def Group(self, grp, name=""):
1666 return self.GroupOnGeom(grp, name)
1668 ## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead.
1669 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1670 ## allowing to overwrite the file if it exists or add the exported data to its contents
1671 # @param f the file name
1672 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1673 # @param opt boolean parameter for creating/not creating
1674 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1675 # @param overwrite boolean parameter for overwriting/not overwriting the file
1676 # @ingroup l2_impexp
1677 def ExportToMED(self, f, version, opt=0, overwrite=1):
1678 self.mesh.ExportToMEDX(f, opt, version, overwrite)
1680 ## Exports the mesh in a file in MED format and chooses the \a version of MED format
1681 ## allowing to overwrite the file if it exists or add the exported data to its contents
1682 # @param f is the file name
1683 # @param auto_groups boolean parameter for creating/not creating
1684 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1685 # the typical use is auto_groups=false.
1686 # @param version MED format version(MED_V2_1 or MED_V2_2)
1687 # @param overwrite boolean parameter for overwriting/not overwriting the file
1688 # @ingroup l2_impexp
1689 def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1):
1690 self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
1692 ## Exports the mesh in a file in DAT format
1693 # @param f the file name
1694 # @ingroup l2_impexp
1695 def ExportDAT(self, f):
1696 self.mesh.ExportDAT(f)
1698 ## Exports the mesh in a file in UNV format
1699 # @param f the file name
1700 # @ingroup l2_impexp
1701 def ExportUNV(self, f):
1702 self.mesh.ExportUNV(f)
1704 ## Export the mesh in a file in STL format
1705 # @param f the file name
1706 # @param ascii defines the file encoding
1707 # @ingroup l2_impexp
1708 def ExportSTL(self, f, ascii=1):
1709 self.mesh.ExportSTL(f, ascii)
1712 # Operations with groups:
1713 # ----------------------
1715 ## Creates an empty mesh group
1716 # @param elementType the type of elements in the group
1717 # @param name the name of the mesh group
1718 # @return SMESH_Group
1719 # @ingroup l2_grps_create
1720 def CreateEmptyGroup(self, elementType, name):
1721 return self.mesh.CreateGroup(elementType, name)
1723 ## Creates a mesh group based on the geometrical object \a grp
1724 # and gives a \a name, \n if this parameter is not defined
1725 # the name is the same as the geometrical group name
1726 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1727 # @param name the name of the mesh group
1728 # @param typ the type of elements in the group. If not set, it is
1729 # automatically detected by the type of the geometry
1730 # @return SMESH_GroupOnGeom
1731 # @ingroup l2_grps_create
1732 def GroupOnGeom(self, grp, name="", typ=None):
1734 name = grp.GetName()
1737 tgeo = str(grp.GetShapeType())
1738 if tgeo == "VERTEX":
1740 elif tgeo == "EDGE":
1742 elif tgeo == "FACE":
1744 elif tgeo == "SOLID":
1746 elif tgeo == "SHELL":
1748 elif tgeo == "COMPOUND":
1749 try: # it raises on a compound of compounds
1750 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1751 print "Mesh.Group: empty geometric group", GetName( grp )
1756 if grp.GetType() == 37: # GEOMImpl_Types.hxx: #define GEOM_GROUP 37
1758 tgeo = self.geompyD.GetType(grp)
1759 if tgeo == geompyDC.ShapeType["VERTEX"]:
1761 elif tgeo == geompyDC.ShapeType["EDGE"]:
1763 elif tgeo == geompyDC.ShapeType["FACE"]:
1765 elif tgeo == geompyDC.ShapeType["SOLID"]:
1771 for elemType, shapeType in [[VOLUME,"SOLID"],[FACE,"FACE"],
1772 [EDGE,"EDGE"],[NODE,"VERTEX"]]:
1773 if self.geompyD.SubShapeAll(grp,geompyDC.ShapeType[shapeType]):
1781 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1784 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1786 ## Creates a mesh group by the given ids of elements
1787 # @param groupName the name of the mesh group
1788 # @param elementType the type of elements in the group
1789 # @param elemIDs the list of ids
1790 # @return SMESH_Group
1791 # @ingroup l2_grps_create
1792 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1793 group = self.mesh.CreateGroup(elementType, groupName)
1797 ## Creates a mesh group by the given conditions
1798 # @param groupName the name of the mesh group
1799 # @param elementType the type of elements in the group
1800 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1801 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1802 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1803 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1804 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
1805 # FT_LyingOnGeom, FT_CoplanarFaces criteria
1806 # @return SMESH_Group
1807 # @ingroup l2_grps_create
1811 CritType=FT_Undefined,
1814 UnaryOp=FT_Undefined,
1816 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined,Tolerance)
1817 group = self.MakeGroupByCriterion(groupName, aCriterion)
1820 ## Creates a mesh group by the given criterion
1821 # @param groupName the name of the mesh group
1822 # @param Criterion the instance of Criterion class
1823 # @return SMESH_Group
1824 # @ingroup l2_grps_create
1825 def MakeGroupByCriterion(self, groupName, Criterion):
1826 aFilterMgr = self.smeshpyD.CreateFilterManager()
1827 aFilter = aFilterMgr.CreateFilter()
1829 aCriteria.append(Criterion)
1830 aFilter.SetCriteria(aCriteria)
1831 group = self.MakeGroupByFilter(groupName, aFilter)
1832 aFilterMgr.UnRegister()
1835 ## Creates a mesh group by the given criteria (list of criteria)
1836 # @param groupName the name of the mesh group
1837 # @param theCriteria the list of criteria
1838 # @return SMESH_Group
1839 # @ingroup l2_grps_create
1840 def MakeGroupByCriteria(self, groupName, theCriteria):
1841 aFilterMgr = self.smeshpyD.CreateFilterManager()
1842 aFilter = aFilterMgr.CreateFilter()
1843 aFilter.SetCriteria(theCriteria)
1844 group = self.MakeGroupByFilter(groupName, aFilter)
1845 aFilterMgr.UnRegister()
1848 ## Creates a mesh group by the given filter
1849 # @param groupName the name of the mesh group
1850 # @param theFilter the instance of Filter class
1851 # @return SMESH_Group
1852 # @ingroup l2_grps_create
1853 def MakeGroupByFilter(self, groupName, theFilter):
1854 group = self.CreateEmptyGroup(theFilter.GetElementType(), groupName)
1855 theFilter.SetMesh( self.mesh )
1856 group.AddFrom( theFilter )
1859 ## Passes mesh elements through the given filter and return IDs of fitting elements
1860 # @param theFilter SMESH_Filter
1861 # @return a list of ids
1862 # @ingroup l1_controls
1863 def GetIdsFromFilter(self, theFilter):
1864 theFilter.SetMesh( self.mesh )
1865 return theFilter.GetIDs()
1867 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1868 # Returns a list of special structures (borders).
1869 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1870 # @ingroup l1_controls
1871 def GetFreeBorders(self):
1872 aFilterMgr = self.smeshpyD.CreateFilterManager()
1873 aPredicate = aFilterMgr.CreateFreeEdges()
1874 aPredicate.SetMesh(self.mesh)
1875 aBorders = aPredicate.GetBorders()
1876 aFilterMgr.UnRegister()
1880 # @ingroup l2_grps_delete
1881 def RemoveGroup(self, group):
1882 self.mesh.RemoveGroup(group)
1884 ## Removes a group with its contents
1885 # @ingroup l2_grps_delete
1886 def RemoveGroupWithContents(self, group):
1887 self.mesh.RemoveGroupWithContents(group)
1889 ## Gets the list of groups existing in the mesh
1890 # @return a sequence of SMESH_GroupBase
1891 # @ingroup l2_grps_create
1892 def GetGroups(self):
1893 return self.mesh.GetGroups()
1895 ## Gets the number of groups existing in the mesh
1896 # @return the quantity of groups as an integer value
1897 # @ingroup l2_grps_create
1899 return self.mesh.NbGroups()
1901 ## Gets the list of names of groups existing in the mesh
1902 # @return list of strings
1903 # @ingroup l2_grps_create
1904 def GetGroupNames(self):
1905 groups = self.GetGroups()
1907 for group in groups:
1908 names.append(group.GetName())
1911 ## Produces a union of two groups
1912 # A new group is created. All mesh elements that are
1913 # present in the initial groups are added to the new one
1914 # @return an instance of SMESH_Group
1915 # @ingroup l2_grps_operon
1916 def UnionGroups(self, group1, group2, name):
1917 return self.mesh.UnionGroups(group1, group2, name)
1919 ## Produces a union list of groups
1920 # New group is created. All mesh elements that are present in
1921 # initial groups are added to the new one
1922 # @return an instance of SMESH_Group
1923 # @ingroup l2_grps_operon
1924 def UnionListOfGroups(self, groups, name):
1925 return self.mesh.UnionListOfGroups(groups, name)
1927 ## Prodices an intersection of two groups
1928 # A new group is created. All mesh elements that are common
1929 # for the two initial groups are added to the new one.
1930 # @return an instance of SMESH_Group
1931 # @ingroup l2_grps_operon
1932 def IntersectGroups(self, group1, group2, name):
1933 return self.mesh.IntersectGroups(group1, group2, name)
1935 ## Produces an intersection of groups
1936 # New group is created. All mesh elements that are present in all
1937 # initial groups simultaneously are added to the new one
1938 # @return an instance of SMESH_Group
1939 # @ingroup l2_grps_operon
1940 def IntersectListOfGroups(self, groups, name):
1941 return self.mesh.IntersectListOfGroups(groups, name)
1943 ## Produces a cut of two groups
1944 # A new group is created. All mesh elements that are present in
1945 # the main group but are not present in the tool group are added to the new one
1946 # @return an instance of SMESH_Group
1947 # @ingroup l2_grps_operon
1948 def CutGroups(self, main_group, tool_group, name):
1949 return self.mesh.CutGroups(main_group, tool_group, name)
1951 ## Produces a cut of groups
1952 # A new group is created. All mesh elements that are present in main groups
1953 # but do not present in tool groups are added to the new one
1954 # @return an instance of SMESH_Group
1955 # @ingroup l2_grps_operon
1956 def CutListOfGroups(self, main_groups, tool_groups, name):
1957 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1959 ## Produces a group of elements of specified type using list of existing groups
1960 # A new group is created. System
1961 # 1) extracts all nodes on which groups elements are built
1962 # 2) combines all elements of specified dimension laying on these nodes
1963 # @return an instance of SMESH_Group
1964 # @ingroup l2_grps_operon
1965 def CreateDimGroup(self, groups, elem_type, name):
1966 return self.mesh.CreateDimGroup(groups, elem_type, name)
1969 ## Convert group on geom into standalone group
1970 # @ingroup l2_grps_delete
1971 def ConvertToStandalone(self, group):
1972 return self.mesh.ConvertToStandalone(group)
1974 # Get some info about mesh:
1975 # ------------------------
1977 ## Returns the log of nodes and elements added or removed
1978 # since the previous clear of the log.
1979 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1980 # @return list of log_block structures:
1985 # @ingroup l1_auxiliary
1986 def GetLog(self, clearAfterGet):
1987 return self.mesh.GetLog(clearAfterGet)
1989 ## Clears the log of nodes and elements added or removed since the previous
1990 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1991 # @ingroup l1_auxiliary
1993 self.mesh.ClearLog()
1995 ## Toggles auto color mode on the object.
1996 # @param theAutoColor the flag which toggles auto color mode.
1997 # @ingroup l1_auxiliary
1998 def SetAutoColor(self, theAutoColor):
1999 self.mesh.SetAutoColor(theAutoColor)
2001 ## Gets flag of object auto color mode.
2002 # @return True or False
2003 # @ingroup l1_auxiliary
2004 def GetAutoColor(self):
2005 return self.mesh.GetAutoColor()
2007 ## Gets the internal ID
2008 # @return integer value, which is the internal Id of the mesh
2009 # @ingroup l1_auxiliary
2011 return self.mesh.GetId()
2014 # @return integer value, which is the study Id of the mesh
2015 # @ingroup l1_auxiliary
2016 def GetStudyId(self):
2017 return self.mesh.GetStudyId()
2019 ## Checks the group names for duplications.
2020 # Consider the maximum group name length stored in MED file.
2021 # @return True or False
2022 # @ingroup l1_auxiliary
2023 def HasDuplicatedGroupNamesMED(self):
2024 return self.mesh.HasDuplicatedGroupNamesMED()
2026 ## Obtains the mesh editor tool
2027 # @return an instance of SMESH_MeshEditor
2028 # @ingroup l1_modifying
2029 def GetMeshEditor(self):
2030 return self.mesh.GetMeshEditor()
2032 ## Wrap a list of IDs of elements or nodes into SMESH_IDSource which
2033 # can be passed as argument to accepting mesh, group or sub-mesh
2034 # @return an instance of SMESH_IDSource
2035 # @ingroup l1_auxiliary
2036 def GetIDSource(self, ids, elemType):
2037 return self.GetMeshEditor().MakeIDSource(ids, elemType)
2040 # @return an instance of SALOME_MED::MESH
2041 # @ingroup l1_auxiliary
2042 def GetMEDMesh(self):
2043 return self.mesh.GetMEDMesh()
2046 # Get informations about mesh contents:
2047 # ------------------------------------
2049 ## Gets the mesh stattistic
2050 # @return dictionary type element - count of elements
2051 # @ingroup l1_meshinfo
2052 def GetMeshInfo(self, obj = None):
2053 if not obj: obj = self.mesh
2054 return self.smeshpyD.GetMeshInfo(obj)
2056 ## Returns the number of nodes in the mesh
2057 # @return an integer value
2058 # @ingroup l1_meshinfo
2060 return self.mesh.NbNodes()
2062 ## Returns the number of elements in the mesh
2063 # @return an integer value
2064 # @ingroup l1_meshinfo
2065 def NbElements(self):
2066 return self.mesh.NbElements()
2068 ## Returns the number of 0d elements in the mesh
2069 # @return an integer value
2070 # @ingroup l1_meshinfo
2071 def Nb0DElements(self):
2072 return self.mesh.Nb0DElements()
2074 ## Returns the number of edges in the mesh
2075 # @return an integer value
2076 # @ingroup l1_meshinfo
2078 return self.mesh.NbEdges()
2080 ## Returns the number of edges with the given order in the mesh
2081 # @param elementOrder the order of elements:
2082 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2083 # @return an integer value
2084 # @ingroup l1_meshinfo
2085 def NbEdgesOfOrder(self, elementOrder):
2086 return self.mesh.NbEdgesOfOrder(elementOrder)
2088 ## Returns the number of faces in the mesh
2089 # @return an integer value
2090 # @ingroup l1_meshinfo
2092 return self.mesh.NbFaces()
2094 ## Returns the number of faces with the given order in the mesh
2095 # @param elementOrder the order of elements:
2096 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2097 # @return an integer value
2098 # @ingroup l1_meshinfo
2099 def NbFacesOfOrder(self, elementOrder):
2100 return self.mesh.NbFacesOfOrder(elementOrder)
2102 ## Returns the number of triangles in the mesh
2103 # @return an integer value
2104 # @ingroup l1_meshinfo
2105 def NbTriangles(self):
2106 return self.mesh.NbTriangles()
2108 ## Returns the number of triangles with the given order in the mesh
2109 # @param elementOrder is the order of elements:
2110 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2111 # @return an integer value
2112 # @ingroup l1_meshinfo
2113 def NbTrianglesOfOrder(self, elementOrder):
2114 return self.mesh.NbTrianglesOfOrder(elementOrder)
2116 ## Returns the number of quadrangles in the mesh
2117 # @return an integer value
2118 # @ingroup l1_meshinfo
2119 def NbQuadrangles(self):
2120 return self.mesh.NbQuadrangles()
2122 ## Returns the number of quadrangles with the given order in the mesh
2123 # @param elementOrder the order of elements:
2124 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2125 # @return an integer value
2126 # @ingroup l1_meshinfo
2127 def NbQuadranglesOfOrder(self, elementOrder):
2128 return self.mesh.NbQuadranglesOfOrder(elementOrder)
2130 ## Returns the number of polygons in the mesh
2131 # @return an integer value
2132 # @ingroup l1_meshinfo
2133 def NbPolygons(self):
2134 return self.mesh.NbPolygons()
2136 ## Returns the number of volumes in the mesh
2137 # @return an integer value
2138 # @ingroup l1_meshinfo
2139 def NbVolumes(self):
2140 return self.mesh.NbVolumes()
2142 ## Returns the number of volumes 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 NbVolumesOfOrder(self, elementOrder):
2148 return self.mesh.NbVolumesOfOrder(elementOrder)
2150 ## Returns the number of tetrahedrons in the mesh
2151 # @return an integer value
2152 # @ingroup l1_meshinfo
2154 return self.mesh.NbTetras()
2156 ## Returns the number of tetrahedrons with the given order in the mesh
2157 # @param elementOrder the order of elements:
2158 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2159 # @return an integer value
2160 # @ingroup l1_meshinfo
2161 def NbTetrasOfOrder(self, elementOrder):
2162 return self.mesh.NbTetrasOfOrder(elementOrder)
2164 ## Returns the number of hexahedrons in the mesh
2165 # @return an integer value
2166 # @ingroup l1_meshinfo
2168 return self.mesh.NbHexas()
2170 ## Returns the number of hexahedrons 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 NbHexasOfOrder(self, elementOrder):
2176 return self.mesh.NbHexasOfOrder(elementOrder)
2178 ## Returns the number of pyramids in the mesh
2179 # @return an integer value
2180 # @ingroup l1_meshinfo
2181 def NbPyramids(self):
2182 return self.mesh.NbPyramids()
2184 ## Returns the number of pyramids with the given order in the mesh
2185 # @param elementOrder the order of elements:
2186 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2187 # @return an integer value
2188 # @ingroup l1_meshinfo
2189 def NbPyramidsOfOrder(self, elementOrder):
2190 return self.mesh.NbPyramidsOfOrder(elementOrder)
2192 ## Returns the number of prisms in the mesh
2193 # @return an integer value
2194 # @ingroup l1_meshinfo
2196 return self.mesh.NbPrisms()
2198 ## Returns the number of prisms with the given order in the mesh
2199 # @param elementOrder the order of elements:
2200 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2201 # @return an integer value
2202 # @ingroup l1_meshinfo
2203 def NbPrismsOfOrder(self, elementOrder):
2204 return self.mesh.NbPrismsOfOrder(elementOrder)
2206 ## Returns the number of polyhedrons in the mesh
2207 # @return an integer value
2208 # @ingroup l1_meshinfo
2209 def NbPolyhedrons(self):
2210 return self.mesh.NbPolyhedrons()
2212 ## Returns the number of submeshes in the mesh
2213 # @return an integer value
2214 # @ingroup l1_meshinfo
2215 def NbSubMesh(self):
2216 return self.mesh.NbSubMesh()
2218 ## Returns the list of mesh elements IDs
2219 # @return the list of integer values
2220 # @ingroup l1_meshinfo
2221 def GetElementsId(self):
2222 return self.mesh.GetElementsId()
2224 ## Returns the list of IDs of mesh elements with the given type
2225 # @param elementType the required type of elements (SMESH.NODE, SMESH.EDGE, SMESH.FACE or SMESH.VOLUME)
2226 # @return list of integer values
2227 # @ingroup l1_meshinfo
2228 def GetElementsByType(self, elementType):
2229 return self.mesh.GetElementsByType(elementType)
2231 ## Returns the list of mesh nodes IDs
2232 # @return the list of integer values
2233 # @ingroup l1_meshinfo
2234 def GetNodesId(self):
2235 return self.mesh.GetNodesId()
2237 # Get the information about mesh elements:
2238 # ------------------------------------
2240 ## Returns the type of mesh element
2241 # @return the value from SMESH::ElementType enumeration
2242 # @ingroup l1_meshinfo
2243 def GetElementType(self, id, iselem):
2244 return self.mesh.GetElementType(id, iselem)
2246 ## Returns the geometric type of mesh element
2247 # @return the value from SMESH::EntityType enumeration
2248 # @ingroup l1_meshinfo
2249 def GetElementGeomType(self, id):
2250 return self.mesh.GetElementGeomType(id)
2252 ## Returns the list of submesh elements IDs
2253 # @param Shape a geom object(subshape) IOR
2254 # Shape must be the subshape of a ShapeToMesh()
2255 # @return the list of integer values
2256 # @ingroup l1_meshinfo
2257 def GetSubMeshElementsId(self, Shape):
2258 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2259 ShapeID = Shape.GetSubShapeIndices()[0]
2262 return self.mesh.GetSubMeshElementsId(ShapeID)
2264 ## Returns the list of submesh nodes IDs
2265 # @param Shape a geom object(subshape) IOR
2266 # Shape must be the subshape of a ShapeToMesh()
2267 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
2268 # @return the list of integer values
2269 # @ingroup l1_meshinfo
2270 def GetSubMeshNodesId(self, Shape, all):
2271 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2272 ShapeID = Shape.GetSubShapeIndices()[0]
2275 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2277 ## Returns type of elements on given shape
2278 # @param Shape a geom object(subshape) IOR
2279 # Shape must be a subshape of a ShapeToMesh()
2280 # @return element type
2281 # @ingroup l1_meshinfo
2282 def GetSubMeshElementType(self, Shape):
2283 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2284 ShapeID = Shape.GetSubShapeIndices()[0]
2287 return self.mesh.GetSubMeshElementType(ShapeID)
2289 ## Gets the mesh description
2290 # @return string value
2291 # @ingroup l1_meshinfo
2293 return self.mesh.Dump()
2296 # Get the information about nodes and elements of a mesh by its IDs:
2297 # -----------------------------------------------------------
2299 ## Gets XYZ coordinates of a node
2300 # \n If there is no nodes for the given ID - returns an empty list
2301 # @return a list of double precision values
2302 # @ingroup l1_meshinfo
2303 def GetNodeXYZ(self, id):
2304 return self.mesh.GetNodeXYZ(id)
2306 ## Returns list of IDs of inverse elements for the given node
2307 # \n If there is no node for the given ID - returns an empty list
2308 # @return a list of integer values
2309 # @ingroup l1_meshinfo
2310 def GetNodeInverseElements(self, id):
2311 return self.mesh.GetNodeInverseElements(id)
2313 ## @brief Returns the position of a node on the shape
2314 # @return SMESH::NodePosition
2315 # @ingroup l1_meshinfo
2316 def GetNodePosition(self,NodeID):
2317 return self.mesh.GetNodePosition(NodeID)
2319 ## If the given element is a node, returns the ID of shape
2320 # \n If there is no node for the given ID - returns -1
2321 # @return an integer value
2322 # @ingroup l1_meshinfo
2323 def GetShapeID(self, id):
2324 return self.mesh.GetShapeID(id)
2326 ## Returns the ID of the result shape after
2327 # FindShape() from SMESH_MeshEditor for the given element
2328 # \n If there is no element for the given ID - returns -1
2329 # @return an integer value
2330 # @ingroup l1_meshinfo
2331 def GetShapeIDForElem(self,id):
2332 return self.mesh.GetShapeIDForElem(id)
2334 ## Returns the number of nodes for the given element
2335 # \n If there is no element for the given ID - returns -1
2336 # @return an integer value
2337 # @ingroup l1_meshinfo
2338 def GetElemNbNodes(self, id):
2339 return self.mesh.GetElemNbNodes(id)
2341 ## Returns the node ID the given index for the given element
2342 # \n If there is no element for the given ID - returns -1
2343 # \n If there is no node for the given index - returns -2
2344 # @return an integer value
2345 # @ingroup l1_meshinfo
2346 def GetElemNode(self, id, index):
2347 return self.mesh.GetElemNode(id, index)
2349 ## Returns the IDs of nodes of the given element
2350 # @return a list of integer values
2351 # @ingroup l1_meshinfo
2352 def GetElemNodes(self, id):
2353 return self.mesh.GetElemNodes(id)
2355 ## Returns true if the given node is the medium node in the given quadratic element
2356 # @ingroup l1_meshinfo
2357 def IsMediumNode(self, elementID, nodeID):
2358 return self.mesh.IsMediumNode(elementID, nodeID)
2360 ## Returns true if the given node is the medium node in one of quadratic elements
2361 # @ingroup l1_meshinfo
2362 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2363 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2365 ## Returns the number of edges for the given element
2366 # @ingroup l1_meshinfo
2367 def ElemNbEdges(self, id):
2368 return self.mesh.ElemNbEdges(id)
2370 ## Returns the number of faces for the given element
2371 # @ingroup l1_meshinfo
2372 def ElemNbFaces(self, id):
2373 return self.mesh.ElemNbFaces(id)
2375 ## Returns nodes of given face (counted from zero) for given volumic element.
2376 # @ingroup l1_meshinfo
2377 def GetElemFaceNodes(self,elemId, faceIndex):
2378 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2380 ## Returns an element based on all given nodes.
2381 # @ingroup l1_meshinfo
2382 def FindElementByNodes(self,nodes):
2383 return self.mesh.FindElementByNodes(nodes)
2385 ## Returns true if the given element is a polygon
2386 # @ingroup l1_meshinfo
2387 def IsPoly(self, id):
2388 return self.mesh.IsPoly(id)
2390 ## Returns true if the given element is quadratic
2391 # @ingroup l1_meshinfo
2392 def IsQuadratic(self, id):
2393 return self.mesh.IsQuadratic(id)
2395 ## Returns XYZ coordinates of the barycenter of the given element
2396 # \n If there is no element for the given ID - returns an empty list
2397 # @return a list of three double values
2398 # @ingroup l1_meshinfo
2399 def BaryCenter(self, id):
2400 return self.mesh.BaryCenter(id)
2403 # Get mesh measurements information:
2404 # ------------------------------------
2406 ## Get minimum distance between two nodes, elements or distance to the origin
2407 # @param id1 first node/element id
2408 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2409 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2410 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2411 # @return minimum distance value
2412 # @sa GetMinDistance()
2413 def MinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2414 aMeasure = self.GetMinDistance(id1, id2, isElem1, isElem2)
2415 return aMeasure.value
2417 ## Get measure structure specifying minimum distance data between two objects
2418 # @param id1 first node/element id
2419 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2420 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2421 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2422 # @return Measure structure
2424 def GetMinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2426 id1 = self.editor.MakeIDSource([id1], SMESH.FACE)
2428 id1 = self.editor.MakeIDSource([id1], SMESH.NODE)
2431 id2 = self.editor.MakeIDSource([id2], SMESH.FACE)
2433 id2 = self.editor.MakeIDSource([id2], SMESH.NODE)
2438 aMeasurements = self.smeshpyD.CreateMeasurements()
2439 aMeasure = aMeasurements.MinDistance(id1, id2)
2440 aMeasurements.UnRegister()
2443 ## Get bounding box of the specified object(s)
2444 # @param objects single source object or list of source objects or list of nodes/elements IDs
2445 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2446 # @c False specifies that @a objects are nodes
2447 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
2448 # @sa GetBoundingBox()
2449 def BoundingBox(self, objects=None, isElem=False):
2450 result = self.GetBoundingBox(objects, isElem)
2454 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
2457 ## Get measure structure specifying bounding box data of the specified object(s)
2458 # @param objects single source object or list of source objects or list of nodes/elements IDs
2459 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2460 # @c False specifies that @a objects are nodes
2461 # @return Measure structure
2463 def GetBoundingBox(self, IDs=None, isElem=False):
2466 elif isinstance(IDs, tuple):
2468 if not isinstance(IDs, list):
2470 if len(IDs) > 0 and isinstance(IDs[0], int):
2474 if isinstance(o, Mesh):
2475 srclist.append(o.mesh)
2476 elif hasattr(o, "_narrow"):
2477 src = o._narrow(SMESH.SMESH_IDSource)
2478 if src: srclist.append(src)
2480 elif isinstance(o, list):
2482 srclist.append(self.editor.MakeIDSource(o, SMESH.FACE))
2484 srclist.append(self.editor.MakeIDSource(o, SMESH.NODE))
2487 aMeasurements = self.smeshpyD.CreateMeasurements()
2488 aMeasure = aMeasurements.BoundingBox(srclist)
2489 aMeasurements.UnRegister()
2492 # Mesh edition (SMESH_MeshEditor functionality):
2493 # ---------------------------------------------
2495 ## Removes the elements from the mesh by ids
2496 # @param IDsOfElements is a list of ids of elements to remove
2497 # @return True or False
2498 # @ingroup l2_modif_del
2499 def RemoveElements(self, IDsOfElements):
2500 return self.editor.RemoveElements(IDsOfElements)
2502 ## Removes nodes from mesh by ids
2503 # @param IDsOfNodes is a list of ids of nodes to remove
2504 # @return True or False
2505 # @ingroup l2_modif_del
2506 def RemoveNodes(self, IDsOfNodes):
2507 return self.editor.RemoveNodes(IDsOfNodes)
2509 ## Removes all orphan (free) nodes from mesh
2510 # @return number of the removed nodes
2511 # @ingroup l2_modif_del
2512 def RemoveOrphanNodes(self):
2513 return self.editor.RemoveOrphanNodes()
2515 ## Add a node to the mesh by coordinates
2516 # @return Id of the new node
2517 # @ingroup l2_modif_add
2518 def AddNode(self, x, y, z):
2519 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2520 self.mesh.SetParameters(Parameters)
2521 return self.editor.AddNode( x, y, z)
2523 ## Creates a 0D element on a node with given number.
2524 # @param IDOfNode the ID of node for creation of the element.
2525 # @return the Id of the new 0D element
2526 # @ingroup l2_modif_add
2527 def Add0DElement(self, IDOfNode):
2528 return self.editor.Add0DElement(IDOfNode)
2530 ## Creates a linear or quadratic edge (this is determined
2531 # by the number of given nodes).
2532 # @param IDsOfNodes the list of node IDs for creation of the element.
2533 # The order of nodes in this list should correspond to the description
2534 # of MED. \n This description is located by the following link:
2535 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2536 # @return the Id of the new edge
2537 # @ingroup l2_modif_add
2538 def AddEdge(self, IDsOfNodes):
2539 return self.editor.AddEdge(IDsOfNodes)
2541 ## Creates a linear or quadratic face (this is determined
2542 # by the number of given nodes).
2543 # @param IDsOfNodes the list of node IDs for creation of the element.
2544 # The order of nodes in this list should correspond to the description
2545 # of MED. \n This description is located by the following link:
2546 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2547 # @return the Id of the new face
2548 # @ingroup l2_modif_add
2549 def AddFace(self, IDsOfNodes):
2550 return self.editor.AddFace(IDsOfNodes)
2552 ## Adds a polygonal face to the mesh by the list of node IDs
2553 # @param IdsOfNodes the list of node IDs for creation of the element.
2554 # @return the Id of the new face
2555 # @ingroup l2_modif_add
2556 def AddPolygonalFace(self, IdsOfNodes):
2557 return self.editor.AddPolygonalFace(IdsOfNodes)
2559 ## Creates both simple and quadratic volume (this is determined
2560 # by the number of given nodes).
2561 # @param IDsOfNodes the list of node IDs for creation of the element.
2562 # The order of nodes in this list should correspond to the description
2563 # of MED. \n This description is located by the following link:
2564 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2565 # @return the Id of the new volumic element
2566 # @ingroup l2_modif_add
2567 def AddVolume(self, IDsOfNodes):
2568 return self.editor.AddVolume(IDsOfNodes)
2570 ## Creates a volume of many faces, giving nodes for each face.
2571 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2572 # @param Quantities the list of integer values, Quantities[i]
2573 # gives the quantity of nodes in face number i.
2574 # @return the Id of the new volumic element
2575 # @ingroup l2_modif_add
2576 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2577 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2579 ## Creates a volume of many faces, giving the IDs of the existing faces.
2580 # @param IdsOfFaces the list of face IDs for volume creation.
2582 # Note: The created volume will refer only to the nodes
2583 # of the given faces, not to the faces themselves.
2584 # @return the Id of the new volumic element
2585 # @ingroup l2_modif_add
2586 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2587 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2590 ## @brief Binds a node to a vertex
2591 # @param NodeID a node ID
2592 # @param Vertex a vertex or vertex ID
2593 # @return True if succeed else raises an exception
2594 # @ingroup l2_modif_add
2595 def SetNodeOnVertex(self, NodeID, Vertex):
2596 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2597 VertexID = Vertex.GetSubShapeIndices()[0]
2601 self.editor.SetNodeOnVertex(NodeID, VertexID)
2602 except SALOME.SALOME_Exception, inst:
2603 raise ValueError, inst.details.text
2607 ## @brief Stores the node position on an edge
2608 # @param NodeID a node ID
2609 # @param Edge an edge or edge ID
2610 # @param paramOnEdge a parameter on the edge where the node is located
2611 # @return True if succeed else raises an exception
2612 # @ingroup l2_modif_add
2613 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2614 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2615 EdgeID = Edge.GetSubShapeIndices()[0]
2619 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2620 except SALOME.SALOME_Exception, inst:
2621 raise ValueError, inst.details.text
2624 ## @brief Stores node position on a face
2625 # @param NodeID a node ID
2626 # @param Face a face or face ID
2627 # @param u U parameter on the face where the node is located
2628 # @param v V parameter on the face where the node is located
2629 # @return True if succeed else raises an exception
2630 # @ingroup l2_modif_add
2631 def SetNodeOnFace(self, NodeID, Face, u, v):
2632 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2633 FaceID = Face.GetSubShapeIndices()[0]
2637 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2638 except SALOME.SALOME_Exception, inst:
2639 raise ValueError, inst.details.text
2642 ## @brief Binds a node to a solid
2643 # @param NodeID a node ID
2644 # @param Solid a solid or solid ID
2645 # @return True if succeed else raises an exception
2646 # @ingroup l2_modif_add
2647 def SetNodeInVolume(self, NodeID, Solid):
2648 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2649 SolidID = Solid.GetSubShapeIndices()[0]
2653 self.editor.SetNodeInVolume(NodeID, SolidID)
2654 except SALOME.SALOME_Exception, inst:
2655 raise ValueError, inst.details.text
2658 ## @brief Bind an element to a shape
2659 # @param ElementID an element ID
2660 # @param Shape a shape or shape ID
2661 # @return True if succeed else raises an exception
2662 # @ingroup l2_modif_add
2663 def SetMeshElementOnShape(self, ElementID, Shape):
2664 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2665 ShapeID = Shape.GetSubShapeIndices()[0]
2669 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2670 except SALOME.SALOME_Exception, inst:
2671 raise ValueError, inst.details.text
2675 ## Moves the node with the given id
2676 # @param NodeID the id of the node
2677 # @param x a new X coordinate
2678 # @param y a new Y coordinate
2679 # @param z a new Z coordinate
2680 # @return True if succeed else False
2681 # @ingroup l2_modif_movenode
2682 def MoveNode(self, NodeID, x, y, z):
2683 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2684 self.mesh.SetParameters(Parameters)
2685 return self.editor.MoveNode(NodeID, x, y, z)
2687 ## Finds the node closest to a point and moves it to a point location
2688 # @param x the X coordinate of a point
2689 # @param y the Y coordinate of a point
2690 # @param z the Z coordinate of a point
2691 # @param NodeID if specified (>0), the node with this ID is moved,
2692 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2693 # @return the ID of a node
2694 # @ingroup l2_modif_throughp
2695 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2696 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2697 self.mesh.SetParameters(Parameters)
2698 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2700 ## Finds the node closest to a point
2701 # @param x the X coordinate of a point
2702 # @param y the Y coordinate of a point
2703 # @param z the Z coordinate of a point
2704 # @return the ID of a node
2705 # @ingroup l2_modif_throughp
2706 def FindNodeClosestTo(self, x, y, z):
2707 #preview = self.mesh.GetMeshEditPreviewer()
2708 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2709 return self.editor.FindNodeClosestTo(x, y, z)
2711 ## Finds the elements where a point lays IN or ON
2712 # @param x the X coordinate of a point
2713 # @param y the Y coordinate of a point
2714 # @param z the Z coordinate of a point
2715 # @param elementType type of elements to find (SMESH.ALL type
2716 # means elements of any type excluding nodes and 0D elements)
2717 # @return list of IDs of found elements
2718 # @ingroup l2_modif_throughp
2719 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2720 return self.editor.FindElementsByPoint(x, y, z, elementType)
2722 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2723 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2725 def GetPointState(self, x, y, z):
2726 return self.editor.GetPointState(x, y, z)
2728 ## Finds the node closest to a point and moves it to a point location
2729 # @param x the X coordinate of a point
2730 # @param y the Y coordinate of a point
2731 # @param z the Z coordinate of a point
2732 # @return the ID of a moved node
2733 # @ingroup l2_modif_throughp
2734 def MeshToPassThroughAPoint(self, x, y, z):
2735 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2737 ## Replaces two neighbour triangles sharing Node1-Node2 link
2738 # with the triangles built on the same 4 nodes but having other common link.
2739 # @param NodeID1 the ID of the first node
2740 # @param NodeID2 the ID of the second node
2741 # @return false if proper faces were not found
2742 # @ingroup l2_modif_invdiag
2743 def InverseDiag(self, NodeID1, NodeID2):
2744 return self.editor.InverseDiag(NodeID1, NodeID2)
2746 ## Replaces two neighbour triangles sharing Node1-Node2 link
2747 # with a quadrangle built on the same 4 nodes.
2748 # @param NodeID1 the ID of the first node
2749 # @param NodeID2 the ID of the second node
2750 # @return false if proper faces were not found
2751 # @ingroup l2_modif_unitetri
2752 def DeleteDiag(self, NodeID1, NodeID2):
2753 return self.editor.DeleteDiag(NodeID1, NodeID2)
2755 ## Reorients elements by ids
2756 # @param IDsOfElements if undefined reorients all mesh elements
2757 # @return True if succeed else False
2758 # @ingroup l2_modif_changori
2759 def Reorient(self, IDsOfElements=None):
2760 if IDsOfElements == None:
2761 IDsOfElements = self.GetElementsId()
2762 return self.editor.Reorient(IDsOfElements)
2764 ## Reorients all elements of the object
2765 # @param theObject mesh, submesh or group
2766 # @return True if succeed else False
2767 # @ingroup l2_modif_changori
2768 def ReorientObject(self, theObject):
2769 if ( isinstance( theObject, Mesh )):
2770 theObject = theObject.GetMesh()
2771 return self.editor.ReorientObject(theObject)
2773 ## Fuses the neighbouring triangles into quadrangles.
2774 # @param IDsOfElements The triangles to be fused,
2775 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2776 # @param MaxAngle is the maximum angle between element normals at which the fusion
2777 # is still performed; theMaxAngle is mesured in radians.
2778 # Also it could be a name of variable which defines angle in degrees.
2779 # @return TRUE in case of success, FALSE otherwise.
2780 # @ingroup l2_modif_unitetri
2781 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2783 if isinstance(MaxAngle,str):
2785 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2787 MaxAngle = DegreesToRadians(MaxAngle)
2788 if IDsOfElements == []:
2789 IDsOfElements = self.GetElementsId()
2790 self.mesh.SetParameters(Parameters)
2792 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2793 Functor = theCriterion
2795 Functor = self.smeshpyD.GetFunctor(theCriterion)
2796 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2798 ## Fuses the neighbouring triangles of the object into quadrangles
2799 # @param theObject is mesh, submesh or group
2800 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2801 # @param MaxAngle a max angle between element normals at which the fusion
2802 # is still performed; theMaxAngle is mesured in radians.
2803 # @return TRUE in case of success, FALSE otherwise.
2804 # @ingroup l2_modif_unitetri
2805 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2806 if ( isinstance( theObject, Mesh )):
2807 theObject = theObject.GetMesh()
2808 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2810 ## Splits quadrangles into triangles.
2811 # @param IDsOfElements the faces to be splitted.
2812 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2813 # @return TRUE in case of success, FALSE otherwise.
2814 # @ingroup l2_modif_cutquadr
2815 def QuadToTri (self, IDsOfElements, theCriterion):
2816 if IDsOfElements == []:
2817 IDsOfElements = self.GetElementsId()
2818 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2820 ## Splits quadrangles into triangles.
2821 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2822 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2823 # @return TRUE in case of success, FALSE otherwise.
2824 # @ingroup l2_modif_cutquadr
2825 def QuadToTriObject (self, theObject, theCriterion):
2826 if ( isinstance( theObject, Mesh )):
2827 theObject = theObject.GetMesh()
2828 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2830 ## Splits quadrangles into triangles.
2831 # @param IDsOfElements the faces to be splitted
2832 # @param Diag13 is used to choose a diagonal for splitting.
2833 # @return TRUE in case of success, FALSE otherwise.
2834 # @ingroup l2_modif_cutquadr
2835 def SplitQuad (self, IDsOfElements, Diag13):
2836 if IDsOfElements == []:
2837 IDsOfElements = self.GetElementsId()
2838 return self.editor.SplitQuad(IDsOfElements, Diag13)
2840 ## Splits quadrangles into triangles.
2841 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2842 # @param Diag13 is used to choose a diagonal for splitting.
2843 # @return TRUE in case of success, FALSE otherwise.
2844 # @ingroup l2_modif_cutquadr
2845 def SplitQuadObject (self, theObject, Diag13):
2846 if ( isinstance( theObject, Mesh )):
2847 theObject = theObject.GetMesh()
2848 return self.editor.SplitQuadObject(theObject, Diag13)
2850 ## Finds a better splitting of the given quadrangle.
2851 # @param IDOfQuad the ID of the quadrangle to be splitted.
2852 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2853 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2854 # diagonal is better, 0 if error occurs.
2855 # @ingroup l2_modif_cutquadr
2856 def BestSplit (self, IDOfQuad, theCriterion):
2857 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2859 ## Splits volumic elements into tetrahedrons
2860 # @param elemIDs either list of elements or mesh or group or submesh
2861 # @param method flags passing splitting method: Hex_5Tet, Hex_6Tet, Hex_24Tet
2862 # Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc
2863 # @ingroup l2_modif_cutquadr
2864 def SplitVolumesIntoTetra(self, elemIDs, method=Hex_5Tet ):
2865 if isinstance( elemIDs, Mesh ):
2866 elemIDs = elemIDs.GetMesh()
2867 if ( isinstance( elemIDs, list )):
2868 elemIDs = self.editor.MakeIDSource(elemIDs, SMESH.VOLUME)
2869 self.editor.SplitVolumesIntoTetra(elemIDs, method)
2871 ## Splits quadrangle faces near triangular facets of volumes
2873 # @ingroup l1_auxiliary
2874 def SplitQuadsNearTriangularFacets(self):
2875 faces_array = self.GetElementsByType(SMESH.FACE)
2876 for face_id in faces_array:
2877 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2878 quad_nodes = self.mesh.GetElemNodes(face_id)
2879 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2880 isVolumeFound = False
2881 for node1_elem in node1_elems:
2882 if not isVolumeFound:
2883 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2884 nb_nodes = self.GetElemNbNodes(node1_elem)
2885 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2886 volume_elem = node1_elem
2887 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2888 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2889 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2890 isVolumeFound = True
2891 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2892 self.SplitQuad([face_id], False) # diagonal 2-4
2893 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2894 isVolumeFound = True
2895 self.SplitQuad([face_id], True) # diagonal 1-3
2896 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2897 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2898 isVolumeFound = True
2899 self.SplitQuad([face_id], True) # diagonal 1-3
2901 ## @brief Splits hexahedrons into tetrahedrons.
2903 # This operation uses pattern mapping functionality for splitting.
2904 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2905 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2906 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2907 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2908 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2909 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2910 # @return TRUE in case of success, FALSE otherwise.
2911 # @ingroup l1_auxiliary
2912 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2913 # Pattern: 5.---------.6
2918 # (0,0,1) 4.---------.7 * |
2925 # (0,0,0) 0.---------.3
2926 pattern_tetra = "!!! Nb of points: \n 8 \n\
2936 !!! Indices of points of 6 tetras: \n\
2944 pattern = self.smeshpyD.GetPattern()
2945 isDone = pattern.LoadFromFile(pattern_tetra)
2947 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2950 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2951 isDone = pattern.MakeMesh(self.mesh, False, False)
2952 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2954 # split quafrangle faces near triangular facets of volumes
2955 self.SplitQuadsNearTriangularFacets()
2959 ## @brief Split hexahedrons into prisms.
2961 # Uses the pattern mapping functionality for splitting.
2962 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2963 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2964 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2965 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2966 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2967 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2968 # @return TRUE in case of success, FALSE otherwise.
2969 # @ingroup l1_auxiliary
2970 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2971 # Pattern: 5.---------.6
2976 # (0,0,1) 4.---------.7 |
2983 # (0,0,0) 0.---------.3
2984 pattern_prism = "!!! Nb of points: \n 8 \n\
2994 !!! Indices of points of 2 prisms: \n\
2998 pattern = self.smeshpyD.GetPattern()
2999 isDone = pattern.LoadFromFile(pattern_prism)
3001 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
3004 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
3005 isDone = pattern.MakeMesh(self.mesh, False, False)
3006 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
3008 # Splits quafrangle faces near triangular facets of volumes
3009 self.SplitQuadsNearTriangularFacets()
3013 ## Smoothes elements
3014 # @param IDsOfElements the list if ids of elements to smooth
3015 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3016 # Note that nodes built on edges and boundary nodes are always fixed.
3017 # @param MaxNbOfIterations the maximum number of iterations
3018 # @param MaxAspectRatio varies in range [1.0, inf]
3019 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3020 # @return TRUE in case of success, FALSE otherwise.
3021 # @ingroup l2_modif_smooth
3022 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
3023 MaxNbOfIterations, MaxAspectRatio, Method):
3024 if IDsOfElements == []:
3025 IDsOfElements = self.GetElementsId()
3026 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
3027 self.mesh.SetParameters(Parameters)
3028 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
3029 MaxNbOfIterations, MaxAspectRatio, Method)
3031 ## Smoothes elements which belong to the given object
3032 # @param theObject the object to smooth
3033 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3034 # Note that nodes built on edges and boundary nodes are always fixed.
3035 # @param MaxNbOfIterations the maximum number of iterations
3036 # @param MaxAspectRatio varies in range [1.0, inf]
3037 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3038 # @return TRUE in case of success, FALSE otherwise.
3039 # @ingroup l2_modif_smooth
3040 def SmoothObject(self, theObject, IDsOfFixedNodes,
3041 MaxNbOfIterations, MaxAspectRatio, Method):
3042 if ( isinstance( theObject, Mesh )):
3043 theObject = theObject.GetMesh()
3044 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
3045 MaxNbOfIterations, MaxAspectRatio, Method)
3047 ## Parametrically smoothes the given elements
3048 # @param IDsOfElements the list if ids of elements to smooth
3049 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3050 # Note that nodes built on edges and boundary nodes are always fixed.
3051 # @param MaxNbOfIterations the maximum number of iterations
3052 # @param MaxAspectRatio varies in range [1.0, inf]
3053 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3054 # @return TRUE in case of success, FALSE otherwise.
3055 # @ingroup l2_modif_smooth
3056 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
3057 MaxNbOfIterations, MaxAspectRatio, Method):
3058 if IDsOfElements == []:
3059 IDsOfElements = self.GetElementsId()
3060 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
3061 self.mesh.SetParameters(Parameters)
3062 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
3063 MaxNbOfIterations, MaxAspectRatio, Method)
3065 ## Parametrically smoothes the elements which belong to the given object
3066 # @param theObject the object 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 Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3072 # @return TRUE in case of success, FALSE otherwise.
3073 # @ingroup l2_modif_smooth
3074 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
3075 MaxNbOfIterations, MaxAspectRatio, Method):
3076 if ( isinstance( theObject, Mesh )):
3077 theObject = theObject.GetMesh()
3078 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
3079 MaxNbOfIterations, MaxAspectRatio, Method)
3081 ## Converts the mesh to quadratic, deletes old elements, replacing
3082 # them with quadratic with the same id.
3083 # @param theForce3d new node creation method:
3084 # 0 - the medium node lies at the geometrical entity from which the mesh element is built
3085 # 1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element
3086 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
3087 # @ingroup l2_modif_tofromqu
3088 def ConvertToQuadratic(self, theForce3d, theSubMesh=None):
3090 self.editor.ConvertToQuadraticObject(theForce3d,theSubMesh)
3092 self.editor.ConvertToQuadratic(theForce3d)
3094 ## Converts the mesh from quadratic to ordinary,
3095 # deletes old quadratic elements, \n replacing
3096 # them with ordinary mesh elements with the same id.
3097 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
3098 # @ingroup l2_modif_tofromqu
3099 def ConvertFromQuadratic(self, theSubMesh=None):
3101 self.editor.ConvertFromQuadraticObject(theSubMesh)
3103 return self.editor.ConvertFromQuadratic()
3105 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
3106 # @return TRUE if operation has been completed successfully, FALSE otherwise
3107 # @ingroup l2_modif_edit
3108 def Make2DMeshFrom3D(self):
3109 return self.editor. Make2DMeshFrom3D()
3111 ## Creates missing boundary elements
3112 # @param elements - elements whose boundary is to be checked:
3113 # mesh, group, sub-mesh or list of elements
3114 # if elements is mesh, it must be the mesh whose MakeBoundaryMesh() is called
3115 # @param dimension - defines type of boundary elements to create:
3116 # SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D
3117 # SMESH.BND_1DFROM3D creates mesh edges on all borders of free facets of 3D cells
3118 # @param groupName - a name of group to store created boundary elements in,
3119 # "" means not to create the group
3120 # @param meshName - a name of new mesh to store created boundary elements in,
3121 # "" means not to create the new mesh
3122 # @param toCopyElements - if true, the checked elements will be copied into
3123 # the new mesh else only boundary elements will be copied into the new mesh
3124 # @param toCopyExistingBondary - if true, not only new but also pre-existing
3125 # boundary elements will be copied into the new mesh
3126 # @return tuple (mesh, group) where bondary elements were added to
3127 # @ingroup l2_modif_edit
3128 def MakeBoundaryMesh(self, elements, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3129 toCopyElements=False, toCopyExistingBondary=False):
3130 if isinstance( elements, Mesh ):
3131 elements = elements.GetMesh()
3132 if ( isinstance( elements, list )):
3133 elemType = SMESH.ALL
3134 if elements: elemType = self.GetElementType( elements[0], iselem=True)
3135 elements = self.editor.MakeIDSource(elements, elemType)
3136 mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName,
3137 toCopyElements,toCopyExistingBondary)
3138 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3142 # @brief Creates missing boundary elements around either the whole mesh or
3143 # groups of 2D elements
3144 # @param dimension - defines type of boundary elements to create
3145 # @param groupName - a name of group to store all boundary elements in,
3146 # "" means not to create the group
3147 # @param meshName - a name of a new mesh, which is a copy of the initial
3148 # mesh + created boundary elements; "" means not to create the new mesh
3149 # @param toCopyAll - if true, the whole initial mesh will be copied into
3150 # the new mesh else only boundary elements will be copied into the new mesh
3151 # @param groups - groups of 2D elements to make boundary around
3152 # @retval tuple( long, mesh, groups )
3153 # long - number of added boundary elements
3154 # mesh - the mesh where elements were added to
3155 # group - the group of boundary elements or None
3157 def MakeBoundaryElements(self, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3158 toCopyAll=False, groups=[]):
3159 nb, mesh, group = self.editor.MakeBoundaryElements(dimension,groupName,meshName,
3161 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3162 return nb, mesh, group
3164 ## Renumber mesh nodes
3165 # @ingroup l2_modif_renumber
3166 def RenumberNodes(self):
3167 self.editor.RenumberNodes()
3169 ## Renumber mesh elements
3170 # @ingroup l2_modif_renumber
3171 def RenumberElements(self):
3172 self.editor.RenumberElements()
3174 ## Generates new elements by rotation of the elements around the axis
3175 # @param IDsOfElements the list of ids of elements to sweep
3176 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3177 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
3178 # @param NbOfSteps the number of steps
3179 # @param Tolerance tolerance
3180 # @param MakeGroups forces the generation of new groups from existing ones
3181 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3182 # of all steps, else - size of each step
3183 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3184 # @ingroup l2_modif_extrurev
3185 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
3186 MakeGroups=False, TotalAngle=False):
3188 if isinstance(AngleInRadians,str):
3190 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3192 AngleInRadians = DegreesToRadians(AngleInRadians)
3193 if IDsOfElements == []:
3194 IDsOfElements = self.GetElementsId()
3195 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3196 Axis = self.smeshpyD.GetAxisStruct(Axis)
3197 Axis,AxisParameters = ParseAxisStruct(Axis)
3198 if TotalAngle and NbOfSteps:
3199 AngleInRadians /= NbOfSteps
3200 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3201 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3202 self.mesh.SetParameters(Parameters)
3204 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
3205 AngleInRadians, NbOfSteps, Tolerance)
3206 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
3209 ## Generates new elements by rotation of the elements of object around the axis
3210 # @param theObject object which elements should be sweeped.
3211 # It can be a mesh, a sub mesh or a group.
3212 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3213 # @param AngleInRadians the angle of Rotation
3214 # @param NbOfSteps number of steps
3215 # @param Tolerance tolerance
3216 # @param MakeGroups forces the generation of new groups from existing ones
3217 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3218 # of all steps, else - size of each step
3219 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3220 # @ingroup l2_modif_extrurev
3221 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3222 MakeGroups=False, TotalAngle=False):
3224 if isinstance(AngleInRadians,str):
3226 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3228 AngleInRadians = DegreesToRadians(AngleInRadians)
3229 if ( isinstance( theObject, Mesh )):
3230 theObject = theObject.GetMesh()
3231 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3232 Axis = self.smeshpyD.GetAxisStruct(Axis)
3233 Axis,AxisParameters = ParseAxisStruct(Axis)
3234 if TotalAngle and NbOfSteps:
3235 AngleInRadians /= NbOfSteps
3236 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3237 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3238 self.mesh.SetParameters(Parameters)
3240 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
3241 NbOfSteps, Tolerance)
3242 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3245 ## Generates new elements by rotation of the elements of object around the axis
3246 # @param theObject object which elements should be sweeped.
3247 # It can be a mesh, a sub mesh or a group.
3248 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3249 # @param AngleInRadians the angle of Rotation
3250 # @param NbOfSteps number of steps
3251 # @param Tolerance tolerance
3252 # @param MakeGroups forces the generation of new groups from existing ones
3253 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3254 # of all steps, else - size of each step
3255 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3256 # @ingroup l2_modif_extrurev
3257 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3258 MakeGroups=False, TotalAngle=False):
3260 if isinstance(AngleInRadians,str):
3262 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3264 AngleInRadians = DegreesToRadians(AngleInRadians)
3265 if ( isinstance( theObject, Mesh )):
3266 theObject = theObject.GetMesh()
3267 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3268 Axis = self.smeshpyD.GetAxisStruct(Axis)
3269 Axis,AxisParameters = ParseAxisStruct(Axis)
3270 if TotalAngle and NbOfSteps:
3271 AngleInRadians /= NbOfSteps
3272 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3273 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3274 self.mesh.SetParameters(Parameters)
3276 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
3277 NbOfSteps, Tolerance)
3278 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3281 ## Generates new elements by rotation of the elements of object around the axis
3282 # @param theObject object which elements should be sweeped.
3283 # It can be a mesh, a sub mesh or a group.
3284 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3285 # @param AngleInRadians the angle of Rotation
3286 # @param NbOfSteps number of steps
3287 # @param Tolerance tolerance
3288 # @param MakeGroups forces the generation of new groups from existing ones
3289 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3290 # of all steps, else - size of each step
3291 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3292 # @ingroup l2_modif_extrurev
3293 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3294 MakeGroups=False, TotalAngle=False):
3296 if isinstance(AngleInRadians,str):
3298 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3300 AngleInRadians = DegreesToRadians(AngleInRadians)
3301 if ( isinstance( theObject, Mesh )):
3302 theObject = theObject.GetMesh()
3303 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3304 Axis = self.smeshpyD.GetAxisStruct(Axis)
3305 Axis,AxisParameters = ParseAxisStruct(Axis)
3306 if TotalAngle and NbOfSteps:
3307 AngleInRadians /= NbOfSteps
3308 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3309 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3310 self.mesh.SetParameters(Parameters)
3312 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
3313 NbOfSteps, Tolerance)
3314 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3317 ## Generates new elements by extrusion of the elements with given ids
3318 # @param IDsOfElements the list of elements ids for extrusion
3319 # @param StepVector vector or DirStruct, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3320 # @param NbOfSteps the number of steps
3321 # @param MakeGroups forces the generation of new groups from existing ones
3322 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3323 # @ingroup l2_modif_extrurev
3324 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
3325 if IDsOfElements == []:
3326 IDsOfElements = self.GetElementsId()
3327 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3328 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3329 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3330 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3331 Parameters = StepVectorParameters + var_separator + Parameters
3332 self.mesh.SetParameters(Parameters)
3334 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
3335 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
3338 ## Generates new elements by extrusion of the elements with given ids
3339 # @param IDsOfElements is ids of elements
3340 # @param StepVector vector, defining the direction and value of extrusion
3341 # @param NbOfSteps the number of steps
3342 # @param ExtrFlags sets flags for extrusion
3343 # @param SewTolerance uses for comparing locations of nodes if flag
3344 # EXTRUSION_FLAG_SEW is set
3345 # @param MakeGroups forces the generation of new groups from existing ones
3346 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3347 # @ingroup l2_modif_extrurev
3348 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
3349 ExtrFlags, SewTolerance, MakeGroups=False):
3350 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3351 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3353 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
3354 ExtrFlags, SewTolerance)
3355 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
3356 ExtrFlags, SewTolerance)
3359 ## Generates new elements by extrusion of the elements which belong to the object
3360 # @param theObject the object which elements should be processed.
3361 # It can be a mesh, a sub mesh or a group.
3362 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3363 # @param NbOfSteps the number of steps
3364 # @param MakeGroups forces the generation of new groups from existing ones
3365 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3366 # @ingroup l2_modif_extrurev
3367 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3368 if ( isinstance( theObject, Mesh )):
3369 theObject = theObject.GetMesh()
3370 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3371 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3372 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3373 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3374 Parameters = StepVectorParameters + var_separator + Parameters
3375 self.mesh.SetParameters(Parameters)
3377 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3378 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
3381 ## Generates new elements by extrusion of the elements which belong to the object
3382 # @param theObject object which elements should be processed.
3383 # It can be a mesh, a sub mesh or a group.
3384 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3385 # @param NbOfSteps the number of steps
3386 # @param MakeGroups to generate new groups from existing ones
3387 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3388 # @ingroup l2_modif_extrurev
3389 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3390 if ( isinstance( theObject, Mesh )):
3391 theObject = theObject.GetMesh()
3392 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3393 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3394 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3395 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3396 Parameters = StepVectorParameters + var_separator + Parameters
3397 self.mesh.SetParameters(Parameters)
3399 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3400 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3403 ## Generates new elements by extrusion of the elements which belong to the object
3404 # @param theObject object which elements should be processed.
3405 # It can be a mesh, a sub mesh or a group.
3406 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3407 # @param NbOfSteps the number of steps
3408 # @param MakeGroups forces the generation of new groups from existing ones
3409 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3410 # @ingroup l2_modif_extrurev
3411 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3412 if ( isinstance( theObject, Mesh )):
3413 theObject = theObject.GetMesh()
3414 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3415 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3416 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3417 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3418 Parameters = StepVectorParameters + var_separator + Parameters
3419 self.mesh.SetParameters(Parameters)
3421 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3422 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3427 ## Generates new elements by extrusion of the given elements
3428 # The path of extrusion must be a meshed edge.
3429 # @param Base mesh or group, or submesh, or list of ids of elements for extrusion
3430 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3431 # @param NodeStart the start node from Path. Defines the direction of extrusion
3432 # @param HasAngles allows the shape to be rotated around the path
3433 # to get the resulting mesh in a helical fashion
3434 # @param Angles list of angles in radians
3435 # @param LinearVariation forces the computation of rotation angles as linear
3436 # variation of the given Angles along path steps
3437 # @param HasRefPoint allows using the reference point
3438 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3439 # The User can specify any point as the Reference Point.
3440 # @param MakeGroups forces the generation of new groups from existing ones
3441 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3442 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3443 # only SMESH::Extrusion_Error otherwise
3444 # @ingroup l2_modif_extrurev
3445 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3446 HasAngles, Angles, LinearVariation,
3447 HasRefPoint, RefPoint, MakeGroups, ElemType):
3448 Angles,AnglesParameters = ParseAngles(Angles)
3449 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3450 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3451 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3453 Parameters = AnglesParameters + var_separator + RefPointParameters
3454 self.mesh.SetParameters(Parameters)
3456 if (isinstance(Path, Mesh)): Path = Path.GetMesh()
3458 if isinstance(Base, list):
3460 if Base == []: IDsOfElements = self.GetElementsId()
3461 else: IDsOfElements = Base
3462 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3463 HasAngles, Angles, LinearVariation,
3464 HasRefPoint, RefPoint, MakeGroups, ElemType)
3466 if isinstance(Base, Mesh): Base = Base.GetMesh()
3467 if isinstance(Base, SMESH._objref_SMESH_Mesh) or isinstance(Base, SMESH._objref_SMESH_Group) or isinstance(Base, SMESH._objref_SMESH_subMesh):
3468 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3469 HasAngles, Angles, LinearVariation,
3470 HasRefPoint, RefPoint, MakeGroups, ElemType)
3472 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3475 ## Generates new elements by extrusion of the given elements
3476 # The path of extrusion must be a meshed edge.
3477 # @param IDsOfElements ids of elements
3478 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3479 # @param PathShape shape(edge) defines the sub-mesh for the path
3480 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3481 # @param HasAngles allows the shape to be rotated around the path
3482 # to get the resulting mesh in a helical fashion
3483 # @param Angles list of angles in radians
3484 # @param HasRefPoint allows using the reference point
3485 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3486 # The User can specify any point as the Reference Point.
3487 # @param MakeGroups forces the generation of new groups from existing ones
3488 # @param LinearVariation forces the computation of rotation angles as linear
3489 # variation of the given Angles along path steps
3490 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3491 # only SMESH::Extrusion_Error otherwise
3492 # @ingroup l2_modif_extrurev
3493 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3494 HasAngles, Angles, HasRefPoint, RefPoint,
3495 MakeGroups=False, LinearVariation=False):
3496 Angles,AnglesParameters = ParseAngles(Angles)
3497 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3498 if IDsOfElements == []:
3499 IDsOfElements = self.GetElementsId()
3500 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3501 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3503 if ( isinstance( PathMesh, Mesh )):
3504 PathMesh = PathMesh.GetMesh()
3505 if HasAngles and Angles and LinearVariation:
3506 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3508 Parameters = AnglesParameters + var_separator + RefPointParameters
3509 self.mesh.SetParameters(Parameters)
3511 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3512 PathShape, NodeStart, HasAngles,
3513 Angles, HasRefPoint, RefPoint)
3514 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3515 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3517 ## Generates new elements by extrusion of the elements which belong to the object
3518 # The path of extrusion must be a meshed edge.
3519 # @param theObject the object which elements should be processed.
3520 # It can be a mesh, a sub mesh or a group.
3521 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3522 # @param PathShape shape(edge) defines the sub-mesh for the path
3523 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3524 # @param HasAngles allows the shape to be rotated around the path
3525 # to get the resulting mesh in a helical fashion
3526 # @param Angles list of angles
3527 # @param HasRefPoint allows using the reference point
3528 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3529 # The User can specify any point as the Reference Point.
3530 # @param MakeGroups forces the generation of new groups from existing ones
3531 # @param LinearVariation forces the computation of rotation angles as linear
3532 # variation of the given Angles along path steps
3533 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3534 # only SMESH::Extrusion_Error otherwise
3535 # @ingroup l2_modif_extrurev
3536 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3537 HasAngles, Angles, HasRefPoint, RefPoint,
3538 MakeGroups=False, LinearVariation=False):
3539 Angles,AnglesParameters = ParseAngles(Angles)
3540 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3541 if ( isinstance( theObject, Mesh )):
3542 theObject = theObject.GetMesh()
3543 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3544 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3545 if ( isinstance( PathMesh, Mesh )):
3546 PathMesh = PathMesh.GetMesh()
3547 if HasAngles and Angles and LinearVariation:
3548 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3550 Parameters = AnglesParameters + var_separator + RefPointParameters
3551 self.mesh.SetParameters(Parameters)
3553 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3554 PathShape, NodeStart, HasAngles,
3555 Angles, HasRefPoint, RefPoint)
3556 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3557 NodeStart, HasAngles, Angles, HasRefPoint,
3560 ## Generates new elements by extrusion of the elements which belong to the object
3561 # The path of extrusion must be a meshed edge.
3562 # @param theObject the object which elements should be processed.
3563 # It can be a mesh, a sub mesh or a group.
3564 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3565 # @param PathShape shape(edge) defines the sub-mesh for the path
3566 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3567 # @param HasAngles allows the shape to be rotated around the path
3568 # to get the resulting mesh in a helical fashion
3569 # @param Angles list of angles
3570 # @param HasRefPoint allows using the reference point
3571 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3572 # The User can specify any point as the Reference Point.
3573 # @param MakeGroups forces the generation of new groups from existing ones
3574 # @param LinearVariation forces the computation of rotation angles as linear
3575 # variation of the given Angles along path steps
3576 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3577 # only SMESH::Extrusion_Error otherwise
3578 # @ingroup l2_modif_extrurev
3579 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3580 HasAngles, Angles, HasRefPoint, RefPoint,
3581 MakeGroups=False, LinearVariation=False):
3582 Angles,AnglesParameters = ParseAngles(Angles)
3583 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3584 if ( isinstance( theObject, Mesh )):
3585 theObject = theObject.GetMesh()
3586 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3587 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3588 if ( isinstance( PathMesh, Mesh )):
3589 PathMesh = PathMesh.GetMesh()
3590 if HasAngles and Angles and LinearVariation:
3591 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3593 Parameters = AnglesParameters + var_separator + RefPointParameters
3594 self.mesh.SetParameters(Parameters)
3596 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3597 PathShape, NodeStart, HasAngles,
3598 Angles, HasRefPoint, RefPoint)
3599 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3600 NodeStart, HasAngles, Angles, HasRefPoint,
3603 ## Generates new elements by extrusion of the elements which belong to the object
3604 # The path of extrusion must be a meshed edge.
3605 # @param theObject the object which elements should be processed.
3606 # It can be a mesh, a sub mesh or a group.
3607 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3608 # @param PathShape shape(edge) defines the sub-mesh for the path
3609 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3610 # @param HasAngles allows the shape to be rotated around the path
3611 # to get the resulting mesh in a helical fashion
3612 # @param Angles list of angles
3613 # @param HasRefPoint allows using the reference point
3614 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3615 # The User can specify any point as the Reference Point.
3616 # @param MakeGroups forces the generation of new groups from existing ones
3617 # @param LinearVariation forces the computation of rotation angles as linear
3618 # variation of the given Angles along path steps
3619 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3620 # only SMESH::Extrusion_Error otherwise
3621 # @ingroup l2_modif_extrurev
3622 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3623 HasAngles, Angles, HasRefPoint, RefPoint,
3624 MakeGroups=False, LinearVariation=False):
3625 Angles,AnglesParameters = ParseAngles(Angles)
3626 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3627 if ( isinstance( theObject, Mesh )):
3628 theObject = theObject.GetMesh()
3629 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3630 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3631 if ( isinstance( PathMesh, Mesh )):
3632 PathMesh = PathMesh.GetMesh()
3633 if HasAngles and Angles and LinearVariation:
3634 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3636 Parameters = AnglesParameters + var_separator + RefPointParameters
3637 self.mesh.SetParameters(Parameters)
3639 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3640 PathShape, NodeStart, HasAngles,
3641 Angles, HasRefPoint, RefPoint)
3642 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3643 NodeStart, HasAngles, Angles, HasRefPoint,
3646 ## Creates a symmetrical copy of mesh elements
3647 # @param IDsOfElements list of elements ids
3648 # @param Mirror is AxisStruct or geom object(point, line, plane)
3649 # @param theMirrorType is POINT, AXIS or PLANE
3650 # If the Mirror is a geom object this parameter is unnecessary
3651 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3652 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3653 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3654 # @ingroup l2_modif_trsf
3655 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3656 if IDsOfElements == []:
3657 IDsOfElements = self.GetElementsId()
3658 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3659 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3660 Mirror,Parameters = ParseAxisStruct(Mirror)
3661 self.mesh.SetParameters(Parameters)
3662 if Copy and MakeGroups:
3663 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3664 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3667 ## Creates a new mesh by a symmetrical copy of mesh elements
3668 # @param IDsOfElements the list of elements ids
3669 # @param Mirror is AxisStruct or geom object (point, line, plane)
3670 # @param theMirrorType is POINT, AXIS or PLANE
3671 # If the Mirror is a geom object this parameter is unnecessary
3672 # @param MakeGroups to generate new groups from existing ones
3673 # @param NewMeshName a name of the new mesh to create
3674 # @return instance of Mesh class
3675 # @ingroup l2_modif_trsf
3676 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3677 if IDsOfElements == []:
3678 IDsOfElements = self.GetElementsId()
3679 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3680 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3681 Mirror,Parameters = ParseAxisStruct(Mirror)
3682 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3683 MakeGroups, NewMeshName)
3684 mesh.SetParameters(Parameters)
3685 return Mesh(self.smeshpyD,self.geompyD,mesh)
3687 ## Creates a symmetrical copy of the object
3688 # @param theObject mesh, submesh or group
3689 # @param Mirror AxisStruct or geom object (point, line, plane)
3690 # @param theMirrorType is POINT, AXIS or PLANE
3691 # If the Mirror is a geom object this parameter is unnecessary
3692 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3693 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3694 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3695 # @ingroup l2_modif_trsf
3696 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3697 if ( isinstance( theObject, Mesh )):
3698 theObject = theObject.GetMesh()
3699 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3700 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3701 Mirror,Parameters = ParseAxisStruct(Mirror)
3702 self.mesh.SetParameters(Parameters)
3703 if Copy and MakeGroups:
3704 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3705 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3708 ## Creates a new mesh by a symmetrical copy of the object
3709 # @param theObject mesh, submesh or group
3710 # @param Mirror AxisStruct or geom object (point, line, plane)
3711 # @param theMirrorType POINT, AXIS or PLANE
3712 # If the Mirror is a geom object this parameter is unnecessary
3713 # @param MakeGroups forces the generation of new groups from existing ones
3714 # @param NewMeshName the name of the new mesh to create
3715 # @return instance of Mesh class
3716 # @ingroup l2_modif_trsf
3717 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3718 if ( isinstance( theObject, Mesh )):
3719 theObject = theObject.GetMesh()
3720 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3721 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3722 Mirror,Parameters = ParseAxisStruct(Mirror)
3723 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3724 MakeGroups, NewMeshName)
3725 mesh.SetParameters(Parameters)
3726 return Mesh( self.smeshpyD,self.geompyD,mesh )
3728 ## Translates the elements
3729 # @param IDsOfElements list of elements ids
3730 # @param Vector the direction of translation (DirStruct or vector)
3731 # @param Copy allows copying the translated elements
3732 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3733 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3734 # @ingroup l2_modif_trsf
3735 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3736 if IDsOfElements == []:
3737 IDsOfElements = self.GetElementsId()
3738 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3739 Vector = self.smeshpyD.GetDirStruct(Vector)
3740 Vector,Parameters = ParseDirStruct(Vector)
3741 self.mesh.SetParameters(Parameters)
3742 if Copy and MakeGroups:
3743 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3744 self.editor.Translate(IDsOfElements, Vector, Copy)
3747 ## Creates a new mesh of translated elements
3748 # @param IDsOfElements list of elements ids
3749 # @param Vector the direction of translation (DirStruct or vector)
3750 # @param MakeGroups forces the generation of new groups from existing ones
3751 # @param NewMeshName the name of the newly created mesh
3752 # @return instance of Mesh class
3753 # @ingroup l2_modif_trsf
3754 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3755 if IDsOfElements == []:
3756 IDsOfElements = self.GetElementsId()
3757 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3758 Vector = self.smeshpyD.GetDirStruct(Vector)
3759 Vector,Parameters = ParseDirStruct(Vector)
3760 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3761 mesh.SetParameters(Parameters)
3762 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3764 ## Translates the object
3765 # @param theObject the object to translate (mesh, submesh, or group)
3766 # @param Vector direction of translation (DirStruct or geom vector)
3767 # @param Copy allows copying the translated elements
3768 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3769 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3770 # @ingroup l2_modif_trsf
3771 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3772 if ( isinstance( theObject, Mesh )):
3773 theObject = theObject.GetMesh()
3774 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3775 Vector = self.smeshpyD.GetDirStruct(Vector)
3776 Vector,Parameters = ParseDirStruct(Vector)
3777 self.mesh.SetParameters(Parameters)
3778 if Copy and MakeGroups:
3779 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3780 self.editor.TranslateObject(theObject, Vector, Copy)
3783 ## Creates a new mesh from the translated object
3784 # @param theObject the object to translate (mesh, submesh, or group)
3785 # @param Vector the direction of translation (DirStruct or geom vector)
3786 # @param MakeGroups forces the generation of new groups from existing ones
3787 # @param NewMeshName the name of the newly created mesh
3788 # @return instance of Mesh class
3789 # @ingroup l2_modif_trsf
3790 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3791 if (isinstance(theObject, Mesh)):
3792 theObject = theObject.GetMesh()
3793 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3794 Vector = self.smeshpyD.GetDirStruct(Vector)
3795 Vector,Parameters = ParseDirStruct(Vector)
3796 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3797 mesh.SetParameters(Parameters)
3798 return Mesh( self.smeshpyD, self.geompyD, mesh )
3802 ## Scales the object
3803 # @param theObject - the object to translate (mesh, submesh, or group)
3804 # @param thePoint - base point for scale
3805 # @param theScaleFact - list of 1-3 scale factors for axises
3806 # @param Copy - allows copying the translated elements
3807 # @param MakeGroups - forces the generation of new groups from existing
3809 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3810 # empty list otherwise
3811 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3812 if ( isinstance( theObject, Mesh )):
3813 theObject = theObject.GetMesh()
3814 if ( isinstance( theObject, list )):
3815 theObject = self.GetIDSource(theObject, SMESH.ALL)
3817 thePoint, Parameters = ParsePointStruct(thePoint)
3818 self.mesh.SetParameters(Parameters)
3820 if Copy and MakeGroups:
3821 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3822 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3825 ## Creates a new mesh from the translated object
3826 # @param theObject - the object to translate (mesh, submesh, or group)
3827 # @param thePoint - base point for scale
3828 # @param theScaleFact - list of 1-3 scale factors for axises
3829 # @param MakeGroups - forces the generation of new groups from existing ones
3830 # @param NewMeshName - the name of the newly created mesh
3831 # @return instance of Mesh class
3832 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3833 if (isinstance(theObject, Mesh)):
3834 theObject = theObject.GetMesh()
3835 if ( isinstance( theObject, list )):
3836 theObject = self.GetIDSource(theObject,SMESH.ALL)
3838 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3839 MakeGroups, NewMeshName)
3840 #mesh.SetParameters(Parameters)
3841 return Mesh( self.smeshpyD, self.geompyD, mesh )
3845 ## Rotates the elements
3846 # @param IDsOfElements list of elements ids
3847 # @param Axis the axis of rotation (AxisStruct or geom line)
3848 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3849 # @param Copy allows copying the rotated elements
3850 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3851 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3852 # @ingroup l2_modif_trsf
3853 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3855 if isinstance(AngleInRadians,str):
3857 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3859 AngleInRadians = DegreesToRadians(AngleInRadians)
3860 if IDsOfElements == []:
3861 IDsOfElements = self.GetElementsId()
3862 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3863 Axis = self.smeshpyD.GetAxisStruct(Axis)
3864 Axis,AxisParameters = ParseAxisStruct(Axis)
3865 Parameters = AxisParameters + var_separator + Parameters
3866 self.mesh.SetParameters(Parameters)
3867 if Copy and MakeGroups:
3868 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3869 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3872 ## Creates a new mesh of rotated elements
3873 # @param IDsOfElements list of element ids
3874 # @param Axis the axis of rotation (AxisStruct or geom line)
3875 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3876 # @param MakeGroups forces the generation of new groups from existing ones
3877 # @param NewMeshName the name of the newly created mesh
3878 # @return instance of Mesh class
3879 # @ingroup l2_modif_trsf
3880 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3882 if isinstance(AngleInRadians,str):
3884 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3886 AngleInRadians = DegreesToRadians(AngleInRadians)
3887 if IDsOfElements == []:
3888 IDsOfElements = self.GetElementsId()
3889 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3890 Axis = self.smeshpyD.GetAxisStruct(Axis)
3891 Axis,AxisParameters = ParseAxisStruct(Axis)
3892 Parameters = AxisParameters + var_separator + Parameters
3893 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3894 MakeGroups, NewMeshName)
3895 mesh.SetParameters(Parameters)
3896 return Mesh( self.smeshpyD, self.geompyD, mesh )
3898 ## Rotates the object
3899 # @param theObject the object to rotate( mesh, submesh, or group)
3900 # @param Axis the axis of rotation (AxisStruct or geom line)
3901 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3902 # @param Copy allows copying the rotated elements
3903 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3904 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3905 # @ingroup l2_modif_trsf
3906 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3908 if isinstance(AngleInRadians,str):
3910 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3912 AngleInRadians = DegreesToRadians(AngleInRadians)
3913 if (isinstance(theObject, Mesh)):
3914 theObject = theObject.GetMesh()
3915 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3916 Axis = self.smeshpyD.GetAxisStruct(Axis)
3917 Axis,AxisParameters = ParseAxisStruct(Axis)
3918 Parameters = AxisParameters + ":" + Parameters
3919 self.mesh.SetParameters(Parameters)
3920 if Copy and MakeGroups:
3921 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3922 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3925 ## Creates a new mesh from the rotated object
3926 # @param theObject the object to rotate (mesh, submesh, or group)
3927 # @param Axis the axis of rotation (AxisStruct or geom line)
3928 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3929 # @param MakeGroups forces the generation of new groups from existing ones
3930 # @param NewMeshName the name of the newly created mesh
3931 # @return instance of Mesh class
3932 # @ingroup l2_modif_trsf
3933 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3935 if isinstance(AngleInRadians,str):
3937 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3939 AngleInRadians = DegreesToRadians(AngleInRadians)
3940 if (isinstance( theObject, Mesh )):
3941 theObject = theObject.GetMesh()
3942 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3943 Axis = self.smeshpyD.GetAxisStruct(Axis)
3944 Axis,AxisParameters = ParseAxisStruct(Axis)
3945 Parameters = AxisParameters + ":" + Parameters
3946 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3947 MakeGroups, NewMeshName)
3948 mesh.SetParameters(Parameters)
3949 return Mesh( self.smeshpyD, self.geompyD, mesh )
3951 ## Finds groups of ajacent nodes within Tolerance.
3952 # @param Tolerance the value of tolerance
3953 # @return the list of groups of nodes
3954 # @ingroup l2_modif_trsf
3955 def FindCoincidentNodes (self, Tolerance):
3956 return self.editor.FindCoincidentNodes(Tolerance)
3958 ## Finds groups of ajacent nodes within Tolerance.
3959 # @param Tolerance the value of tolerance
3960 # @param SubMeshOrGroup SubMesh or Group
3961 # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
3962 # @return the list of groups of nodes
3963 # @ingroup l2_modif_trsf
3964 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
3965 if (isinstance( SubMeshOrGroup, Mesh )):
3966 SubMeshOrGroup = SubMeshOrGroup.GetMesh()
3967 if not isinstance( exceptNodes, list):
3968 exceptNodes = [ exceptNodes ]
3969 if exceptNodes and isinstance( exceptNodes[0], int):
3970 exceptNodes = [ self.GetIDSource( exceptNodes, SMESH.NODE)]
3971 return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes)
3974 # @param GroupsOfNodes the list of groups of nodes
3975 # @ingroup l2_modif_trsf
3976 def MergeNodes (self, GroupsOfNodes):
3977 self.editor.MergeNodes(GroupsOfNodes)
3979 ## Finds the elements built on the same nodes.
3980 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3981 # @return a list of groups of equal elements
3982 # @ingroup l2_modif_trsf
3983 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3984 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3985 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3986 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3988 ## Merges elements in each given group.
3989 # @param GroupsOfElementsID groups of elements for merging
3990 # @ingroup l2_modif_trsf
3991 def MergeElements(self, GroupsOfElementsID):
3992 self.editor.MergeElements(GroupsOfElementsID)
3994 ## Leaves one element and removes all other elements built on the same nodes.
3995 # @ingroup l2_modif_trsf
3996 def MergeEqualElements(self):
3997 self.editor.MergeEqualElements()
3999 ## Sews free borders
4000 # @return SMESH::Sew_Error
4001 # @ingroup l2_modif_trsf
4002 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
4003 FirstNodeID2, SecondNodeID2, LastNodeID2,
4004 CreatePolygons, CreatePolyedrs):
4005 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
4006 FirstNodeID2, SecondNodeID2, LastNodeID2,
4007 CreatePolygons, CreatePolyedrs)
4009 ## Sews conform free borders
4010 # @return SMESH::Sew_Error
4011 # @ingroup l2_modif_trsf
4012 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
4013 FirstNodeID2, SecondNodeID2):
4014 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
4015 FirstNodeID2, SecondNodeID2)
4017 ## Sews border to side
4018 # @return SMESH::Sew_Error
4019 # @ingroup l2_modif_trsf
4020 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
4021 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
4022 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
4023 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
4025 ## Sews two sides of a mesh. The nodes belonging to Side1 are
4026 # merged with the nodes of elements of Side2.
4027 # The number of elements in theSide1 and in theSide2 must be
4028 # equal and they should have similar nodal connectivity.
4029 # The nodes to merge should belong to side borders and
4030 # the first node should be linked to the second.
4031 # @return SMESH::Sew_Error
4032 # @ingroup l2_modif_trsf
4033 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
4034 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
4035 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
4036 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
4037 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
4038 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
4040 ## Sets new nodes for the given element.
4041 # @param ide the element id
4042 # @param newIDs nodes ids
4043 # @return If the number of nodes does not correspond to the type of element - returns false
4044 # @ingroup l2_modif_edit
4045 def ChangeElemNodes(self, ide, newIDs):
4046 return self.editor.ChangeElemNodes(ide, newIDs)
4048 ## If during the last operation of MeshEditor some nodes were
4049 # created, this method returns the list of their IDs, \n
4050 # if new nodes were not created - returns empty list
4051 # @return the list of integer values (can be empty)
4052 # @ingroup l1_auxiliary
4053 def GetLastCreatedNodes(self):
4054 return self.editor.GetLastCreatedNodes()
4056 ## If during the last operation of MeshEditor some elements were
4057 # created this method returns the list of their IDs, \n
4058 # if new elements were not created - returns empty list
4059 # @return the list of integer values (can be empty)
4060 # @ingroup l1_auxiliary
4061 def GetLastCreatedElems(self):
4062 return self.editor.GetLastCreatedElems()
4064 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4065 # @param theNodes identifiers of nodes to be doubled
4066 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
4067 # nodes. If list of element identifiers is empty then nodes are doubled but
4068 # they not assigned to elements
4069 # @return TRUE if operation has been completed successfully, FALSE otherwise
4070 # @ingroup l2_modif_edit
4071 def DoubleNodes(self, theNodes, theModifiedElems):
4072 return self.editor.DoubleNodes(theNodes, theModifiedElems)
4074 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4075 # This method provided for convenience works as DoubleNodes() described above.
4076 # @param theNodeId identifiers of node to be doubled
4077 # @param theModifiedElems identifiers of elements to be updated
4078 # @return TRUE if operation has been completed successfully, FALSE otherwise
4079 # @ingroup l2_modif_edit
4080 def DoubleNode(self, theNodeId, theModifiedElems):
4081 return self.editor.DoubleNode(theNodeId, theModifiedElems)
4083 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4084 # This method provided for convenience works as DoubleNodes() described above.
4085 # @param theNodes group of nodes to be doubled
4086 # @param theModifiedElems group of elements to be updated.
4087 # @param theMakeGroup forces the generation of a group containing new nodes.
4088 # @return TRUE or a created group if operation has been completed successfully,
4089 # FALSE or None otherwise
4090 # @ingroup l2_modif_edit
4091 def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
4093 return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
4094 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
4096 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4097 # This method provided for convenience works as DoubleNodes() described above.
4098 # @param theNodes list of groups of nodes to be doubled
4099 # @param theModifiedElems list of groups of elements to be updated.
4100 # @return TRUE if operation has been completed successfully, FALSE otherwise
4101 # @ingroup l2_modif_edit
4102 def DoubleNodeGroups(self, theNodes, theModifiedElems, theMakeGroup=False):
4104 return self.editor.DoubleNodeGroupsNew(theNodes, theModifiedElems)
4105 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
4107 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4108 # @param theElems - the list of elements (edges or faces) to be replicated
4109 # The nodes for duplication could be found from these elements
4110 # @param theNodesNot - list of nodes to NOT replicate
4111 # @param theAffectedElems - the list of elements (cells and edges) to which the
4112 # replicated nodes should be associated to.
4113 # @return TRUE if operation has been completed successfully, FALSE otherwise
4114 # @ingroup l2_modif_edit
4115 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
4116 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
4118 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4119 # @param theElems - the list of elements (edges or faces) to be replicated
4120 # The nodes for duplication could be found from these elements
4121 # @param theNodesNot - list of nodes to NOT replicate
4122 # @param theShape - shape to detect affected elements (element which geometric center
4123 # located on or inside shape).
4124 # The replicated nodes should be associated to affected elements.
4125 # @return TRUE if operation has been completed successfully, FALSE otherwise
4126 # @ingroup l2_modif_edit
4127 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
4128 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
4130 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4131 # This method provided for convenience works as DoubleNodes() described above.
4132 # @param theElems - group of of elements (edges or faces) to be replicated
4133 # @param theNodesNot - group of nodes not to replicated
4134 # @param theAffectedElems - group of elements to which the replicated nodes
4135 # should be associated to.
4136 # @param theMakeGroup forces the generation of a group containing new elements.
4137 # @return TRUE or a created group if operation has been completed successfully,
4138 # FALSE or None otherwise
4139 # @ingroup l2_modif_edit
4140 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4142 return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
4143 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
4145 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4146 # This method provided for convenience works as DoubleNodes() described above.
4147 # @param theElems - group of of elements (edges or faces) to be replicated
4148 # @param theNodesNot - group of nodes not to replicated
4149 # @param theShape - shape to detect affected elements (element which geometric center
4150 # located on or inside shape).
4151 # The replicated nodes should be associated to affected elements.
4152 # @ingroup l2_modif_edit
4153 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
4154 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
4156 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4157 # This method provided for convenience works as DoubleNodes() described above.
4158 # @param theElems - list of groups of elements (edges or faces) to be replicated
4159 # @param theNodesNot - list of groups of nodes not to replicated
4160 # @param theAffectedElems - group of elements to which the replicated nodes
4161 # should be associated to.
4162 # @param theMakeGroup forces the generation of a group containing new elements.
4163 # @return TRUE or a created group if operation has been completed successfully,
4164 # FALSE or None otherwise
4165 # @ingroup l2_modif_edit
4166 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4168 return self.editor.DoubleNodeElemGroupsNew(theElems, theNodesNot, theAffectedElems)
4169 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
4171 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4172 # This method provided for convenience works as DoubleNodes() described above.
4173 # @param theElems - list of groups of elements (edges or faces) to be replicated
4174 # @param theNodesNot - list of groups of nodes not to replicated
4175 # @param theShape - shape to detect affected elements (element which geometric center
4176 # located on or inside shape).
4177 # The replicated nodes should be associated to affected elements.
4178 # @return TRUE if operation has been completed successfully, FALSE otherwise
4179 # @ingroup l2_modif_edit
4180 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
4181 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
4183 ## Double nodes on shared faces between groups of volumes and create flat elements on demand.
4184 # The list of groups must describe a partition of the mesh volumes.
4185 # The nodes of the internal faces at the boundaries of the groups are doubled.
4186 # In option, the internal faces are replaced by flat elements.
4187 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4188 # @param theDomains - list of groups of volumes
4189 # @param createJointElems - if TRUE, create the elements
4190 # @return TRUE if operation has been completed successfully, FALSE otherwise
4191 def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems ):
4192 return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems )
4194 ## Double nodes on some external faces and create flat elements.
4195 # Flat elements are mainly used by some types of mechanic calculations.
4197 # Each group of the list must be constituted of faces.
4198 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4199 # @param theGroupsOfFaces - list of groups of faces
4200 # @return TRUE if operation has been completed successfully, FALSE otherwise
4201 def CreateFlatElementsOnFacesGroups(self, theGroupsOfFaces ):
4202 return self.editor.CreateFlatElementsOnFacesGroups( theGroupsOfFaces )
4204 def _valueFromFunctor(self, funcType, elemId):
4205 fn = self.smeshpyD.GetFunctor(funcType)
4206 fn.SetMesh(self.mesh)
4207 if fn.GetElementType() == self.GetElementType(elemId, True):
4208 val = fn.GetValue(elemId)
4213 ## Get length of 1D element.
4214 # @param elemId mesh element ID
4215 # @return element's length value
4216 # @ingroup l1_measurements
4217 def GetLength(self, elemId):
4218 return self._valueFromFunctor(SMESH.FT_Length, elemId)
4220 ## Get area of 2D element.
4221 # @param elemId mesh element ID
4222 # @return element's area value
4223 # @ingroup l1_measurements
4224 def GetArea(self, elemId):
4225 return self._valueFromFunctor(SMESH.FT_Area, elemId)
4227 ## Get volume of 3D element.
4228 # @param elemId mesh element ID
4229 # @return element's volume value
4230 # @ingroup l1_measurements
4231 def GetVolume(self, elemId):
4232 return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
4234 ## Get maximum element length.
4235 # @param elemId mesh element ID
4236 # @return element's maximum length value
4237 # @ingroup l1_measurements
4238 def GetMaxElementLength(self, elemId):
4239 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4240 ftype = SMESH.FT_MaxElementLength3D
4242 ftype = SMESH.FT_MaxElementLength2D
4243 return self._valueFromFunctor(ftype, elemId)
4245 ## Get aspect ratio of 2D or 3D element.
4246 # @param elemId mesh element ID
4247 # @return element's aspect ratio value
4248 # @ingroup l1_measurements
4249 def GetAspectRatio(self, elemId):
4250 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4251 ftype = SMESH.FT_AspectRatio3D
4253 ftype = SMESH.FT_AspectRatio
4254 return self._valueFromFunctor(ftype, elemId)
4256 ## Get warping angle of 2D element.
4257 # @param elemId mesh element ID
4258 # @return element's warping angle value
4259 # @ingroup l1_measurements
4260 def GetWarping(self, elemId):
4261 return self._valueFromFunctor(SMESH.FT_Warping, elemId)
4263 ## Get minimum angle of 2D element.
4264 # @param elemId mesh element ID
4265 # @return element's minimum angle value
4266 # @ingroup l1_measurements
4267 def GetMinimumAngle(self, elemId):
4268 return self._valueFromFunctor(SMESH.FT_MinimumAngle, elemId)
4270 ## Get taper of 2D element.
4271 # @param elemId mesh element ID
4272 # @return element's taper value
4273 # @ingroup l1_measurements
4274 def GetTaper(self, elemId):
4275 return self._valueFromFunctor(SMESH.FT_Taper, elemId)
4277 ## Get skew of 2D element.
4278 # @param elemId mesh element ID
4279 # @return element's skew value
4280 # @ingroup l1_measurements
4281 def GetSkew(self, elemId):
4282 return self._valueFromFunctor(SMESH.FT_Skew, elemId)
4284 ## The mother class to define algorithm, it is not recommended to use it directly.
4287 # @ingroup l2_algorithms
4288 class Mesh_Algorithm:
4289 # @class Mesh_Algorithm
4290 # @brief Class Mesh_Algorithm
4292 #def __init__(self,smesh):
4300 ## Finds a hypothesis in the study by its type name and parameters.
4301 # Finds only the hypotheses created in smeshpyD engine.
4302 # @return SMESH.SMESH_Hypothesis
4303 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
4304 study = smeshpyD.GetCurrentStudy()
4305 #to do: find component by smeshpyD object, not by its data type
4306 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4307 if scomp is not None:
4308 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
4309 # Check if the root label of the hypotheses exists
4310 if res and hypRoot is not None:
4311 iter = study.NewChildIterator(hypRoot)
4312 # Check all published hypotheses
4314 hypo_so_i = iter.Value()
4315 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
4316 if attr is not None:
4317 anIOR = attr.Value()
4318 hypo_o_i = salome.orb.string_to_object(anIOR)
4319 if hypo_o_i is not None:
4320 # Check if this is a hypothesis
4321 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
4322 if hypo_i is not None:
4323 # Check if the hypothesis belongs to current engine
4324 if smeshpyD.GetObjectId(hypo_i) > 0:
4325 # Check if this is the required hypothesis
4326 if hypo_i.GetName() == hypname:
4328 if CompareMethod(hypo_i, args):
4342 ## Finds the algorithm in the study by its type name.
4343 # Finds only the algorithms, which have been created in smeshpyD engine.
4344 # @return SMESH.SMESH_Algo
4345 def FindAlgorithm (self, algoname, smeshpyD):
4346 study = smeshpyD.GetCurrentStudy()
4347 #to do: find component by smeshpyD object, not by its data type
4348 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4349 if scomp is not None:
4350 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
4351 # Check if the root label of the algorithms exists
4352 if res and hypRoot is not None:
4353 iter = study.NewChildIterator(hypRoot)
4354 # Check all published algorithms
4356 algo_so_i = iter.Value()
4357 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
4358 if attr is not None:
4359 anIOR = attr.Value()
4360 algo_o_i = salome.orb.string_to_object(anIOR)
4361 if algo_o_i is not None:
4362 # Check if this is an algorithm
4363 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
4364 if algo_i is not None:
4365 # Checks if the algorithm belongs to the current engine
4366 if smeshpyD.GetObjectId(algo_i) > 0:
4367 # Check if this is the required algorithm
4368 if algo_i.GetName() == algoname:
4381 ## If the algorithm is global, returns 0; \n
4382 # else returns the submesh associated to this algorithm.
4383 def GetSubMesh(self):
4386 ## Returns the wrapped mesher.
4387 def GetAlgorithm(self):
4390 ## Gets the list of hypothesis that can be used with this algorithm
4391 def GetCompatibleHypothesis(self):
4394 mylist = self.algo.GetCompatibleHypothesis()
4397 ## Gets the name of the algorithm
4401 ## Sets the name to the algorithm
4402 def SetName(self, name):
4403 self.mesh.smeshpyD.SetName(self.algo, name)
4405 ## Gets the id of the algorithm
4407 return self.algo.GetId()
4410 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
4412 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
4413 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
4415 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
4417 self.Assign(algo, mesh, geom)
4421 def Assign(self, algo, mesh, geom):
4423 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
4427 self.geom = mesh.geom
4430 self.AssureGeomPublished( geom )
4432 name = GetName(geom)
4436 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
4438 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
4439 TreatHypoStatus( status, algo.GetName(), name, True )
4442 ## Private method. Add geom into the study if not yet there
4443 def AssureGeomPublished(self, geom, name=''):
4444 if not isinstance( geom, geompyDC.GEOM._objref_GEOM_Object ):
4446 if not geom.IsSame( self.mesh.geom ) and not geom.GetStudyEntry():
4448 studyID = self.mesh.smeshpyD.GetCurrentStudy()._get_StudyId()
4449 if studyID != self.mesh.geompyD.myStudyId:
4450 self.mesh.geompyD.init_geom( self.mesh.smeshpyD.GetCurrentStudy())
4452 if not name and geom.GetShapeType() != geompyDC.GEOM.COMPOUND:
4453 # for all groups SubShapeName() returns "Compound_-1"
4454 name = self.mesh.geompyD.SubShapeName(geom, self.mesh.geom)
4456 name = "%s_%s"%(geom.GetShapeType(), id(geom)%10000)
4458 self.mesh.geompyD.addToStudyInFather( self.mesh.geom, geom, name )
4461 def CompareHyp (self, hyp, args):
4462 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
4465 def CompareEqualHyp (self, hyp, args):
4469 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
4470 UseExisting=0, CompareMethod=""):
4473 if CompareMethod == "": CompareMethod = self.CompareHyp
4474 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
4477 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
4483 a = a + s + str(args[i])
4487 self.mesh.smeshpyD.SetName(hypo, hyp + a)
4491 geomName = GetName(self.geom)
4492 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
4493 TreatHypoStatus( status, GetName(hypo), geomName, 0 )
4496 ## Returns entry of the shape to mesh in the study
4497 def MainShapeEntry(self):
4499 if not self.mesh or not self.mesh.GetMesh(): return entry
4500 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
4501 study = self.mesh.smeshpyD.GetCurrentStudy()
4502 ior = salome.orb.object_to_string( self.mesh.GetShape() )
4503 sobj = study.FindObjectIOR(ior)
4504 if sobj: entry = sobj.GetID()
4505 if not entry: return ""
4508 ## Defines "ViscousLayers" hypothesis to give parameters of layers of prisms to build
4509 # near mesh boundary. This hypothesis can be used by several 3D algorithms:
4510 # NETGEN 3D, GHS3D, Hexahedron(i,j,k)
4511 # @param thickness total thickness of layers of prisms
4512 # @param numberOfLayers number of layers of prisms
4513 # @param stretchFactor factor (>1.0) of growth of layer thickness towards inside of mesh
4514 # @param ignoreFaces list of geometrical faces (or their ids) not to generate layers on
4515 # @ingroup l3_hypos_additi
4516 def ViscousLayers(self, thickness, numberOfLayers, stretchFactor, ignoreFaces=[]):
4517 if not isinstance(self.algo, SMESH._objref_SMESH_3D_Algo):
4518 raise TypeError, "ViscousLayers are supported by 3D algorithms only"
4519 if not "ViscousLayers" in self.GetCompatibleHypothesis():
4520 raise TypeError, "ViscousLayers are not supported by %s"%self.algo.GetName()
4521 if ignoreFaces and isinstance( ignoreFaces[0], geompyDC.GEOM._objref_GEOM_Object ):
4522 ignoreFaces = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, f) for f in ignoreFaces ]
4523 hyp = self.Hypothesis("ViscousLayers",
4524 [thickness, numberOfLayers, stretchFactor, ignoreFaces])
4525 hyp.SetTotalThickness(thickness)
4526 hyp.SetNumberLayers(numberOfLayers)
4527 hyp.SetStretchFactor(stretchFactor)
4528 hyp.SetIgnoreFaces(ignoreFaces)
4531 # Public class: Mesh_Segment
4532 # --------------------------
4534 ## Class to define a segment 1D algorithm for discretization
4537 # @ingroup l3_algos_basic
4538 class Mesh_Segment(Mesh_Algorithm):
4540 ## Private constructor.
4541 def __init__(self, mesh, geom=0):
4542 Mesh_Algorithm.__init__(self)
4543 self.Create(mesh, geom, "Regular_1D")
4545 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
4546 # @param l for the length of segments that cut an edge
4547 # @param UseExisting if ==true - searches for an existing hypothesis created with
4548 # the same parameters, else (default) - creates a new one
4549 # @param p precision, used for calculation of the number of segments.
4550 # The precision should be a positive, meaningful value within the range [0,1].
4551 # In general, the number of segments is calculated with the formula:
4552 # nb = ceil((edge_length / l) - p)
4553 # Function ceil rounds its argument to the higher integer.
4554 # So, p=0 means rounding of (edge_length / l) to the higher integer,
4555 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
4556 # p=1 means rounding of (edge_length / l) to the lower integer.
4557 # Default value is 1e-07.
4558 # @return an instance of StdMeshers_LocalLength hypothesis
4559 # @ingroup l3_hypos_1dhyps
4560 def LocalLength(self, l, UseExisting=0, p=1e-07):
4561 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
4562 CompareMethod=self.CompareLocalLength)
4568 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
4569 def CompareLocalLength(self, hyp, args):
4570 if IsEqual(hyp.GetLength(), args[0]):
4571 return IsEqual(hyp.GetPrecision(), args[1])
4574 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
4575 # @param length is optional maximal allowed length of segment, if it is omitted
4576 # the preestimated length is used that depends on geometry size
4577 # @param UseExisting if ==true - searches for an existing hypothesis created with
4578 # the same parameters, else (default) - create a new one
4579 # @return an instance of StdMeshers_MaxLength hypothesis
4580 # @ingroup l3_hypos_1dhyps
4581 def MaxSize(self, length=0.0, UseExisting=0):
4582 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
4585 hyp.SetLength(length)
4587 # set preestimated length
4588 gen = self.mesh.smeshpyD
4589 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
4590 self.mesh.GetMesh(), self.mesh.GetShape(),
4592 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
4594 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
4597 hyp.SetUsePreestimatedLength( length == 0.0 )
4600 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
4601 # @param n for the number of segments that cut an edge
4602 # @param s for the scale factor (optional)
4603 # @param reversedEdges is a list of edges to mesh using reversed orientation
4604 # @param UseExisting if ==true - searches for an existing hypothesis created with
4605 # the same parameters, else (default) - create a new one
4606 # @return an instance of StdMeshers_NumberOfSegments hypothesis
4607 # @ingroup l3_hypos_1dhyps
4608 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4609 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4610 reversedEdges, UseExisting = [], reversedEdges
4611 entry = self.MainShapeEntry()
4612 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4613 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4615 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
4616 UseExisting=UseExisting,
4617 CompareMethod=self.CompareNumberOfSegments)
4619 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
4620 UseExisting=UseExisting,
4621 CompareMethod=self.CompareNumberOfSegments)
4622 hyp.SetDistrType( 1 )
4623 hyp.SetScaleFactor(s)
4624 hyp.SetNumberOfSegments(n)
4625 hyp.SetReversedEdges( reversedEdges )
4626 hyp.SetObjectEntry( entry )
4630 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4631 def CompareNumberOfSegments(self, hyp, args):
4632 if hyp.GetNumberOfSegments() == args[0]:
4634 if hyp.GetReversedEdges() == args[1]:
4635 if not args[1] or hyp.GetObjectEntry() == args[2]:
4638 if hyp.GetReversedEdges() == args[2]:
4639 if not args[2] or hyp.GetObjectEntry() == args[3]:
4640 if hyp.GetDistrType() == 1:
4641 if IsEqual(hyp.GetScaleFactor(), args[1]):
4645 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4646 # @param start defines the length of the first segment
4647 # @param end defines the length of the last segment
4648 # @param reversedEdges is a list of edges to mesh using reversed orientation
4649 # @param UseExisting if ==true - searches for an existing hypothesis created with
4650 # the same parameters, else (default) - creates a new one
4651 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4652 # @ingroup l3_hypos_1dhyps
4653 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4654 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4655 reversedEdges, UseExisting = [], reversedEdges
4656 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4657 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4658 entry = self.MainShapeEntry()
4659 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
4660 UseExisting=UseExisting,
4661 CompareMethod=self.CompareArithmetic1D)
4662 hyp.SetStartLength(start)
4663 hyp.SetEndLength(end)
4664 hyp.SetReversedEdges( reversedEdges )
4665 hyp.SetObjectEntry( entry )
4669 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4670 def CompareArithmetic1D(self, hyp, args):
4671 if IsEqual(hyp.GetLength(1), args[0]):
4672 if IsEqual(hyp.GetLength(0), args[1]):
4673 if hyp.GetReversedEdges() == args[2]:
4674 if not args[2] or hyp.GetObjectEntry() == args[3]:
4679 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4680 # on curve from 0 to 1 (additionally it is neecessary to check
4681 # orientation of edges and create list of reversed edges if it is
4682 # needed) and sets numbers of segments between given points (default
4683 # values are equals 1
4684 # @param points defines the list of parameters on curve
4685 # @param nbSegs defines the list of numbers of segments
4686 # @param reversedEdges is a list of edges to mesh using reversed orientation
4687 # @param UseExisting if ==true - searches for an existing hypothesis created with
4688 # the same parameters, else (default) - creates a new one
4689 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4690 # @ingroup l3_hypos_1dhyps
4691 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4692 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4693 reversedEdges, UseExisting = [], reversedEdges
4694 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4695 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4696 entry = self.MainShapeEntry()
4697 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
4698 UseExisting=UseExisting,
4699 CompareMethod=self.CompareFixedPoints1D)
4700 hyp.SetPoints(points)
4701 hyp.SetNbSegments(nbSegs)
4702 hyp.SetReversedEdges(reversedEdges)
4703 hyp.SetObjectEntry(entry)
4707 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4708 ## as the given arguments
4709 def CompareFixedPoints1D(self, hyp, args):
4710 if hyp.GetPoints() == args[0]:
4711 if hyp.GetNbSegments() == args[1]:
4712 if hyp.GetReversedEdges() == args[2]:
4713 if not args[2] or hyp.GetObjectEntry() == args[3]:
4719 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4720 # @param start defines the length of the first segment
4721 # @param end defines the length of the last segment
4722 # @param reversedEdges is a list of edges to mesh using reversed orientation
4723 # @param UseExisting if ==true - searches for an existing hypothesis created with
4724 # the same parameters, else (default) - creates a new one
4725 # @return an instance of StdMeshers_StartEndLength hypothesis
4726 # @ingroup l3_hypos_1dhyps
4727 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4728 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4729 reversedEdges, UseExisting = [], reversedEdges
4730 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4731 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4732 entry = self.MainShapeEntry()
4733 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
4734 UseExisting=UseExisting,
4735 CompareMethod=self.CompareStartEndLength)
4736 hyp.SetStartLength(start)
4737 hyp.SetEndLength(end)
4738 hyp.SetReversedEdges( reversedEdges )
4739 hyp.SetObjectEntry( entry )
4742 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4743 def CompareStartEndLength(self, hyp, args):
4744 if IsEqual(hyp.GetLength(1), args[0]):
4745 if IsEqual(hyp.GetLength(0), args[1]):
4746 if hyp.GetReversedEdges() == args[2]:
4747 if not args[2] or hyp.GetObjectEntry() == args[3]:
4751 ## Defines "Deflection1D" hypothesis
4752 # @param d for the deflection
4753 # @param UseExisting if ==true - searches for an existing hypothesis created with
4754 # the same parameters, else (default) - create a new one
4755 # @ingroup l3_hypos_1dhyps
4756 def Deflection1D(self, d, UseExisting=0):
4757 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4758 CompareMethod=self.CompareDeflection1D)
4759 hyp.SetDeflection(d)
4762 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4763 def CompareDeflection1D(self, hyp, args):
4764 return IsEqual(hyp.GetDeflection(), args[0])
4766 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4767 # the opposite side in case of quadrangular faces
4768 # @ingroup l3_hypos_additi
4769 def Propagation(self):
4770 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4772 ## Defines "AutomaticLength" hypothesis
4773 # @param fineness for the fineness [0-1]
4774 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4775 # same parameters, else (default) - create a new one
4776 # @ingroup l3_hypos_1dhyps
4777 def AutomaticLength(self, fineness=0, UseExisting=0):
4778 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4779 CompareMethod=self.CompareAutomaticLength)
4780 hyp.SetFineness( fineness )
4783 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4784 def CompareAutomaticLength(self, hyp, args):
4785 return IsEqual(hyp.GetFineness(), args[0])
4787 ## Defines "SegmentLengthAroundVertex" hypothesis
4788 # @param length for the segment length
4789 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4790 # Any other integer value means that the hypothesis will be set on the
4791 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4792 # @param UseExisting if ==true - searches for an existing hypothesis created with
4793 # the same parameters, else (default) - creates a new one
4794 # @ingroup l3_algos_segmarv
4795 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4797 store_geom = self.geom
4798 if type(vertex) is types.IntType:
4799 if vertex == 0 or vertex == 1:
4800 vertex = self.mesh.geompyD.ExtractShapes(self.geom, geompyDC.ShapeType["VERTEX"],True)[vertex]
4808 if self.geom is None:
4809 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4810 self.AssureGeomPublished( self.geom )
4811 name = GetName(self.geom)
4813 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4815 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4817 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4818 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4820 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4821 CompareMethod=self.CompareLengthNearVertex)
4822 self.geom = store_geom
4823 hyp.SetLength( length )
4826 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4827 # @ingroup l3_algos_segmarv
4828 def CompareLengthNearVertex(self, hyp, args):
4829 return IsEqual(hyp.GetLength(), args[0])
4831 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4832 # If the 2D mesher sees that all boundary edges are quadratic,
4833 # it generates quadratic faces, else it generates linear faces using
4834 # medium nodes as if they are vertices.
4835 # The 3D mesher generates quadratic volumes only if all boundary faces
4836 # are quadratic, else it fails.
4838 # @ingroup l3_hypos_additi
4839 def QuadraticMesh(self):
4840 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4843 # Public class: Mesh_CompositeSegment
4844 # --------------------------
4846 ## Defines a segment 1D algorithm for discretization
4848 # @ingroup l3_algos_basic
4849 class Mesh_CompositeSegment(Mesh_Segment):
4851 ## Private constructor.
4852 def __init__(self, mesh, geom=0):
4853 self.Create(mesh, geom, "CompositeSegment_1D")
4856 # Public class: Mesh_Segment_Python
4857 # ---------------------------------
4859 ## Defines a segment 1D algorithm for discretization with python function
4861 # @ingroup l3_algos_basic
4862 class Mesh_Segment_Python(Mesh_Segment):
4864 ## Private constructor.
4865 def __init__(self, mesh, geom=0):
4866 import Python1dPlugin
4867 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4869 ## Defines "PythonSplit1D" hypothesis
4870 # @param n for the number of segments that cut an edge
4871 # @param func for the python function that calculates the length of all segments
4872 # @param UseExisting if ==true - searches for the existing hypothesis created with
4873 # the same parameters, else (default) - creates a new one
4874 # @ingroup l3_hypos_1dhyps
4875 def PythonSplit1D(self, n, func, UseExisting=0):
4876 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4877 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4878 hyp.SetNumberOfSegments(n)
4879 hyp.SetPythonLog10RatioFunction(func)
4882 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4883 def ComparePythonSplit1D(self, hyp, args):
4884 #if hyp.GetNumberOfSegments() == args[0]:
4885 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4889 # Public class: Mesh_Triangle
4890 # ---------------------------
4892 ## Defines a triangle 2D algorithm
4894 # @ingroup l3_algos_basic
4895 class Mesh_Triangle(Mesh_Algorithm):
4904 ## Private constructor.
4905 def __init__(self, mesh, algoType, geom=0):
4906 Mesh_Algorithm.__init__(self)
4908 self.algoType = algoType
4909 if algoType == MEFISTO:
4910 self.Create(mesh, geom, "MEFISTO_2D")
4912 elif algoType == BLSURF:
4914 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4915 #self.SetPhysicalMesh() - PAL19680
4916 elif algoType == NETGEN:
4918 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4920 elif algoType == NETGEN_2D:
4922 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4925 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4926 # @param area for the maximum area of each triangle
4927 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4928 # same parameters, else (default) - creates a new one
4930 # Only for algoType == MEFISTO || NETGEN_2D
4931 # @ingroup l3_hypos_2dhyps
4932 def MaxElementArea(self, area, UseExisting=0):
4933 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4934 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4935 CompareMethod=self.CompareMaxElementArea)
4936 elif self.algoType == NETGEN:
4937 hyp = self.Parameters(SIMPLE)
4938 hyp.SetMaxElementArea(area)
4941 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4942 def CompareMaxElementArea(self, hyp, args):
4943 return IsEqual(hyp.GetMaxElementArea(), args[0])
4945 ## Defines "LengthFromEdges" hypothesis to build triangles
4946 # based on the length of the edges taken from the wire
4948 # Only for algoType == MEFISTO || NETGEN_2D
4949 # @ingroup l3_hypos_2dhyps
4950 def LengthFromEdges(self):
4951 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4952 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4954 elif self.algoType == NETGEN:
4955 hyp = self.Parameters(SIMPLE)
4956 hyp.LengthFromEdges()
4959 ## Sets a way to define size of mesh elements to generate.
4960 # @param thePhysicalMesh is: DefaultSize or Custom.
4961 # @ingroup l3_hypos_blsurf
4962 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4963 # Parameter of BLSURF algo
4964 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4966 ## Sets size of mesh elements to generate.
4967 # @ingroup l3_hypos_blsurf
4968 def SetPhySize(self, theVal):
4969 # Parameter of BLSURF algo
4970 self.SetPhysicalMesh(1) #Custom - else why to set the size?
4971 self.Parameters().SetPhySize(theVal)
4973 ## Sets lower boundary of mesh element size (PhySize).
4974 # @ingroup l3_hypos_blsurf
4975 def SetPhyMin(self, theVal=-1):
4976 # Parameter of BLSURF algo
4977 self.Parameters().SetPhyMin(theVal)
4979 ## Sets upper boundary of mesh element size (PhySize).
4980 # @ingroup l3_hypos_blsurf
4981 def SetPhyMax(self, theVal=-1):
4982 # Parameter of BLSURF algo
4983 self.Parameters().SetPhyMax(theVal)
4985 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4986 # @param theGeometricMesh is: 0 (None) or 1 (Custom)
4987 # @ingroup l3_hypos_blsurf
4988 def SetGeometricMesh(self, theGeometricMesh=0):
4989 # Parameter of BLSURF algo
4990 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4991 self.params.SetGeometricMesh(theGeometricMesh)
4993 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4994 # @ingroup l3_hypos_blsurf
4995 def SetAngleMeshS(self, theVal=_angleMeshS):
4996 # Parameter of BLSURF algo
4997 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4998 self.params.SetAngleMeshS(theVal)
5000 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
5001 # @ingroup l3_hypos_blsurf
5002 def SetAngleMeshC(self, theVal=_angleMeshS):
5003 # Parameter of BLSURF algo
5004 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
5005 self.params.SetAngleMeshC(theVal)
5007 ## Sets lower boundary of mesh element size computed to respect angular deflection.
5008 # @ingroup l3_hypos_blsurf
5009 def SetGeoMin(self, theVal=-1):
5010 # Parameter of BLSURF algo
5011 self.Parameters().SetGeoMin(theVal)
5013 ## Sets upper boundary of mesh element size computed to respect angular deflection.
5014 # @ingroup l3_hypos_blsurf
5015 def SetGeoMax(self, theVal=-1):
5016 # Parameter of BLSURF algo
5017 self.Parameters().SetGeoMax(theVal)
5019 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
5020 # @ingroup l3_hypos_blsurf
5021 def SetGradation(self, theVal=_gradation):
5022 # Parameter of BLSURF algo
5023 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
5024 self.params.SetGradation(theVal)
5026 ## Sets topology usage way.
5027 # @param way defines how mesh conformity is assured <ul>
5028 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
5029 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
5030 # @ingroup l3_hypos_blsurf
5031 def SetTopology(self, way):
5032 # Parameter of BLSURF algo
5033 self.Parameters().SetTopology(way)
5035 ## To respect geometrical edges or not.
5036 # @ingroup l3_hypos_blsurf
5037 def SetDecimesh(self, toIgnoreEdges=False):
5038 # Parameter of BLSURF algo
5039 self.Parameters().SetDecimesh(toIgnoreEdges)
5041 ## Sets verbosity level in the range 0 to 100.
5042 # @ingroup l3_hypos_blsurf
5043 def SetVerbosity(self, level):
5044 # Parameter of BLSURF algo
5045 self.Parameters().SetVerbosity(level)
5047 ## Sets advanced option value.
5048 # @ingroup l3_hypos_blsurf
5049 def SetOptionValue(self, optionName, level):
5050 # Parameter of BLSURF algo
5051 self.Parameters().SetOptionValue(optionName,level)
5053 ## 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 ]
5054 # @param theFace : face on which the attractor will be defined
5055 # @param theAttractor : geometrical object from which the mesh size "h" decreases exponentially
5056 # @param theStartSize : mesh size on theAttractor
5057 # @param theEndSize : maximum size that will be reached on theFace
5058 # @param theInfluenceDistance : influence of the attractor ( the size grow slower on theFace if it's high)
5059 # @param theConstantSizeDistance : distance until which the mesh size will be kept constant on theFace
5060 # @ingroup l3_hypos_blsurf
5061 def SetAttractorGeom(self, theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance):
5062 self.AssureGeomPublished( theFace )
5063 self.AssureGeomPublished( theAttractor )
5064 # Parameter of BLSURF algo
5065 self.Parameters().SetAttractorGeom(theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance)
5067 ## Unsets an attractor on the chosen face.
5068 # @param theFace : face on which the attractor has to be removed
5069 # @ingroup l3_hypos_blsurf
5070 def UnsetAttractorGeom(self, theFace):
5071 self.AssureGeomPublished( theFace )
5072 # Parameter of BLSURF algo
5073 self.Parameters().SetAttractorGeom(theFace)
5075 ## Sets QuadAllowed flag.
5076 # Only for algoType == NETGEN(NETGEN_1D2D) || NETGEN_2D || BLSURF
5077 # @ingroup l3_hypos_netgen l3_hypos_blsurf
5078 def SetQuadAllowed(self, toAllow=True):
5079 if self.algoType == NETGEN_2D:
5082 hasSimpleHyps = False
5083 simpleHyps = ["QuadranglePreference","LengthFromEdges","MaxElementArea"]
5084 for hyp in self.mesh.GetHypothesisList( self.geom ):
5085 if hyp.GetName() in simpleHyps:
5086 hasSimpleHyps = True
5087 if hyp.GetName() == "QuadranglePreference":
5088 if not toAllow: # remove QuadranglePreference
5089 self.mesh.RemoveHypothesis( self.geom, hyp )
5095 if toAllow: # add QuadranglePreference
5096 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
5101 if self.Parameters():
5102 self.params.SetQuadAllowed(toAllow)
5105 ## Defines hypothesis having several parameters
5107 # @ingroup l3_hypos_netgen
5108 def Parameters(self, which=SOLE):
5110 if self.algoType == NETGEN:
5112 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
5113 "libNETGENEngine.so", UseExisting=0)
5115 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
5116 "libNETGENEngine.so", UseExisting=0)
5117 elif self.algoType == MEFISTO:
5118 print "Mefisto algo support no multi-parameter hypothesis"
5119 elif self.algoType == NETGEN_2D:
5120 self.params = self.Hypothesis("NETGEN_Parameters_2D_ONLY", [],
5121 "libNETGENEngine.so", UseExisting=0)
5122 elif self.algoType == BLSURF:
5123 self.params = self.Hypothesis("BLSURF_Parameters", [],
5124 "libBLSURFEngine.so", UseExisting=0)
5126 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
5131 # Only for algoType == NETGEN
5132 # @ingroup l3_hypos_netgen
5133 def SetMaxSize(self, theSize):
5134 if self.Parameters():
5135 self.params.SetMaxSize(theSize)
5137 ## Sets SecondOrder flag
5139 # Only for algoType == NETGEN
5140 # @ingroup l3_hypos_netgen
5141 def SetSecondOrder(self, theVal):
5142 if self.Parameters():
5143 self.params.SetSecondOrder(theVal)
5145 ## Sets Optimize flag
5147 # Only for algoType == NETGEN
5148 # @ingroup l3_hypos_netgen
5149 def SetOptimize(self, theVal):
5150 if self.Parameters():
5151 self.params.SetOptimize(theVal)
5154 # @param theFineness is:
5155 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5157 # Only for algoType == NETGEN
5158 # @ingroup l3_hypos_netgen
5159 def SetFineness(self, theFineness):
5160 if self.Parameters():
5161 self.params.SetFineness(theFineness)
5165 # Only for algoType == NETGEN
5166 # @ingroup l3_hypos_netgen
5167 def SetGrowthRate(self, theRate):
5168 if self.Parameters():
5169 self.params.SetGrowthRate(theRate)
5171 ## Sets NbSegPerEdge
5173 # Only for algoType == NETGEN
5174 # @ingroup l3_hypos_netgen
5175 def SetNbSegPerEdge(self, theVal):
5176 if self.Parameters():
5177 self.params.SetNbSegPerEdge(theVal)
5179 ## Sets NbSegPerRadius
5181 # Only for algoType == NETGEN
5182 # @ingroup l3_hypos_netgen
5183 def SetNbSegPerRadius(self, theVal):
5184 if self.Parameters():
5185 self.params.SetNbSegPerRadius(theVal)
5187 ## Sets number of segments overriding value set by SetLocalLength()
5189 # Only for algoType == NETGEN
5190 # @ingroup l3_hypos_netgen
5191 def SetNumberOfSegments(self, theVal):
5192 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5194 ## Sets number of segments overriding value set by SetNumberOfSegments()
5196 # Only for algoType == NETGEN
5197 # @ingroup l3_hypos_netgen
5198 def SetLocalLength(self, theVal):
5199 self.Parameters(SIMPLE).SetLocalLength(theVal)
5204 # Public class: Mesh_Quadrangle
5205 # -----------------------------
5207 ## Defines a quadrangle 2D algorithm
5209 # @ingroup l3_algos_basic
5210 class Mesh_Quadrangle(Mesh_Algorithm):
5214 ## Private constructor.
5215 def __init__(self, mesh, geom=0):
5216 Mesh_Algorithm.__init__(self)
5217 self.Create(mesh, geom, "Quadrangle_2D")
5220 ## Defines "QuadrangleParameters" hypothesis
5221 # @param quadType defines the algorithm of transition between differently descretized
5222 # sides of a geometrical face:
5223 # - QUAD_STANDARD - both triangles and quadrangles are possible in the transition
5224 # area along the finer meshed sides.
5225 # - QUAD_TRIANGLE_PREF - only triangles are built in the transition area along the
5226 # finer meshed sides.
5227 # - QUAD_QUADRANGLE_PREF - only quadrangles are built in the transition area along
5228 # the finer meshed sides, iff the total quantity of segments on
5229 # all four sides of the face is even (divisible by 2).
5230 # - QUAD_QUADRANGLE_PREF_REVERSED - same as QUAD_QUADRANGLE_PREF but the transition
5231 # area is located along the coarser meshed sides.
5232 # - QUAD_REDUCED - only quadrangles are built and the transition between the sides
5233 # is made gradually, layer by layer. This type has a limitation on
5234 # the number of segments: one pair of opposite sides must have the
5235 # same number of segments, the other pair must have an even difference
5236 # between the numbers of segments on the sides.
5237 # @param triangleVertex: vertex of a trilateral geometrical face, around which triangles
5238 # will be created while other elements will be quadrangles.
5239 # Vertex can be either a GEOM_Object or a vertex ID within the
5241 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5242 # the same parameters, else (default) - creates a new one
5243 # @ingroup l3_hypos_quad
5244 def QuadrangleParameters(self, quadType=StdMeshers.QUAD_STANDARD, triangleVertex=0, UseExisting=0):
5245 vertexID = triangleVertex
5246 if isinstance( triangleVertex, geompyDC.GEOM._objref_GEOM_Object ):
5247 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, triangleVertex )
5249 compFun = lambda hyp,args: \
5250 hyp.GetQuadType() == args[0] and \
5251 ( hyp.GetTriaVertex()==args[1] or ( hyp.GetTriaVertex()<1 and args[1]<1))
5252 self.params = self.Hypothesis("QuadrangleParams", [quadType,vertexID],
5253 UseExisting = UseExisting, CompareMethod=compFun)
5255 if self.params.GetQuadType() != quadType:
5256 self.params.SetQuadType(quadType)
5258 self.params.SetTriaVertex( vertexID )
5261 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5262 # quadrangles are built in the transition area along the finer meshed sides,
5263 # iff the total quantity of segments on all four sides of the face is even.
5264 # @param reversed if True, transition area is located along the coarser meshed sides.
5265 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5266 # the same parameters, else (default) - creates a new one
5267 # @ingroup l3_hypos_quad
5268 def QuadranglePreference(self, reversed=False, UseExisting=0):
5270 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF_REVERSED,UseExisting=UseExisting)
5271 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF,UseExisting=UseExisting)
5273 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5274 # triangles are built in the transition area along the finer meshed sides.
5275 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5276 # the same parameters, else (default) - creates a new one
5277 # @ingroup l3_hypos_quad
5278 def TrianglePreference(self, UseExisting=0):
5279 return self.QuadrangleParameters(QUAD_TRIANGLE_PREF,UseExisting=UseExisting)
5281 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5282 # quadrangles are built and the transition between the sides is made gradually,
5283 # layer by layer. This type has a limitation on the number of segments: one pair
5284 # of opposite sides must have the same number of segments, the other pair must
5285 # have an even difference between the numbers of segments on the sides.
5286 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5287 # the same parameters, else (default) - creates a new one
5288 # @ingroup l3_hypos_quad
5289 def Reduced(self, UseExisting=0):
5290 return self.QuadrangleParameters(QUAD_REDUCED,UseExisting=UseExisting)
5292 ## Defines "QuadrangleParams" hypothesis with QUAD_STANDARD type of quadrangulation
5293 # @param vertex: vertex of a trilateral geometrical face, around which triangles
5294 # will be created while other elements will be quadrangles.
5295 # Vertex can be either a GEOM_Object or a vertex ID within the
5297 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5298 # the same parameters, else (default) - creates a new one
5299 # @ingroup l3_hypos_quad
5300 def TriangleVertex(self, vertex, UseExisting=0):
5301 return self.QuadrangleParameters(QUAD_STANDARD,vertex,UseExisting)
5304 # Public class: Mesh_Tetrahedron
5305 # ------------------------------
5307 ## Defines a tetrahedron 3D algorithm
5309 # @ingroup l3_algos_basic
5310 class Mesh_Tetrahedron(Mesh_Algorithm):
5315 ## Private constructor.
5316 def __init__(self, mesh, algoType, geom=0):
5317 Mesh_Algorithm.__init__(self)
5319 if algoType == NETGEN:
5321 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
5324 elif algoType == FULL_NETGEN:
5326 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5329 elif algoType == GHS3D:
5331 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
5334 elif algoType == GHS3DPRL:
5335 CheckPlugin(GHS3DPRL)
5336 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
5339 self.algoType = algoType
5341 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
5342 # @param vol for the maximum volume of each tetrahedron
5343 # @param UseExisting if ==true - searches for the existing hypothesis created with
5344 # the same parameters, else (default) - creates a new one
5345 # @ingroup l3_hypos_maxvol
5346 def MaxElementVolume(self, vol, UseExisting=0):
5347 if self.algoType == NETGEN:
5348 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
5349 CompareMethod=self.CompareMaxElementVolume)
5350 hyp.SetMaxElementVolume(vol)
5352 elif self.algoType == FULL_NETGEN:
5353 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
5356 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
5357 def CompareMaxElementVolume(self, hyp, args):
5358 return IsEqual(hyp.GetMaxElementVolume(), args[0])
5360 ## Defines hypothesis having several parameters
5362 # @ingroup l3_hypos_netgen
5363 def Parameters(self, which=SOLE):
5366 if self.algoType == FULL_NETGEN:
5368 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
5369 "libNETGENEngine.so", UseExisting=0)
5371 self.params = self.Hypothesis("NETGEN_Parameters", [],
5372 "libNETGENEngine.so", UseExisting=0)
5374 elif self.algoType == NETGEN:
5375 self.params = self.Hypothesis("NETGEN_Parameters_3D", [],
5376 "libNETGENEngine.so", UseExisting=0)
5378 elif self.algoType == GHS3D:
5379 self.params = self.Hypothesis("GHS3D_Parameters", [],
5380 "libGHS3DEngine.so", UseExisting=0)
5382 elif self.algoType == GHS3DPRL:
5383 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
5384 "libGHS3DPRLEngine.so", UseExisting=0)
5386 print "Warning: %s supports no multi-parameter hypothesis"%self.algo.GetName()
5391 # Parameter of FULL_NETGEN and NETGEN
5392 # @ingroup l3_hypos_netgen
5393 def SetMaxSize(self, theSize):
5394 self.Parameters().SetMaxSize(theSize)
5396 ## Sets SecondOrder flag
5397 # Parameter of FULL_NETGEN
5398 # @ingroup l3_hypos_netgen
5399 def SetSecondOrder(self, theVal):
5400 self.Parameters().SetSecondOrder(theVal)
5402 ## Sets Optimize flag
5403 # Parameter of FULL_NETGEN and NETGEN
5404 # @ingroup l3_hypos_netgen
5405 def SetOptimize(self, theVal):
5406 self.Parameters().SetOptimize(theVal)
5409 # @param theFineness is:
5410 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5411 # Parameter of FULL_NETGEN
5412 # @ingroup l3_hypos_netgen
5413 def SetFineness(self, theFineness):
5414 self.Parameters().SetFineness(theFineness)
5417 # Parameter of FULL_NETGEN
5418 # @ingroup l3_hypos_netgen
5419 def SetGrowthRate(self, theRate):
5420 self.Parameters().SetGrowthRate(theRate)
5422 ## Sets NbSegPerEdge
5423 # Parameter of FULL_NETGEN
5424 # @ingroup l3_hypos_netgen
5425 def SetNbSegPerEdge(self, theVal):
5426 self.Parameters().SetNbSegPerEdge(theVal)
5428 ## Sets NbSegPerRadius
5429 # Parameter of FULL_NETGEN
5430 # @ingroup l3_hypos_netgen
5431 def SetNbSegPerRadius(self, theVal):
5432 self.Parameters().SetNbSegPerRadius(theVal)
5434 ## Sets number of segments overriding value set by SetLocalLength()
5435 # Only for algoType == NETGEN_FULL
5436 # @ingroup l3_hypos_netgen
5437 def SetNumberOfSegments(self, theVal):
5438 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5440 ## Sets number of segments overriding value set by SetNumberOfSegments()
5441 # Only for algoType == NETGEN_FULL
5442 # @ingroup l3_hypos_netgen
5443 def SetLocalLength(self, theVal):
5444 self.Parameters(SIMPLE).SetLocalLength(theVal)
5446 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
5447 # Overrides value set by LengthFromEdges()
5448 # Only for algoType == NETGEN_FULL
5449 # @ingroup l3_hypos_netgen
5450 def MaxElementArea(self, area):
5451 self.Parameters(SIMPLE).SetMaxElementArea(area)
5453 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
5454 # Overrides value set by MaxElementArea()
5455 # Only for algoType == NETGEN_FULL
5456 # @ingroup l3_hypos_netgen
5457 def LengthFromEdges(self):
5458 self.Parameters(SIMPLE).LengthFromEdges()
5460 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
5461 # Overrides value set by MaxElementVolume()
5462 # Only for algoType == NETGEN_FULL
5463 # @ingroup l3_hypos_netgen
5464 def LengthFromFaces(self):
5465 self.Parameters(SIMPLE).LengthFromFaces()
5467 ## To mesh "holes" in a solid or not. Default is to mesh.
5468 # @ingroup l3_hypos_ghs3dh
5469 def SetToMeshHoles(self, toMesh):
5470 # Parameter of GHS3D
5471 self.Parameters().SetToMeshHoles(toMesh)
5473 ## Set Optimization level:
5474 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
5475 # Strong_Optimization.
5476 # Default is Standard_Optimization
5477 # @ingroup l3_hypos_ghs3dh
5478 def SetOptimizationLevel(self, level):
5479 # Parameter of GHS3D
5480 self.Parameters().SetOptimizationLevel(level)
5482 ## Maximal size of memory to be used by the algorithm (in Megabytes).
5483 # @ingroup l3_hypos_ghs3dh
5484 def SetMaximumMemory(self, MB):
5485 # Advanced parameter of GHS3D
5486 self.Parameters().SetMaximumMemory(MB)
5488 ## Initial size of memory to be used by the algorithm (in Megabytes) in
5489 # automatic memory adjustment mode.
5490 # @ingroup l3_hypos_ghs3dh
5491 def SetInitialMemory(self, MB):
5492 # Advanced parameter of GHS3D
5493 self.Parameters().SetInitialMemory(MB)
5495 ## Path to working directory.
5496 # @ingroup l3_hypos_ghs3dh
5497 def SetWorkingDirectory(self, path):
5498 # Advanced parameter of GHS3D
5499 self.Parameters().SetWorkingDirectory(path)
5501 ## To keep working files or remove them. Log file remains in case of errors anyway.
5502 # @ingroup l3_hypos_ghs3dh
5503 def SetKeepFiles(self, toKeep):
5504 # Advanced parameter of GHS3D and GHS3DPRL
5505 self.Parameters().SetKeepFiles(toKeep)
5507 ## To set verbose level [0-10]. <ul>
5508 #<li> 0 - no standard output,
5509 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
5510 # indicates when the final mesh is being saved. In addition the software
5511 # gives indication regarding the CPU time.
5512 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
5513 # histogram of the skin mesh, quality statistics histogram together with
5514 # the characteristics of the final mesh.</ul>
5515 # @ingroup l3_hypos_ghs3dh
5516 def SetVerboseLevel(self, level):
5517 # Advanced parameter of GHS3D
5518 self.Parameters().SetVerboseLevel(level)
5520 ## To create new nodes.
5521 # @ingroup l3_hypos_ghs3dh
5522 def SetToCreateNewNodes(self, toCreate):
5523 # Advanced parameter of GHS3D
5524 self.Parameters().SetToCreateNewNodes(toCreate)
5526 ## To use boundary recovery version which tries to create mesh on a very poor
5527 # quality surface mesh.
5528 # @ingroup l3_hypos_ghs3dh
5529 def SetToUseBoundaryRecoveryVersion(self, toUse):
5530 # Advanced parameter of GHS3D
5531 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
5533 ## Applies finite-element correction by replacing overconstrained elements where
5534 # it is possible. The process is cutting first the overconstrained edges and
5535 # second the overconstrained facets. This insure that no edges have two boundary
5536 # vertices and that no facets have three boundary vertices.
5537 # @ingroup l3_hypos_ghs3dh
5538 def SetFEMCorrection(self, toUseFem):
5539 # Advanced parameter of GHS3D
5540 self.Parameters().SetFEMCorrection(toUseFem)
5542 ## To removes initial central point.
5543 # @ingroup l3_hypos_ghs3dh
5544 def SetToRemoveCentralPoint(self, toRemove):
5545 # Advanced parameter of GHS3D
5546 self.Parameters().SetToRemoveCentralPoint(toRemove)
5548 ## To set an enforced vertex.
5549 # @ingroup l3_hypos_ghs3dh
5550 def SetEnforcedVertex(self, x, y, z, size):
5551 # Advanced parameter of GHS3D
5552 return self.Parameters().SetEnforcedVertex(x, y, z, size)
5554 ## To set an enforced vertex and add it in the group "groupName".
5555 # Only on meshes w/o geometry
5556 # @ingroup l3_hypos_ghs3dh
5557 def SetEnforcedVertexWithGroup(self, x, y, z, size, groupName):
5558 # Advanced parameter of GHS3D
5559 return self.Parameters().SetEnforcedVertex(x, y, z, size,groupName)
5561 ## To remove an enforced vertex.
5562 # @ingroup l3_hypos_ghs3dh
5563 def RemoveEnforcedVertex(self, x, y, z):
5564 # Advanced parameter of GHS3D
5565 return self.Parameters().RemoveEnforcedVertex(x, y, z)
5567 ## To set an enforced vertex given a GEOM vertex, group or compound.
5568 # @ingroup l3_hypos_ghs3dh
5569 def SetEnforcedVertexGeom(self, theVertex, size):
5570 self.AssureGeomPublished( theVertex )
5571 # Advanced parameter of GHS3D
5572 return self.Parameters().SetEnforcedVertexGeom(theVertex, size)
5574 ## To set an enforced vertex given a GEOM vertex, group or compound
5575 # and add it in the group "groupName".
5576 # Only on meshes w/o geometry
5577 # @ingroup l3_hypos_ghs3dh
5578 def SetEnforcedVertexGeomWithGroup(self, theVertex, size, groupName):
5579 self.AssureGeomPublished( theVertex )
5580 # Advanced parameter of GHS3D
5581 return self.Parameters().SetEnforcedVertexGeomWithGroup(theVertex, size,groupName)
5583 ## To remove an enforced vertex given a GEOM vertex, group or compound.
5584 # @ingroup l3_hypos_ghs3dh
5585 def RemoveEnforcedVertexGeom(self, theVertex):
5586 self.AssureGeomPublished( theVertex )
5587 # Advanced parameter of GHS3D
5588 return self.Parameters().RemoveEnforcedVertexGeom(theVertex)
5590 ## To set an enforced mesh.
5591 # @ingroup l3_hypos_ghs3dh
5592 def SetEnforcedMesh(self, theSource, elementType):
5593 # Advanced parameter of GHS3D
5594 return self.Parameters().SetEnforcedMesh(theSource, elementType)
5596 ## To set an enforced mesh and add the enforced elements in the group "groupName".
5597 # @ingroup l3_hypos_ghs3dh
5598 def SetEnforcedMeshWithGroup(self, theSource, elementType, groupName):
5599 # Advanced parameter of GHS3D
5600 return self.Parameters().SetEnforcedMeshWithGroup(theSource, elementType, groupName)
5602 ## To set an enforced mesh with given size.
5603 # @ingroup l3_hypos_ghs3dh
5604 def SetEnforcedMeshSize(self, theSource, elementType, size):
5605 # Advanced parameter of GHS3D
5606 return self.Parameters().SetEnforcedMeshSize(theSource, elementType, size)
5608 ## To set an enforced mesh with given size and add the enforced elements in the group "groupName".
5609 # @ingroup l3_hypos_ghs3dh
5610 def SetEnforcedMeshSizeWithGroup(self, theSource, elementType, size, groupName):
5611 # Advanced parameter of GHS3D
5612 return self.Parameters().SetEnforcedMeshSizeWithGroup(theSource, elementType, size, groupName)
5614 ## Sets command line option as text.
5615 # @ingroup l3_hypos_ghs3dh
5616 def SetTextOption(self, option):
5617 # Advanced parameter of GHS3D
5618 self.Parameters().SetTextOption(option)
5620 ## Sets MED files name and path.
5621 def SetMEDName(self, value):
5622 self.Parameters().SetMEDName(value)
5624 ## Sets the number of partition of the initial mesh
5625 def SetNbPart(self, value):
5626 self.Parameters().SetNbPart(value)
5628 ## When big mesh, start tepal in background
5629 def SetBackground(self, value):
5630 self.Parameters().SetBackground(value)
5632 # Public class: Mesh_Hexahedron
5633 # ------------------------------
5635 ## Defines a hexahedron 3D algorithm
5637 # @ingroup l3_algos_basic
5638 class Mesh_Hexahedron(Mesh_Algorithm):
5643 ## Private constructor.
5644 def __init__(self, mesh, algoType=Hexa, geom=0):
5645 Mesh_Algorithm.__init__(self)
5647 self.algoType = algoType
5649 if algoType == Hexa:
5650 self.Create(mesh, geom, "Hexa_3D")
5653 elif algoType == Hexotic:
5654 CheckPlugin(Hexotic)
5655 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
5658 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
5659 # @ingroup l3_hypos_hexotic
5660 def MinMaxQuad(self, min=3, max=8, quad=True):
5661 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
5663 self.params.SetHexesMinLevel(min)
5664 self.params.SetHexesMaxLevel(max)
5665 self.params.SetHexoticQuadrangles(quad)
5668 # Deprecated, only for compatibility!
5669 # Public class: Mesh_Netgen
5670 # ------------------------------
5672 ## Defines a NETGEN-based 2D or 3D algorithm
5673 # that needs no discrete boundary (i.e. independent)
5675 # This class is deprecated, only for compatibility!
5678 # @ingroup l3_algos_basic
5679 class Mesh_Netgen(Mesh_Algorithm):
5683 ## Private constructor.
5684 def __init__(self, mesh, is3D, geom=0):
5685 Mesh_Algorithm.__init__(self)
5691 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5695 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
5698 ## Defines the hypothesis containing parameters of the algorithm
5699 def Parameters(self):
5701 hyp = self.Hypothesis("NETGEN_Parameters", [],
5702 "libNETGENEngine.so", UseExisting=0)
5704 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
5705 "libNETGENEngine.so", UseExisting=0)
5708 # Public class: Mesh_Projection1D
5709 # ------------------------------
5711 ## Defines a projection 1D algorithm
5712 # @ingroup l3_algos_proj
5714 class Mesh_Projection1D(Mesh_Algorithm):
5716 ## Private constructor.
5717 def __init__(self, mesh, geom=0):
5718 Mesh_Algorithm.__init__(self)
5719 self.Create(mesh, geom, "Projection_1D")
5721 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
5722 # a mesh pattern is taken, and, optionally, the association of vertices
5723 # between the source edge and a target edge (to which a hypothesis is assigned)
5724 # @param edge from which nodes distribution is taken
5725 # @param mesh from which nodes distribution is taken (optional)
5726 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
5727 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
5728 # to associate with \a srcV (optional)
5729 # @param UseExisting if ==true - searches for the existing hypothesis created with
5730 # the same parameters, else (default) - creates a new one
5731 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
5732 self.AssureGeomPublished( edge )
5733 self.AssureGeomPublished( srcV )
5734 self.AssureGeomPublished( tgtV )
5735 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
5737 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
5738 hyp.SetSourceEdge( edge )
5739 if not mesh is None and isinstance(mesh, Mesh):
5740 mesh = mesh.GetMesh()
5741 hyp.SetSourceMesh( mesh )
5742 hyp.SetVertexAssociation( srcV, tgtV )
5745 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
5746 #def CompareSourceEdge(self, hyp, args):
5747 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
5751 # Public class: Mesh_Projection2D
5752 # ------------------------------
5754 ## Defines a projection 2D algorithm
5755 # @ingroup l3_algos_proj
5757 class Mesh_Projection2D(Mesh_Algorithm):
5759 ## Private constructor.
5760 def __init__(self, mesh, geom=0):
5761 Mesh_Algorithm.__init__(self)
5762 self.Create(mesh, geom, "Projection_2D")
5764 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
5765 # a mesh pattern is taken, and, optionally, the association of vertices
5766 # between the source face and the target face (to which a hypothesis is assigned)
5767 # @param face from which the mesh pattern is taken
5768 # @param mesh from which the mesh pattern is taken (optional)
5769 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
5770 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
5771 # to associate with \a srcV1 (optional)
5772 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
5773 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
5774 # to associate with \a srcV2 (optional)
5775 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
5776 # the same parameters, else (default) - forces the creation a new one
5778 # Note: all association vertices must belong to one edge of a face
5779 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
5780 srcV2=None, tgtV2=None, UseExisting=0):
5781 for geom in [ face, srcV1, tgtV1, srcV2, tgtV2 ]:
5782 self.AssureGeomPublished( geom )
5783 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
5785 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
5786 hyp.SetSourceFace( face )
5787 if isinstance(mesh, Mesh):
5788 mesh = mesh.GetMesh()
5789 hyp.SetSourceMesh( mesh )
5790 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5793 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
5794 #def CompareSourceFace(self, hyp, args):
5795 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
5798 # Public class: Mesh_Projection3D
5799 # ------------------------------
5801 ## Defines a projection 3D algorithm
5802 # @ingroup l3_algos_proj
5804 class Mesh_Projection3D(Mesh_Algorithm):
5806 ## Private constructor.
5807 def __init__(self, mesh, geom=0):
5808 Mesh_Algorithm.__init__(self)
5809 self.Create(mesh, geom, "Projection_3D")
5811 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
5812 # the mesh pattern is taken, and, optionally, the association of vertices
5813 # between the source and the target solid (to which a hipothesis is assigned)
5814 # @param solid from where the mesh pattern is taken
5815 # @param mesh from where the mesh pattern is taken (optional)
5816 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
5817 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
5818 # to associate with \a srcV1 (optional)
5819 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
5820 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
5821 # to associate with \a srcV2 (optional)
5822 # @param UseExisting - if ==true - searches for the existing hypothesis created with
5823 # the same parameters, else (default) - creates a new one
5825 # Note: association vertices must belong to one edge of a solid
5826 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
5827 srcV2=0, tgtV2=0, UseExisting=0):
5828 for geom in [ solid, srcV1, tgtV1, srcV2, tgtV2 ]:
5829 self.AssureGeomPublished( geom )
5830 hyp = self.Hypothesis("ProjectionSource3D",
5831 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
5833 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
5834 hyp.SetSource3DShape( solid )
5835 if not mesh is None and isinstance(mesh, Mesh):
5836 mesh = mesh.GetMesh()
5837 hyp.SetSourceMesh( mesh )
5838 if srcV1 and srcV2 and tgtV1 and tgtV2:
5839 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5840 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
5843 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
5844 #def CompareSourceShape3D(self, hyp, args):
5845 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
5849 # Public class: Mesh_Prism
5850 # ------------------------
5852 ## Defines a 3D extrusion algorithm
5853 # @ingroup l3_algos_3dextr
5855 class Mesh_Prism3D(Mesh_Algorithm):
5857 ## Private constructor.
5858 def __init__(self, mesh, geom=0):
5859 Mesh_Algorithm.__init__(self)
5860 self.Create(mesh, geom, "Prism_3D")
5862 # Public class: Mesh_RadialPrism
5863 # -------------------------------
5865 ## Defines a Radial Prism 3D algorithm
5866 # @ingroup l3_algos_radialp
5868 class Mesh_RadialPrism3D(Mesh_Algorithm):
5870 ## Private constructor.
5871 def __init__(self, mesh, geom=0):
5872 Mesh_Algorithm.__init__(self)
5873 self.Create(mesh, geom, "RadialPrism_3D")
5875 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
5876 self.nbLayers = None
5878 ## Return 3D hypothesis holding the 1D one
5879 def Get3DHypothesis(self):
5880 return self.distribHyp
5882 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5883 # hypothesis. Returns the created hypothesis
5884 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5885 #print "OwnHypothesis",hypType
5886 if not self.nbLayers is None:
5887 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5888 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5889 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5890 self.mesh.smeshpyD.SetCurrentStudy( None )
5891 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5892 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5893 self.distribHyp.SetLayerDistribution( hyp )
5896 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
5897 # prisms to build between the inner and outer shells
5898 # @param n number of layers
5899 # @param UseExisting if ==true - searches for the existing hypothesis created with
5900 # the same parameters, else (default) - creates a new one
5901 def NumberOfLayers(self, n, UseExisting=0):
5902 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5903 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
5904 CompareMethod=self.CompareNumberOfLayers)
5905 self.nbLayers.SetNumberOfLayers( n )
5906 return self.nbLayers
5908 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5909 def CompareNumberOfLayers(self, hyp, args):
5910 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5912 ## Defines "LocalLength" hypothesis, specifying the segment length
5913 # to build between the inner and the outer shells
5914 # @param l the length of segments
5915 # @param p the precision of rounding
5916 def LocalLength(self, l, p=1e-07):
5917 hyp = self.OwnHypothesis("LocalLength", [l,p])
5922 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
5923 # prisms to build between the inner and the outer shells.
5924 # @param n the number of layers
5925 # @param s the scale factor (optional)
5926 def NumberOfSegments(self, n, s=[]):
5928 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5930 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5931 hyp.SetDistrType( 1 )
5932 hyp.SetScaleFactor(s)
5933 hyp.SetNumberOfSegments(n)
5936 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5937 # to build between the inner and the outer shells with a length that changes in arithmetic progression
5938 # @param start the length of the first segment
5939 # @param end the length of the last segment
5940 def Arithmetic1D(self, start, end ):
5941 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5942 hyp.SetLength(start, 1)
5943 hyp.SetLength(end , 0)
5946 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5947 # to build between the inner and the outer shells as geometric length increasing
5948 # @param start for the length of the first segment
5949 # @param end for the length of the last segment
5950 def StartEndLength(self, start, end):
5951 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5952 hyp.SetLength(start, 1)
5953 hyp.SetLength(end , 0)
5956 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5957 # to build between the inner and outer shells
5958 # @param fineness defines the quality of the mesh within the range [0-1]
5959 def AutomaticLength(self, fineness=0):
5960 hyp = self.OwnHypothesis("AutomaticLength")
5961 hyp.SetFineness( fineness )
5964 # Public class: Mesh_RadialQuadrangle1D2D
5965 # -------------------------------
5967 ## Defines a Radial Quadrangle 1D2D algorithm
5968 # @ingroup l2_algos_radialq
5970 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
5972 ## Private constructor.
5973 def __init__(self, mesh, geom=0):
5974 Mesh_Algorithm.__init__(self)
5975 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5977 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
5978 self.nbLayers = None
5980 ## Return 2D hypothesis holding the 1D one
5981 def Get2DHypothesis(self):
5982 return self.distribHyp
5984 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5985 # hypothesis. Returns the created hypothesis
5986 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5987 #print "OwnHypothesis",hypType
5989 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5990 if self.distribHyp is None:
5991 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5993 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5994 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5995 self.mesh.smeshpyD.SetCurrentStudy( None )
5996 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5997 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5998 self.distribHyp.SetLayerDistribution( hyp )
6001 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
6002 # @param n number of layers
6003 # @param UseExisting if ==true - searches for the existing hypothesis created with
6004 # the same parameters, else (default) - creates a new one
6005 def NumberOfLayers(self, n, UseExisting=0):
6007 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
6008 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
6009 CompareMethod=self.CompareNumberOfLayers)
6010 self.nbLayers.SetNumberOfLayers( n )
6011 return self.nbLayers
6013 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
6014 def CompareNumberOfLayers(self, hyp, args):
6015 return IsEqual(hyp.GetNumberOfLayers(), args[0])
6017 ## Defines "LocalLength" hypothesis, specifying the segment length
6018 # @param l the length of segments
6019 # @param p the precision of rounding
6020 def LocalLength(self, l, p=1e-07):
6021 hyp = self.OwnHypothesis("LocalLength", [l,p])
6026 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
6027 # @param n the number of layers
6028 # @param s the scale factor (optional)
6029 def NumberOfSegments(self, n, s=[]):
6031 hyp = self.OwnHypothesis("NumberOfSegments", [n])
6033 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
6034 hyp.SetDistrType( 1 )
6035 hyp.SetScaleFactor(s)
6036 hyp.SetNumberOfSegments(n)
6039 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
6040 # with a length that changes in arithmetic progression
6041 # @param start the length of the first segment
6042 # @param end the length of the last segment
6043 def Arithmetic1D(self, start, end ):
6044 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
6045 hyp.SetLength(start, 1)
6046 hyp.SetLength(end , 0)
6049 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
6050 # as geometric length increasing
6051 # @param start for the length of the first segment
6052 # @param end for the length of the last segment
6053 def StartEndLength(self, start, end):
6054 hyp = self.OwnHypothesis("StartEndLength", [start, end])
6055 hyp.SetLength(start, 1)
6056 hyp.SetLength(end , 0)
6059 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
6060 # @param fineness defines the quality of the mesh within the range [0-1]
6061 def AutomaticLength(self, fineness=0):
6062 hyp = self.OwnHypothesis("AutomaticLength")
6063 hyp.SetFineness( fineness )
6067 # Public class: Mesh_UseExistingElements
6068 # --------------------------------------
6069 ## Defines a Radial Quadrangle 1D2D algorithm
6070 # @ingroup l3_algos_basic
6072 class Mesh_UseExistingElements(Mesh_Algorithm):
6074 def __init__(self, dim, mesh, geom=0):
6076 self.Create(mesh, geom, "Import_1D")
6078 self.Create(mesh, geom, "Import_1D2D")
6081 ## Defines "Source edges" hypothesis, specifying groups of edges to import
6082 # @param groups list of groups of edges
6083 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
6084 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
6085 # @param UseExisting if ==true - searches for the existing hypothesis created with
6086 # the same parameters, else (default) - creates a new one
6087 def SourceEdges(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
6088 if self.algo.GetName() == "Import_2D":
6089 raise ValueError, "algoritm dimension mismatch"
6090 for group in groups:
6091 self.AssureGeomPublished( group )
6092 hyp = self.Hypothesis("ImportSource1D", [groups, toCopyMesh, toCopyGroups],
6093 UseExisting=UseExisting, CompareMethod=self._compareHyp)
6094 hyp.SetSourceEdges(groups)
6095 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
6098 ## Defines "Source faces" hypothesis, specifying groups of faces to import
6099 # @param groups list of groups of faces
6100 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
6101 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
6102 # @param UseExisting if ==true - searches for the existing hypothesis created with
6103 # the same parameters, else (default) - creates a new one
6104 def SourceFaces(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
6105 if self.algo.GetName() == "Import_1D":
6106 raise ValueError, "algoritm dimension mismatch"
6107 for group in groups:
6108 self.AssureGeomPublished( group )
6109 hyp = self.Hypothesis("ImportSource2D", [groups, toCopyMesh, toCopyGroups],
6110 UseExisting=UseExisting, CompareMethod=self._compareHyp)
6111 hyp.SetSourceFaces(groups)
6112 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
6115 def _compareHyp(self,hyp,args):
6116 if hasattr( hyp, "GetSourceEdges"):
6117 entries = hyp.GetSourceEdges()
6119 entries = hyp.GetSourceFaces()
6121 toCopyMesh,toCopyGroups = hyp.GetCopySourceMesh()
6122 if len(entries)==len(groups) and toCopyMesh==args[1] and toCopyGroups==args[2]:
6124 study = self.mesh.smeshpyD.GetCurrentStudy()
6127 ior = salome.orb.object_to_string(g)
6128 sobj = study.FindObjectIOR(ior)
6129 if sobj: entries2.append( sobj.GetID() )
6134 return entries == entries2
6138 # Private class: Mesh_UseExisting
6139 # -------------------------------
6140 class Mesh_UseExisting(Mesh_Algorithm):
6142 def __init__(self, dim, mesh, geom=0):
6144 self.Create(mesh, geom, "UseExisting_1D")
6146 self.Create(mesh, geom, "UseExisting_2D")
6149 import salome_notebook
6150 notebook = salome_notebook.notebook
6152 ##Return values of the notebook variables
6153 def ParseParameters(last, nbParams,nbParam, value):
6157 listSize = len(last)
6158 for n in range(0,nbParams):
6160 if counter < listSize:
6161 strResult = strResult + last[counter]
6163 strResult = strResult + ""
6165 if isinstance(value, str):
6166 if notebook.isVariable(value):
6167 result = notebook.get(value)
6168 strResult=strResult+value
6170 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
6172 strResult=strResult+str(value)
6174 if nbParams - 1 != counter:
6175 strResult=strResult+var_separator #":"
6177 return result, strResult
6179 #Wrapper class for StdMeshers_LocalLength hypothesis
6180 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
6182 ## Set Length parameter value
6183 # @param length numerical value or name of variable from notebook
6184 def SetLength(self, length):
6185 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
6186 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6187 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
6189 ## Set Precision parameter value
6190 # @param precision numerical value or name of variable from notebook
6191 def SetPrecision(self, precision):
6192 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
6193 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6194 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
6196 #Registering the new proxy for LocalLength
6197 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
6200 #Wrapper class for StdMeshers_LayerDistribution hypothesis
6201 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
6203 def SetLayerDistribution(self, hypo):
6204 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
6205 hypo.ClearParameters();
6206 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
6208 #Registering the new proxy for LayerDistribution
6209 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
6211 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
6212 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
6214 ## Set Length parameter value
6215 # @param length numerical value or name of variable from notebook
6216 def SetLength(self, length):
6217 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
6218 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
6219 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
6221 #Registering the new proxy for SegmentLengthAroundVertex
6222 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
6225 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
6226 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
6228 ## Set Length parameter value
6229 # @param length numerical value or name of variable from notebook
6230 # @param isStart true is length is Start Length, otherwise false
6231 def SetLength(self, length, isStart):
6235 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
6236 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
6237 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
6239 #Registering the new proxy for Arithmetic1D
6240 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
6242 #Wrapper class for StdMeshers_Deflection1D hypothesis
6243 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
6245 ## Set Deflection parameter value
6246 # @param deflection numerical value or name of variable from notebook
6247 def SetDeflection(self, deflection):
6248 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
6249 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
6250 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
6252 #Registering the new proxy for Deflection1D
6253 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
6255 #Wrapper class for StdMeshers_StartEndLength hypothesis
6256 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
6258 ## Set Length parameter value
6259 # @param length numerical value or name of variable from notebook
6260 # @param isStart true is length is Start Length, otherwise false
6261 def SetLength(self, length, isStart):
6265 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
6266 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
6267 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
6269 #Registering the new proxy for StartEndLength
6270 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
6272 #Wrapper class for StdMeshers_MaxElementArea hypothesis
6273 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
6275 ## Set Max Element Area parameter value
6276 # @param area numerical value or name of variable from notebook
6277 def SetMaxElementArea(self, area):
6278 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
6279 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
6280 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
6282 #Registering the new proxy for MaxElementArea
6283 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
6286 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
6287 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
6289 ## Set Max Element Volume parameter value
6290 # @param volume numerical value or name of variable from notebook
6291 def SetMaxElementVolume(self, volume):
6292 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
6293 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
6294 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
6296 #Registering the new proxy for MaxElementVolume
6297 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
6300 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
6301 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
6303 ## Set Number Of Layers parameter value
6304 # @param nbLayers numerical value or name of variable from notebook
6305 def SetNumberOfLayers(self, nbLayers):
6306 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
6307 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
6308 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
6310 #Registering the new proxy for NumberOfLayers
6311 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
6313 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
6314 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
6316 ## Set Number Of Segments parameter value
6317 # @param nbSeg numerical value or name of variable from notebook
6318 def SetNumberOfSegments(self, nbSeg):
6319 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
6320 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
6321 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6322 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
6324 ## Set Scale Factor parameter value
6325 # @param factor numerical value or name of variable from notebook
6326 def SetScaleFactor(self, factor):
6327 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
6328 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6329 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
6331 #Registering the new proxy for NumberOfSegments
6332 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
6334 if not noNETGENPlugin:
6335 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
6336 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
6338 ## Set Max Size parameter value
6339 # @param maxsize numerical value or name of variable from notebook
6340 def SetMaxSize(self, maxsize):
6341 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6342 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
6343 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6344 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
6346 ## Set Growth Rate parameter value
6347 # @param value numerical value or name of variable from notebook
6348 def SetGrowthRate(self, value):
6349 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6350 value, parameters = ParseParameters(lastParameters,4,2,value)
6351 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6352 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
6354 ## Set Number of Segments per Edge parameter value
6355 # @param value numerical value or name of variable from notebook
6356 def SetNbSegPerEdge(self, value):
6357 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6358 value, parameters = ParseParameters(lastParameters,4,3,value)
6359 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6360 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
6362 ## Set Number of Segments per Radius parameter value
6363 # @param value numerical value or name of variable from notebook
6364 def SetNbSegPerRadius(self, value):
6365 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6366 value, parameters = ParseParameters(lastParameters,4,4,value)
6367 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6368 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
6370 #Registering the new proxy for NETGENPlugin_Hypothesis
6371 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
6374 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
6375 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
6378 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
6379 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
6381 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
6382 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
6384 ## Set Number of Segments parameter value
6385 # @param nbSeg numerical value or name of variable from notebook
6386 def SetNumberOfSegments(self, nbSeg):
6387 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6388 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
6389 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6390 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
6392 ## Set Local Length parameter value
6393 # @param length numerical value or name of variable from notebook
6394 def SetLocalLength(self, length):
6395 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6396 length, parameters = ParseParameters(lastParameters,2,1,length)
6397 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6398 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
6400 ## Set Max Element Area parameter value
6401 # @param area numerical value or name of variable from notebook
6402 def SetMaxElementArea(self, area):
6403 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6404 area, parameters = ParseParameters(lastParameters,2,2,area)
6405 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6406 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
6408 def LengthFromEdges(self):
6409 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6411 value, parameters = ParseParameters(lastParameters,2,2,value)
6412 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6413 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
6415 #Registering the new proxy for NETGEN_SimpleParameters_2D
6416 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
6419 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
6420 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
6421 ## Set Max Element Volume parameter value
6422 # @param volume numerical value or name of variable from notebook
6423 def SetMaxElementVolume(self, volume):
6424 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6425 volume, parameters = ParseParameters(lastParameters,3,3,volume)
6426 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6427 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
6429 def LengthFromFaces(self):
6430 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6432 value, parameters = ParseParameters(lastParameters,3,3,value)
6433 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6434 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
6436 #Registering the new proxy for NETGEN_SimpleParameters_3D
6437 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
6439 pass # if not noNETGENPlugin:
6441 class Pattern(SMESH._objref_SMESH_Pattern):
6443 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
6445 if isinstance(theNodeIndexOnKeyPoint1,str):
6447 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
6449 theNodeIndexOnKeyPoint1 -= 1
6450 theMesh.SetParameters(Parameters)
6451 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
6453 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
6456 if isinstance(theNode000Index,str):
6458 if isinstance(theNode001Index,str):
6460 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
6462 theNode000Index -= 1
6464 theNode001Index -= 1
6465 theMesh.SetParameters(Parameters)
6466 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
6468 #Registering the new proxy for Pattern
6469 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)