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 ExportMED() 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 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1689 # @ingroup l2_impexp
1690 def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1, meshPart=None):
1692 if isinstance( meshPart, list ):
1693 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1694 self.mesh.ExportPartToMED( meshPart, f, auto_groups, version, overwrite )
1696 self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
1698 ## Exports the mesh in a file in DAT format
1699 # @param f the file name
1700 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1701 # @ingroup l2_impexp
1702 def ExportDAT(self, f, meshPart=None):
1704 if isinstance( meshPart, list ):
1705 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1706 self.mesh.ExportPartToDAT( meshPart, f )
1708 self.mesh.ExportDAT(f)
1710 ## Exports the mesh in a file in UNV format
1711 # @param f the file name
1712 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1713 # @ingroup l2_impexp
1714 def ExportUNV(self, f, meshPart=None):
1716 if isinstance( meshPart, list ):
1717 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1718 self.mesh.ExportPartToUNV( meshPart, f )
1720 self.mesh.ExportUNV(f)
1722 ## Export the mesh in a file in STL format
1723 # @param f the file name
1724 # @param ascii defines the file encoding
1725 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1726 # @ingroup l2_impexp
1727 def ExportSTL(self, f, ascii=1, meshPart=None):
1729 if isinstance( meshPart, list ):
1730 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1731 self.mesh.ExportPartToSTL( meshPart, f, ascii )
1733 self.mesh.ExportSTL(f, ascii)
1736 # Operations with groups:
1737 # ----------------------
1739 ## Creates an empty mesh group
1740 # @param elementType the type of elements in the group
1741 # @param name the name of the mesh group
1742 # @return SMESH_Group
1743 # @ingroup l2_grps_create
1744 def CreateEmptyGroup(self, elementType, name):
1745 return self.mesh.CreateGroup(elementType, name)
1747 ## Creates a mesh group based on the geometrical object \a grp
1748 # and gives a \a name, \n if this parameter is not defined
1749 # the name is the same as the geometrical group name
1750 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1751 # @param name the name of the mesh group
1752 # @param typ the type of elements in the group. If not set, it is
1753 # automatically detected by the type of the geometry
1754 # @return SMESH_GroupOnGeom
1755 # @ingroup l2_grps_create
1756 def GroupOnGeom(self, grp, name="", typ=None):
1758 name = grp.GetName()
1761 tgeo = str(grp.GetShapeType())
1762 if tgeo == "VERTEX":
1764 elif tgeo == "EDGE":
1766 elif tgeo == "FACE":
1768 elif tgeo == "SOLID":
1770 elif tgeo == "SHELL":
1772 elif tgeo == "COMPOUND":
1773 try: # it raises on a compound of compounds
1774 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1775 print "Mesh.Group: empty geometric group", GetName( grp )
1780 if grp.GetType() == 37: # GEOMImpl_Types.hxx: #define GEOM_GROUP 37
1782 tgeo = self.geompyD.GetType(grp)
1783 if tgeo == geompyDC.ShapeType["VERTEX"]:
1785 elif tgeo == geompyDC.ShapeType["EDGE"]:
1787 elif tgeo == geompyDC.ShapeType["FACE"]:
1789 elif tgeo == geompyDC.ShapeType["SOLID"]:
1795 for elemType, shapeType in [[VOLUME,"SOLID"],[FACE,"FACE"],
1796 [EDGE,"EDGE"],[NODE,"VERTEX"]]:
1797 if self.geompyD.SubShapeAll(grp,geompyDC.ShapeType[shapeType]):
1805 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1808 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1810 ## Creates a mesh group by the given ids of elements
1811 # @param groupName the name of the mesh group
1812 # @param elementType the type of elements in the group
1813 # @param elemIDs the list of ids
1814 # @return SMESH_Group
1815 # @ingroup l2_grps_create
1816 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1817 group = self.mesh.CreateGroup(elementType, groupName)
1821 ## Creates a mesh group by the given conditions
1822 # @param groupName the name of the mesh group
1823 # @param elementType the type of elements in the group
1824 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1825 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1826 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1827 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1828 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
1829 # FT_LyingOnGeom, FT_CoplanarFaces criteria
1830 # @return SMESH_Group
1831 # @ingroup l2_grps_create
1835 CritType=FT_Undefined,
1838 UnaryOp=FT_Undefined,
1840 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined,Tolerance)
1841 group = self.MakeGroupByCriterion(groupName, aCriterion)
1844 ## Creates a mesh group by the given criterion
1845 # @param groupName the name of the mesh group
1846 # @param Criterion the instance of Criterion class
1847 # @return SMESH_Group
1848 # @ingroup l2_grps_create
1849 def MakeGroupByCriterion(self, groupName, Criterion):
1850 aFilterMgr = self.smeshpyD.CreateFilterManager()
1851 aFilter = aFilterMgr.CreateFilter()
1853 aCriteria.append(Criterion)
1854 aFilter.SetCriteria(aCriteria)
1855 group = self.MakeGroupByFilter(groupName, aFilter)
1856 aFilterMgr.UnRegister()
1859 ## Creates a mesh group by the given criteria (list of criteria)
1860 # @param groupName the name of the mesh group
1861 # @param theCriteria the list of criteria
1862 # @return SMESH_Group
1863 # @ingroup l2_grps_create
1864 def MakeGroupByCriteria(self, groupName, theCriteria):
1865 aFilterMgr = self.smeshpyD.CreateFilterManager()
1866 aFilter = aFilterMgr.CreateFilter()
1867 aFilter.SetCriteria(theCriteria)
1868 group = self.MakeGroupByFilter(groupName, aFilter)
1869 aFilterMgr.UnRegister()
1872 ## Creates a mesh group by the given filter
1873 # @param groupName the name of the mesh group
1874 # @param theFilter the instance of Filter class
1875 # @return SMESH_Group
1876 # @ingroup l2_grps_create
1877 def MakeGroupByFilter(self, groupName, theFilter):
1878 group = self.CreateEmptyGroup(theFilter.GetElementType(), groupName)
1879 theFilter.SetMesh( self.mesh )
1880 group.AddFrom( theFilter )
1883 ## Passes mesh elements through the given filter and return IDs of fitting elements
1884 # @param theFilter SMESH_Filter
1885 # @return a list of ids
1886 # @ingroup l1_controls
1887 def GetIdsFromFilter(self, theFilter):
1888 theFilter.SetMesh( self.mesh )
1889 return theFilter.GetIDs()
1891 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1892 # Returns a list of special structures (borders).
1893 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1894 # @ingroup l1_controls
1895 def GetFreeBorders(self):
1896 aFilterMgr = self.smeshpyD.CreateFilterManager()
1897 aPredicate = aFilterMgr.CreateFreeEdges()
1898 aPredicate.SetMesh(self.mesh)
1899 aBorders = aPredicate.GetBorders()
1900 aFilterMgr.UnRegister()
1904 # @ingroup l2_grps_delete
1905 def RemoveGroup(self, group):
1906 self.mesh.RemoveGroup(group)
1908 ## Removes a group with its contents
1909 # @ingroup l2_grps_delete
1910 def RemoveGroupWithContents(self, group):
1911 self.mesh.RemoveGroupWithContents(group)
1913 ## Gets the list of groups existing in the mesh
1914 # @return a sequence of SMESH_GroupBase
1915 # @ingroup l2_grps_create
1916 def GetGroups(self):
1917 return self.mesh.GetGroups()
1919 ## Gets the number of groups existing in the mesh
1920 # @return the quantity of groups as an integer value
1921 # @ingroup l2_grps_create
1923 return self.mesh.NbGroups()
1925 ## Gets the list of names of groups existing in the mesh
1926 # @return list of strings
1927 # @ingroup l2_grps_create
1928 def GetGroupNames(self):
1929 groups = self.GetGroups()
1931 for group in groups:
1932 names.append(group.GetName())
1935 ## Produces a union of two groups
1936 # A new group is created. All mesh elements that are
1937 # present in the initial groups are added to the new one
1938 # @return an instance of SMESH_Group
1939 # @ingroup l2_grps_operon
1940 def UnionGroups(self, group1, group2, name):
1941 return self.mesh.UnionGroups(group1, group2, name)
1943 ## Produces a union list of groups
1944 # New group is created. All mesh elements that are present in
1945 # initial groups are added to the new one
1946 # @return an instance of SMESH_Group
1947 # @ingroup l2_grps_operon
1948 def UnionListOfGroups(self, groups, name):
1949 return self.mesh.UnionListOfGroups(groups, name)
1951 ## Prodices an intersection of two groups
1952 # A new group is created. All mesh elements that are common
1953 # for the two initial groups are added to the new one.
1954 # @return an instance of SMESH_Group
1955 # @ingroup l2_grps_operon
1956 def IntersectGroups(self, group1, group2, name):
1957 return self.mesh.IntersectGroups(group1, group2, name)
1959 ## Produces an intersection of groups
1960 # New group is created. All mesh elements that are present in all
1961 # initial groups simultaneously are added to the new one
1962 # @return an instance of SMESH_Group
1963 # @ingroup l2_grps_operon
1964 def IntersectListOfGroups(self, groups, name):
1965 return self.mesh.IntersectListOfGroups(groups, name)
1967 ## Produces a cut of two groups
1968 # A new group is created. All mesh elements that are present in
1969 # the main group but are not present in the tool group are added to the new one
1970 # @return an instance of SMESH_Group
1971 # @ingroup l2_grps_operon
1972 def CutGroups(self, main_group, tool_group, name):
1973 return self.mesh.CutGroups(main_group, tool_group, name)
1975 ## Produces a cut of groups
1976 # A new group is created. All mesh elements that are present in main groups
1977 # but do not present in tool groups are added to the new one
1978 # @return an instance of SMESH_Group
1979 # @ingroup l2_grps_operon
1980 def CutListOfGroups(self, main_groups, tool_groups, name):
1981 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1983 ## Produces a group of elements of specified type using list of existing groups
1984 # A new group is created. System
1985 # 1) extracts all nodes on which groups elements are built
1986 # 2) combines all elements of specified dimension laying on these nodes
1987 # @return an instance of SMESH_Group
1988 # @ingroup l2_grps_operon
1989 def CreateDimGroup(self, groups, elem_type, name):
1990 return self.mesh.CreateDimGroup(groups, elem_type, name)
1993 ## Convert group on geom into standalone group
1994 # @ingroup l2_grps_delete
1995 def ConvertToStandalone(self, group):
1996 return self.mesh.ConvertToStandalone(group)
1998 # Get some info about mesh:
1999 # ------------------------
2001 ## Returns the log of nodes and elements added or removed
2002 # since the previous clear of the log.
2003 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
2004 # @return list of log_block structures:
2009 # @ingroup l1_auxiliary
2010 def GetLog(self, clearAfterGet):
2011 return self.mesh.GetLog(clearAfterGet)
2013 ## Clears the log of nodes and elements added or removed since the previous
2014 # clear. Must be used immediately after GetLog if clearAfterGet is false.
2015 # @ingroup l1_auxiliary
2017 self.mesh.ClearLog()
2019 ## Toggles auto color mode on the object.
2020 # @param theAutoColor the flag which toggles auto color mode.
2021 # @ingroup l1_auxiliary
2022 def SetAutoColor(self, theAutoColor):
2023 self.mesh.SetAutoColor(theAutoColor)
2025 ## Gets flag of object auto color mode.
2026 # @return True or False
2027 # @ingroup l1_auxiliary
2028 def GetAutoColor(self):
2029 return self.mesh.GetAutoColor()
2031 ## Gets the internal ID
2032 # @return integer value, which is the internal Id of the mesh
2033 # @ingroup l1_auxiliary
2035 return self.mesh.GetId()
2038 # @return integer value, which is the study Id of the mesh
2039 # @ingroup l1_auxiliary
2040 def GetStudyId(self):
2041 return self.mesh.GetStudyId()
2043 ## Checks the group names for duplications.
2044 # Consider the maximum group name length stored in MED file.
2045 # @return True or False
2046 # @ingroup l1_auxiliary
2047 def HasDuplicatedGroupNamesMED(self):
2048 return self.mesh.HasDuplicatedGroupNamesMED()
2050 ## Obtains the mesh editor tool
2051 # @return an instance of SMESH_MeshEditor
2052 # @ingroup l1_modifying
2053 def GetMeshEditor(self):
2054 return self.mesh.GetMeshEditor()
2056 ## Wrap a list of IDs of elements or nodes into SMESH_IDSource which
2057 # can be passed as argument to accepting mesh, group or sub-mesh
2058 # @return an instance of SMESH_IDSource
2059 # @ingroup l1_auxiliary
2060 def GetIDSource(self, ids, elemType):
2061 return self.GetMeshEditor().MakeIDSource(ids, elemType)
2064 # @return an instance of SALOME_MED::MESH
2065 # @ingroup l1_auxiliary
2066 def GetMEDMesh(self):
2067 return self.mesh.GetMEDMesh()
2070 # Get informations about mesh contents:
2071 # ------------------------------------
2073 ## Gets the mesh stattistic
2074 # @return dictionary type element - count of elements
2075 # @ingroup l1_meshinfo
2076 def GetMeshInfo(self, obj = None):
2077 if not obj: obj = self.mesh
2078 return self.smeshpyD.GetMeshInfo(obj)
2080 ## Returns the number of nodes in the mesh
2081 # @return an integer value
2082 # @ingroup l1_meshinfo
2084 return self.mesh.NbNodes()
2086 ## Returns the number of elements in the mesh
2087 # @return an integer value
2088 # @ingroup l1_meshinfo
2089 def NbElements(self):
2090 return self.mesh.NbElements()
2092 ## Returns the number of 0d elements in the mesh
2093 # @return an integer value
2094 # @ingroup l1_meshinfo
2095 def Nb0DElements(self):
2096 return self.mesh.Nb0DElements()
2098 ## Returns the number of edges in the mesh
2099 # @return an integer value
2100 # @ingroup l1_meshinfo
2102 return self.mesh.NbEdges()
2104 ## Returns the number of edges with the given order in the mesh
2105 # @param elementOrder the order of elements:
2106 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2107 # @return an integer value
2108 # @ingroup l1_meshinfo
2109 def NbEdgesOfOrder(self, elementOrder):
2110 return self.mesh.NbEdgesOfOrder(elementOrder)
2112 ## Returns the number of faces in the mesh
2113 # @return an integer value
2114 # @ingroup l1_meshinfo
2116 return self.mesh.NbFaces()
2118 ## Returns the number of faces with the given order in the mesh
2119 # @param elementOrder the order of elements:
2120 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2121 # @return an integer value
2122 # @ingroup l1_meshinfo
2123 def NbFacesOfOrder(self, elementOrder):
2124 return self.mesh.NbFacesOfOrder(elementOrder)
2126 ## Returns the number of triangles in the mesh
2127 # @return an integer value
2128 # @ingroup l1_meshinfo
2129 def NbTriangles(self):
2130 return self.mesh.NbTriangles()
2132 ## Returns the number of triangles with the given order in the mesh
2133 # @param elementOrder is the order of elements:
2134 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2135 # @return an integer value
2136 # @ingroup l1_meshinfo
2137 def NbTrianglesOfOrder(self, elementOrder):
2138 return self.mesh.NbTrianglesOfOrder(elementOrder)
2140 ## Returns the number of quadrangles in the mesh
2141 # @return an integer value
2142 # @ingroup l1_meshinfo
2143 def NbQuadrangles(self):
2144 return self.mesh.NbQuadrangles()
2146 ## Returns the number of quadrangles with the given order in the mesh
2147 # @param elementOrder the order of elements:
2148 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2149 # @return an integer value
2150 # @ingroup l1_meshinfo
2151 def NbQuadranglesOfOrder(self, elementOrder):
2152 return self.mesh.NbQuadranglesOfOrder(elementOrder)
2154 ## Returns the number of polygons in the mesh
2155 # @return an integer value
2156 # @ingroup l1_meshinfo
2157 def NbPolygons(self):
2158 return self.mesh.NbPolygons()
2160 ## Returns the number of volumes in the mesh
2161 # @return an integer value
2162 # @ingroup l1_meshinfo
2163 def NbVolumes(self):
2164 return self.mesh.NbVolumes()
2166 ## Returns the number of volumes with the given order in the mesh
2167 # @param elementOrder the order of elements:
2168 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2169 # @return an integer value
2170 # @ingroup l1_meshinfo
2171 def NbVolumesOfOrder(self, elementOrder):
2172 return self.mesh.NbVolumesOfOrder(elementOrder)
2174 ## Returns the number of tetrahedrons in the mesh
2175 # @return an integer value
2176 # @ingroup l1_meshinfo
2178 return self.mesh.NbTetras()
2180 ## Returns the number of tetrahedrons with the given order in the mesh
2181 # @param elementOrder the order of elements:
2182 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2183 # @return an integer value
2184 # @ingroup l1_meshinfo
2185 def NbTetrasOfOrder(self, elementOrder):
2186 return self.mesh.NbTetrasOfOrder(elementOrder)
2188 ## Returns the number of hexahedrons in the mesh
2189 # @return an integer value
2190 # @ingroup l1_meshinfo
2192 return self.mesh.NbHexas()
2194 ## Returns the number of hexahedrons with the given order in the mesh
2195 # @param elementOrder the order of elements:
2196 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2197 # @return an integer value
2198 # @ingroup l1_meshinfo
2199 def NbHexasOfOrder(self, elementOrder):
2200 return self.mesh.NbHexasOfOrder(elementOrder)
2202 ## Returns the number of pyramids in the mesh
2203 # @return an integer value
2204 # @ingroup l1_meshinfo
2205 def NbPyramids(self):
2206 return self.mesh.NbPyramids()
2208 ## Returns the number of pyramids with the given order in the mesh
2209 # @param elementOrder the order of elements:
2210 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2211 # @return an integer value
2212 # @ingroup l1_meshinfo
2213 def NbPyramidsOfOrder(self, elementOrder):
2214 return self.mesh.NbPyramidsOfOrder(elementOrder)
2216 ## Returns the number of prisms in the mesh
2217 # @return an integer value
2218 # @ingroup l1_meshinfo
2220 return self.mesh.NbPrisms()
2222 ## Returns the number of prisms with the given order in the mesh
2223 # @param elementOrder the order of elements:
2224 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2225 # @return an integer value
2226 # @ingroup l1_meshinfo
2227 def NbPrismsOfOrder(self, elementOrder):
2228 return self.mesh.NbPrismsOfOrder(elementOrder)
2230 ## Returns the number of polyhedrons in the mesh
2231 # @return an integer value
2232 # @ingroup l1_meshinfo
2233 def NbPolyhedrons(self):
2234 return self.mesh.NbPolyhedrons()
2236 ## Returns the number of submeshes in the mesh
2237 # @return an integer value
2238 # @ingroup l1_meshinfo
2239 def NbSubMesh(self):
2240 return self.mesh.NbSubMesh()
2242 ## Returns the list of mesh elements IDs
2243 # @return the list of integer values
2244 # @ingroup l1_meshinfo
2245 def GetElementsId(self):
2246 return self.mesh.GetElementsId()
2248 ## Returns the list of IDs of mesh elements with the given type
2249 # @param elementType the required type of elements (SMESH.NODE, SMESH.EDGE, SMESH.FACE or SMESH.VOLUME)
2250 # @return list of integer values
2251 # @ingroup l1_meshinfo
2252 def GetElementsByType(self, elementType):
2253 return self.mesh.GetElementsByType(elementType)
2255 ## Returns the list of mesh nodes IDs
2256 # @return the list of integer values
2257 # @ingroup l1_meshinfo
2258 def GetNodesId(self):
2259 return self.mesh.GetNodesId()
2261 # Get the information about mesh elements:
2262 # ------------------------------------
2264 ## Returns the type of mesh element
2265 # @return the value from SMESH::ElementType enumeration
2266 # @ingroup l1_meshinfo
2267 def GetElementType(self, id, iselem):
2268 return self.mesh.GetElementType(id, iselem)
2270 ## Returns the geometric type of mesh element
2271 # @return the value from SMESH::EntityType enumeration
2272 # @ingroup l1_meshinfo
2273 def GetElementGeomType(self, id):
2274 return self.mesh.GetElementGeomType(id)
2276 ## Returns the list of submesh elements IDs
2277 # @param Shape a geom object(subshape) IOR
2278 # Shape must be the subshape of a ShapeToMesh()
2279 # @return the list of integer values
2280 # @ingroup l1_meshinfo
2281 def GetSubMeshElementsId(self, Shape):
2282 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2283 ShapeID = Shape.GetSubShapeIndices()[0]
2286 return self.mesh.GetSubMeshElementsId(ShapeID)
2288 ## Returns the list of submesh nodes IDs
2289 # @param Shape a geom object(subshape) IOR
2290 # Shape must be the subshape of a ShapeToMesh()
2291 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
2292 # @return the list of integer values
2293 # @ingroup l1_meshinfo
2294 def GetSubMeshNodesId(self, Shape, all):
2295 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2296 ShapeID = Shape.GetSubShapeIndices()[0]
2299 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2301 ## Returns type of elements on given shape
2302 # @param Shape a geom object(subshape) IOR
2303 # Shape must be a subshape of a ShapeToMesh()
2304 # @return element type
2305 # @ingroup l1_meshinfo
2306 def GetSubMeshElementType(self, Shape):
2307 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2308 ShapeID = Shape.GetSubShapeIndices()[0]
2311 return self.mesh.GetSubMeshElementType(ShapeID)
2313 ## Gets the mesh description
2314 # @return string value
2315 # @ingroup l1_meshinfo
2317 return self.mesh.Dump()
2320 # Get the information about nodes and elements of a mesh by its IDs:
2321 # -----------------------------------------------------------
2323 ## Gets XYZ coordinates of a node
2324 # \n If there is no nodes for the given ID - returns an empty list
2325 # @return a list of double precision values
2326 # @ingroup l1_meshinfo
2327 def GetNodeXYZ(self, id):
2328 return self.mesh.GetNodeXYZ(id)
2330 ## Returns list of IDs of inverse elements for the given node
2331 # \n If there is no node for the given ID - returns an empty list
2332 # @return a list of integer values
2333 # @ingroup l1_meshinfo
2334 def GetNodeInverseElements(self, id):
2335 return self.mesh.GetNodeInverseElements(id)
2337 ## @brief Returns the position of a node on the shape
2338 # @return SMESH::NodePosition
2339 # @ingroup l1_meshinfo
2340 def GetNodePosition(self,NodeID):
2341 return self.mesh.GetNodePosition(NodeID)
2343 ## If the given element is a node, returns the ID of shape
2344 # \n If there is no node for the given ID - returns -1
2345 # @return an integer value
2346 # @ingroup l1_meshinfo
2347 def GetShapeID(self, id):
2348 return self.mesh.GetShapeID(id)
2350 ## Returns the ID of the result shape after
2351 # FindShape() from SMESH_MeshEditor for the given element
2352 # \n If there is no element for the given ID - returns -1
2353 # @return an integer value
2354 # @ingroup l1_meshinfo
2355 def GetShapeIDForElem(self,id):
2356 return self.mesh.GetShapeIDForElem(id)
2358 ## Returns the number of nodes for the given element
2359 # \n If there is no element for the given ID - returns -1
2360 # @return an integer value
2361 # @ingroup l1_meshinfo
2362 def GetElemNbNodes(self, id):
2363 return self.mesh.GetElemNbNodes(id)
2365 ## Returns the node ID the given index for the given element
2366 # \n If there is no element for the given ID - returns -1
2367 # \n If there is no node for the given index - returns -2
2368 # @return an integer value
2369 # @ingroup l1_meshinfo
2370 def GetElemNode(self, id, index):
2371 return self.mesh.GetElemNode(id, index)
2373 ## Returns the IDs of nodes of the given element
2374 # @return a list of integer values
2375 # @ingroup l1_meshinfo
2376 def GetElemNodes(self, id):
2377 return self.mesh.GetElemNodes(id)
2379 ## Returns true if the given node is the medium node in the given quadratic element
2380 # @ingroup l1_meshinfo
2381 def IsMediumNode(self, elementID, nodeID):
2382 return self.mesh.IsMediumNode(elementID, nodeID)
2384 ## Returns true if the given node is the medium node in one of quadratic elements
2385 # @ingroup l1_meshinfo
2386 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2387 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2389 ## Returns the number of edges for the given element
2390 # @ingroup l1_meshinfo
2391 def ElemNbEdges(self, id):
2392 return self.mesh.ElemNbEdges(id)
2394 ## Returns the number of faces for the given element
2395 # @ingroup l1_meshinfo
2396 def ElemNbFaces(self, id):
2397 return self.mesh.ElemNbFaces(id)
2399 ## Returns nodes of given face (counted from zero) for given volumic element.
2400 # @ingroup l1_meshinfo
2401 def GetElemFaceNodes(self,elemId, faceIndex):
2402 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2404 ## Returns an element based on all given nodes.
2405 # @ingroup l1_meshinfo
2406 def FindElementByNodes(self,nodes):
2407 return self.mesh.FindElementByNodes(nodes)
2409 ## Returns true if the given element is a polygon
2410 # @ingroup l1_meshinfo
2411 def IsPoly(self, id):
2412 return self.mesh.IsPoly(id)
2414 ## Returns true if the given element is quadratic
2415 # @ingroup l1_meshinfo
2416 def IsQuadratic(self, id):
2417 return self.mesh.IsQuadratic(id)
2419 ## Returns XYZ coordinates of the barycenter of the given element
2420 # \n If there is no element for the given ID - returns an empty list
2421 # @return a list of three double values
2422 # @ingroup l1_meshinfo
2423 def BaryCenter(self, id):
2424 return self.mesh.BaryCenter(id)
2427 # Get mesh measurements information:
2428 # ------------------------------------
2430 ## Get minimum distance between two nodes, elements or distance to the origin
2431 # @param id1 first node/element id
2432 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2433 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2434 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2435 # @return minimum distance value
2436 # @sa GetMinDistance()
2437 def MinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2438 aMeasure = self.GetMinDistance(id1, id2, isElem1, isElem2)
2439 return aMeasure.value
2441 ## Get measure structure specifying minimum distance data between two objects
2442 # @param id1 first node/element id
2443 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2444 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2445 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2446 # @return Measure structure
2448 def GetMinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2450 id1 = self.editor.MakeIDSource([id1], SMESH.FACE)
2452 id1 = self.editor.MakeIDSource([id1], SMESH.NODE)
2455 id2 = self.editor.MakeIDSource([id2], SMESH.FACE)
2457 id2 = self.editor.MakeIDSource([id2], SMESH.NODE)
2462 aMeasurements = self.smeshpyD.CreateMeasurements()
2463 aMeasure = aMeasurements.MinDistance(id1, id2)
2464 aMeasurements.UnRegister()
2467 ## Get bounding box of the specified object(s)
2468 # @param objects single source object or list of source objects or list of nodes/elements IDs
2469 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2470 # @c False specifies that @a objects are nodes
2471 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
2472 # @sa GetBoundingBox()
2473 def BoundingBox(self, objects=None, isElem=False):
2474 result = self.GetBoundingBox(objects, isElem)
2478 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
2481 ## Get measure structure specifying bounding box data of the specified object(s)
2482 # @param objects single source object or list of source objects or list of nodes/elements IDs
2483 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2484 # @c False specifies that @a objects are nodes
2485 # @return Measure structure
2487 def GetBoundingBox(self, IDs=None, isElem=False):
2490 elif isinstance(IDs, tuple):
2492 if not isinstance(IDs, list):
2494 if len(IDs) > 0 and isinstance(IDs[0], int):
2498 if isinstance(o, Mesh):
2499 srclist.append(o.mesh)
2500 elif hasattr(o, "_narrow"):
2501 src = o._narrow(SMESH.SMESH_IDSource)
2502 if src: srclist.append(src)
2504 elif isinstance(o, list):
2506 srclist.append(self.editor.MakeIDSource(o, SMESH.FACE))
2508 srclist.append(self.editor.MakeIDSource(o, SMESH.NODE))
2511 aMeasurements = self.smeshpyD.CreateMeasurements()
2512 aMeasure = aMeasurements.BoundingBox(srclist)
2513 aMeasurements.UnRegister()
2516 # Mesh edition (SMESH_MeshEditor functionality):
2517 # ---------------------------------------------
2519 ## Removes the elements from the mesh by ids
2520 # @param IDsOfElements is a list of ids of elements to remove
2521 # @return True or False
2522 # @ingroup l2_modif_del
2523 def RemoveElements(self, IDsOfElements):
2524 return self.editor.RemoveElements(IDsOfElements)
2526 ## Removes nodes from mesh by ids
2527 # @param IDsOfNodes is a list of ids of nodes to remove
2528 # @return True or False
2529 # @ingroup l2_modif_del
2530 def RemoveNodes(self, IDsOfNodes):
2531 return self.editor.RemoveNodes(IDsOfNodes)
2533 ## Removes all orphan (free) nodes from mesh
2534 # @return number of the removed nodes
2535 # @ingroup l2_modif_del
2536 def RemoveOrphanNodes(self):
2537 return self.editor.RemoveOrphanNodes()
2539 ## Add a node to the mesh by coordinates
2540 # @return Id of the new node
2541 # @ingroup l2_modif_add
2542 def AddNode(self, x, y, z):
2543 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2544 self.mesh.SetParameters(Parameters)
2545 return self.editor.AddNode( x, y, z)
2547 ## Creates a 0D element on a node with given number.
2548 # @param IDOfNode the ID of node for creation of the element.
2549 # @return the Id of the new 0D element
2550 # @ingroup l2_modif_add
2551 def Add0DElement(self, IDOfNode):
2552 return self.editor.Add0DElement(IDOfNode)
2554 ## Creates a linear or quadratic edge (this is determined
2555 # by the number of given nodes).
2556 # @param IDsOfNodes the list of node IDs for creation of the element.
2557 # The order of nodes in this list should correspond to the description
2558 # of MED. \n This description is located by the following link:
2559 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2560 # @return the Id of the new edge
2561 # @ingroup l2_modif_add
2562 def AddEdge(self, IDsOfNodes):
2563 return self.editor.AddEdge(IDsOfNodes)
2565 ## Creates a linear or quadratic face (this is determined
2566 # by the number of given nodes).
2567 # @param IDsOfNodes the list of node IDs for creation of the element.
2568 # The order of nodes in this list should correspond to the description
2569 # of MED. \n This description is located by the following link:
2570 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2571 # @return the Id of the new face
2572 # @ingroup l2_modif_add
2573 def AddFace(self, IDsOfNodes):
2574 return self.editor.AddFace(IDsOfNodes)
2576 ## Adds a polygonal face to the mesh by the list of node IDs
2577 # @param IdsOfNodes the list of node IDs for creation of the element.
2578 # @return the Id of the new face
2579 # @ingroup l2_modif_add
2580 def AddPolygonalFace(self, IdsOfNodes):
2581 return self.editor.AddPolygonalFace(IdsOfNodes)
2583 ## Creates both simple and quadratic volume (this is determined
2584 # by the number of given nodes).
2585 # @param IDsOfNodes the list of node IDs for creation of the element.
2586 # The order of nodes in this list should correspond to the description
2587 # of MED. \n This description is located by the following link:
2588 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2589 # @return the Id of the new volumic element
2590 # @ingroup l2_modif_add
2591 def AddVolume(self, IDsOfNodes):
2592 return self.editor.AddVolume(IDsOfNodes)
2594 ## Creates a volume of many faces, giving nodes for each face.
2595 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2596 # @param Quantities the list of integer values, Quantities[i]
2597 # gives the quantity of nodes in face number i.
2598 # @return the Id of the new volumic element
2599 # @ingroup l2_modif_add
2600 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2601 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2603 ## Creates a volume of many faces, giving the IDs of the existing faces.
2604 # @param IdsOfFaces the list of face IDs for volume creation.
2606 # Note: The created volume will refer only to the nodes
2607 # of the given faces, not to the faces themselves.
2608 # @return the Id of the new volumic element
2609 # @ingroup l2_modif_add
2610 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2611 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2614 ## @brief Binds a node to a vertex
2615 # @param NodeID a node ID
2616 # @param Vertex a vertex or vertex ID
2617 # @return True if succeed else raises an exception
2618 # @ingroup l2_modif_add
2619 def SetNodeOnVertex(self, NodeID, Vertex):
2620 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2621 VertexID = Vertex.GetSubShapeIndices()[0]
2625 self.editor.SetNodeOnVertex(NodeID, VertexID)
2626 except SALOME.SALOME_Exception, inst:
2627 raise ValueError, inst.details.text
2631 ## @brief Stores the node position on an edge
2632 # @param NodeID a node ID
2633 # @param Edge an edge or edge ID
2634 # @param paramOnEdge a parameter on the edge where the node is located
2635 # @return True if succeed else raises an exception
2636 # @ingroup l2_modif_add
2637 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2638 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2639 EdgeID = Edge.GetSubShapeIndices()[0]
2643 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2644 except SALOME.SALOME_Exception, inst:
2645 raise ValueError, inst.details.text
2648 ## @brief Stores node position on a face
2649 # @param NodeID a node ID
2650 # @param Face a face or face ID
2651 # @param u U parameter on the face where the node is located
2652 # @param v V parameter on the face where the node is located
2653 # @return True if succeed else raises an exception
2654 # @ingroup l2_modif_add
2655 def SetNodeOnFace(self, NodeID, Face, u, v):
2656 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2657 FaceID = Face.GetSubShapeIndices()[0]
2661 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2662 except SALOME.SALOME_Exception, inst:
2663 raise ValueError, inst.details.text
2666 ## @brief Binds a node to a solid
2667 # @param NodeID a node ID
2668 # @param Solid a solid or solid ID
2669 # @return True if succeed else raises an exception
2670 # @ingroup l2_modif_add
2671 def SetNodeInVolume(self, NodeID, Solid):
2672 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2673 SolidID = Solid.GetSubShapeIndices()[0]
2677 self.editor.SetNodeInVolume(NodeID, SolidID)
2678 except SALOME.SALOME_Exception, inst:
2679 raise ValueError, inst.details.text
2682 ## @brief Bind an element to a shape
2683 # @param ElementID an element ID
2684 # @param Shape a shape or shape ID
2685 # @return True if succeed else raises an exception
2686 # @ingroup l2_modif_add
2687 def SetMeshElementOnShape(self, ElementID, Shape):
2688 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2689 ShapeID = Shape.GetSubShapeIndices()[0]
2693 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2694 except SALOME.SALOME_Exception, inst:
2695 raise ValueError, inst.details.text
2699 ## Moves the node with the given id
2700 # @param NodeID the id of the node
2701 # @param x a new X coordinate
2702 # @param y a new Y coordinate
2703 # @param z a new Z coordinate
2704 # @return True if succeed else False
2705 # @ingroup l2_modif_movenode
2706 def MoveNode(self, NodeID, x, y, z):
2707 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2708 self.mesh.SetParameters(Parameters)
2709 return self.editor.MoveNode(NodeID, x, y, z)
2711 ## Finds the node closest to a point and moves it to a point location
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 NodeID if specified (>0), the node with this ID is moved,
2716 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2717 # @return the ID of a node
2718 # @ingroup l2_modif_throughp
2719 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2720 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2721 self.mesh.SetParameters(Parameters)
2722 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2724 ## Finds the node closest to a point
2725 # @param x the X coordinate of a point
2726 # @param y the Y coordinate of a point
2727 # @param z the Z coordinate of a point
2728 # @return the ID of a node
2729 # @ingroup l2_modif_throughp
2730 def FindNodeClosestTo(self, x, y, z):
2731 #preview = self.mesh.GetMeshEditPreviewer()
2732 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2733 return self.editor.FindNodeClosestTo(x, y, z)
2735 ## Finds the elements where a point lays IN or ON
2736 # @param x the X coordinate of a point
2737 # @param y the Y coordinate of a point
2738 # @param z the Z coordinate of a point
2739 # @param elementType type of elements to find (SMESH.ALL type
2740 # means elements of any type excluding nodes and 0D elements)
2741 # @param meshPart a part of mesh (group, sub-mesh) to search within
2742 # @return list of IDs of found elements
2743 # @ingroup l2_modif_throughp
2744 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL, meshPart=None):
2746 return self.editor.FindAmongElementsByPoint( meshPart, x, y, z, elementType );
2748 return self.editor.FindElementsByPoint(x, y, z, elementType)
2750 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2751 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2753 def GetPointState(self, x, y, z):
2754 return self.editor.GetPointState(x, y, z)
2756 ## Finds the node closest to a point and moves it to a point location
2757 # @param x the X coordinate of a point
2758 # @param y the Y coordinate of a point
2759 # @param z the Z coordinate of a point
2760 # @return the ID of a moved node
2761 # @ingroup l2_modif_throughp
2762 def MeshToPassThroughAPoint(self, x, y, z):
2763 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2765 ## Replaces two neighbour triangles sharing Node1-Node2 link
2766 # with the triangles built on the same 4 nodes but having other common link.
2767 # @param NodeID1 the ID of the first node
2768 # @param NodeID2 the ID of the second node
2769 # @return false if proper faces were not found
2770 # @ingroup l2_modif_invdiag
2771 def InverseDiag(self, NodeID1, NodeID2):
2772 return self.editor.InverseDiag(NodeID1, NodeID2)
2774 ## Replaces two neighbour triangles sharing Node1-Node2 link
2775 # with a quadrangle built on the same 4 nodes.
2776 # @param NodeID1 the ID of the first node
2777 # @param NodeID2 the ID of the second node
2778 # @return false if proper faces were not found
2779 # @ingroup l2_modif_unitetri
2780 def DeleteDiag(self, NodeID1, NodeID2):
2781 return self.editor.DeleteDiag(NodeID1, NodeID2)
2783 ## Reorients elements by ids
2784 # @param IDsOfElements if undefined reorients all mesh elements
2785 # @return True if succeed else False
2786 # @ingroup l2_modif_changori
2787 def Reorient(self, IDsOfElements=None):
2788 if IDsOfElements == None:
2789 IDsOfElements = self.GetElementsId()
2790 return self.editor.Reorient(IDsOfElements)
2792 ## Reorients all elements of the object
2793 # @param theObject mesh, submesh or group
2794 # @return True if succeed else False
2795 # @ingroup l2_modif_changori
2796 def ReorientObject(self, theObject):
2797 if ( isinstance( theObject, Mesh )):
2798 theObject = theObject.GetMesh()
2799 return self.editor.ReorientObject(theObject)
2801 ## Fuses the neighbouring triangles into quadrangles.
2802 # @param IDsOfElements The triangles to be fused,
2803 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2804 # @param MaxAngle is the maximum angle between element normals at which the fusion
2805 # is still performed; theMaxAngle is mesured in radians.
2806 # Also it could be a name of variable which defines angle in degrees.
2807 # @return TRUE in case of success, FALSE otherwise.
2808 # @ingroup l2_modif_unitetri
2809 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2811 if isinstance(MaxAngle,str):
2813 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2815 MaxAngle = DegreesToRadians(MaxAngle)
2816 if IDsOfElements == []:
2817 IDsOfElements = self.GetElementsId()
2818 self.mesh.SetParameters(Parameters)
2820 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2821 Functor = theCriterion
2823 Functor = self.smeshpyD.GetFunctor(theCriterion)
2824 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2826 ## Fuses the neighbouring triangles of the object into quadrangles
2827 # @param theObject is mesh, submesh or group
2828 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2829 # @param MaxAngle a max angle between element normals at which the fusion
2830 # is still performed; theMaxAngle is mesured in radians.
2831 # @return TRUE in case of success, FALSE otherwise.
2832 # @ingroup l2_modif_unitetri
2833 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2834 if ( isinstance( theObject, Mesh )):
2835 theObject = theObject.GetMesh()
2836 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2838 ## Splits quadrangles into triangles.
2839 # @param IDsOfElements the faces to be splitted.
2840 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2841 # @return TRUE in case of success, FALSE otherwise.
2842 # @ingroup l2_modif_cutquadr
2843 def QuadToTri (self, IDsOfElements, theCriterion):
2844 if IDsOfElements == []:
2845 IDsOfElements = self.GetElementsId()
2846 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2848 ## Splits quadrangles into triangles.
2849 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2850 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2851 # @return TRUE in case of success, FALSE otherwise.
2852 # @ingroup l2_modif_cutquadr
2853 def QuadToTriObject (self, theObject, theCriterion):
2854 if ( isinstance( theObject, Mesh )):
2855 theObject = theObject.GetMesh()
2856 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2858 ## Splits quadrangles into triangles.
2859 # @param IDsOfElements the faces to be splitted
2860 # @param Diag13 is used to choose a diagonal for splitting.
2861 # @return TRUE in case of success, FALSE otherwise.
2862 # @ingroup l2_modif_cutquadr
2863 def SplitQuad (self, IDsOfElements, Diag13):
2864 if IDsOfElements == []:
2865 IDsOfElements = self.GetElementsId()
2866 return self.editor.SplitQuad(IDsOfElements, Diag13)
2868 ## Splits quadrangles into triangles.
2869 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2870 # @param Diag13 is used to choose a diagonal for splitting.
2871 # @return TRUE in case of success, FALSE otherwise.
2872 # @ingroup l2_modif_cutquadr
2873 def SplitQuadObject (self, theObject, Diag13):
2874 if ( isinstance( theObject, Mesh )):
2875 theObject = theObject.GetMesh()
2876 return self.editor.SplitQuadObject(theObject, Diag13)
2878 ## Finds a better splitting of the given quadrangle.
2879 # @param IDOfQuad the ID of the quadrangle to be splitted.
2880 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2881 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2882 # diagonal is better, 0 if error occurs.
2883 # @ingroup l2_modif_cutquadr
2884 def BestSplit (self, IDOfQuad, theCriterion):
2885 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2887 ## Splits volumic elements into tetrahedrons
2888 # @param elemIDs either list of elements or mesh or group or submesh
2889 # @param method flags passing splitting method: Hex_5Tet, Hex_6Tet, Hex_24Tet
2890 # Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc
2891 # @ingroup l2_modif_cutquadr
2892 def SplitVolumesIntoTetra(self, elemIDs, method=Hex_5Tet ):
2893 if isinstance( elemIDs, Mesh ):
2894 elemIDs = elemIDs.GetMesh()
2895 if ( isinstance( elemIDs, list )):
2896 elemIDs = self.editor.MakeIDSource(elemIDs, SMESH.VOLUME)
2897 self.editor.SplitVolumesIntoTetra(elemIDs, method)
2899 ## Splits quadrangle faces near triangular facets of volumes
2901 # @ingroup l1_auxiliary
2902 def SplitQuadsNearTriangularFacets(self):
2903 faces_array = self.GetElementsByType(SMESH.FACE)
2904 for face_id in faces_array:
2905 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2906 quad_nodes = self.mesh.GetElemNodes(face_id)
2907 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2908 isVolumeFound = False
2909 for node1_elem in node1_elems:
2910 if not isVolumeFound:
2911 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2912 nb_nodes = self.GetElemNbNodes(node1_elem)
2913 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2914 volume_elem = node1_elem
2915 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2916 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2917 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2918 isVolumeFound = True
2919 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2920 self.SplitQuad([face_id], False) # diagonal 2-4
2921 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2922 isVolumeFound = True
2923 self.SplitQuad([face_id], True) # diagonal 1-3
2924 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2925 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2926 isVolumeFound = True
2927 self.SplitQuad([face_id], True) # diagonal 1-3
2929 ## @brief Splits hexahedrons into tetrahedrons.
2931 # This operation uses pattern mapping functionality for splitting.
2932 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2933 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2934 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2935 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2936 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2937 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2938 # @return TRUE in case of success, FALSE otherwise.
2939 # @ingroup l1_auxiliary
2940 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2941 # Pattern: 5.---------.6
2946 # (0,0,1) 4.---------.7 * |
2953 # (0,0,0) 0.---------.3
2954 pattern_tetra = "!!! Nb of points: \n 8 \n\
2964 !!! Indices of points of 6 tetras: \n\
2972 pattern = self.smeshpyD.GetPattern()
2973 isDone = pattern.LoadFromFile(pattern_tetra)
2975 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2978 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2979 isDone = pattern.MakeMesh(self.mesh, False, False)
2980 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2982 # split quafrangle faces near triangular facets of volumes
2983 self.SplitQuadsNearTriangularFacets()
2987 ## @brief Split hexahedrons into prisms.
2989 # Uses the pattern mapping functionality for splitting.
2990 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2991 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2992 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2993 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2994 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2995 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2996 # @return TRUE in case of success, FALSE otherwise.
2997 # @ingroup l1_auxiliary
2998 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2999 # Pattern: 5.---------.6
3004 # (0,0,1) 4.---------.7 |
3011 # (0,0,0) 0.---------.3
3012 pattern_prism = "!!! Nb of points: \n 8 \n\
3022 !!! Indices of points of 2 prisms: \n\
3026 pattern = self.smeshpyD.GetPattern()
3027 isDone = pattern.LoadFromFile(pattern_prism)
3029 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
3032 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
3033 isDone = pattern.MakeMesh(self.mesh, False, False)
3034 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
3036 # Splits quafrangle faces near triangular facets of volumes
3037 self.SplitQuadsNearTriangularFacets()
3041 ## Smoothes elements
3042 # @param IDsOfElements the list if ids of elements to smooth
3043 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3044 # Note that nodes built on edges and boundary nodes are always fixed.
3045 # @param MaxNbOfIterations the maximum number of iterations
3046 # @param MaxAspectRatio varies in range [1.0, inf]
3047 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3048 # @return TRUE in case of success, FALSE otherwise.
3049 # @ingroup l2_modif_smooth
3050 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
3051 MaxNbOfIterations, MaxAspectRatio, Method):
3052 if IDsOfElements == []:
3053 IDsOfElements = self.GetElementsId()
3054 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
3055 self.mesh.SetParameters(Parameters)
3056 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
3057 MaxNbOfIterations, MaxAspectRatio, Method)
3059 ## Smoothes elements which belong to the given object
3060 # @param theObject the object to smooth
3061 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3062 # Note that nodes built on edges and boundary nodes are always fixed.
3063 # @param MaxNbOfIterations the maximum number of iterations
3064 # @param MaxAspectRatio varies in range [1.0, inf]
3065 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3066 # @return TRUE in case of success, FALSE otherwise.
3067 # @ingroup l2_modif_smooth
3068 def SmoothObject(self, theObject, IDsOfFixedNodes,
3069 MaxNbOfIterations, MaxAspectRatio, Method):
3070 if ( isinstance( theObject, Mesh )):
3071 theObject = theObject.GetMesh()
3072 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
3073 MaxNbOfIterations, MaxAspectRatio, Method)
3075 ## Parametrically smoothes the given elements
3076 # @param IDsOfElements the list if ids of elements to smooth
3077 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3078 # Note that nodes built on edges and boundary nodes are always fixed.
3079 # @param MaxNbOfIterations the maximum number of iterations
3080 # @param MaxAspectRatio varies in range [1.0, inf]
3081 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3082 # @return TRUE in case of success, FALSE otherwise.
3083 # @ingroup l2_modif_smooth
3084 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
3085 MaxNbOfIterations, MaxAspectRatio, Method):
3086 if IDsOfElements == []:
3087 IDsOfElements = self.GetElementsId()
3088 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
3089 self.mesh.SetParameters(Parameters)
3090 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
3091 MaxNbOfIterations, MaxAspectRatio, Method)
3093 ## Parametrically smoothes the elements which belong to the given object
3094 # @param theObject the object to smooth
3095 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3096 # Note that nodes built on edges and boundary nodes are always fixed.
3097 # @param MaxNbOfIterations the maximum number of iterations
3098 # @param MaxAspectRatio varies in range [1.0, inf]
3099 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3100 # @return TRUE in case of success, FALSE otherwise.
3101 # @ingroup l2_modif_smooth
3102 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
3103 MaxNbOfIterations, MaxAspectRatio, Method):
3104 if ( isinstance( theObject, Mesh )):
3105 theObject = theObject.GetMesh()
3106 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
3107 MaxNbOfIterations, MaxAspectRatio, Method)
3109 ## Converts the mesh to quadratic, deletes old elements, replacing
3110 # them with quadratic with the same id.
3111 # @param theForce3d new node creation method:
3112 # 0 - the medium node lies at the geometrical entity from which the mesh element is built
3113 # 1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element
3114 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
3115 # @ingroup l2_modif_tofromqu
3116 def ConvertToQuadratic(self, theForce3d, theSubMesh=None):
3118 self.editor.ConvertToQuadraticObject(theForce3d,theSubMesh)
3120 self.editor.ConvertToQuadratic(theForce3d)
3122 ## Converts the mesh from quadratic to ordinary,
3123 # deletes old quadratic elements, \n replacing
3124 # them with ordinary mesh elements with the same id.
3125 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
3126 # @ingroup l2_modif_tofromqu
3127 def ConvertFromQuadratic(self, theSubMesh=None):
3129 self.editor.ConvertFromQuadraticObject(theSubMesh)
3131 return self.editor.ConvertFromQuadratic()
3133 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
3134 # @return TRUE if operation has been completed successfully, FALSE otherwise
3135 # @ingroup l2_modif_edit
3136 def Make2DMeshFrom3D(self):
3137 return self.editor. Make2DMeshFrom3D()
3139 ## Creates missing boundary elements
3140 # @param elements - elements whose boundary is to be checked:
3141 # mesh, group, sub-mesh or list of elements
3142 # if elements is mesh, it must be the mesh whose MakeBoundaryMesh() is called
3143 # @param dimension - defines type of boundary elements to create:
3144 # SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D
3145 # SMESH.BND_1DFROM3D creates mesh edges on all borders of free facets of 3D cells
3146 # @param groupName - a name of group to store created boundary elements in,
3147 # "" means not to create the group
3148 # @param meshName - a name of new mesh to store created boundary elements in,
3149 # "" means not to create the new mesh
3150 # @param toCopyElements - if true, the checked elements will be copied into
3151 # the new mesh else only boundary elements will be copied into the new mesh
3152 # @param toCopyExistingBondary - if true, not only new but also pre-existing
3153 # boundary elements will be copied into the new mesh
3154 # @return tuple (mesh, group) where bondary elements were added to
3155 # @ingroup l2_modif_edit
3156 def MakeBoundaryMesh(self, elements, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3157 toCopyElements=False, toCopyExistingBondary=False):
3158 if isinstance( elements, Mesh ):
3159 elements = elements.GetMesh()
3160 if ( isinstance( elements, list )):
3161 elemType = SMESH.ALL
3162 if elements: elemType = self.GetElementType( elements[0], iselem=True)
3163 elements = self.editor.MakeIDSource(elements, elemType)
3164 mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName,
3165 toCopyElements,toCopyExistingBondary)
3166 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3170 # @brief Creates missing boundary elements around either the whole mesh or
3171 # groups of 2D elements
3172 # @param dimension - defines type of boundary elements to create
3173 # @param groupName - a name of group to store all boundary elements in,
3174 # "" means not to create the group
3175 # @param meshName - a name of a new mesh, which is a copy of the initial
3176 # mesh + created boundary elements; "" means not to create the new mesh
3177 # @param toCopyAll - if true, the whole initial mesh will be copied into
3178 # the new mesh else only boundary elements will be copied into the new mesh
3179 # @param groups - groups of 2D elements to make boundary around
3180 # @retval tuple( long, mesh, groups )
3181 # long - number of added boundary elements
3182 # mesh - the mesh where elements were added to
3183 # group - the group of boundary elements or None
3185 def MakeBoundaryElements(self, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3186 toCopyAll=False, groups=[]):
3187 nb, mesh, group = self.editor.MakeBoundaryElements(dimension,groupName,meshName,
3189 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3190 return nb, mesh, group
3192 ## Renumber mesh nodes
3193 # @ingroup l2_modif_renumber
3194 def RenumberNodes(self):
3195 self.editor.RenumberNodes()
3197 ## Renumber mesh elements
3198 # @ingroup l2_modif_renumber
3199 def RenumberElements(self):
3200 self.editor.RenumberElements()
3202 ## Generates new elements by rotation of the elements around the axis
3203 # @param IDsOfElements the list of ids of elements to sweep
3204 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3205 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
3206 # @param NbOfSteps the number of steps
3207 # @param Tolerance tolerance
3208 # @param MakeGroups forces the generation of new groups from existing ones
3209 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3210 # of all steps, else - size of each step
3211 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3212 # @ingroup l2_modif_extrurev
3213 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
3214 MakeGroups=False, TotalAngle=False):
3216 if isinstance(AngleInRadians,str):
3218 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3220 AngleInRadians = DegreesToRadians(AngleInRadians)
3221 if IDsOfElements == []:
3222 IDsOfElements = self.GetElementsId()
3223 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3224 Axis = self.smeshpyD.GetAxisStruct(Axis)
3225 Axis,AxisParameters = ParseAxisStruct(Axis)
3226 if TotalAngle and NbOfSteps:
3227 AngleInRadians /= NbOfSteps
3228 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3229 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3230 self.mesh.SetParameters(Parameters)
3232 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
3233 AngleInRadians, NbOfSteps, Tolerance)
3234 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
3237 ## Generates new elements by rotation of the elements of object around the axis
3238 # @param theObject object which elements should be sweeped.
3239 # It can be a mesh, a sub mesh or a group.
3240 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3241 # @param AngleInRadians the angle of Rotation
3242 # @param NbOfSteps number of steps
3243 # @param Tolerance tolerance
3244 # @param MakeGroups forces the generation of new groups from existing ones
3245 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3246 # of all steps, else - size of each step
3247 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3248 # @ingroup l2_modif_extrurev
3249 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3250 MakeGroups=False, TotalAngle=False):
3252 if isinstance(AngleInRadians,str):
3254 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3256 AngleInRadians = DegreesToRadians(AngleInRadians)
3257 if ( isinstance( theObject, Mesh )):
3258 theObject = theObject.GetMesh()
3259 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3260 Axis = self.smeshpyD.GetAxisStruct(Axis)
3261 Axis,AxisParameters = ParseAxisStruct(Axis)
3262 if TotalAngle and NbOfSteps:
3263 AngleInRadians /= NbOfSteps
3264 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3265 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3266 self.mesh.SetParameters(Parameters)
3268 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
3269 NbOfSteps, Tolerance)
3270 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3273 ## Generates new elements by rotation of the elements of object around the axis
3274 # @param theObject object which elements should be sweeped.
3275 # It can be a mesh, a sub mesh or a group.
3276 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3277 # @param AngleInRadians the angle of Rotation
3278 # @param NbOfSteps number of steps
3279 # @param Tolerance tolerance
3280 # @param MakeGroups forces the generation of new groups from existing ones
3281 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3282 # of all steps, else - size of each step
3283 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3284 # @ingroup l2_modif_extrurev
3285 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3286 MakeGroups=False, TotalAngle=False):
3288 if isinstance(AngleInRadians,str):
3290 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3292 AngleInRadians = DegreesToRadians(AngleInRadians)
3293 if ( isinstance( theObject, Mesh )):
3294 theObject = theObject.GetMesh()
3295 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3296 Axis = self.smeshpyD.GetAxisStruct(Axis)
3297 Axis,AxisParameters = ParseAxisStruct(Axis)
3298 if TotalAngle and NbOfSteps:
3299 AngleInRadians /= NbOfSteps
3300 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3301 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3302 self.mesh.SetParameters(Parameters)
3304 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
3305 NbOfSteps, Tolerance)
3306 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3309 ## Generates new elements by rotation of the elements of object around the axis
3310 # @param theObject object which elements should be sweeped.
3311 # It can be a mesh, a sub mesh or a group.
3312 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3313 # @param AngleInRadians the angle of Rotation
3314 # @param NbOfSteps number of steps
3315 # @param Tolerance tolerance
3316 # @param MakeGroups forces the generation of new groups from existing ones
3317 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3318 # of all steps, else - size of each step
3319 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3320 # @ingroup l2_modif_extrurev
3321 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3322 MakeGroups=False, TotalAngle=False):
3324 if isinstance(AngleInRadians,str):
3326 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3328 AngleInRadians = DegreesToRadians(AngleInRadians)
3329 if ( isinstance( theObject, Mesh )):
3330 theObject = theObject.GetMesh()
3331 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3332 Axis = self.smeshpyD.GetAxisStruct(Axis)
3333 Axis,AxisParameters = ParseAxisStruct(Axis)
3334 if TotalAngle and NbOfSteps:
3335 AngleInRadians /= NbOfSteps
3336 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3337 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3338 self.mesh.SetParameters(Parameters)
3340 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
3341 NbOfSteps, Tolerance)
3342 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3345 ## Generates new elements by extrusion of the elements with given ids
3346 # @param IDsOfElements the list of elements ids for extrusion
3347 # @param StepVector vector or DirStruct, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3348 # @param NbOfSteps the number of steps
3349 # @param MakeGroups forces the generation of new groups from existing ones
3350 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3351 # @ingroup l2_modif_extrurev
3352 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
3353 if IDsOfElements == []:
3354 IDsOfElements = self.GetElementsId()
3355 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3356 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3357 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3358 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3359 Parameters = StepVectorParameters + var_separator + Parameters
3360 self.mesh.SetParameters(Parameters)
3362 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
3363 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
3366 ## Generates new elements by extrusion of the elements with given ids
3367 # @param IDsOfElements is ids of elements
3368 # @param StepVector vector, defining the direction and value of extrusion
3369 # @param NbOfSteps the number of steps
3370 # @param ExtrFlags sets flags for extrusion
3371 # @param SewTolerance uses for comparing locations of nodes if flag
3372 # EXTRUSION_FLAG_SEW is set
3373 # @param MakeGroups forces the generation of new groups from existing ones
3374 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3375 # @ingroup l2_modif_extrurev
3376 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
3377 ExtrFlags, SewTolerance, MakeGroups=False):
3378 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3379 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3381 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
3382 ExtrFlags, SewTolerance)
3383 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
3384 ExtrFlags, SewTolerance)
3387 ## Generates new elements by extrusion of the elements which belong to the object
3388 # @param theObject the object which elements should be processed.
3389 # It can be a mesh, a sub mesh or a group.
3390 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3391 # @param NbOfSteps the number of steps
3392 # @param MakeGroups forces the generation of new groups from existing ones
3393 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3394 # @ingroup l2_modif_extrurev
3395 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3396 if ( isinstance( theObject, Mesh )):
3397 theObject = theObject.GetMesh()
3398 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3399 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3400 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3401 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3402 Parameters = StepVectorParameters + var_separator + Parameters
3403 self.mesh.SetParameters(Parameters)
3405 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3406 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
3409 ## Generates new elements by extrusion of the elements which belong to the object
3410 # @param theObject object which elements should be processed.
3411 # It can be a mesh, a sub mesh or a group.
3412 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3413 # @param NbOfSteps the number of steps
3414 # @param MakeGroups to generate new groups from existing ones
3415 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3416 # @ingroup l2_modif_extrurev
3417 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3418 if ( isinstance( theObject, Mesh )):
3419 theObject = theObject.GetMesh()
3420 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3421 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3422 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3423 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3424 Parameters = StepVectorParameters + var_separator + Parameters
3425 self.mesh.SetParameters(Parameters)
3427 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3428 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3431 ## Generates new elements by extrusion of the elements which belong to the object
3432 # @param theObject object which elements should be processed.
3433 # It can be a mesh, a sub mesh or a group.
3434 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3435 # @param NbOfSteps the number of steps
3436 # @param MakeGroups forces the generation of new groups from existing ones
3437 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3438 # @ingroup l2_modif_extrurev
3439 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3440 if ( isinstance( theObject, Mesh )):
3441 theObject = theObject.GetMesh()
3442 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3443 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3444 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3445 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3446 Parameters = StepVectorParameters + var_separator + Parameters
3447 self.mesh.SetParameters(Parameters)
3449 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3450 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3455 ## Generates new elements by extrusion of the given elements
3456 # The path of extrusion must be a meshed edge.
3457 # @param Base mesh or group, or submesh, or list of ids of elements for extrusion
3458 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3459 # @param NodeStart the start node from Path. Defines the direction of extrusion
3460 # @param HasAngles allows the shape to be rotated around the path
3461 # to get the resulting mesh in a helical fashion
3462 # @param Angles list of angles in radians
3463 # @param LinearVariation forces the computation of rotation angles as linear
3464 # variation of the given Angles along path steps
3465 # @param HasRefPoint allows using the reference point
3466 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3467 # The User can specify any point as the Reference Point.
3468 # @param MakeGroups forces the generation of new groups from existing ones
3469 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3470 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3471 # only SMESH::Extrusion_Error otherwise
3472 # @ingroup l2_modif_extrurev
3473 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3474 HasAngles, Angles, LinearVariation,
3475 HasRefPoint, RefPoint, MakeGroups, ElemType):
3476 Angles,AnglesParameters = ParseAngles(Angles)
3477 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3478 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3479 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3481 Parameters = AnglesParameters + var_separator + RefPointParameters
3482 self.mesh.SetParameters(Parameters)
3484 if (isinstance(Path, Mesh)): Path = Path.GetMesh()
3486 if isinstance(Base, list):
3488 if Base == []: IDsOfElements = self.GetElementsId()
3489 else: IDsOfElements = Base
3490 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3491 HasAngles, Angles, LinearVariation,
3492 HasRefPoint, RefPoint, MakeGroups, ElemType)
3494 if isinstance(Base, Mesh): Base = Base.GetMesh()
3495 if isinstance(Base, SMESH._objref_SMESH_Mesh) or isinstance(Base, SMESH._objref_SMESH_Group) or isinstance(Base, SMESH._objref_SMESH_subMesh):
3496 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3497 HasAngles, Angles, LinearVariation,
3498 HasRefPoint, RefPoint, MakeGroups, ElemType)
3500 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3503 ## Generates new elements by extrusion of the given elements
3504 # The path of extrusion must be a meshed edge.
3505 # @param IDsOfElements ids of elements
3506 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3507 # @param PathShape shape(edge) defines the sub-mesh for the path
3508 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3509 # @param HasAngles allows the shape to be rotated around the path
3510 # to get the resulting mesh in a helical fashion
3511 # @param Angles list of angles in radians
3512 # @param HasRefPoint allows using the reference point
3513 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3514 # The User can specify any point as the Reference Point.
3515 # @param MakeGroups forces the generation of new groups from existing ones
3516 # @param LinearVariation forces the computation of rotation angles as linear
3517 # variation of the given Angles along path steps
3518 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3519 # only SMESH::Extrusion_Error otherwise
3520 # @ingroup l2_modif_extrurev
3521 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3522 HasAngles, Angles, HasRefPoint, RefPoint,
3523 MakeGroups=False, LinearVariation=False):
3524 Angles,AnglesParameters = ParseAngles(Angles)
3525 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3526 if IDsOfElements == []:
3527 IDsOfElements = self.GetElementsId()
3528 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3529 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3531 if ( isinstance( PathMesh, Mesh )):
3532 PathMesh = PathMesh.GetMesh()
3533 if HasAngles and Angles and LinearVariation:
3534 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3536 Parameters = AnglesParameters + var_separator + RefPointParameters
3537 self.mesh.SetParameters(Parameters)
3539 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3540 PathShape, NodeStart, HasAngles,
3541 Angles, HasRefPoint, RefPoint)
3542 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3543 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3545 ## Generates new elements by extrusion of the elements which belong to the object
3546 # The path of extrusion must be a meshed edge.
3547 # @param theObject the object which elements should be processed.
3548 # It can be a mesh, a sub mesh or a group.
3549 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3550 # @param PathShape shape(edge) defines the sub-mesh for the path
3551 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3552 # @param HasAngles allows the shape to be rotated around the path
3553 # to get the resulting mesh in a helical fashion
3554 # @param Angles list of angles
3555 # @param HasRefPoint allows using the reference point
3556 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3557 # The User can specify any point as the Reference Point.
3558 # @param MakeGroups forces the generation of new groups from existing ones
3559 # @param LinearVariation forces the computation of rotation angles as linear
3560 # variation of the given Angles along path steps
3561 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3562 # only SMESH::Extrusion_Error otherwise
3563 # @ingroup l2_modif_extrurev
3564 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3565 HasAngles, Angles, HasRefPoint, RefPoint,
3566 MakeGroups=False, LinearVariation=False):
3567 Angles,AnglesParameters = ParseAngles(Angles)
3568 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3569 if ( isinstance( theObject, Mesh )):
3570 theObject = theObject.GetMesh()
3571 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3572 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3573 if ( isinstance( PathMesh, Mesh )):
3574 PathMesh = PathMesh.GetMesh()
3575 if HasAngles and Angles and LinearVariation:
3576 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3578 Parameters = AnglesParameters + var_separator + RefPointParameters
3579 self.mesh.SetParameters(Parameters)
3581 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3582 PathShape, NodeStart, HasAngles,
3583 Angles, HasRefPoint, RefPoint)
3584 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3585 NodeStart, HasAngles, Angles, HasRefPoint,
3588 ## Generates new elements by extrusion of the elements which belong to the object
3589 # The path of extrusion must be a meshed edge.
3590 # @param theObject the object which elements should be processed.
3591 # It can be a mesh, a sub mesh or a group.
3592 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3593 # @param PathShape shape(edge) defines the sub-mesh for the path
3594 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3595 # @param HasAngles allows the shape to be rotated around the path
3596 # to get the resulting mesh in a helical fashion
3597 # @param Angles list of angles
3598 # @param HasRefPoint allows using the reference point
3599 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3600 # The User can specify any point as the Reference Point.
3601 # @param MakeGroups forces the generation of new groups from existing ones
3602 # @param LinearVariation forces the computation of rotation angles as linear
3603 # variation of the given Angles along path steps
3604 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3605 # only SMESH::Extrusion_Error otherwise
3606 # @ingroup l2_modif_extrurev
3607 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3608 HasAngles, Angles, HasRefPoint, RefPoint,
3609 MakeGroups=False, LinearVariation=False):
3610 Angles,AnglesParameters = ParseAngles(Angles)
3611 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3612 if ( isinstance( theObject, Mesh )):
3613 theObject = theObject.GetMesh()
3614 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3615 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3616 if ( isinstance( PathMesh, Mesh )):
3617 PathMesh = PathMesh.GetMesh()
3618 if HasAngles and Angles and LinearVariation:
3619 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3621 Parameters = AnglesParameters + var_separator + RefPointParameters
3622 self.mesh.SetParameters(Parameters)
3624 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3625 PathShape, NodeStart, HasAngles,
3626 Angles, HasRefPoint, RefPoint)
3627 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3628 NodeStart, HasAngles, Angles, HasRefPoint,
3631 ## Generates new elements by extrusion of the elements which belong to the object
3632 # The path of extrusion must be a meshed edge.
3633 # @param theObject the object which elements should be processed.
3634 # It can be a mesh, a sub mesh or a group.
3635 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3636 # @param PathShape shape(edge) defines the sub-mesh for the path
3637 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3638 # @param HasAngles allows the shape to be rotated around the path
3639 # to get the resulting mesh in a helical fashion
3640 # @param Angles list of angles
3641 # @param HasRefPoint allows using the reference point
3642 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3643 # The User can specify any point as the Reference Point.
3644 # @param MakeGroups forces the generation of new groups from existing ones
3645 # @param LinearVariation forces the computation of rotation angles as linear
3646 # variation of the given Angles along path steps
3647 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3648 # only SMESH::Extrusion_Error otherwise
3649 # @ingroup l2_modif_extrurev
3650 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3651 HasAngles, Angles, HasRefPoint, RefPoint,
3652 MakeGroups=False, LinearVariation=False):
3653 Angles,AnglesParameters = ParseAngles(Angles)
3654 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3655 if ( isinstance( theObject, Mesh )):
3656 theObject = theObject.GetMesh()
3657 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3658 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3659 if ( isinstance( PathMesh, Mesh )):
3660 PathMesh = PathMesh.GetMesh()
3661 if HasAngles and Angles and LinearVariation:
3662 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3664 Parameters = AnglesParameters + var_separator + RefPointParameters
3665 self.mesh.SetParameters(Parameters)
3667 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3668 PathShape, NodeStart, HasAngles,
3669 Angles, HasRefPoint, RefPoint)
3670 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3671 NodeStart, HasAngles, Angles, HasRefPoint,
3674 ## Creates a symmetrical copy of mesh elements
3675 # @param IDsOfElements list of elements ids
3676 # @param Mirror is AxisStruct or geom object(point, line, plane)
3677 # @param theMirrorType is POINT, AXIS or PLANE
3678 # If the Mirror is a geom object this parameter is unnecessary
3679 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3680 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3681 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3682 # @ingroup l2_modif_trsf
3683 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3684 if IDsOfElements == []:
3685 IDsOfElements = self.GetElementsId()
3686 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3687 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3688 Mirror,Parameters = ParseAxisStruct(Mirror)
3689 self.mesh.SetParameters(Parameters)
3690 if Copy and MakeGroups:
3691 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3692 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3695 ## Creates a new mesh by a symmetrical copy of mesh elements
3696 # @param IDsOfElements the list of elements ids
3697 # @param Mirror is AxisStruct or geom object (point, line, plane)
3698 # @param theMirrorType is POINT, AXIS or PLANE
3699 # If the Mirror is a geom object this parameter is unnecessary
3700 # @param MakeGroups to generate new groups from existing ones
3701 # @param NewMeshName a name of the new mesh to create
3702 # @return instance of Mesh class
3703 # @ingroup l2_modif_trsf
3704 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3705 if IDsOfElements == []:
3706 IDsOfElements = self.GetElementsId()
3707 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3708 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3709 Mirror,Parameters = ParseAxisStruct(Mirror)
3710 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3711 MakeGroups, NewMeshName)
3712 mesh.SetParameters(Parameters)
3713 return Mesh(self.smeshpyD,self.geompyD,mesh)
3715 ## Creates a symmetrical copy of the object
3716 # @param theObject mesh, submesh or group
3717 # @param Mirror AxisStruct or geom object (point, line, plane)
3718 # @param theMirrorType is POINT, AXIS or PLANE
3719 # If the Mirror is a geom object this parameter is unnecessary
3720 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3721 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3722 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3723 # @ingroup l2_modif_trsf
3724 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3725 if ( isinstance( theObject, Mesh )):
3726 theObject = theObject.GetMesh()
3727 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3728 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3729 Mirror,Parameters = ParseAxisStruct(Mirror)
3730 self.mesh.SetParameters(Parameters)
3731 if Copy and MakeGroups:
3732 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3733 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3736 ## Creates a new mesh by a symmetrical copy of the object
3737 # @param theObject mesh, submesh or group
3738 # @param Mirror AxisStruct or geom object (point, line, plane)
3739 # @param theMirrorType POINT, AXIS or PLANE
3740 # If the Mirror is a geom object this parameter is unnecessary
3741 # @param MakeGroups forces the generation of new groups from existing ones
3742 # @param NewMeshName the name of the new mesh to create
3743 # @return instance of Mesh class
3744 # @ingroup l2_modif_trsf
3745 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3746 if ( isinstance( theObject, Mesh )):
3747 theObject = theObject.GetMesh()
3748 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3749 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3750 Mirror,Parameters = ParseAxisStruct(Mirror)
3751 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3752 MakeGroups, NewMeshName)
3753 mesh.SetParameters(Parameters)
3754 return Mesh( self.smeshpyD,self.geompyD,mesh )
3756 ## Translates the elements
3757 # @param IDsOfElements list of elements ids
3758 # @param Vector the direction of translation (DirStruct or vector)
3759 # @param Copy allows copying the translated elements
3760 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3761 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3762 # @ingroup l2_modif_trsf
3763 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3764 if IDsOfElements == []:
3765 IDsOfElements = self.GetElementsId()
3766 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3767 Vector = self.smeshpyD.GetDirStruct(Vector)
3768 Vector,Parameters = ParseDirStruct(Vector)
3769 self.mesh.SetParameters(Parameters)
3770 if Copy and MakeGroups:
3771 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3772 self.editor.Translate(IDsOfElements, Vector, Copy)
3775 ## Creates a new mesh of translated elements
3776 # @param IDsOfElements list of elements ids
3777 # @param Vector the direction of translation (DirStruct or vector)
3778 # @param MakeGroups forces the generation of new groups from existing ones
3779 # @param NewMeshName the name of the newly created mesh
3780 # @return instance of Mesh class
3781 # @ingroup l2_modif_trsf
3782 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3783 if IDsOfElements == []:
3784 IDsOfElements = self.GetElementsId()
3785 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3786 Vector = self.smeshpyD.GetDirStruct(Vector)
3787 Vector,Parameters = ParseDirStruct(Vector)
3788 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3789 mesh.SetParameters(Parameters)
3790 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3792 ## Translates the object
3793 # @param theObject the object to translate (mesh, submesh, or group)
3794 # @param Vector direction of translation (DirStruct or geom vector)
3795 # @param Copy allows copying the translated elements
3796 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3797 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3798 # @ingroup l2_modif_trsf
3799 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3800 if ( isinstance( theObject, Mesh )):
3801 theObject = theObject.GetMesh()
3802 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3803 Vector = self.smeshpyD.GetDirStruct(Vector)
3804 Vector,Parameters = ParseDirStruct(Vector)
3805 self.mesh.SetParameters(Parameters)
3806 if Copy and MakeGroups:
3807 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3808 self.editor.TranslateObject(theObject, Vector, Copy)
3811 ## Creates a new mesh from the translated object
3812 # @param theObject the object to translate (mesh, submesh, or group)
3813 # @param Vector the direction of translation (DirStruct or geom vector)
3814 # @param MakeGroups forces the generation of new groups from existing ones
3815 # @param NewMeshName the name of the newly created mesh
3816 # @return instance of Mesh class
3817 # @ingroup l2_modif_trsf
3818 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3819 if (isinstance(theObject, Mesh)):
3820 theObject = theObject.GetMesh()
3821 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3822 Vector = self.smeshpyD.GetDirStruct(Vector)
3823 Vector,Parameters = ParseDirStruct(Vector)
3824 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3825 mesh.SetParameters(Parameters)
3826 return Mesh( self.smeshpyD, self.geompyD, mesh )
3830 ## Scales the object
3831 # @param theObject - the object to translate (mesh, submesh, or group)
3832 # @param thePoint - base point for scale
3833 # @param theScaleFact - list of 1-3 scale factors for axises
3834 # @param Copy - allows copying the translated elements
3835 # @param MakeGroups - forces the generation of new groups from existing
3837 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3838 # empty list otherwise
3839 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3840 if ( isinstance( theObject, Mesh )):
3841 theObject = theObject.GetMesh()
3842 if ( isinstance( theObject, list )):
3843 theObject = self.GetIDSource(theObject, SMESH.ALL)
3845 thePoint, Parameters = ParsePointStruct(thePoint)
3846 self.mesh.SetParameters(Parameters)
3848 if Copy and MakeGroups:
3849 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3850 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3853 ## Creates a new mesh from the translated object
3854 # @param theObject - the object to translate (mesh, submesh, or group)
3855 # @param thePoint - base point for scale
3856 # @param theScaleFact - list of 1-3 scale factors for axises
3857 # @param MakeGroups - forces the generation of new groups from existing ones
3858 # @param NewMeshName - the name of the newly created mesh
3859 # @return instance of Mesh class
3860 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3861 if (isinstance(theObject, Mesh)):
3862 theObject = theObject.GetMesh()
3863 if ( isinstance( theObject, list )):
3864 theObject = self.GetIDSource(theObject,SMESH.ALL)
3866 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3867 MakeGroups, NewMeshName)
3868 #mesh.SetParameters(Parameters)
3869 return Mesh( self.smeshpyD, self.geompyD, mesh )
3873 ## Rotates the elements
3874 # @param IDsOfElements list of elements ids
3875 # @param Axis the axis of rotation (AxisStruct or geom line)
3876 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3877 # @param Copy allows copying the rotated elements
3878 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3879 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3880 # @ingroup l2_modif_trsf
3881 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3883 if isinstance(AngleInRadians,str):
3885 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3887 AngleInRadians = DegreesToRadians(AngleInRadians)
3888 if IDsOfElements == []:
3889 IDsOfElements = self.GetElementsId()
3890 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3891 Axis = self.smeshpyD.GetAxisStruct(Axis)
3892 Axis,AxisParameters = ParseAxisStruct(Axis)
3893 Parameters = AxisParameters + var_separator + Parameters
3894 self.mesh.SetParameters(Parameters)
3895 if Copy and MakeGroups:
3896 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3897 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3900 ## Creates a new mesh of rotated elements
3901 # @param IDsOfElements list of element ids
3902 # @param Axis the axis of rotation (AxisStruct or geom line)
3903 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3904 # @param MakeGroups forces the generation of new groups from existing ones
3905 # @param NewMeshName the name of the newly created mesh
3906 # @return instance of Mesh class
3907 # @ingroup l2_modif_trsf
3908 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3910 if isinstance(AngleInRadians,str):
3912 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3914 AngleInRadians = DegreesToRadians(AngleInRadians)
3915 if IDsOfElements == []:
3916 IDsOfElements = self.GetElementsId()
3917 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3918 Axis = self.smeshpyD.GetAxisStruct(Axis)
3919 Axis,AxisParameters = ParseAxisStruct(Axis)
3920 Parameters = AxisParameters + var_separator + Parameters
3921 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3922 MakeGroups, NewMeshName)
3923 mesh.SetParameters(Parameters)
3924 return Mesh( self.smeshpyD, self.geompyD, mesh )
3926 ## Rotates the object
3927 # @param theObject the object to rotate( mesh, submesh, or group)
3928 # @param Axis the axis of rotation (AxisStruct or geom line)
3929 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3930 # @param Copy allows copying the rotated elements
3931 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3932 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3933 # @ingroup l2_modif_trsf
3934 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3936 if isinstance(AngleInRadians,str):
3938 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3940 AngleInRadians = DegreesToRadians(AngleInRadians)
3941 if (isinstance(theObject, Mesh)):
3942 theObject = theObject.GetMesh()
3943 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3944 Axis = self.smeshpyD.GetAxisStruct(Axis)
3945 Axis,AxisParameters = ParseAxisStruct(Axis)
3946 Parameters = AxisParameters + ":" + Parameters
3947 self.mesh.SetParameters(Parameters)
3948 if Copy and MakeGroups:
3949 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3950 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3953 ## Creates a new mesh from the rotated object
3954 # @param theObject the object to rotate (mesh, submesh, or group)
3955 # @param Axis the axis of rotation (AxisStruct or geom line)
3956 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3957 # @param MakeGroups forces the generation of new groups from existing ones
3958 # @param NewMeshName the name of the newly created mesh
3959 # @return instance of Mesh class
3960 # @ingroup l2_modif_trsf
3961 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3963 if isinstance(AngleInRadians,str):
3965 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3967 AngleInRadians = DegreesToRadians(AngleInRadians)
3968 if (isinstance( theObject, Mesh )):
3969 theObject = theObject.GetMesh()
3970 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3971 Axis = self.smeshpyD.GetAxisStruct(Axis)
3972 Axis,AxisParameters = ParseAxisStruct(Axis)
3973 Parameters = AxisParameters + ":" + Parameters
3974 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3975 MakeGroups, NewMeshName)
3976 mesh.SetParameters(Parameters)
3977 return Mesh( self.smeshpyD, self.geompyD, mesh )
3979 ## Finds groups of ajacent nodes within Tolerance.
3980 # @param Tolerance the value of tolerance
3981 # @return the list of groups of nodes
3982 # @ingroup l2_modif_trsf
3983 def FindCoincidentNodes (self, Tolerance):
3984 return self.editor.FindCoincidentNodes(Tolerance)
3986 ## Finds groups of ajacent nodes within Tolerance.
3987 # @param Tolerance the value of tolerance
3988 # @param SubMeshOrGroup SubMesh or Group
3989 # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
3990 # @return the list of groups of nodes
3991 # @ingroup l2_modif_trsf
3992 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
3993 if (isinstance( SubMeshOrGroup, Mesh )):
3994 SubMeshOrGroup = SubMeshOrGroup.GetMesh()
3995 if not isinstance( exceptNodes, list):
3996 exceptNodes = [ exceptNodes ]
3997 if exceptNodes and isinstance( exceptNodes[0], int):
3998 exceptNodes = [ self.GetIDSource( exceptNodes, SMESH.NODE)]
3999 return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes)
4002 # @param GroupsOfNodes the list of groups of nodes
4003 # @ingroup l2_modif_trsf
4004 def MergeNodes (self, GroupsOfNodes):
4005 self.editor.MergeNodes(GroupsOfNodes)
4007 ## Finds the elements built on the same nodes.
4008 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
4009 # @return a list of groups of equal elements
4010 # @ingroup l2_modif_trsf
4011 def FindEqualElements (self, MeshOrSubMeshOrGroup):
4012 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
4013 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
4014 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
4016 ## Merges elements in each given group.
4017 # @param GroupsOfElementsID groups of elements for merging
4018 # @ingroup l2_modif_trsf
4019 def MergeElements(self, GroupsOfElementsID):
4020 self.editor.MergeElements(GroupsOfElementsID)
4022 ## Leaves one element and removes all other elements built on the same nodes.
4023 # @ingroup l2_modif_trsf
4024 def MergeEqualElements(self):
4025 self.editor.MergeEqualElements()
4027 ## Sews free borders
4028 # @return SMESH::Sew_Error
4029 # @ingroup l2_modif_trsf
4030 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
4031 FirstNodeID2, SecondNodeID2, LastNodeID2,
4032 CreatePolygons, CreatePolyedrs):
4033 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
4034 FirstNodeID2, SecondNodeID2, LastNodeID2,
4035 CreatePolygons, CreatePolyedrs)
4037 ## Sews conform free borders
4038 # @return SMESH::Sew_Error
4039 # @ingroup l2_modif_trsf
4040 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
4041 FirstNodeID2, SecondNodeID2):
4042 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
4043 FirstNodeID2, SecondNodeID2)
4045 ## Sews border to side
4046 # @return SMESH::Sew_Error
4047 # @ingroup l2_modif_trsf
4048 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
4049 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
4050 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
4051 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
4053 ## Sews two sides of a mesh. The nodes belonging to Side1 are
4054 # merged with the nodes of elements of Side2.
4055 # The number of elements in theSide1 and in theSide2 must be
4056 # equal and they should have similar nodal connectivity.
4057 # The nodes to merge should belong to side borders and
4058 # the first node should be linked to the second.
4059 # @return SMESH::Sew_Error
4060 # @ingroup l2_modif_trsf
4061 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
4062 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
4063 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
4064 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
4065 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
4066 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
4068 ## Sets new nodes for the given element.
4069 # @param ide the element id
4070 # @param newIDs nodes ids
4071 # @return If the number of nodes does not correspond to the type of element - returns false
4072 # @ingroup l2_modif_edit
4073 def ChangeElemNodes(self, ide, newIDs):
4074 return self.editor.ChangeElemNodes(ide, newIDs)
4076 ## If during the last operation of MeshEditor some nodes were
4077 # created, this method returns the list of their IDs, \n
4078 # if new nodes were not created - returns empty list
4079 # @return the list of integer values (can be empty)
4080 # @ingroup l1_auxiliary
4081 def GetLastCreatedNodes(self):
4082 return self.editor.GetLastCreatedNodes()
4084 ## If during the last operation of MeshEditor some elements were
4085 # created this method returns the list of their IDs, \n
4086 # if new elements were not created - returns empty list
4087 # @return the list of integer values (can be empty)
4088 # @ingroup l1_auxiliary
4089 def GetLastCreatedElems(self):
4090 return self.editor.GetLastCreatedElems()
4092 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4093 # @param theNodes identifiers of nodes to be doubled
4094 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
4095 # nodes. If list of element identifiers is empty then nodes are doubled but
4096 # they not assigned to elements
4097 # @return TRUE if operation has been completed successfully, FALSE otherwise
4098 # @ingroup l2_modif_edit
4099 def DoubleNodes(self, theNodes, theModifiedElems):
4100 return self.editor.DoubleNodes(theNodes, theModifiedElems)
4102 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4103 # This method provided for convenience works as DoubleNodes() described above.
4104 # @param theNodeId identifiers of node to be doubled
4105 # @param theModifiedElems identifiers of elements to be updated
4106 # @return TRUE if operation has been completed successfully, FALSE otherwise
4107 # @ingroup l2_modif_edit
4108 def DoubleNode(self, theNodeId, theModifiedElems):
4109 return self.editor.DoubleNode(theNodeId, theModifiedElems)
4111 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4112 # This method provided for convenience works as DoubleNodes() described above.
4113 # @param theNodes group of nodes to be doubled
4114 # @param theModifiedElems group of elements to be updated.
4115 # @param theMakeGroup forces the generation of a group containing new nodes.
4116 # @return TRUE or a created group if operation has been completed successfully,
4117 # FALSE or None otherwise
4118 # @ingroup l2_modif_edit
4119 def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
4121 return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
4122 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
4124 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4125 # This method provided for convenience works as DoubleNodes() described above.
4126 # @param theNodes list of groups of nodes to be doubled
4127 # @param theModifiedElems list of groups of elements to be updated.
4128 # @return TRUE if operation has been completed successfully, FALSE otherwise
4129 # @ingroup l2_modif_edit
4130 def DoubleNodeGroups(self, theNodes, theModifiedElems, theMakeGroup=False):
4132 return self.editor.DoubleNodeGroupsNew(theNodes, theModifiedElems)
4133 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
4135 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4136 # @param theElems - the list of elements (edges or faces) to be replicated
4137 # The nodes for duplication could be found from these elements
4138 # @param theNodesNot - list of nodes to NOT replicate
4139 # @param theAffectedElems - the list of elements (cells and edges) to which the
4140 # replicated nodes should be associated to.
4141 # @return TRUE if operation has been completed successfully, FALSE otherwise
4142 # @ingroup l2_modif_edit
4143 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
4144 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
4146 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4147 # @param theElems - the list of elements (edges or faces) to be replicated
4148 # The nodes for duplication could be found from these elements
4149 # @param theNodesNot - list of nodes to NOT replicate
4150 # @param theShape - shape to detect affected elements (element which geometric center
4151 # located on or inside shape).
4152 # The replicated nodes should be associated to affected elements.
4153 # @return TRUE if operation has been completed successfully, FALSE otherwise
4154 # @ingroup l2_modif_edit
4155 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
4156 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
4158 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4159 # This method provided for convenience works as DoubleNodes() described above.
4160 # @param theElems - group of of elements (edges or faces) to be replicated
4161 # @param theNodesNot - group of nodes not to replicated
4162 # @param theAffectedElems - group of elements to which the replicated nodes
4163 # should be associated to.
4164 # @param theMakeGroup forces the generation of a group containing new elements.
4165 # @return TRUE or a created group if operation has been completed successfully,
4166 # FALSE or None otherwise
4167 # @ingroup l2_modif_edit
4168 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4170 return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
4171 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
4173 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4174 # This method provided for convenience works as DoubleNodes() described above.
4175 # @param theElems - group of of elements (edges or faces) to be replicated
4176 # @param theNodesNot - group of nodes not to replicated
4177 # @param theShape - shape to detect affected elements (element which geometric center
4178 # located on or inside shape).
4179 # The replicated nodes should be associated to affected elements.
4180 # @ingroup l2_modif_edit
4181 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
4182 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
4184 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4185 # This method provided for convenience works as DoubleNodes() described above.
4186 # @param theElems - list of groups of elements (edges or faces) to be replicated
4187 # @param theNodesNot - list of groups of nodes not to replicated
4188 # @param theAffectedElems - group of elements to which the replicated nodes
4189 # should be associated to.
4190 # @param theMakeGroup forces the generation of a group containing new elements.
4191 # @return TRUE or a created group if operation has been completed successfully,
4192 # FALSE or None otherwise
4193 # @ingroup l2_modif_edit
4194 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4196 return self.editor.DoubleNodeElemGroupsNew(theElems, theNodesNot, theAffectedElems)
4197 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
4199 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4200 # This method provided for convenience works as DoubleNodes() described above.
4201 # @param theElems - list of groups of elements (edges or faces) to be replicated
4202 # @param theNodesNot - list of groups of nodes not to replicated
4203 # @param theShape - shape to detect affected elements (element which geometric center
4204 # located on or inside shape).
4205 # The replicated nodes should be associated to affected elements.
4206 # @return TRUE if operation has been completed successfully, FALSE otherwise
4207 # @ingroup l2_modif_edit
4208 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
4209 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
4211 ## Double nodes on shared faces between groups of volumes and create flat elements on demand.
4212 # The list of groups must describe a partition of the mesh volumes.
4213 # The nodes of the internal faces at the boundaries of the groups are doubled.
4214 # In option, the internal faces are replaced by flat elements.
4215 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4216 # @param theDomains - list of groups of volumes
4217 # @param createJointElems - if TRUE, create the elements
4218 # @return TRUE if operation has been completed successfully, FALSE otherwise
4219 def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems ):
4220 return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems )
4222 ## Double nodes on some external faces and create flat elements.
4223 # Flat elements are mainly used by some types of mechanic calculations.
4225 # Each group of the list must be constituted of faces.
4226 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4227 # @param theGroupsOfFaces - list of groups of faces
4228 # @return TRUE if operation has been completed successfully, FALSE otherwise
4229 def CreateFlatElementsOnFacesGroups(self, theGroupsOfFaces ):
4230 return self.editor.CreateFlatElementsOnFacesGroups( theGroupsOfFaces )
4232 def _valueFromFunctor(self, funcType, elemId):
4233 fn = self.smeshpyD.GetFunctor(funcType)
4234 fn.SetMesh(self.mesh)
4235 if fn.GetElementType() == self.GetElementType(elemId, True):
4236 val = fn.GetValue(elemId)
4241 ## Get length of 1D element.
4242 # @param elemId mesh element ID
4243 # @return element's length value
4244 # @ingroup l1_measurements
4245 def GetLength(self, elemId):
4246 return self._valueFromFunctor(SMESH.FT_Length, elemId)
4248 ## Get area of 2D element.
4249 # @param elemId mesh element ID
4250 # @return element's area value
4251 # @ingroup l1_measurements
4252 def GetArea(self, elemId):
4253 return self._valueFromFunctor(SMESH.FT_Area, elemId)
4255 ## Get volume of 3D element.
4256 # @param elemId mesh element ID
4257 # @return element's volume value
4258 # @ingroup l1_measurements
4259 def GetVolume(self, elemId):
4260 return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
4262 ## Get maximum element length.
4263 # @param elemId mesh element ID
4264 # @return element's maximum length value
4265 # @ingroup l1_measurements
4266 def GetMaxElementLength(self, elemId):
4267 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4268 ftype = SMESH.FT_MaxElementLength3D
4270 ftype = SMESH.FT_MaxElementLength2D
4271 return self._valueFromFunctor(ftype, elemId)
4273 ## Get aspect ratio of 2D or 3D element.
4274 # @param elemId mesh element ID
4275 # @return element's aspect ratio value
4276 # @ingroup l1_measurements
4277 def GetAspectRatio(self, elemId):
4278 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4279 ftype = SMESH.FT_AspectRatio3D
4281 ftype = SMESH.FT_AspectRatio
4282 return self._valueFromFunctor(ftype, elemId)
4284 ## Get warping angle of 2D element.
4285 # @param elemId mesh element ID
4286 # @return element's warping angle value
4287 # @ingroup l1_measurements
4288 def GetWarping(self, elemId):
4289 return self._valueFromFunctor(SMESH.FT_Warping, elemId)
4291 ## Get minimum angle of 2D element.
4292 # @param elemId mesh element ID
4293 # @return element's minimum angle value
4294 # @ingroup l1_measurements
4295 def GetMinimumAngle(self, elemId):
4296 return self._valueFromFunctor(SMESH.FT_MinimumAngle, elemId)
4298 ## Get taper of 2D element.
4299 # @param elemId mesh element ID
4300 # @return element's taper value
4301 # @ingroup l1_measurements
4302 def GetTaper(self, elemId):
4303 return self._valueFromFunctor(SMESH.FT_Taper, elemId)
4305 ## Get skew of 2D element.
4306 # @param elemId mesh element ID
4307 # @return element's skew value
4308 # @ingroup l1_measurements
4309 def GetSkew(self, elemId):
4310 return self._valueFromFunctor(SMESH.FT_Skew, elemId)
4312 ## The mother class to define algorithm, it is not recommended to use it directly.
4315 # @ingroup l2_algorithms
4316 class Mesh_Algorithm:
4317 # @class Mesh_Algorithm
4318 # @brief Class Mesh_Algorithm
4320 #def __init__(self,smesh):
4328 ## Finds a hypothesis in the study by its type name and parameters.
4329 # Finds only the hypotheses created in smeshpyD engine.
4330 # @return SMESH.SMESH_Hypothesis
4331 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
4332 study = smeshpyD.GetCurrentStudy()
4333 #to do: find component by smeshpyD object, not by its data type
4334 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4335 if scomp is not None:
4336 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
4337 # Check if the root label of the hypotheses exists
4338 if res and hypRoot is not None:
4339 iter = study.NewChildIterator(hypRoot)
4340 # Check all published hypotheses
4342 hypo_so_i = iter.Value()
4343 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
4344 if attr is not None:
4345 anIOR = attr.Value()
4346 hypo_o_i = salome.orb.string_to_object(anIOR)
4347 if hypo_o_i is not None:
4348 # Check if this is a hypothesis
4349 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
4350 if hypo_i is not None:
4351 # Check if the hypothesis belongs to current engine
4352 if smeshpyD.GetObjectId(hypo_i) > 0:
4353 # Check if this is the required hypothesis
4354 if hypo_i.GetName() == hypname:
4356 if CompareMethod(hypo_i, args):
4370 ## Finds the algorithm in the study by its type name.
4371 # Finds only the algorithms, which have been created in smeshpyD engine.
4372 # @return SMESH.SMESH_Algo
4373 def FindAlgorithm (self, algoname, smeshpyD):
4374 study = smeshpyD.GetCurrentStudy()
4375 #to do: find component by smeshpyD object, not by its data type
4376 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4377 if scomp is not None:
4378 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
4379 # Check if the root label of the algorithms exists
4380 if res and hypRoot is not None:
4381 iter = study.NewChildIterator(hypRoot)
4382 # Check all published algorithms
4384 algo_so_i = iter.Value()
4385 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
4386 if attr is not None:
4387 anIOR = attr.Value()
4388 algo_o_i = salome.orb.string_to_object(anIOR)
4389 if algo_o_i is not None:
4390 # Check if this is an algorithm
4391 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
4392 if algo_i is not None:
4393 # Checks if the algorithm belongs to the current engine
4394 if smeshpyD.GetObjectId(algo_i) > 0:
4395 # Check if this is the required algorithm
4396 if algo_i.GetName() == algoname:
4409 ## If the algorithm is global, returns 0; \n
4410 # else returns the submesh associated to this algorithm.
4411 def GetSubMesh(self):
4414 ## Returns the wrapped mesher.
4415 def GetAlgorithm(self):
4418 ## Gets the list of hypothesis that can be used with this algorithm
4419 def GetCompatibleHypothesis(self):
4422 mylist = self.algo.GetCompatibleHypothesis()
4425 ## Gets the name of the algorithm
4429 ## Sets the name to the algorithm
4430 def SetName(self, name):
4431 self.mesh.smeshpyD.SetName(self.algo, name)
4433 ## Gets the id of the algorithm
4435 return self.algo.GetId()
4438 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
4440 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
4441 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
4443 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
4445 self.Assign(algo, mesh, geom)
4449 def Assign(self, algo, mesh, geom):
4451 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
4455 self.geom = mesh.geom
4458 self.AssureGeomPublished( geom )
4460 name = GetName(geom)
4464 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
4466 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
4467 TreatHypoStatus( status, algo.GetName(), name, True )
4470 ## Private method. Add geom into the study if not yet there
4471 def AssureGeomPublished(self, geom, name=''):
4472 if not isinstance( geom, geompyDC.GEOM._objref_GEOM_Object ):
4474 if not geom.IsSame( self.mesh.geom ) and not geom.GetStudyEntry():
4476 studyID = self.mesh.smeshpyD.GetCurrentStudy()._get_StudyId()
4477 if studyID != self.mesh.geompyD.myStudyId:
4478 self.mesh.geompyD.init_geom( self.mesh.smeshpyD.GetCurrentStudy())
4480 if not name and geom.GetShapeType() != geompyDC.GEOM.COMPOUND:
4481 # for all groups SubShapeName() returns "Compound_-1"
4482 name = self.mesh.geompyD.SubShapeName(geom, self.mesh.geom)
4484 name = "%s_%s"%(geom.GetShapeType(), id(geom)%10000)
4486 self.mesh.geompyD.addToStudyInFather( self.mesh.geom, geom, name )
4489 def CompareHyp (self, hyp, args):
4490 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
4493 def CompareEqualHyp (self, hyp, args):
4497 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
4498 UseExisting=0, CompareMethod=""):
4501 if CompareMethod == "": CompareMethod = self.CompareHyp
4502 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
4505 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
4511 a = a + s + str(args[i])
4515 self.mesh.smeshpyD.SetName(hypo, hyp + a)
4519 geomName = GetName(self.geom)
4520 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
4521 TreatHypoStatus( status, GetName(hypo), geomName, 0 )
4524 ## Returns entry of the shape to mesh in the study
4525 def MainShapeEntry(self):
4527 if not self.mesh or not self.mesh.GetMesh(): return entry
4528 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
4529 study = self.mesh.smeshpyD.GetCurrentStudy()
4530 ior = salome.orb.object_to_string( self.mesh.GetShape() )
4531 sobj = study.FindObjectIOR(ior)
4532 if sobj: entry = sobj.GetID()
4533 if not entry: return ""
4536 ## Defines "ViscousLayers" hypothesis to give parameters of layers of prisms to build
4537 # near mesh boundary. This hypothesis can be used by several 3D algorithms:
4538 # NETGEN 3D, GHS3D, Hexahedron(i,j,k)
4539 # @param thickness total thickness of layers of prisms
4540 # @param numberOfLayers number of layers of prisms
4541 # @param stretchFactor factor (>1.0) of growth of layer thickness towards inside of mesh
4542 # @param ignoreFaces list of geometrical faces (or their ids) not to generate layers on
4543 # @ingroup l3_hypos_additi
4544 def ViscousLayers(self, thickness, numberOfLayers, stretchFactor, ignoreFaces=[]):
4545 if not isinstance(self.algo, SMESH._objref_SMESH_3D_Algo):
4546 raise TypeError, "ViscousLayers are supported by 3D algorithms only"
4547 if not "ViscousLayers" in self.GetCompatibleHypothesis():
4548 raise TypeError, "ViscousLayers are not supported by %s"%self.algo.GetName()
4549 if ignoreFaces and isinstance( ignoreFaces[0], geompyDC.GEOM._objref_GEOM_Object ):
4550 ignoreFaces = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, f) for f in ignoreFaces ]
4551 hyp = self.Hypothesis("ViscousLayers",
4552 [thickness, numberOfLayers, stretchFactor, ignoreFaces])
4553 hyp.SetTotalThickness(thickness)
4554 hyp.SetNumberLayers(numberOfLayers)
4555 hyp.SetStretchFactor(stretchFactor)
4556 hyp.SetIgnoreFaces(ignoreFaces)
4559 # Public class: Mesh_Segment
4560 # --------------------------
4562 ## Class to define a segment 1D algorithm for discretization
4565 # @ingroup l3_algos_basic
4566 class Mesh_Segment(Mesh_Algorithm):
4568 ## Private constructor.
4569 def __init__(self, mesh, geom=0):
4570 Mesh_Algorithm.__init__(self)
4571 self.Create(mesh, geom, "Regular_1D")
4573 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
4574 # @param l for the length of segments that cut an edge
4575 # @param UseExisting if ==true - searches for an existing hypothesis created with
4576 # the same parameters, else (default) - creates a new one
4577 # @param p precision, used for calculation of the number of segments.
4578 # The precision should be a positive, meaningful value within the range [0,1].
4579 # In general, the number of segments is calculated with the formula:
4580 # nb = ceil((edge_length / l) - p)
4581 # Function ceil rounds its argument to the higher integer.
4582 # So, p=0 means rounding of (edge_length / l) to the higher integer,
4583 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
4584 # p=1 means rounding of (edge_length / l) to the lower integer.
4585 # Default value is 1e-07.
4586 # @return an instance of StdMeshers_LocalLength hypothesis
4587 # @ingroup l3_hypos_1dhyps
4588 def LocalLength(self, l, UseExisting=0, p=1e-07):
4589 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
4590 CompareMethod=self.CompareLocalLength)
4596 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
4597 def CompareLocalLength(self, hyp, args):
4598 if IsEqual(hyp.GetLength(), args[0]):
4599 return IsEqual(hyp.GetPrecision(), args[1])
4602 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
4603 # @param length is optional maximal allowed length of segment, if it is omitted
4604 # the preestimated length is used that depends on geometry size
4605 # @param UseExisting if ==true - searches for an existing hypothesis created with
4606 # the same parameters, else (default) - create a new one
4607 # @return an instance of StdMeshers_MaxLength hypothesis
4608 # @ingroup l3_hypos_1dhyps
4609 def MaxSize(self, length=0.0, UseExisting=0):
4610 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
4613 hyp.SetLength(length)
4615 # set preestimated length
4616 gen = self.mesh.smeshpyD
4617 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
4618 self.mesh.GetMesh(), self.mesh.GetShape(),
4620 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
4622 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
4625 hyp.SetUsePreestimatedLength( length == 0.0 )
4628 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
4629 # @param n for the number of segments that cut an edge
4630 # @param s for the scale factor (optional)
4631 # @param reversedEdges is a list of edges to mesh using reversed orientation
4632 # @param UseExisting if ==true - searches for an existing hypothesis created with
4633 # the same parameters, else (default) - create a new one
4634 # @return an instance of StdMeshers_NumberOfSegments hypothesis
4635 # @ingroup l3_hypos_1dhyps
4636 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4637 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4638 reversedEdges, UseExisting = [], reversedEdges
4639 entry = self.MainShapeEntry()
4640 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4641 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4643 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
4644 UseExisting=UseExisting,
4645 CompareMethod=self.CompareNumberOfSegments)
4647 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
4648 UseExisting=UseExisting,
4649 CompareMethod=self.CompareNumberOfSegments)
4650 hyp.SetDistrType( 1 )
4651 hyp.SetScaleFactor(s)
4652 hyp.SetNumberOfSegments(n)
4653 hyp.SetReversedEdges( reversedEdges )
4654 hyp.SetObjectEntry( entry )
4658 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4659 def CompareNumberOfSegments(self, hyp, args):
4660 if hyp.GetNumberOfSegments() == args[0]:
4662 if hyp.GetReversedEdges() == args[1]:
4663 if not args[1] or hyp.GetObjectEntry() == args[2]:
4666 if hyp.GetReversedEdges() == args[2]:
4667 if not args[2] or hyp.GetObjectEntry() == args[3]:
4668 if hyp.GetDistrType() == 1:
4669 if IsEqual(hyp.GetScaleFactor(), args[1]):
4673 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4674 # @param start defines the length of the first segment
4675 # @param end defines the length of the last segment
4676 # @param reversedEdges is a list of edges to mesh using reversed orientation
4677 # @param UseExisting if ==true - searches for an existing hypothesis created with
4678 # the same parameters, else (default) - creates a new one
4679 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4680 # @ingroup l3_hypos_1dhyps
4681 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4682 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4683 reversedEdges, UseExisting = [], reversedEdges
4684 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4685 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4686 entry = self.MainShapeEntry()
4687 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
4688 UseExisting=UseExisting,
4689 CompareMethod=self.CompareArithmetic1D)
4690 hyp.SetStartLength(start)
4691 hyp.SetEndLength(end)
4692 hyp.SetReversedEdges( reversedEdges )
4693 hyp.SetObjectEntry( entry )
4697 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4698 def CompareArithmetic1D(self, hyp, args):
4699 if IsEqual(hyp.GetLength(1), args[0]):
4700 if IsEqual(hyp.GetLength(0), args[1]):
4701 if hyp.GetReversedEdges() == args[2]:
4702 if not args[2] or hyp.GetObjectEntry() == args[3]:
4707 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4708 # on curve from 0 to 1 (additionally it is neecessary to check
4709 # orientation of edges and create list of reversed edges if it is
4710 # needed) and sets numbers of segments between given points (default
4711 # values are equals 1
4712 # @param points defines the list of parameters on curve
4713 # @param nbSegs defines the list of numbers of segments
4714 # @param reversedEdges is a list of edges to mesh using reversed orientation
4715 # @param UseExisting if ==true - searches for an existing hypothesis created with
4716 # the same parameters, else (default) - creates a new one
4717 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4718 # @ingroup l3_hypos_1dhyps
4719 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4720 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4721 reversedEdges, UseExisting = [], reversedEdges
4722 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4723 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4724 entry = self.MainShapeEntry()
4725 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
4726 UseExisting=UseExisting,
4727 CompareMethod=self.CompareFixedPoints1D)
4728 hyp.SetPoints(points)
4729 hyp.SetNbSegments(nbSegs)
4730 hyp.SetReversedEdges(reversedEdges)
4731 hyp.SetObjectEntry(entry)
4735 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4736 ## as the given arguments
4737 def CompareFixedPoints1D(self, hyp, args):
4738 if hyp.GetPoints() == args[0]:
4739 if hyp.GetNbSegments() == args[1]:
4740 if hyp.GetReversedEdges() == args[2]:
4741 if not args[2] or hyp.GetObjectEntry() == args[3]:
4747 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4748 # @param start defines the length of the first segment
4749 # @param end defines the length of the last segment
4750 # @param reversedEdges is a list of edges to mesh using reversed orientation
4751 # @param UseExisting if ==true - searches for an existing hypothesis created with
4752 # the same parameters, else (default) - creates a new one
4753 # @return an instance of StdMeshers_StartEndLength hypothesis
4754 # @ingroup l3_hypos_1dhyps
4755 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4756 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4757 reversedEdges, UseExisting = [], reversedEdges
4758 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4759 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4760 entry = self.MainShapeEntry()
4761 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
4762 UseExisting=UseExisting,
4763 CompareMethod=self.CompareStartEndLength)
4764 hyp.SetStartLength(start)
4765 hyp.SetEndLength(end)
4766 hyp.SetReversedEdges( reversedEdges )
4767 hyp.SetObjectEntry( entry )
4770 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4771 def CompareStartEndLength(self, hyp, args):
4772 if IsEqual(hyp.GetLength(1), args[0]):
4773 if IsEqual(hyp.GetLength(0), args[1]):
4774 if hyp.GetReversedEdges() == args[2]:
4775 if not args[2] or hyp.GetObjectEntry() == args[3]:
4779 ## Defines "Deflection1D" hypothesis
4780 # @param d for the deflection
4781 # @param UseExisting if ==true - searches for an existing hypothesis created with
4782 # the same parameters, else (default) - create a new one
4783 # @ingroup l3_hypos_1dhyps
4784 def Deflection1D(self, d, UseExisting=0):
4785 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4786 CompareMethod=self.CompareDeflection1D)
4787 hyp.SetDeflection(d)
4790 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4791 def CompareDeflection1D(self, hyp, args):
4792 return IsEqual(hyp.GetDeflection(), args[0])
4794 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4795 # the opposite side in case of quadrangular faces
4796 # @ingroup l3_hypos_additi
4797 def Propagation(self):
4798 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4800 ## Defines "AutomaticLength" hypothesis
4801 # @param fineness for the fineness [0-1]
4802 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4803 # same parameters, else (default) - create a new one
4804 # @ingroup l3_hypos_1dhyps
4805 def AutomaticLength(self, fineness=0, UseExisting=0):
4806 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4807 CompareMethod=self.CompareAutomaticLength)
4808 hyp.SetFineness( fineness )
4811 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4812 def CompareAutomaticLength(self, hyp, args):
4813 return IsEqual(hyp.GetFineness(), args[0])
4815 ## Defines "SegmentLengthAroundVertex" hypothesis
4816 # @param length for the segment length
4817 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4818 # Any other integer value means that the hypothesis will be set on the
4819 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4820 # @param UseExisting if ==true - searches for an existing hypothesis created with
4821 # the same parameters, else (default) - creates a new one
4822 # @ingroup l3_algos_segmarv
4823 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4825 store_geom = self.geom
4826 if type(vertex) is types.IntType:
4827 if vertex == 0 or vertex == 1:
4828 vertex = self.mesh.geompyD.ExtractShapes(self.geom, geompyDC.ShapeType["VERTEX"],True)[vertex]
4836 if self.geom is None:
4837 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4838 self.AssureGeomPublished( self.geom )
4839 name = GetName(self.geom)
4841 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4843 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4845 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4846 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4848 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4849 CompareMethod=self.CompareLengthNearVertex)
4850 self.geom = store_geom
4851 hyp.SetLength( length )
4854 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4855 # @ingroup l3_algos_segmarv
4856 def CompareLengthNearVertex(self, hyp, args):
4857 return IsEqual(hyp.GetLength(), args[0])
4859 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4860 # If the 2D mesher sees that all boundary edges are quadratic,
4861 # it generates quadratic faces, else it generates linear faces using
4862 # medium nodes as if they are vertices.
4863 # The 3D mesher generates quadratic volumes only if all boundary faces
4864 # are quadratic, else it fails.
4866 # @ingroup l3_hypos_additi
4867 def QuadraticMesh(self):
4868 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4871 # Public class: Mesh_CompositeSegment
4872 # --------------------------
4874 ## Defines a segment 1D algorithm for discretization
4876 # @ingroup l3_algos_basic
4877 class Mesh_CompositeSegment(Mesh_Segment):
4879 ## Private constructor.
4880 def __init__(self, mesh, geom=0):
4881 self.Create(mesh, geom, "CompositeSegment_1D")
4884 # Public class: Mesh_Segment_Python
4885 # ---------------------------------
4887 ## Defines a segment 1D algorithm for discretization with python function
4889 # @ingroup l3_algos_basic
4890 class Mesh_Segment_Python(Mesh_Segment):
4892 ## Private constructor.
4893 def __init__(self, mesh, geom=0):
4894 import Python1dPlugin
4895 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4897 ## Defines "PythonSplit1D" hypothesis
4898 # @param n for the number of segments that cut an edge
4899 # @param func for the python function that calculates the length of all segments
4900 # @param UseExisting if ==true - searches for the existing hypothesis created with
4901 # the same parameters, else (default) - creates a new one
4902 # @ingroup l3_hypos_1dhyps
4903 def PythonSplit1D(self, n, func, UseExisting=0):
4904 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4905 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4906 hyp.SetNumberOfSegments(n)
4907 hyp.SetPythonLog10RatioFunction(func)
4910 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4911 def ComparePythonSplit1D(self, hyp, args):
4912 #if hyp.GetNumberOfSegments() == args[0]:
4913 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4917 # Public class: Mesh_Triangle
4918 # ---------------------------
4920 ## Defines a triangle 2D algorithm
4922 # @ingroup l3_algos_basic
4923 class Mesh_Triangle(Mesh_Algorithm):
4932 ## Private constructor.
4933 def __init__(self, mesh, algoType, geom=0):
4934 Mesh_Algorithm.__init__(self)
4936 self.algoType = algoType
4937 if algoType == MEFISTO:
4938 self.Create(mesh, geom, "MEFISTO_2D")
4940 elif algoType == BLSURF:
4942 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4943 #self.SetPhysicalMesh() - PAL19680
4944 elif algoType == NETGEN:
4946 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4948 elif algoType == NETGEN_2D:
4950 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4953 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4954 # @param area for the maximum area of each triangle
4955 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4956 # same parameters, else (default) - creates a new one
4958 # Only for algoType == MEFISTO || NETGEN_2D
4959 # @ingroup l3_hypos_2dhyps
4960 def MaxElementArea(self, area, UseExisting=0):
4961 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4962 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4963 CompareMethod=self.CompareMaxElementArea)
4964 elif self.algoType == NETGEN:
4965 hyp = self.Parameters(SIMPLE)
4966 hyp.SetMaxElementArea(area)
4969 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4970 def CompareMaxElementArea(self, hyp, args):
4971 return IsEqual(hyp.GetMaxElementArea(), args[0])
4973 ## Defines "LengthFromEdges" hypothesis to build triangles
4974 # based on the length of the edges taken from the wire
4976 # Only for algoType == MEFISTO || NETGEN_2D
4977 # @ingroup l3_hypos_2dhyps
4978 def LengthFromEdges(self):
4979 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4980 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4982 elif self.algoType == NETGEN:
4983 hyp = self.Parameters(SIMPLE)
4984 hyp.LengthFromEdges()
4987 ## Sets a way to define size of mesh elements to generate.
4988 # @param thePhysicalMesh is: DefaultSize or Custom.
4989 # @ingroup l3_hypos_blsurf
4990 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4991 # Parameter of BLSURF algo
4992 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4994 ## Sets size of mesh elements to generate.
4995 # @ingroup l3_hypos_blsurf
4996 def SetPhySize(self, theVal):
4997 # Parameter of BLSURF algo
4998 self.SetPhysicalMesh(1) #Custom - else why to set the size?
4999 self.Parameters().SetPhySize(theVal)
5001 ## Sets lower boundary of mesh element size (PhySize).
5002 # @ingroup l3_hypos_blsurf
5003 def SetPhyMin(self, theVal=-1):
5004 # Parameter of BLSURF algo
5005 self.Parameters().SetPhyMin(theVal)
5007 ## Sets upper boundary of mesh element size (PhySize).
5008 # @ingroup l3_hypos_blsurf
5009 def SetPhyMax(self, theVal=-1):
5010 # Parameter of BLSURF algo
5011 self.Parameters().SetPhyMax(theVal)
5013 ## Sets a way to define maximum angular deflection of mesh from CAD model.
5014 # @param theGeometricMesh is: 0 (None) or 1 (Custom)
5015 # @ingroup l3_hypos_blsurf
5016 def SetGeometricMesh(self, theGeometricMesh=0):
5017 # Parameter of BLSURF algo
5018 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
5019 self.params.SetGeometricMesh(theGeometricMesh)
5021 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
5022 # @ingroup l3_hypos_blsurf
5023 def SetAngleMeshS(self, theVal=_angleMeshS):
5024 # Parameter of BLSURF algo
5025 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
5026 self.params.SetAngleMeshS(theVal)
5028 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
5029 # @ingroup l3_hypos_blsurf
5030 def SetAngleMeshC(self, theVal=_angleMeshS):
5031 # Parameter of BLSURF algo
5032 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
5033 self.params.SetAngleMeshC(theVal)
5035 ## Sets lower boundary of mesh element size computed to respect angular deflection.
5036 # @ingroup l3_hypos_blsurf
5037 def SetGeoMin(self, theVal=-1):
5038 # Parameter of BLSURF algo
5039 self.Parameters().SetGeoMin(theVal)
5041 ## Sets upper boundary of mesh element size computed to respect angular deflection.
5042 # @ingroup l3_hypos_blsurf
5043 def SetGeoMax(self, theVal=-1):
5044 # Parameter of BLSURF algo
5045 self.Parameters().SetGeoMax(theVal)
5047 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
5048 # @ingroup l3_hypos_blsurf
5049 def SetGradation(self, theVal=_gradation):
5050 # Parameter of BLSURF algo
5051 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
5052 self.params.SetGradation(theVal)
5054 ## Sets topology usage way.
5055 # @param way defines how mesh conformity is assured <ul>
5056 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
5057 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
5058 # @ingroup l3_hypos_blsurf
5059 def SetTopology(self, way):
5060 # Parameter of BLSURF algo
5061 self.Parameters().SetTopology(way)
5063 ## To respect geometrical edges or not.
5064 # @ingroup l3_hypos_blsurf
5065 def SetDecimesh(self, toIgnoreEdges=False):
5066 # Parameter of BLSURF algo
5067 self.Parameters().SetDecimesh(toIgnoreEdges)
5069 ## Sets verbosity level in the range 0 to 100.
5070 # @ingroup l3_hypos_blsurf
5071 def SetVerbosity(self, level):
5072 # Parameter of BLSURF algo
5073 self.Parameters().SetVerbosity(level)
5075 ## Sets advanced option value.
5076 # @ingroup l3_hypos_blsurf
5077 def SetOptionValue(self, optionName, level):
5078 # Parameter of BLSURF algo
5079 self.Parameters().SetOptionValue(optionName,level)
5081 ## 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 ]
5082 # @param theFace : face on which the attractor will be defined
5083 # @param theAttractor : geometrical object from which the mesh size "h" decreases exponentially
5084 # @param theStartSize : mesh size on theAttractor
5085 # @param theEndSize : maximum size that will be reached on theFace
5086 # @param theInfluenceDistance : influence of the attractor ( the size grow slower on theFace if it's high)
5087 # @param theConstantSizeDistance : distance until which the mesh size will be kept constant on theFace
5088 # @ingroup l3_hypos_blsurf
5089 def SetAttractorGeom(self, theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance):
5090 self.AssureGeomPublished( theFace )
5091 self.AssureGeomPublished( theAttractor )
5092 # Parameter of BLSURF algo
5093 self.Parameters().SetAttractorGeom(theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance)
5095 ## Unsets an attractor on the chosen face.
5096 # @param theFace : face on which the attractor has to be removed
5097 # @ingroup l3_hypos_blsurf
5098 def UnsetAttractorGeom(self, theFace):
5099 self.AssureGeomPublished( theFace )
5100 # Parameter of BLSURF algo
5101 self.Parameters().SetAttractorGeom(theFace)
5103 ## Sets QuadAllowed flag.
5104 # Only for algoType == NETGEN(NETGEN_1D2D) || NETGEN_2D || BLSURF
5105 # @ingroup l3_hypos_netgen l3_hypos_blsurf
5106 def SetQuadAllowed(self, toAllow=True):
5107 if self.algoType == NETGEN_2D:
5110 hasSimpleHyps = False
5111 simpleHyps = ["QuadranglePreference","LengthFromEdges","MaxElementArea"]
5112 for hyp in self.mesh.GetHypothesisList( self.geom ):
5113 if hyp.GetName() in simpleHyps:
5114 hasSimpleHyps = True
5115 if hyp.GetName() == "QuadranglePreference":
5116 if not toAllow: # remove QuadranglePreference
5117 self.mesh.RemoveHypothesis( self.geom, hyp )
5123 if toAllow: # add QuadranglePreference
5124 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
5129 if self.Parameters():
5130 self.params.SetQuadAllowed(toAllow)
5133 ## Defines hypothesis having several parameters
5135 # @ingroup l3_hypos_netgen
5136 def Parameters(self, which=SOLE):
5138 if self.algoType == NETGEN:
5140 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
5141 "libNETGENEngine.so", UseExisting=0)
5143 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
5144 "libNETGENEngine.so", UseExisting=0)
5145 elif self.algoType == MEFISTO:
5146 print "Mefisto algo support no multi-parameter hypothesis"
5147 elif self.algoType == NETGEN_2D:
5148 self.params = self.Hypothesis("NETGEN_Parameters_2D_ONLY", [],
5149 "libNETGENEngine.so", UseExisting=0)
5150 elif self.algoType == BLSURF:
5151 self.params = self.Hypothesis("BLSURF_Parameters", [],
5152 "libBLSURFEngine.so", UseExisting=0)
5154 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
5159 # Only for algoType == NETGEN
5160 # @ingroup l3_hypos_netgen
5161 def SetMaxSize(self, theSize):
5162 if self.Parameters():
5163 self.params.SetMaxSize(theSize)
5165 ## Sets SecondOrder flag
5167 # Only for algoType == NETGEN
5168 # @ingroup l3_hypos_netgen
5169 def SetSecondOrder(self, theVal):
5170 if self.Parameters():
5171 self.params.SetSecondOrder(theVal)
5173 ## Sets Optimize flag
5175 # Only for algoType == NETGEN
5176 # @ingroup l3_hypos_netgen
5177 def SetOptimize(self, theVal):
5178 if self.Parameters():
5179 self.params.SetOptimize(theVal)
5182 # @param theFineness is:
5183 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5185 # Only for algoType == NETGEN
5186 # @ingroup l3_hypos_netgen
5187 def SetFineness(self, theFineness):
5188 if self.Parameters():
5189 self.params.SetFineness(theFineness)
5193 # Only for algoType == NETGEN
5194 # @ingroup l3_hypos_netgen
5195 def SetGrowthRate(self, theRate):
5196 if self.Parameters():
5197 self.params.SetGrowthRate(theRate)
5199 ## Sets NbSegPerEdge
5201 # Only for algoType == NETGEN
5202 # @ingroup l3_hypos_netgen
5203 def SetNbSegPerEdge(self, theVal):
5204 if self.Parameters():
5205 self.params.SetNbSegPerEdge(theVal)
5207 ## Sets NbSegPerRadius
5209 # Only for algoType == NETGEN
5210 # @ingroup l3_hypos_netgen
5211 def SetNbSegPerRadius(self, theVal):
5212 if self.Parameters():
5213 self.params.SetNbSegPerRadius(theVal)
5215 ## Sets number of segments overriding value set by SetLocalLength()
5217 # Only for algoType == NETGEN
5218 # @ingroup l3_hypos_netgen
5219 def SetNumberOfSegments(self, theVal):
5220 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5222 ## Sets number of segments overriding value set by SetNumberOfSegments()
5224 # Only for algoType == NETGEN
5225 # @ingroup l3_hypos_netgen
5226 def SetLocalLength(self, theVal):
5227 self.Parameters(SIMPLE).SetLocalLength(theVal)
5232 # Public class: Mesh_Quadrangle
5233 # -----------------------------
5235 ## Defines a quadrangle 2D algorithm
5237 # @ingroup l3_algos_basic
5238 class Mesh_Quadrangle(Mesh_Algorithm):
5242 ## Private constructor.
5243 def __init__(self, mesh, geom=0):
5244 Mesh_Algorithm.__init__(self)
5245 self.Create(mesh, geom, "Quadrangle_2D")
5248 ## Defines "QuadrangleParameters" hypothesis
5249 # @param quadType defines the algorithm of transition between differently descretized
5250 # sides of a geometrical face:
5251 # - QUAD_STANDARD - both triangles and quadrangles are possible in the transition
5252 # area along the finer meshed sides.
5253 # - QUAD_TRIANGLE_PREF - only triangles are built in the transition area along the
5254 # finer meshed sides.
5255 # - QUAD_QUADRANGLE_PREF - only quadrangles are built in the transition area along
5256 # the finer meshed sides, iff the total quantity of segments on
5257 # all four sides of the face is even (divisible by 2).
5258 # - QUAD_QUADRANGLE_PREF_REVERSED - same as QUAD_QUADRANGLE_PREF but the transition
5259 # area is located along the coarser meshed sides.
5260 # - QUAD_REDUCED - only quadrangles are built and the transition between the sides
5261 # is made gradually, layer by layer. This type has a limitation on
5262 # the number of segments: one pair of opposite sides must have the
5263 # same number of segments, the other pair must have an even difference
5264 # between the numbers of segments on the sides.
5265 # @param triangleVertex: vertex of a trilateral geometrical face, around which triangles
5266 # will be created while other elements will be quadrangles.
5267 # Vertex can be either a GEOM_Object or a vertex ID within the
5269 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5270 # the same parameters, else (default) - creates a new one
5271 # @ingroup l3_hypos_quad
5272 def QuadrangleParameters(self, quadType=StdMeshers.QUAD_STANDARD, triangleVertex=0, UseExisting=0):
5273 vertexID = triangleVertex
5274 if isinstance( triangleVertex, geompyDC.GEOM._objref_GEOM_Object ):
5275 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, triangleVertex )
5277 compFun = lambda hyp,args: \
5278 hyp.GetQuadType() == args[0] and \
5279 ( hyp.GetTriaVertex()==args[1] or ( hyp.GetTriaVertex()<1 and args[1]<1))
5280 self.params = self.Hypothesis("QuadrangleParams", [quadType,vertexID],
5281 UseExisting = UseExisting, CompareMethod=compFun)
5283 if self.params.GetQuadType() != quadType:
5284 self.params.SetQuadType(quadType)
5286 self.params.SetTriaVertex( vertexID )
5289 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5290 # quadrangles are built in the transition area along the finer meshed sides,
5291 # iff the total quantity of segments on all four sides of the face is even.
5292 # @param reversed if True, transition area is located along the coarser meshed sides.
5293 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5294 # the same parameters, else (default) - creates a new one
5295 # @ingroup l3_hypos_quad
5296 def QuadranglePreference(self, reversed=False, UseExisting=0):
5298 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF_REVERSED,UseExisting=UseExisting)
5299 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF,UseExisting=UseExisting)
5301 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5302 # triangles are built in the transition area along the finer meshed sides.
5303 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5304 # the same parameters, else (default) - creates a new one
5305 # @ingroup l3_hypos_quad
5306 def TrianglePreference(self, UseExisting=0):
5307 return self.QuadrangleParameters(QUAD_TRIANGLE_PREF,UseExisting=UseExisting)
5309 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5310 # quadrangles are built and the transition between the sides is made gradually,
5311 # layer by layer. This type has a limitation on the number of segments: one pair
5312 # of opposite sides must have the same number of segments, the other pair must
5313 # have an even difference between the numbers of segments on the sides.
5314 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5315 # the same parameters, else (default) - creates a new one
5316 # @ingroup l3_hypos_quad
5317 def Reduced(self, UseExisting=0):
5318 return self.QuadrangleParameters(QUAD_REDUCED,UseExisting=UseExisting)
5320 ## Defines "QuadrangleParams" hypothesis with QUAD_STANDARD type of quadrangulation
5321 # @param vertex: vertex of a trilateral geometrical face, around which triangles
5322 # will be created while other elements will be quadrangles.
5323 # Vertex can be either a GEOM_Object or a vertex ID within the
5325 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5326 # the same parameters, else (default) - creates a new one
5327 # @ingroup l3_hypos_quad
5328 def TriangleVertex(self, vertex, UseExisting=0):
5329 return self.QuadrangleParameters(QUAD_STANDARD,vertex,UseExisting)
5332 # Public class: Mesh_Tetrahedron
5333 # ------------------------------
5335 ## Defines a tetrahedron 3D algorithm
5337 # @ingroup l3_algos_basic
5338 class Mesh_Tetrahedron(Mesh_Algorithm):
5343 ## Private constructor.
5344 def __init__(self, mesh, algoType, geom=0):
5345 Mesh_Algorithm.__init__(self)
5347 if algoType == NETGEN:
5349 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
5352 elif algoType == FULL_NETGEN:
5354 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5357 elif algoType == GHS3D:
5359 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
5362 elif algoType == GHS3DPRL:
5363 CheckPlugin(GHS3DPRL)
5364 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
5367 self.algoType = algoType
5369 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
5370 # @param vol for the maximum volume of each tetrahedron
5371 # @param UseExisting if ==true - searches for the existing hypothesis created with
5372 # the same parameters, else (default) - creates a new one
5373 # @ingroup l3_hypos_maxvol
5374 def MaxElementVolume(self, vol, UseExisting=0):
5375 if self.algoType == NETGEN:
5376 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
5377 CompareMethod=self.CompareMaxElementVolume)
5378 hyp.SetMaxElementVolume(vol)
5380 elif self.algoType == FULL_NETGEN:
5381 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
5384 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
5385 def CompareMaxElementVolume(self, hyp, args):
5386 return IsEqual(hyp.GetMaxElementVolume(), args[0])
5388 ## Defines hypothesis having several parameters
5390 # @ingroup l3_hypos_netgen
5391 def Parameters(self, which=SOLE):
5394 if self.algoType == FULL_NETGEN:
5396 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
5397 "libNETGENEngine.so", UseExisting=0)
5399 self.params = self.Hypothesis("NETGEN_Parameters", [],
5400 "libNETGENEngine.so", UseExisting=0)
5402 elif self.algoType == NETGEN:
5403 self.params = self.Hypothesis("NETGEN_Parameters_3D", [],
5404 "libNETGENEngine.so", UseExisting=0)
5406 elif self.algoType == GHS3D:
5407 self.params = self.Hypothesis("GHS3D_Parameters", [],
5408 "libGHS3DEngine.so", UseExisting=0)
5410 elif self.algoType == GHS3DPRL:
5411 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
5412 "libGHS3DPRLEngine.so", UseExisting=0)
5414 print "Warning: %s supports no multi-parameter hypothesis"%self.algo.GetName()
5419 # Parameter of FULL_NETGEN and NETGEN
5420 # @ingroup l3_hypos_netgen
5421 def SetMaxSize(self, theSize):
5422 self.Parameters().SetMaxSize(theSize)
5424 ## Sets SecondOrder flag
5425 # Parameter of FULL_NETGEN
5426 # @ingroup l3_hypos_netgen
5427 def SetSecondOrder(self, theVal):
5428 self.Parameters().SetSecondOrder(theVal)
5430 ## Sets Optimize flag
5431 # Parameter of FULL_NETGEN and NETGEN
5432 # @ingroup l3_hypos_netgen
5433 def SetOptimize(self, theVal):
5434 self.Parameters().SetOptimize(theVal)
5437 # @param theFineness is:
5438 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5439 # Parameter of FULL_NETGEN
5440 # @ingroup l3_hypos_netgen
5441 def SetFineness(self, theFineness):
5442 self.Parameters().SetFineness(theFineness)
5445 # Parameter of FULL_NETGEN
5446 # @ingroup l3_hypos_netgen
5447 def SetGrowthRate(self, theRate):
5448 self.Parameters().SetGrowthRate(theRate)
5450 ## Sets NbSegPerEdge
5451 # Parameter of FULL_NETGEN
5452 # @ingroup l3_hypos_netgen
5453 def SetNbSegPerEdge(self, theVal):
5454 self.Parameters().SetNbSegPerEdge(theVal)
5456 ## Sets NbSegPerRadius
5457 # Parameter of FULL_NETGEN
5458 # @ingroup l3_hypos_netgen
5459 def SetNbSegPerRadius(self, theVal):
5460 self.Parameters().SetNbSegPerRadius(theVal)
5462 ## Sets number of segments overriding value set by SetLocalLength()
5463 # Only for algoType == NETGEN_FULL
5464 # @ingroup l3_hypos_netgen
5465 def SetNumberOfSegments(self, theVal):
5466 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5468 ## Sets number of segments overriding value set by SetNumberOfSegments()
5469 # Only for algoType == NETGEN_FULL
5470 # @ingroup l3_hypos_netgen
5471 def SetLocalLength(self, theVal):
5472 self.Parameters(SIMPLE).SetLocalLength(theVal)
5474 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
5475 # Overrides value set by LengthFromEdges()
5476 # Only for algoType == NETGEN_FULL
5477 # @ingroup l3_hypos_netgen
5478 def MaxElementArea(self, area):
5479 self.Parameters(SIMPLE).SetMaxElementArea(area)
5481 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
5482 # Overrides value set by MaxElementArea()
5483 # Only for algoType == NETGEN_FULL
5484 # @ingroup l3_hypos_netgen
5485 def LengthFromEdges(self):
5486 self.Parameters(SIMPLE).LengthFromEdges()
5488 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
5489 # Overrides value set by MaxElementVolume()
5490 # Only for algoType == NETGEN_FULL
5491 # @ingroup l3_hypos_netgen
5492 def LengthFromFaces(self):
5493 self.Parameters(SIMPLE).LengthFromFaces()
5495 ## To mesh "holes" in a solid or not. Default is to mesh.
5496 # @ingroup l3_hypos_ghs3dh
5497 def SetToMeshHoles(self, toMesh):
5498 # Parameter of GHS3D
5499 self.Parameters().SetToMeshHoles(toMesh)
5501 ## Set Optimization level:
5502 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
5503 # Strong_Optimization.
5504 # Default is Standard_Optimization
5505 # @ingroup l3_hypos_ghs3dh
5506 def SetOptimizationLevel(self, level):
5507 # Parameter of GHS3D
5508 self.Parameters().SetOptimizationLevel(level)
5510 ## Maximal size of memory to be used by the algorithm (in Megabytes).
5511 # @ingroup l3_hypos_ghs3dh
5512 def SetMaximumMemory(self, MB):
5513 # Advanced parameter of GHS3D
5514 self.Parameters().SetMaximumMemory(MB)
5516 ## Initial size of memory to be used by the algorithm (in Megabytes) in
5517 # automatic memory adjustment mode.
5518 # @ingroup l3_hypos_ghs3dh
5519 def SetInitialMemory(self, MB):
5520 # Advanced parameter of GHS3D
5521 self.Parameters().SetInitialMemory(MB)
5523 ## Path to working directory.
5524 # @ingroup l3_hypos_ghs3dh
5525 def SetWorkingDirectory(self, path):
5526 # Advanced parameter of GHS3D
5527 self.Parameters().SetWorkingDirectory(path)
5529 ## To keep working files or remove them. Log file remains in case of errors anyway.
5530 # @ingroup l3_hypos_ghs3dh
5531 def SetKeepFiles(self, toKeep):
5532 # Advanced parameter of GHS3D and GHS3DPRL
5533 self.Parameters().SetKeepFiles(toKeep)
5535 ## To set verbose level [0-10]. <ul>
5536 #<li> 0 - no standard output,
5537 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
5538 # indicates when the final mesh is being saved. In addition the software
5539 # gives indication regarding the CPU time.
5540 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
5541 # histogram of the skin mesh, quality statistics histogram together with
5542 # the characteristics of the final mesh.</ul>
5543 # @ingroup l3_hypos_ghs3dh
5544 def SetVerboseLevel(self, level):
5545 # Advanced parameter of GHS3D
5546 self.Parameters().SetVerboseLevel(level)
5548 ## To create new nodes.
5549 # @ingroup l3_hypos_ghs3dh
5550 def SetToCreateNewNodes(self, toCreate):
5551 # Advanced parameter of GHS3D
5552 self.Parameters().SetToCreateNewNodes(toCreate)
5554 ## To use boundary recovery version which tries to create mesh on a very poor
5555 # quality surface mesh.
5556 # @ingroup l3_hypos_ghs3dh
5557 def SetToUseBoundaryRecoveryVersion(self, toUse):
5558 # Advanced parameter of GHS3D
5559 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
5561 ## Applies finite-element correction by replacing overconstrained elements where
5562 # it is possible. The process is cutting first the overconstrained edges and
5563 # second the overconstrained facets. This insure that no edges have two boundary
5564 # vertices and that no facets have three boundary vertices.
5565 # @ingroup l3_hypos_ghs3dh
5566 def SetFEMCorrection(self, toUseFem):
5567 # Advanced parameter of GHS3D
5568 self.Parameters().SetFEMCorrection(toUseFem)
5570 ## To removes initial central point.
5571 # @ingroup l3_hypos_ghs3dh
5572 def SetToRemoveCentralPoint(self, toRemove):
5573 # Advanced parameter of GHS3D
5574 self.Parameters().SetToRemoveCentralPoint(toRemove)
5576 ## To set an enforced vertex.
5577 # @ingroup l3_hypos_ghs3dh
5578 def SetEnforcedVertex(self, x, y, z, size):
5579 # Advanced parameter of GHS3D
5580 return self.Parameters().SetEnforcedVertex(x, y, z, size)
5582 ## To set an enforced vertex and add it in the group "groupName".
5583 # Only on meshes w/o geometry
5584 # @ingroup l3_hypos_ghs3dh
5585 def SetEnforcedVertexWithGroup(self, x, y, z, size, groupName):
5586 # Advanced parameter of GHS3D
5587 return self.Parameters().SetEnforcedVertex(x, y, z, size,groupName)
5589 ## To remove an enforced vertex.
5590 # @ingroup l3_hypos_ghs3dh
5591 def RemoveEnforcedVertex(self, x, y, z):
5592 # Advanced parameter of GHS3D
5593 return self.Parameters().RemoveEnforcedVertex(x, y, z)
5595 ## To set an enforced vertex given a GEOM vertex, group or compound.
5596 # @ingroup l3_hypos_ghs3dh
5597 def SetEnforcedVertexGeom(self, theVertex, size):
5598 self.AssureGeomPublished( theVertex )
5599 # Advanced parameter of GHS3D
5600 return self.Parameters().SetEnforcedVertexGeom(theVertex, size)
5602 ## To set an enforced vertex given a GEOM vertex, group or compound
5603 # and add it in the group "groupName".
5604 # Only on meshes w/o geometry
5605 # @ingroup l3_hypos_ghs3dh
5606 def SetEnforcedVertexGeomWithGroup(self, theVertex, size, groupName):
5607 self.AssureGeomPublished( theVertex )
5608 # Advanced parameter of GHS3D
5609 return self.Parameters().SetEnforcedVertexGeomWithGroup(theVertex, size,groupName)
5611 ## To remove an enforced vertex given a GEOM vertex, group or compound.
5612 # @ingroup l3_hypos_ghs3dh
5613 def RemoveEnforcedVertexGeom(self, theVertex):
5614 self.AssureGeomPublished( theVertex )
5615 # Advanced parameter of GHS3D
5616 return self.Parameters().RemoveEnforcedVertexGeom(theVertex)
5618 ## To set an enforced mesh.
5619 # @ingroup l3_hypos_ghs3dh
5620 def SetEnforcedMesh(self, theSource, elementType):
5621 # Advanced parameter of GHS3D
5622 return self.Parameters().SetEnforcedMesh(theSource, elementType)
5624 ## To set an enforced mesh and add the enforced elements in the group "groupName".
5625 # @ingroup l3_hypos_ghs3dh
5626 def SetEnforcedMeshWithGroup(self, theSource, elementType, groupName):
5627 # Advanced parameter of GHS3D
5628 return self.Parameters().SetEnforcedMeshWithGroup(theSource, elementType, groupName)
5630 ## To set an enforced mesh with given size.
5631 # @ingroup l3_hypos_ghs3dh
5632 def SetEnforcedMeshSize(self, theSource, elementType, size):
5633 # Advanced parameter of GHS3D
5634 return self.Parameters().SetEnforcedMeshSize(theSource, elementType, size)
5636 ## To set an enforced mesh with given size and add the enforced elements in the group "groupName".
5637 # @ingroup l3_hypos_ghs3dh
5638 def SetEnforcedMeshSizeWithGroup(self, theSource, elementType, size, groupName):
5639 # Advanced parameter of GHS3D
5640 return self.Parameters().SetEnforcedMeshSizeWithGroup(theSource, elementType, size, groupName)
5642 ## Sets command line option as text.
5643 # @ingroup l3_hypos_ghs3dh
5644 def SetTextOption(self, option):
5645 # Advanced parameter of GHS3D
5646 self.Parameters().SetTextOption(option)
5648 ## Sets MED files name and path.
5649 def SetMEDName(self, value):
5650 self.Parameters().SetMEDName(value)
5652 ## Sets the number of partition of the initial mesh
5653 def SetNbPart(self, value):
5654 self.Parameters().SetNbPart(value)
5656 ## When big mesh, start tepal in background
5657 def SetBackground(self, value):
5658 self.Parameters().SetBackground(value)
5660 # Public class: Mesh_Hexahedron
5661 # ------------------------------
5663 ## Defines a hexahedron 3D algorithm
5665 # @ingroup l3_algos_basic
5666 class Mesh_Hexahedron(Mesh_Algorithm):
5671 ## Private constructor.
5672 def __init__(self, mesh, algoType=Hexa, geom=0):
5673 Mesh_Algorithm.__init__(self)
5675 self.algoType = algoType
5677 if algoType == Hexa:
5678 self.Create(mesh, geom, "Hexa_3D")
5681 elif algoType == Hexotic:
5682 CheckPlugin(Hexotic)
5683 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
5686 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
5687 # @ingroup l3_hypos_hexotic
5688 def MinMaxQuad(self, min=3, max=8, quad=True):
5689 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
5691 self.params.SetHexesMinLevel(min)
5692 self.params.SetHexesMaxLevel(max)
5693 self.params.SetHexoticQuadrangles(quad)
5696 # Deprecated, only for compatibility!
5697 # Public class: Mesh_Netgen
5698 # ------------------------------
5700 ## Defines a NETGEN-based 2D or 3D algorithm
5701 # that needs no discrete boundary (i.e. independent)
5703 # This class is deprecated, only for compatibility!
5706 # @ingroup l3_algos_basic
5707 class Mesh_Netgen(Mesh_Algorithm):
5711 ## Private constructor.
5712 def __init__(self, mesh, is3D, geom=0):
5713 Mesh_Algorithm.__init__(self)
5719 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5723 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
5726 ## Defines the hypothesis containing parameters of the algorithm
5727 def Parameters(self):
5729 hyp = self.Hypothesis("NETGEN_Parameters", [],
5730 "libNETGENEngine.so", UseExisting=0)
5732 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
5733 "libNETGENEngine.so", UseExisting=0)
5736 # Public class: Mesh_Projection1D
5737 # ------------------------------
5739 ## Defines a projection 1D algorithm
5740 # @ingroup l3_algos_proj
5742 class Mesh_Projection1D(Mesh_Algorithm):
5744 ## Private constructor.
5745 def __init__(self, mesh, geom=0):
5746 Mesh_Algorithm.__init__(self)
5747 self.Create(mesh, geom, "Projection_1D")
5749 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
5750 # a mesh pattern is taken, and, optionally, the association of vertices
5751 # between the source edge and a target edge (to which a hypothesis is assigned)
5752 # @param edge from which nodes distribution is taken
5753 # @param mesh from which nodes distribution is taken (optional)
5754 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
5755 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
5756 # to associate with \a srcV (optional)
5757 # @param UseExisting if ==true - searches for the existing hypothesis created with
5758 # the same parameters, else (default) - creates a new one
5759 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
5760 self.AssureGeomPublished( edge )
5761 self.AssureGeomPublished( srcV )
5762 self.AssureGeomPublished( tgtV )
5763 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
5765 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
5766 hyp.SetSourceEdge( edge )
5767 if not mesh is None and isinstance(mesh, Mesh):
5768 mesh = mesh.GetMesh()
5769 hyp.SetSourceMesh( mesh )
5770 hyp.SetVertexAssociation( srcV, tgtV )
5773 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
5774 #def CompareSourceEdge(self, hyp, args):
5775 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
5779 # Public class: Mesh_Projection2D
5780 # ------------------------------
5782 ## Defines a projection 2D algorithm
5783 # @ingroup l3_algos_proj
5785 class Mesh_Projection2D(Mesh_Algorithm):
5787 ## Private constructor.
5788 def __init__(self, mesh, geom=0):
5789 Mesh_Algorithm.__init__(self)
5790 self.Create(mesh, geom, "Projection_2D")
5792 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
5793 # a mesh pattern is taken, and, optionally, the association of vertices
5794 # between the source face and the target face (to which a hypothesis is assigned)
5795 # @param face from which the mesh pattern is taken
5796 # @param mesh from which the mesh pattern is taken (optional)
5797 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
5798 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
5799 # to associate with \a srcV1 (optional)
5800 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
5801 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
5802 # to associate with \a srcV2 (optional)
5803 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
5804 # the same parameters, else (default) - forces the creation a new one
5806 # Note: all association vertices must belong to one edge of a face
5807 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
5808 srcV2=None, tgtV2=None, UseExisting=0):
5809 for geom in [ face, srcV1, tgtV1, srcV2, tgtV2 ]:
5810 self.AssureGeomPublished( geom )
5811 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
5813 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
5814 hyp.SetSourceFace( face )
5815 if isinstance(mesh, Mesh):
5816 mesh = mesh.GetMesh()
5817 hyp.SetSourceMesh( mesh )
5818 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5821 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
5822 #def CompareSourceFace(self, hyp, args):
5823 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
5826 # Public class: Mesh_Projection3D
5827 # ------------------------------
5829 ## Defines a projection 3D algorithm
5830 # @ingroup l3_algos_proj
5832 class Mesh_Projection3D(Mesh_Algorithm):
5834 ## Private constructor.
5835 def __init__(self, mesh, geom=0):
5836 Mesh_Algorithm.__init__(self)
5837 self.Create(mesh, geom, "Projection_3D")
5839 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
5840 # the mesh pattern is taken, and, optionally, the association of vertices
5841 # between the source and the target solid (to which a hipothesis is assigned)
5842 # @param solid from where the mesh pattern is taken
5843 # @param mesh from where the mesh pattern is taken (optional)
5844 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
5845 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
5846 # to associate with \a srcV1 (optional)
5847 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
5848 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
5849 # to associate with \a srcV2 (optional)
5850 # @param UseExisting - if ==true - searches for the existing hypothesis created with
5851 # the same parameters, else (default) - creates a new one
5853 # Note: association vertices must belong to one edge of a solid
5854 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
5855 srcV2=0, tgtV2=0, UseExisting=0):
5856 for geom in [ solid, srcV1, tgtV1, srcV2, tgtV2 ]:
5857 self.AssureGeomPublished( geom )
5858 hyp = self.Hypothesis("ProjectionSource3D",
5859 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
5861 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
5862 hyp.SetSource3DShape( solid )
5863 if not mesh is None and isinstance(mesh, Mesh):
5864 mesh = mesh.GetMesh()
5865 hyp.SetSourceMesh( mesh )
5866 if srcV1 and srcV2 and tgtV1 and tgtV2:
5867 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5868 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
5871 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
5872 #def CompareSourceShape3D(self, hyp, args):
5873 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
5877 # Public class: Mesh_Prism
5878 # ------------------------
5880 ## Defines a 3D extrusion algorithm
5881 # @ingroup l3_algos_3dextr
5883 class Mesh_Prism3D(Mesh_Algorithm):
5885 ## Private constructor.
5886 def __init__(self, mesh, geom=0):
5887 Mesh_Algorithm.__init__(self)
5888 self.Create(mesh, geom, "Prism_3D")
5890 # Public class: Mesh_RadialPrism
5891 # -------------------------------
5893 ## Defines a Radial Prism 3D algorithm
5894 # @ingroup l3_algos_radialp
5896 class Mesh_RadialPrism3D(Mesh_Algorithm):
5898 ## Private constructor.
5899 def __init__(self, mesh, geom=0):
5900 Mesh_Algorithm.__init__(self)
5901 self.Create(mesh, geom, "RadialPrism_3D")
5903 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
5904 self.nbLayers = None
5906 ## Return 3D hypothesis holding the 1D one
5907 def Get3DHypothesis(self):
5908 return self.distribHyp
5910 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5911 # hypothesis. Returns the created hypothesis
5912 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5913 #print "OwnHypothesis",hypType
5914 if not self.nbLayers is None:
5915 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5916 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5917 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5918 self.mesh.smeshpyD.SetCurrentStudy( None )
5919 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5920 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5921 self.distribHyp.SetLayerDistribution( hyp )
5924 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
5925 # prisms to build between the inner and outer shells
5926 # @param n number of layers
5927 # @param UseExisting if ==true - searches for the existing hypothesis created with
5928 # the same parameters, else (default) - creates a new one
5929 def NumberOfLayers(self, n, UseExisting=0):
5930 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5931 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
5932 CompareMethod=self.CompareNumberOfLayers)
5933 self.nbLayers.SetNumberOfLayers( n )
5934 return self.nbLayers
5936 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5937 def CompareNumberOfLayers(self, hyp, args):
5938 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5940 ## Defines "LocalLength" hypothesis, specifying the segment length
5941 # to build between the inner and the outer shells
5942 # @param l the length of segments
5943 # @param p the precision of rounding
5944 def LocalLength(self, l, p=1e-07):
5945 hyp = self.OwnHypothesis("LocalLength", [l,p])
5950 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
5951 # prisms to build between the inner and the outer shells.
5952 # @param n the number of layers
5953 # @param s the scale factor (optional)
5954 def NumberOfSegments(self, n, s=[]):
5956 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5958 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5959 hyp.SetDistrType( 1 )
5960 hyp.SetScaleFactor(s)
5961 hyp.SetNumberOfSegments(n)
5964 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5965 # to build between the inner and the outer shells with a length that changes in arithmetic progression
5966 # @param start the length of the first segment
5967 # @param end the length of the last segment
5968 def Arithmetic1D(self, start, end ):
5969 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5970 hyp.SetLength(start, 1)
5971 hyp.SetLength(end , 0)
5974 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5975 # to build between the inner and the outer shells as geometric length increasing
5976 # @param start for the length of the first segment
5977 # @param end for the length of the last segment
5978 def StartEndLength(self, start, end):
5979 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5980 hyp.SetLength(start, 1)
5981 hyp.SetLength(end , 0)
5984 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5985 # to build between the inner and outer shells
5986 # @param fineness defines the quality of the mesh within the range [0-1]
5987 def AutomaticLength(self, fineness=0):
5988 hyp = self.OwnHypothesis("AutomaticLength")
5989 hyp.SetFineness( fineness )
5992 # Public class: Mesh_RadialQuadrangle1D2D
5993 # -------------------------------
5995 ## Defines a Radial Quadrangle 1D2D algorithm
5996 # @ingroup l2_algos_radialq
5998 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
6000 ## Private constructor.
6001 def __init__(self, mesh, geom=0):
6002 Mesh_Algorithm.__init__(self)
6003 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
6005 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
6006 self.nbLayers = None
6008 ## Return 2D hypothesis holding the 1D one
6009 def Get2DHypothesis(self):
6010 return self.distribHyp
6012 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
6013 # hypothesis. Returns the created hypothesis
6014 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
6015 #print "OwnHypothesis",hypType
6017 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
6018 if self.distribHyp is None:
6019 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
6021 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
6022 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
6023 self.mesh.smeshpyD.SetCurrentStudy( None )
6024 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
6025 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
6026 self.distribHyp.SetLayerDistribution( hyp )
6029 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
6030 # @param n number of layers
6031 # @param UseExisting if ==true - searches for the existing hypothesis created with
6032 # the same parameters, else (default) - creates a new one
6033 def NumberOfLayers(self, n, UseExisting=0):
6035 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
6036 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
6037 CompareMethod=self.CompareNumberOfLayers)
6038 self.nbLayers.SetNumberOfLayers( n )
6039 return self.nbLayers
6041 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
6042 def CompareNumberOfLayers(self, hyp, args):
6043 return IsEqual(hyp.GetNumberOfLayers(), args[0])
6045 ## Defines "LocalLength" hypothesis, specifying the segment length
6046 # @param l the length of segments
6047 # @param p the precision of rounding
6048 def LocalLength(self, l, p=1e-07):
6049 hyp = self.OwnHypothesis("LocalLength", [l,p])
6054 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
6055 # @param n the number of layers
6056 # @param s the scale factor (optional)
6057 def NumberOfSegments(self, n, s=[]):
6059 hyp = self.OwnHypothesis("NumberOfSegments", [n])
6061 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
6062 hyp.SetDistrType( 1 )
6063 hyp.SetScaleFactor(s)
6064 hyp.SetNumberOfSegments(n)
6067 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
6068 # with a length that changes in arithmetic progression
6069 # @param start the length of the first segment
6070 # @param end the length of the last segment
6071 def Arithmetic1D(self, start, end ):
6072 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
6073 hyp.SetLength(start, 1)
6074 hyp.SetLength(end , 0)
6077 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
6078 # as geometric length increasing
6079 # @param start for the length of the first segment
6080 # @param end for the length of the last segment
6081 def StartEndLength(self, start, end):
6082 hyp = self.OwnHypothesis("StartEndLength", [start, end])
6083 hyp.SetLength(start, 1)
6084 hyp.SetLength(end , 0)
6087 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
6088 # @param fineness defines the quality of the mesh within the range [0-1]
6089 def AutomaticLength(self, fineness=0):
6090 hyp = self.OwnHypothesis("AutomaticLength")
6091 hyp.SetFineness( fineness )
6095 # Public class: Mesh_UseExistingElements
6096 # --------------------------------------
6097 ## Defines a Radial Quadrangle 1D2D algorithm
6098 # @ingroup l3_algos_basic
6100 class Mesh_UseExistingElements(Mesh_Algorithm):
6102 def __init__(self, dim, mesh, geom=0):
6104 self.Create(mesh, geom, "Import_1D")
6106 self.Create(mesh, geom, "Import_1D2D")
6109 ## Defines "Source edges" hypothesis, specifying groups of edges to import
6110 # @param groups list of groups of edges
6111 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
6112 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
6113 # @param UseExisting if ==true - searches for the existing hypothesis created with
6114 # the same parameters, else (default) - creates a new one
6115 def SourceEdges(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
6116 if self.algo.GetName() == "Import_2D":
6117 raise ValueError, "algoritm dimension mismatch"
6118 for group in groups:
6119 self.AssureGeomPublished( group )
6120 hyp = self.Hypothesis("ImportSource1D", [groups, toCopyMesh, toCopyGroups],
6121 UseExisting=UseExisting, CompareMethod=self._compareHyp)
6122 hyp.SetSourceEdges(groups)
6123 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
6126 ## Defines "Source faces" hypothesis, specifying groups of faces to import
6127 # @param groups list of groups of faces
6128 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
6129 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
6130 # @param UseExisting if ==true - searches for the existing hypothesis created with
6131 # the same parameters, else (default) - creates a new one
6132 def SourceFaces(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
6133 if self.algo.GetName() == "Import_1D":
6134 raise ValueError, "algoritm dimension mismatch"
6135 for group in groups:
6136 self.AssureGeomPublished( group )
6137 hyp = self.Hypothesis("ImportSource2D", [groups, toCopyMesh, toCopyGroups],
6138 UseExisting=UseExisting, CompareMethod=self._compareHyp)
6139 hyp.SetSourceFaces(groups)
6140 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
6143 def _compareHyp(self,hyp,args):
6144 if hasattr( hyp, "GetSourceEdges"):
6145 entries = hyp.GetSourceEdges()
6147 entries = hyp.GetSourceFaces()
6149 toCopyMesh,toCopyGroups = hyp.GetCopySourceMesh()
6150 if len(entries)==len(groups) and toCopyMesh==args[1] and toCopyGroups==args[2]:
6152 study = self.mesh.smeshpyD.GetCurrentStudy()
6155 ior = salome.orb.object_to_string(g)
6156 sobj = study.FindObjectIOR(ior)
6157 if sobj: entries2.append( sobj.GetID() )
6162 return entries == entries2
6166 # Private class: Mesh_UseExisting
6167 # -------------------------------
6168 class Mesh_UseExisting(Mesh_Algorithm):
6170 def __init__(self, dim, mesh, geom=0):
6172 self.Create(mesh, geom, "UseExisting_1D")
6174 self.Create(mesh, geom, "UseExisting_2D")
6177 import salome_notebook
6178 notebook = salome_notebook.notebook
6180 ##Return values of the notebook variables
6181 def ParseParameters(last, nbParams,nbParam, value):
6185 listSize = len(last)
6186 for n in range(0,nbParams):
6188 if counter < listSize:
6189 strResult = strResult + last[counter]
6191 strResult = strResult + ""
6193 if isinstance(value, str):
6194 if notebook.isVariable(value):
6195 result = notebook.get(value)
6196 strResult=strResult+value
6198 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
6200 strResult=strResult+str(value)
6202 if nbParams - 1 != counter:
6203 strResult=strResult+var_separator #":"
6205 return result, strResult
6207 #Wrapper class for StdMeshers_LocalLength hypothesis
6208 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
6210 ## Set Length parameter value
6211 # @param length numerical value or name of variable from notebook
6212 def SetLength(self, length):
6213 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
6214 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6215 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
6217 ## Set Precision parameter value
6218 # @param precision numerical value or name of variable from notebook
6219 def SetPrecision(self, precision):
6220 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
6221 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6222 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
6224 #Registering the new proxy for LocalLength
6225 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
6228 #Wrapper class for StdMeshers_LayerDistribution hypothesis
6229 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
6231 def SetLayerDistribution(self, hypo):
6232 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
6233 hypo.ClearParameters();
6234 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
6236 #Registering the new proxy for LayerDistribution
6237 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
6239 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
6240 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
6242 ## Set Length parameter value
6243 # @param length numerical value or name of variable from notebook
6244 def SetLength(self, length):
6245 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
6246 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
6247 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
6249 #Registering the new proxy for SegmentLengthAroundVertex
6250 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
6253 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
6254 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
6256 ## Set Length parameter value
6257 # @param length numerical value or name of variable from notebook
6258 # @param isStart true is length is Start Length, otherwise false
6259 def SetLength(self, length, isStart):
6263 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
6264 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
6265 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
6267 #Registering the new proxy for Arithmetic1D
6268 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
6270 #Wrapper class for StdMeshers_Deflection1D hypothesis
6271 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
6273 ## Set Deflection parameter value
6274 # @param deflection numerical value or name of variable from notebook
6275 def SetDeflection(self, deflection):
6276 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
6277 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
6278 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
6280 #Registering the new proxy for Deflection1D
6281 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
6283 #Wrapper class for StdMeshers_StartEndLength hypothesis
6284 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
6286 ## Set Length parameter value
6287 # @param length numerical value or name of variable from notebook
6288 # @param isStart true is length is Start Length, otherwise false
6289 def SetLength(self, length, isStart):
6293 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
6294 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
6295 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
6297 #Registering the new proxy for StartEndLength
6298 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
6300 #Wrapper class for StdMeshers_MaxElementArea hypothesis
6301 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
6303 ## Set Max Element Area parameter value
6304 # @param area numerical value or name of variable from notebook
6305 def SetMaxElementArea(self, area):
6306 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
6307 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
6308 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
6310 #Registering the new proxy for MaxElementArea
6311 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
6314 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
6315 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
6317 ## Set Max Element Volume parameter value
6318 # @param volume numerical value or name of variable from notebook
6319 def SetMaxElementVolume(self, volume):
6320 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
6321 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
6322 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
6324 #Registering the new proxy for MaxElementVolume
6325 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
6328 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
6329 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
6331 ## Set Number Of Layers parameter value
6332 # @param nbLayers numerical value or name of variable from notebook
6333 def SetNumberOfLayers(self, nbLayers):
6334 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
6335 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
6336 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
6338 #Registering the new proxy for NumberOfLayers
6339 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
6341 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
6342 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
6344 ## Set Number Of Segments parameter value
6345 # @param nbSeg numerical value or name of variable from notebook
6346 def SetNumberOfSegments(self, nbSeg):
6347 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
6348 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
6349 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6350 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
6352 ## Set Scale Factor parameter value
6353 # @param factor numerical value or name of variable from notebook
6354 def SetScaleFactor(self, factor):
6355 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
6356 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6357 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
6359 #Registering the new proxy for NumberOfSegments
6360 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
6362 if not noNETGENPlugin:
6363 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
6364 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
6366 ## Set Max Size parameter value
6367 # @param maxsize numerical value or name of variable from notebook
6368 def SetMaxSize(self, maxsize):
6369 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6370 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
6371 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6372 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
6374 ## Set Growth Rate parameter value
6375 # @param value numerical value or name of variable from notebook
6376 def SetGrowthRate(self, value):
6377 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6378 value, parameters = ParseParameters(lastParameters,4,2,value)
6379 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6380 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
6382 ## Set Number of Segments per Edge parameter value
6383 # @param value numerical value or name of variable from notebook
6384 def SetNbSegPerEdge(self, value):
6385 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6386 value, parameters = ParseParameters(lastParameters,4,3,value)
6387 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6388 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
6390 ## Set Number of Segments per Radius parameter value
6391 # @param value numerical value or name of variable from notebook
6392 def SetNbSegPerRadius(self, value):
6393 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6394 value, parameters = ParseParameters(lastParameters,4,4,value)
6395 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6396 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
6398 #Registering the new proxy for NETGENPlugin_Hypothesis
6399 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
6402 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
6403 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
6406 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
6407 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
6409 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
6410 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
6412 ## Set Number of Segments parameter value
6413 # @param nbSeg numerical value or name of variable from notebook
6414 def SetNumberOfSegments(self, nbSeg):
6415 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6416 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
6417 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6418 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
6420 ## Set Local Length parameter value
6421 # @param length numerical value or name of variable from notebook
6422 def SetLocalLength(self, length):
6423 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6424 length, parameters = ParseParameters(lastParameters,2,1,length)
6425 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6426 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
6428 ## Set Max Element Area parameter value
6429 # @param area numerical value or name of variable from notebook
6430 def SetMaxElementArea(self, area):
6431 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6432 area, parameters = ParseParameters(lastParameters,2,2,area)
6433 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6434 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
6436 def LengthFromEdges(self):
6437 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6439 value, parameters = ParseParameters(lastParameters,2,2,value)
6440 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6441 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
6443 #Registering the new proxy for NETGEN_SimpleParameters_2D
6444 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
6447 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
6448 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
6449 ## Set Max Element Volume parameter value
6450 # @param volume numerical value or name of variable from notebook
6451 def SetMaxElementVolume(self, volume):
6452 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6453 volume, parameters = ParseParameters(lastParameters,3,3,volume)
6454 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6455 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
6457 def LengthFromFaces(self):
6458 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6460 value, parameters = ParseParameters(lastParameters,3,3,value)
6461 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6462 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
6464 #Registering the new proxy for NETGEN_SimpleParameters_3D
6465 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
6467 pass # if not noNETGENPlugin:
6469 class Pattern(SMESH._objref_SMESH_Pattern):
6471 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
6473 if isinstance(theNodeIndexOnKeyPoint1,str):
6475 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
6477 theNodeIndexOnKeyPoint1 -= 1
6478 theMesh.SetParameters(Parameters)
6479 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
6481 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
6484 if isinstance(theNode000Index,str):
6486 if isinstance(theNode001Index,str):
6488 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
6490 theNode000Index -= 1
6492 theNode001Index -= 1
6493 theMesh.SetParameters(Parameters)
6494 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
6496 #Registering the new proxy for Pattern
6497 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)