1 # Copyright (C) 2007-2010 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 theSubObject a geometrical object (shape)
1150 # @param theName 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, theSubObject, theName):
1154 submesh = self.mesh.GetSubMesh(theSubObject, theName)
1157 ## Returns the shape associated to the mesh
1158 # @return a GEOM_Object
1159 # @ingroup l2_construct
1163 ## Associates the given shape to the mesh (entails the recreation of the mesh)
1164 # @param geom the shape to be meshed (GEOM_Object)
1165 # @ingroup l2_construct
1166 def SetShape(self, geom):
1167 self.mesh = self.smeshpyD.CreateMesh(geom)
1169 ## Returns true if the hypotheses are defined well
1170 # @param theSubObject a subshape of a mesh shape
1171 # @return True or False
1172 # @ingroup l2_construct
1173 def IsReadyToCompute(self, theSubObject):
1174 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
1176 ## Returns errors of hypotheses definition.
1177 # The list of errors is empty if everything is OK.
1178 # @param theSubObject a subshape of a mesh shape
1179 # @return a list of errors
1180 # @ingroup l2_construct
1181 def GetAlgoState(self, theSubObject):
1182 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
1184 ## Returns a geometrical object on which the given element was built.
1185 # The returned geometrical object, if not nil, is either found in the
1186 # study or published by this method with the given name
1187 # @param theElementID the id of the mesh element
1188 # @param theGeomName the user-defined name of the geometrical object
1189 # @return GEOM::GEOM_Object instance
1190 # @ingroup l2_construct
1191 def GetGeometryByMeshElement(self, theElementID, theGeomName):
1192 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
1194 ## Returns the mesh dimension depending on the dimension of the underlying shape
1195 # @return mesh dimension as an integer value [0,3]
1196 # @ingroup l1_auxiliary
1197 def MeshDimension(self):
1198 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
1199 if len( shells ) > 0 :
1201 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
1203 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
1209 ## Creates a segment discretization 1D algorithm.
1210 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
1211 # \n If the optional \a geom parameter is not set, this algorithm is global.
1212 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1213 # @param algo the type of the required algorithm. Possible values are:
1215 # - smesh.PYTHON for discretization via a python function,
1216 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
1217 # @param geom If defined is the subshape to be meshed
1218 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
1219 # @ingroup l3_algos_basic
1220 def Segment(self, algo=REGULAR, geom=0):
1221 ## if Segment(geom) is called by mistake
1222 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
1223 algo, geom = geom, algo
1224 if not algo: algo = REGULAR
1227 return Mesh_Segment(self, geom)
1228 elif algo == PYTHON:
1229 return Mesh_Segment_Python(self, geom)
1230 elif algo == COMPOSITE:
1231 return Mesh_CompositeSegment(self, geom)
1233 return Mesh_Segment(self, geom)
1235 ## Creates 1D algorithm importing segments conatined in groups of other mesh.
1236 # If the optional \a geom parameter is not set, this algorithm is global.
1237 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1238 # @param geom If defined the subshape is to be meshed
1239 # @return an instance of Mesh_UseExistingElements class
1240 # @ingroup l3_algos_basic
1241 def UseExisting1DElements(self, geom=0):
1242 return Mesh_UseExistingElements(1,self, geom)
1244 ## Creates 2D algorithm importing faces conatined in groups of other mesh.
1245 # If the optional \a geom parameter is not set, this algorithm is global.
1246 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1247 # @param geom If defined the subshape is to be meshed
1248 # @return an instance of Mesh_UseExistingElements class
1249 # @ingroup l3_algos_basic
1250 def UseExisting2DElements(self, geom=0):
1251 return Mesh_UseExistingElements(2,self, geom)
1253 ## Enables creation of nodes and segments usable by 2D algoritms.
1254 # The added nodes and segments must be bound to edges and vertices by
1255 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
1256 # If the optional \a geom parameter is not set, this algorithm is global.
1257 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1258 # @param geom the subshape to be manually meshed
1259 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
1260 # @ingroup l3_algos_basic
1261 def UseExistingSegments(self, geom=0):
1262 algo = Mesh_UseExisting(1,self,geom)
1263 return algo.GetAlgorithm()
1265 ## Enables creation of nodes and faces usable by 3D algoritms.
1266 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
1267 # and SetMeshElementOnShape()
1268 # If the optional \a geom parameter is not set, this algorithm is global.
1269 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1270 # @param geom the subshape to be manually meshed
1271 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1272 # @ingroup l3_algos_basic
1273 def UseExistingFaces(self, geom=0):
1274 algo = Mesh_UseExisting(2,self,geom)
1275 return algo.GetAlgorithm()
1277 ## Creates a triangle 2D algorithm for faces.
1278 # If the optional \a geom parameter is not set, this algorithm is global.
1279 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1280 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1281 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1282 # @return an instance of Mesh_Triangle algorithm
1283 # @ingroup l3_algos_basic
1284 def Triangle(self, algo=MEFISTO, geom=0):
1285 ## if Triangle(geom) is called by mistake
1286 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1289 return Mesh_Triangle(self, algo, geom)
1291 ## Creates a quadrangle 2D algorithm for faces.
1292 # If the optional \a geom parameter is not set, this algorithm is global.
1293 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1294 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1295 # @param algo values are: smesh.QUADRANGLE || smesh.RADIAL_QUAD
1296 # @return an instance of Mesh_Quadrangle algorithm
1297 # @ingroup l3_algos_basic
1298 def Quadrangle(self, geom=0, algo=QUADRANGLE):
1299 if algo==RADIAL_QUAD:
1300 return Mesh_RadialQuadrangle1D2D(self,geom)
1302 return Mesh_Quadrangle(self, geom)
1304 ## Creates a tetrahedron 3D algorithm for solids.
1305 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1306 # If the optional \a geom parameter is not set, this algorithm is global.
1307 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1308 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1309 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1310 # @return an instance of Mesh_Tetrahedron algorithm
1311 # @ingroup l3_algos_basic
1312 def Tetrahedron(self, algo=NETGEN, geom=0):
1313 ## if Tetrahedron(geom) is called by mistake
1314 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1315 algo, geom = geom, algo
1316 if not algo: algo = NETGEN
1318 return Mesh_Tetrahedron(self, algo, geom)
1320 ## Creates a hexahedron 3D algorithm for solids.
1321 # If the optional \a geom parameter is not set, this algorithm is global.
1322 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1323 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1324 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1325 # @return an instance of Mesh_Hexahedron algorithm
1326 # @ingroup l3_algos_basic
1327 def Hexahedron(self, algo=Hexa, geom=0):
1328 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1329 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1330 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1331 elif geom == 0: algo, geom = Hexa, algo
1332 return Mesh_Hexahedron(self, algo, geom)
1334 ## Deprecated, used only for compatibility!
1335 # @return an instance of Mesh_Netgen algorithm
1336 # @ingroup l3_algos_basic
1337 def Netgen(self, is3D, geom=0):
1338 return Mesh_Netgen(self, is3D, geom)
1340 ## Creates a projection 1D algorithm for edges.
1341 # If the optional \a geom parameter is not set, this algorithm is global.
1342 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1343 # @param geom If defined, the subshape to be meshed
1344 # @return an instance of Mesh_Projection1D algorithm
1345 # @ingroup l3_algos_proj
1346 def Projection1D(self, geom=0):
1347 return Mesh_Projection1D(self, geom)
1349 ## Creates a projection 2D algorithm for faces.
1350 # If the optional \a geom parameter is not set, this algorithm is global.
1351 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1352 # @param geom If defined, the subshape to be meshed
1353 # @return an instance of Mesh_Projection2D algorithm
1354 # @ingroup l3_algos_proj
1355 def Projection2D(self, geom=0):
1356 return Mesh_Projection2D(self, geom)
1358 ## Creates a projection 3D algorithm for solids.
1359 # If the optional \a geom parameter is not set, this algorithm is global.
1360 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1361 # @param geom If defined, the subshape to be meshed
1362 # @return an instance of Mesh_Projection3D algorithm
1363 # @ingroup l3_algos_proj
1364 def Projection3D(self, geom=0):
1365 return Mesh_Projection3D(self, geom)
1367 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1368 # If the optional \a geom parameter is not set, this algorithm is global.
1369 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1370 # @param geom If defined, the subshape to be meshed
1371 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1372 # @ingroup l3_algos_radialp l3_algos_3dextr
1373 def Prism(self, geom=0):
1377 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1378 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1379 if nbSolids == 0 or nbSolids == nbShells:
1380 return Mesh_Prism3D(self, geom)
1381 return Mesh_RadialPrism3D(self, geom)
1383 ## Evaluates size of prospective mesh on a shape
1384 # @return a list where i-th element is a number of elements of i-th SMESH.EntityType
1385 # To know predicted number of e.g. edges, inquire it this way
1386 # Evaluate()[ EnumToLong( Entity_Edge )]
1387 def Evaluate(self, geom=0):
1388 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1390 geom = self.mesh.GetShapeToMesh()
1393 return self.smeshpyD.Evaluate(self.mesh, geom)
1396 ## Computes the mesh and returns the status of the computation
1397 # @param geom geomtrical shape on which mesh data should be computed
1398 # @param discardModifs if True and the mesh has been edited since
1399 # a last total re-compute and that may prevent successful partial re-compute,
1400 # then the mesh is cleaned before Compute()
1401 # @return True or False
1402 # @ingroup l2_construct
1403 def Compute(self, geom=0, discardModifs=False):
1404 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1406 geom = self.mesh.GetShapeToMesh()
1411 if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693
1413 ok = self.smeshpyD.Compute(self.mesh, geom)
1414 except SALOME.SALOME_Exception, ex:
1415 print "Mesh computation failed, exception caught:"
1416 print " ", ex.details.text
1419 print "Mesh computation failed, exception caught:"
1420 traceback.print_exc()
1424 # Treat compute errors
1425 computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
1426 for err in computeErrors:
1428 if self.mesh.HasShapeToMesh():
1430 mainIOR = salome.orb.object_to_string(geom)
1431 for sname in salome.myStudyManager.GetOpenStudies():
1432 s = salome.myStudyManager.GetStudyByName(sname)
1434 mainSO = s.FindObjectIOR(mainIOR)
1435 if not mainSO: continue
1436 if err.subShapeID == 1:
1437 shapeText = ' on "%s"' % mainSO.GetName()
1438 subIt = s.NewChildIterator(mainSO)
1440 subSO = subIt.Value()
1442 obj = subSO.GetObject()
1443 if not obj: continue
1444 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
1446 ids = go.GetSubShapeIndices()
1447 if len(ids) == 1 and ids[0] == err.subShapeID:
1448 shapeText = ' on "%s"' % subSO.GetName()
1451 shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
1453 shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID)
1455 shapeText = " on subshape #%s" % (err.subShapeID)
1457 shapeText = " on subshape #%s" % (err.subShapeID)
1459 stdErrors = ["OK", #COMPERR_OK
1460 "Invalid input mesh", #COMPERR_BAD_INPUT_MESH
1461 "std::exception", #COMPERR_STD_EXCEPTION
1462 "OCC exception", #COMPERR_OCC_EXCEPTION
1463 "SALOME exception", #COMPERR_SLM_EXCEPTION
1464 "Unknown exception", #COMPERR_EXCEPTION
1465 "Memory allocation problem", #COMPERR_MEMORY_PB
1466 "Algorithm failed", #COMPERR_ALGO_FAILED
1467 "Unexpected geometry"]#COMPERR_BAD_SHAPE
1469 if err.code < len(stdErrors): errText = stdErrors[err.code]
1471 errText = "code %s" % -err.code
1472 if errText: errText += ". "
1473 errText += err.comment
1474 if allReasons != "":allReasons += "\n"
1475 allReasons += '"%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
1479 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1481 if err.isGlobalAlgo:
1489 reason = '%s %sD algorithm is missing' % (glob, dim)
1490 elif err.state == HYP_MISSING:
1491 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1492 % (glob, dim, name, dim))
1493 elif err.state == HYP_NOTCONFORM:
1494 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1495 elif err.state == HYP_BAD_PARAMETER:
1496 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1497 % ( glob, dim, name ))
1498 elif err.state == HYP_BAD_GEOMETRY:
1499 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1500 'geometry' % ( glob, dim, name ))
1502 reason = "For unknown reason."+\
1503 " Revise Mesh.Compute() implementation in smeshDC.py!"
1505 if allReasons != "":allReasons += "\n"
1506 allReasons += reason
1508 if allReasons != "":
1509 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1513 print '"' + GetName(self.mesh) + '"',"has not been computed."
1516 if salome.sg.hasDesktop():
1517 smeshgui = salome.ImportComponentGUI("SMESH")
1518 smeshgui.Init(self.mesh.GetStudyId())
1519 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1520 salome.sg.updateObjBrowser(1)
1524 ## Return submesh objects list in meshing order
1525 # @return list of list of submesh objects
1526 # @ingroup l2_construct
1527 def GetMeshOrder(self):
1528 return self.mesh.GetMeshOrder()
1530 ## Return submesh objects list in meshing order
1531 # @return list of list of submesh objects
1532 # @ingroup l2_construct
1533 def SetMeshOrder(self, submeshes):
1534 return self.mesh.SetMeshOrder(submeshes)
1536 ## Removes all nodes and elements
1537 # @ingroup l2_construct
1540 if salome.sg.hasDesktop():
1541 smeshgui = salome.ImportComponentGUI("SMESH")
1542 smeshgui.Init(self.mesh.GetStudyId())
1543 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1544 salome.sg.updateObjBrowser(1)
1546 ## Removes all nodes and elements of indicated shape
1547 # @ingroup l2_construct
1548 def ClearSubMesh(self, geomId):
1549 self.mesh.ClearSubMesh(geomId)
1550 if salome.sg.hasDesktop():
1551 smeshgui = salome.ImportComponentGUI("SMESH")
1552 smeshgui.Init(self.mesh.GetStudyId())
1553 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1554 salome.sg.updateObjBrowser(1)
1556 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1557 # @param fineness [0,-1] defines mesh fineness
1558 # @return True or False
1559 # @ingroup l3_algos_basic
1560 def AutomaticTetrahedralization(self, fineness=0):
1561 dim = self.MeshDimension()
1563 self.RemoveGlobalHypotheses()
1564 self.Segment().AutomaticLength(fineness)
1566 self.Triangle().LengthFromEdges()
1569 self.Tetrahedron(NETGEN)
1571 return self.Compute()
1573 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1574 # @param fineness [0,-1] defines mesh fineness
1575 # @return True or False
1576 # @ingroup l3_algos_basic
1577 def AutomaticHexahedralization(self, fineness=0):
1578 dim = self.MeshDimension()
1579 # assign the hypotheses
1580 self.RemoveGlobalHypotheses()
1581 self.Segment().AutomaticLength(fineness)
1588 return self.Compute()
1590 ## Assigns a hypothesis
1591 # @param hyp a hypothesis to assign
1592 # @param geom a subhape of mesh geometry
1593 # @return SMESH.Hypothesis_Status
1594 # @ingroup l2_hypotheses
1595 def AddHypothesis(self, hyp, geom=0):
1596 if isinstance( hyp, Mesh_Algorithm ):
1597 hyp = hyp.GetAlgorithm()
1602 geom = self.mesh.GetShapeToMesh()
1604 status = self.mesh.AddHypothesis(geom, hyp)
1605 isAlgo = hyp._narrow( SMESH_Algo )
1606 hyp_name = GetName( hyp )
1609 geom_name = GetName( geom )
1610 TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1613 ## Unassigns a hypothesis
1614 # @param hyp a hypothesis to unassign
1615 # @param geom a subshape of mesh geometry
1616 # @return SMESH.Hypothesis_Status
1617 # @ingroup l2_hypotheses
1618 def RemoveHypothesis(self, hyp, geom=0):
1619 if isinstance( hyp, Mesh_Algorithm ):
1620 hyp = hyp.GetAlgorithm()
1625 status = self.mesh.RemoveHypothesis(geom, hyp)
1628 ## Gets the list of hypotheses added on a geometry
1629 # @param geom a subshape of mesh geometry
1630 # @return the sequence of SMESH_Hypothesis
1631 # @ingroup l2_hypotheses
1632 def GetHypothesisList(self, geom):
1633 return self.mesh.GetHypothesisList( geom )
1635 ## Removes all global hypotheses
1636 # @ingroup l2_hypotheses
1637 def RemoveGlobalHypotheses(self):
1638 current_hyps = self.mesh.GetHypothesisList( self.geom )
1639 for hyp in current_hyps:
1640 self.mesh.RemoveHypothesis( self.geom, hyp )
1644 ## Creates a mesh group based on the geometric object \a grp
1645 # and gives a \a name, \n if this parameter is not defined
1646 # the name is the same as the geometric group name \n
1647 # Note: Works like GroupOnGeom().
1648 # @param grp a geometric group, a vertex, an edge, a face or a solid
1649 # @param name the name of the mesh group
1650 # @return SMESH_GroupOnGeom
1651 # @ingroup l2_grps_create
1652 def Group(self, grp, name=""):
1653 return self.GroupOnGeom(grp, name)
1655 ## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead.
1656 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1657 ## allowing to overwrite the file if it exists or add the exported data to its contents
1658 # @param f the file name
1659 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1660 # @param opt boolean parameter for creating/not creating
1661 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1662 # @param overwrite boolean parameter for overwriting/not overwriting the file
1663 # @ingroup l2_impexp
1664 def ExportToMED(self, f, version, opt=0, overwrite=1):
1665 self.mesh.ExportToMEDX(f, opt, version, overwrite)
1667 ## Exports the mesh in a file in MED format and chooses the \a version of MED format
1668 ## allowing to overwrite the file if it exists or add the exported data to its contents
1669 # @param f is the file name
1670 # @param auto_groups boolean parameter for creating/not creating
1671 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1672 # the typical use is auto_groups=false.
1673 # @param version MED format version(MED_V2_1 or MED_V2_2)
1674 # @param overwrite boolean parameter for overwriting/not overwriting the file
1675 # @ingroup l2_impexp
1676 def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1):
1677 self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
1679 ## Exports the mesh in a file in DAT format
1680 # @param f the file name
1681 # @ingroup l2_impexp
1682 def ExportDAT(self, f):
1683 self.mesh.ExportDAT(f)
1685 ## Exports the mesh in a file in UNV format
1686 # @param f the file name
1687 # @ingroup l2_impexp
1688 def ExportUNV(self, f):
1689 self.mesh.ExportUNV(f)
1691 ## Export the mesh in a file in STL format
1692 # @param f the file name
1693 # @param ascii defines the file encoding
1694 # @ingroup l2_impexp
1695 def ExportSTL(self, f, ascii=1):
1696 self.mesh.ExportSTL(f, ascii)
1699 # Operations with groups:
1700 # ----------------------
1702 ## Creates an empty mesh group
1703 # @param elementType the type of elements in the group
1704 # @param name the name of the mesh group
1705 # @return SMESH_Group
1706 # @ingroup l2_grps_create
1707 def CreateEmptyGroup(self, elementType, name):
1708 return self.mesh.CreateGroup(elementType, name)
1710 ## Creates a mesh group based on the geometrical object \a grp
1711 # and gives a \a name, \n if this parameter is not defined
1712 # the name is the same as the geometrical group name
1713 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1714 # @param name the name of the mesh group
1715 # @param typ the type of elements in the group. If not set, it is
1716 # automatically detected by the type of the geometry
1717 # @return SMESH_GroupOnGeom
1718 # @ingroup l2_grps_create
1719 def GroupOnGeom(self, grp, name="", typ=None):
1721 name = grp.GetName()
1724 tgeo = str(grp.GetShapeType())
1725 if tgeo == "VERTEX":
1727 elif tgeo == "EDGE":
1729 elif tgeo == "FACE":
1731 elif tgeo == "SOLID":
1733 elif tgeo == "SHELL":
1735 elif tgeo == "COMPOUND":
1736 try: # it raises on a compound of compounds
1737 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1738 print "Mesh.Group: empty geometric group", GetName( grp )
1743 if grp.GetType() == 37: # GEOMImpl_Types.hxx: #define GEOM_GROUP 37
1745 tgeo = self.geompyD.GetType(grp)
1746 if tgeo == geompyDC.ShapeType["VERTEX"]:
1748 elif tgeo == geompyDC.ShapeType["EDGE"]:
1750 elif tgeo == geompyDC.ShapeType["FACE"]:
1752 elif tgeo == geompyDC.ShapeType["SOLID"]:
1758 for elemType, shapeType in [[VOLUME,"SOLID"],[FACE,"FACE"],
1759 [EDGE,"EDGE"],[NODE,"VERTEX"]]:
1760 if self.geompyD.SubShapeAll(grp,geompyDC.ShapeType[shapeType]):
1768 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1771 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1773 ## Creates a mesh group by the given ids of elements
1774 # @param groupName the name of the mesh group
1775 # @param elementType the type of elements in the group
1776 # @param elemIDs the list of ids
1777 # @return SMESH_Group
1778 # @ingroup l2_grps_create
1779 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1780 group = self.mesh.CreateGroup(elementType, groupName)
1784 ## Creates a mesh group by the given conditions
1785 # @param groupName the name of the mesh group
1786 # @param elementType the type of elements in the group
1787 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1788 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1789 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1790 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1791 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
1792 # FT_LyingOnGeom, FT_CoplanarFaces criteria
1793 # @return SMESH_Group
1794 # @ingroup l2_grps_create
1798 CritType=FT_Undefined,
1801 UnaryOp=FT_Undefined,
1803 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined,Tolerance)
1804 group = self.MakeGroupByCriterion(groupName, aCriterion)
1807 ## Creates a mesh group by the given criterion
1808 # @param groupName the name of the mesh group
1809 # @param Criterion the instance of Criterion class
1810 # @return SMESH_Group
1811 # @ingroup l2_grps_create
1812 def MakeGroupByCriterion(self, groupName, Criterion):
1813 aFilterMgr = self.smeshpyD.CreateFilterManager()
1814 aFilter = aFilterMgr.CreateFilter()
1816 aCriteria.append(Criterion)
1817 aFilter.SetCriteria(aCriteria)
1818 group = self.MakeGroupByFilter(groupName, aFilter)
1819 aFilterMgr.UnRegister()
1822 ## Creates a mesh group by the given criteria (list of criteria)
1823 # @param groupName the name of the mesh group
1824 # @param theCriteria the list of criteria
1825 # @return SMESH_Group
1826 # @ingroup l2_grps_create
1827 def MakeGroupByCriteria(self, groupName, theCriteria):
1828 aFilterMgr = self.smeshpyD.CreateFilterManager()
1829 aFilter = aFilterMgr.CreateFilter()
1830 aFilter.SetCriteria(theCriteria)
1831 group = self.MakeGroupByFilter(groupName, aFilter)
1832 aFilterMgr.UnRegister()
1835 ## Creates a mesh group by the given filter
1836 # @param groupName the name of the mesh group
1837 # @param theFilter the instance of Filter class
1838 # @return SMESH_Group
1839 # @ingroup l2_grps_create
1840 def MakeGroupByFilter(self, groupName, theFilter):
1841 group = self.CreateEmptyGroup(theFilter.GetElementType(), groupName)
1842 theFilter.SetMesh( self.mesh )
1843 group.AddFrom( theFilter )
1846 ## Passes mesh elements through the given filter and return IDs of fitting elements
1847 # @param theFilter SMESH_Filter
1848 # @return a list of ids
1849 # @ingroup l1_controls
1850 def GetIdsFromFilter(self, theFilter):
1851 theFilter.SetMesh( self.mesh )
1852 return theFilter.GetIDs()
1854 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1855 # Returns a list of special structures (borders).
1856 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1857 # @ingroup l1_controls
1858 def GetFreeBorders(self):
1859 aFilterMgr = self.smeshpyD.CreateFilterManager()
1860 aPredicate = aFilterMgr.CreateFreeEdges()
1861 aPredicate.SetMesh(self.mesh)
1862 aBorders = aPredicate.GetBorders()
1863 aFilterMgr.UnRegister()
1867 # @ingroup l2_grps_delete
1868 def RemoveGroup(self, group):
1869 self.mesh.RemoveGroup(group)
1871 ## Removes a group with its contents
1872 # @ingroup l2_grps_delete
1873 def RemoveGroupWithContents(self, group):
1874 self.mesh.RemoveGroupWithContents(group)
1876 ## Gets the list of groups existing in the mesh
1877 # @return a sequence of SMESH_GroupBase
1878 # @ingroup l2_grps_create
1879 def GetGroups(self):
1880 return self.mesh.GetGroups()
1882 ## Gets the number of groups existing in the mesh
1883 # @return the quantity of groups as an integer value
1884 # @ingroup l2_grps_create
1886 return self.mesh.NbGroups()
1888 ## Gets the list of names of groups existing in the mesh
1889 # @return list of strings
1890 # @ingroup l2_grps_create
1891 def GetGroupNames(self):
1892 groups = self.GetGroups()
1894 for group in groups:
1895 names.append(group.GetName())
1898 ## Produces a union of two groups
1899 # A new group is created. All mesh elements that are
1900 # present in the initial groups are added to the new one
1901 # @return an instance of SMESH_Group
1902 # @ingroup l2_grps_operon
1903 def UnionGroups(self, group1, group2, name):
1904 return self.mesh.UnionGroups(group1, group2, name)
1906 ## Produces a union list of groups
1907 # New group is created. All mesh elements that are present in
1908 # initial groups are added to the new one
1909 # @return an instance of SMESH_Group
1910 # @ingroup l2_grps_operon
1911 def UnionListOfGroups(self, groups, name):
1912 return self.mesh.UnionListOfGroups(groups, name)
1914 ## Prodices an intersection of two groups
1915 # A new group is created. All mesh elements that are common
1916 # for the two initial groups are added to the new one.
1917 # @return an instance of SMESH_Group
1918 # @ingroup l2_grps_operon
1919 def IntersectGroups(self, group1, group2, name):
1920 return self.mesh.IntersectGroups(group1, group2, name)
1922 ## Produces an intersection of groups
1923 # New group is created. All mesh elements that are present in all
1924 # initial groups simultaneously are added to the new one
1925 # @return an instance of SMESH_Group
1926 # @ingroup l2_grps_operon
1927 def IntersectListOfGroups(self, groups, name):
1928 return self.mesh.IntersectListOfGroups(groups, name)
1930 ## Produces a cut of two groups
1931 # A new group is created. All mesh elements that are present in
1932 # the main group but are not present in the tool group are added to the new one
1933 # @return an instance of SMESH_Group
1934 # @ingroup l2_grps_operon
1935 def CutGroups(self, main_group, tool_group, name):
1936 return self.mesh.CutGroups(main_group, tool_group, name)
1938 ## Produces a cut of groups
1939 # A new group is created. All mesh elements that are present in main groups
1940 # but do not present in tool groups are added to the new one
1941 # @return an instance of SMESH_Group
1942 # @ingroup l2_grps_operon
1943 def CutListOfGroups(self, main_groups, tool_groups, name):
1944 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1946 ## Produces a group of elements of specified type using list of existing groups
1947 # A new group is created. System
1948 # 1) extracts all nodes on which groups elements are built
1949 # 2) combines all elements of specified dimension laying on these nodes
1950 # @return an instance of SMESH_Group
1951 # @ingroup l2_grps_operon
1952 def CreateDimGroup(self, groups, elem_type, name):
1953 return self.mesh.CreateDimGroup(groups, elem_type, name)
1956 ## Convert group on geom into standalone group
1957 # @ingroup l2_grps_delete
1958 def ConvertToStandalone(self, group):
1959 return self.mesh.ConvertToStandalone(group)
1961 # Get some info about mesh:
1962 # ------------------------
1964 ## Returns the log of nodes and elements added or removed
1965 # since the previous clear of the log.
1966 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1967 # @return list of log_block structures:
1972 # @ingroup l1_auxiliary
1973 def GetLog(self, clearAfterGet):
1974 return self.mesh.GetLog(clearAfterGet)
1976 ## Clears the log of nodes and elements added or removed since the previous
1977 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1978 # @ingroup l1_auxiliary
1980 self.mesh.ClearLog()
1982 ## Toggles auto color mode on the object.
1983 # @param theAutoColor the flag which toggles auto color mode.
1984 # @ingroup l1_auxiliary
1985 def SetAutoColor(self, theAutoColor):
1986 self.mesh.SetAutoColor(theAutoColor)
1988 ## Gets flag of object auto color mode.
1989 # @return True or False
1990 # @ingroup l1_auxiliary
1991 def GetAutoColor(self):
1992 return self.mesh.GetAutoColor()
1994 ## Gets the internal ID
1995 # @return integer value, which is the internal Id of the mesh
1996 # @ingroup l1_auxiliary
1998 return self.mesh.GetId()
2001 # @return integer value, which is the study Id of the mesh
2002 # @ingroup l1_auxiliary
2003 def GetStudyId(self):
2004 return self.mesh.GetStudyId()
2006 ## Checks the group names for duplications.
2007 # Consider the maximum group name length stored in MED file.
2008 # @return True or False
2009 # @ingroup l1_auxiliary
2010 def HasDuplicatedGroupNamesMED(self):
2011 return self.mesh.HasDuplicatedGroupNamesMED()
2013 ## Obtains the mesh editor tool
2014 # @return an instance of SMESH_MeshEditor
2015 # @ingroup l1_modifying
2016 def GetMeshEditor(self):
2017 return self.mesh.GetMeshEditor()
2019 ## Wrap a list of IDs of elements or nodes into SMESH_IDSource which
2020 # can be passed as argument to accepting mesh, group or sub-mesh
2021 # @return an instance of SMESH_IDSource
2022 # @ingroup l1_auxiliary
2023 def GetIDSource(self, ids, elemType):
2024 return self.GetMeshEditor().MakeIDSource(ids, elemType)
2027 # @return an instance of SALOME_MED::MESH
2028 # @ingroup l1_auxiliary
2029 def GetMEDMesh(self):
2030 return self.mesh.GetMEDMesh()
2033 # Get informations about mesh contents:
2034 # ------------------------------------
2036 ## Gets the mesh stattistic
2037 # @return dictionary type element - count of elements
2038 # @ingroup l1_meshinfo
2039 def GetMeshInfo(self, obj = None):
2040 if not obj: obj = self.mesh
2041 return self.smeshpyD.GetMeshInfo(obj)
2043 ## Returns the number of nodes in the mesh
2044 # @return an integer value
2045 # @ingroup l1_meshinfo
2047 return self.mesh.NbNodes()
2049 ## Returns the number of elements in the mesh
2050 # @return an integer value
2051 # @ingroup l1_meshinfo
2052 def NbElements(self):
2053 return self.mesh.NbElements()
2055 ## Returns the number of 0d elements in the mesh
2056 # @return an integer value
2057 # @ingroup l1_meshinfo
2058 def Nb0DElements(self):
2059 return self.mesh.Nb0DElements()
2061 ## Returns the number of edges in the mesh
2062 # @return an integer value
2063 # @ingroup l1_meshinfo
2065 return self.mesh.NbEdges()
2067 ## Returns the number of edges with the given order in the mesh
2068 # @param elementOrder the order of elements:
2069 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2070 # @return an integer value
2071 # @ingroup l1_meshinfo
2072 def NbEdgesOfOrder(self, elementOrder):
2073 return self.mesh.NbEdgesOfOrder(elementOrder)
2075 ## Returns the number of faces in the mesh
2076 # @return an integer value
2077 # @ingroup l1_meshinfo
2079 return self.mesh.NbFaces()
2081 ## Returns the number of faces with the given order in the mesh
2082 # @param elementOrder the order of elements:
2083 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2084 # @return an integer value
2085 # @ingroup l1_meshinfo
2086 def NbFacesOfOrder(self, elementOrder):
2087 return self.mesh.NbFacesOfOrder(elementOrder)
2089 ## Returns the number of triangles in the mesh
2090 # @return an integer value
2091 # @ingroup l1_meshinfo
2092 def NbTriangles(self):
2093 return self.mesh.NbTriangles()
2095 ## Returns the number of triangles with the given order in the mesh
2096 # @param elementOrder is the order of elements:
2097 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2098 # @return an integer value
2099 # @ingroup l1_meshinfo
2100 def NbTrianglesOfOrder(self, elementOrder):
2101 return self.mesh.NbTrianglesOfOrder(elementOrder)
2103 ## Returns the number of quadrangles in the mesh
2104 # @return an integer value
2105 # @ingroup l1_meshinfo
2106 def NbQuadrangles(self):
2107 return self.mesh.NbQuadrangles()
2109 ## Returns the number of quadrangles with the given order in the mesh
2110 # @param elementOrder the order of elements:
2111 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2112 # @return an integer value
2113 # @ingroup l1_meshinfo
2114 def NbQuadranglesOfOrder(self, elementOrder):
2115 return self.mesh.NbQuadranglesOfOrder(elementOrder)
2117 ## Returns the number of polygons in the mesh
2118 # @return an integer value
2119 # @ingroup l1_meshinfo
2120 def NbPolygons(self):
2121 return self.mesh.NbPolygons()
2123 ## Returns the number of volumes in the mesh
2124 # @return an integer value
2125 # @ingroup l1_meshinfo
2126 def NbVolumes(self):
2127 return self.mesh.NbVolumes()
2129 ## Returns the number of volumes with the given order in the mesh
2130 # @param elementOrder the order of elements:
2131 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2132 # @return an integer value
2133 # @ingroup l1_meshinfo
2134 def NbVolumesOfOrder(self, elementOrder):
2135 return self.mesh.NbVolumesOfOrder(elementOrder)
2137 ## Returns the number of tetrahedrons in the mesh
2138 # @return an integer value
2139 # @ingroup l1_meshinfo
2141 return self.mesh.NbTetras()
2143 ## Returns the number of tetrahedrons with the given order in the mesh
2144 # @param elementOrder the order of elements:
2145 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2146 # @return an integer value
2147 # @ingroup l1_meshinfo
2148 def NbTetrasOfOrder(self, elementOrder):
2149 return self.mesh.NbTetrasOfOrder(elementOrder)
2151 ## Returns the number of hexahedrons in the mesh
2152 # @return an integer value
2153 # @ingroup l1_meshinfo
2155 return self.mesh.NbHexas()
2157 ## Returns the number of hexahedrons with the given order in the mesh
2158 # @param elementOrder the order of elements:
2159 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2160 # @return an integer value
2161 # @ingroup l1_meshinfo
2162 def NbHexasOfOrder(self, elementOrder):
2163 return self.mesh.NbHexasOfOrder(elementOrder)
2165 ## Returns the number of pyramids in the mesh
2166 # @return an integer value
2167 # @ingroup l1_meshinfo
2168 def NbPyramids(self):
2169 return self.mesh.NbPyramids()
2171 ## Returns the number of pyramids with the given order in the mesh
2172 # @param elementOrder the order of elements:
2173 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2174 # @return an integer value
2175 # @ingroup l1_meshinfo
2176 def NbPyramidsOfOrder(self, elementOrder):
2177 return self.mesh.NbPyramidsOfOrder(elementOrder)
2179 ## Returns the number of prisms in the mesh
2180 # @return an integer value
2181 # @ingroup l1_meshinfo
2183 return self.mesh.NbPrisms()
2185 ## Returns the number of prisms with the given order in the mesh
2186 # @param elementOrder the order of elements:
2187 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2188 # @return an integer value
2189 # @ingroup l1_meshinfo
2190 def NbPrismsOfOrder(self, elementOrder):
2191 return self.mesh.NbPrismsOfOrder(elementOrder)
2193 ## Returns the number of polyhedrons in the mesh
2194 # @return an integer value
2195 # @ingroup l1_meshinfo
2196 def NbPolyhedrons(self):
2197 return self.mesh.NbPolyhedrons()
2199 ## Returns the number of submeshes in the mesh
2200 # @return an integer value
2201 # @ingroup l1_meshinfo
2202 def NbSubMesh(self):
2203 return self.mesh.NbSubMesh()
2205 ## Returns the list of mesh elements IDs
2206 # @return the list of integer values
2207 # @ingroup l1_meshinfo
2208 def GetElementsId(self):
2209 return self.mesh.GetElementsId()
2211 ## Returns the list of IDs of mesh elements with the given type
2212 # @param elementType the required type of elements (SMESH.NODE, SMESH.EDGE, SMESH.FACE or SMESH.VOLUME)
2213 # @return list of integer values
2214 # @ingroup l1_meshinfo
2215 def GetElementsByType(self, elementType):
2216 return self.mesh.GetElementsByType(elementType)
2218 ## Returns the list of mesh nodes IDs
2219 # @return the list of integer values
2220 # @ingroup l1_meshinfo
2221 def GetNodesId(self):
2222 return self.mesh.GetNodesId()
2224 # Get the information about mesh elements:
2225 # ------------------------------------
2227 ## Returns the type of mesh element
2228 # @return the value from SMESH::ElementType enumeration
2229 # @ingroup l1_meshinfo
2230 def GetElementType(self, id, iselem):
2231 return self.mesh.GetElementType(id, iselem)
2233 ## Returns the geometric type of mesh element
2234 # @return the value from SMESH::EntityType enumeration
2235 # @ingroup l1_meshinfo
2236 def GetElementGeomType(self, id):
2237 return self.mesh.GetElementGeomType(id)
2239 ## Returns the list of submesh elements IDs
2240 # @param Shape a geom object(subshape) IOR
2241 # Shape must be the subshape of a ShapeToMesh()
2242 # @return the list of integer values
2243 # @ingroup l1_meshinfo
2244 def GetSubMeshElementsId(self, Shape):
2245 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2246 ShapeID = Shape.GetSubShapeIndices()[0]
2249 return self.mesh.GetSubMeshElementsId(ShapeID)
2251 ## Returns the list of submesh nodes IDs
2252 # @param Shape a geom object(subshape) IOR
2253 # Shape must be the subshape of a ShapeToMesh()
2254 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
2255 # @return the list of integer values
2256 # @ingroup l1_meshinfo
2257 def GetSubMeshNodesId(self, Shape, all):
2258 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2259 ShapeID = Shape.GetSubShapeIndices()[0]
2262 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2264 ## Returns type of elements on given shape
2265 # @param Shape a geom object(subshape) IOR
2266 # Shape must be a subshape of a ShapeToMesh()
2267 # @return element type
2268 # @ingroup l1_meshinfo
2269 def GetSubMeshElementType(self, Shape):
2270 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2271 ShapeID = Shape.GetSubShapeIndices()[0]
2274 return self.mesh.GetSubMeshElementType(ShapeID)
2276 ## Gets the mesh description
2277 # @return string value
2278 # @ingroup l1_meshinfo
2280 return self.mesh.Dump()
2283 # Get the information about nodes and elements of a mesh by its IDs:
2284 # -----------------------------------------------------------
2286 ## Gets XYZ coordinates of a node
2287 # \n If there is no nodes for the given ID - returns an empty list
2288 # @return a list of double precision values
2289 # @ingroup l1_meshinfo
2290 def GetNodeXYZ(self, id):
2291 return self.mesh.GetNodeXYZ(id)
2293 ## Returns list of IDs of inverse elements for the given node
2294 # \n If there is no node for the given ID - returns an empty list
2295 # @return a list of integer values
2296 # @ingroup l1_meshinfo
2297 def GetNodeInverseElements(self, id):
2298 return self.mesh.GetNodeInverseElements(id)
2300 ## @brief Returns the position of a node on the shape
2301 # @return SMESH::NodePosition
2302 # @ingroup l1_meshinfo
2303 def GetNodePosition(self,NodeID):
2304 return self.mesh.GetNodePosition(NodeID)
2306 ## If the given element is a node, returns the ID of shape
2307 # \n If there is no node for the given ID - returns -1
2308 # @return an integer value
2309 # @ingroup l1_meshinfo
2310 def GetShapeID(self, id):
2311 return self.mesh.GetShapeID(id)
2313 ## Returns the ID of the result shape after
2314 # FindShape() from SMESH_MeshEditor for the given element
2315 # \n If there is no element for the given ID - returns -1
2316 # @return an integer value
2317 # @ingroup l1_meshinfo
2318 def GetShapeIDForElem(self,id):
2319 return self.mesh.GetShapeIDForElem(id)
2321 ## Returns the number of nodes for the given element
2322 # \n If there is no element for the given ID - returns -1
2323 # @return an integer value
2324 # @ingroup l1_meshinfo
2325 def GetElemNbNodes(self, id):
2326 return self.mesh.GetElemNbNodes(id)
2328 ## Returns the node ID the given index for the given element
2329 # \n If there is no element for the given ID - returns -1
2330 # \n If there is no node for the given index - returns -2
2331 # @return an integer value
2332 # @ingroup l1_meshinfo
2333 def GetElemNode(self, id, index):
2334 return self.mesh.GetElemNode(id, index)
2336 ## Returns the IDs of nodes of the given element
2337 # @return a list of integer values
2338 # @ingroup l1_meshinfo
2339 def GetElemNodes(self, id):
2340 return self.mesh.GetElemNodes(id)
2342 ## Returns true if the given node is the medium node in the given quadratic element
2343 # @ingroup l1_meshinfo
2344 def IsMediumNode(self, elementID, nodeID):
2345 return self.mesh.IsMediumNode(elementID, nodeID)
2347 ## Returns true if the given node is the medium node in one of quadratic elements
2348 # @ingroup l1_meshinfo
2349 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2350 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2352 ## Returns the number of edges for the given element
2353 # @ingroup l1_meshinfo
2354 def ElemNbEdges(self, id):
2355 return self.mesh.ElemNbEdges(id)
2357 ## Returns the number of faces for the given element
2358 # @ingroup l1_meshinfo
2359 def ElemNbFaces(self, id):
2360 return self.mesh.ElemNbFaces(id)
2362 ## Returns nodes of given face (counted from zero) for given volumic element.
2363 # @ingroup l1_meshinfo
2364 def GetElemFaceNodes(self,elemId, faceIndex):
2365 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2367 ## Returns an element based on all given nodes.
2368 # @ingroup l1_meshinfo
2369 def FindElementByNodes(self,nodes):
2370 return self.mesh.FindElementByNodes(nodes)
2372 ## Returns true if the given element is a polygon
2373 # @ingroup l1_meshinfo
2374 def IsPoly(self, id):
2375 return self.mesh.IsPoly(id)
2377 ## Returns true if the given element is quadratic
2378 # @ingroup l1_meshinfo
2379 def IsQuadratic(self, id):
2380 return self.mesh.IsQuadratic(id)
2382 ## Returns XYZ coordinates of the barycenter of the given element
2383 # \n If there is no element for the given ID - returns an empty list
2384 # @return a list of three double values
2385 # @ingroup l1_meshinfo
2386 def BaryCenter(self, id):
2387 return self.mesh.BaryCenter(id)
2390 # Get mesh measurements information:
2391 # ------------------------------------
2393 ## Get minimum distance between two nodes, elements or distance to the origin
2394 # @param id1 first node/element id
2395 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2396 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2397 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2398 # @return minimum distance value
2399 # @sa GetMinDistance()
2400 def MinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2401 aMeasure = self.GetMinDistance(id1, id2, isElem1, isElem2)
2402 return aMeasure.value
2404 ## Get measure structure specifying minimum distance data between two objects
2405 # @param id1 first node/element id
2406 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2407 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2408 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2409 # @return Measure structure
2411 def GetMinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2413 id1 = self.editor.MakeIDSource([id1], SMESH.FACE)
2415 id1 = self.editor.MakeIDSource([id1], SMESH.NODE)
2418 id2 = self.editor.MakeIDSource([id2], SMESH.FACE)
2420 id2 = self.editor.MakeIDSource([id2], SMESH.NODE)
2425 aMeasurements = self.smeshpyD.CreateMeasurements()
2426 aMeasure = aMeasurements.MinDistance(id1, id2)
2427 aMeasurements.UnRegister()
2430 ## Get bounding box of the specified object(s)
2431 # @param objects single source object or list of source objects or list of nodes/elements IDs
2432 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2433 # @c False specifies that @a objects are nodes
2434 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
2435 # @sa GetBoundingBox()
2436 def BoundingBox(self, objects=None, isElem=False):
2437 result = self.GetBoundingBox(objects, isElem)
2441 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
2444 ## Get measure structure specifying bounding box data of the specified object(s)
2445 # @param objects single source object or list of source objects or list of nodes/elements IDs
2446 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2447 # @c False specifies that @a objects are nodes
2448 # @return Measure structure
2450 def GetBoundingBox(self, IDs=None, isElem=False):
2453 elif isinstance(IDs, tuple):
2455 if not isinstance(IDs, list):
2457 if len(IDs) > 0 and isinstance(IDs[0], int):
2461 if isinstance(o, Mesh):
2462 srclist.append(o.mesh)
2463 elif hasattr(o, "_narrow"):
2464 src = o._narrow(SMESH.SMESH_IDSource)
2465 if src: srclist.append(src)
2467 elif isinstance(o, list):
2469 srclist.append(self.editor.MakeIDSource(o, SMESH.FACE))
2471 srclist.append(self.editor.MakeIDSource(o, SMESH.NODE))
2474 aMeasurements = self.smeshpyD.CreateMeasurements()
2475 aMeasure = aMeasurements.BoundingBox(srclist)
2476 aMeasurements.UnRegister()
2479 # Mesh edition (SMESH_MeshEditor functionality):
2480 # ---------------------------------------------
2482 ## Removes the elements from the mesh by ids
2483 # @param IDsOfElements is a list of ids of elements to remove
2484 # @return True or False
2485 # @ingroup l2_modif_del
2486 def RemoveElements(self, IDsOfElements):
2487 return self.editor.RemoveElements(IDsOfElements)
2489 ## Removes nodes from mesh by ids
2490 # @param IDsOfNodes is a list of ids of nodes to remove
2491 # @return True or False
2492 # @ingroup l2_modif_del
2493 def RemoveNodes(self, IDsOfNodes):
2494 return self.editor.RemoveNodes(IDsOfNodes)
2496 ## Removes all orphan (free) nodes from mesh
2497 # @return number of the removed nodes
2498 # @ingroup l2_modif_del
2499 def RemoveOrphanNodes(self):
2500 return self.editor.RemoveOrphanNodes()
2502 ## Add a node to the mesh by coordinates
2503 # @return Id of the new node
2504 # @ingroup l2_modif_add
2505 def AddNode(self, x, y, z):
2506 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2507 self.mesh.SetParameters(Parameters)
2508 return self.editor.AddNode( x, y, z)
2510 ## Creates a 0D element on a node with given number.
2511 # @param IDOfNode the ID of node for creation of the element.
2512 # @return the Id of the new 0D element
2513 # @ingroup l2_modif_add
2514 def Add0DElement(self, IDOfNode):
2515 return self.editor.Add0DElement(IDOfNode)
2517 ## Creates a linear or quadratic edge (this is determined
2518 # by the number of given nodes).
2519 # @param IDsOfNodes the list of node IDs for creation of the element.
2520 # The order of nodes in this list should correspond to the description
2521 # of MED. \n This description is located by the following link:
2522 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2523 # @return the Id of the new edge
2524 # @ingroup l2_modif_add
2525 def AddEdge(self, IDsOfNodes):
2526 return self.editor.AddEdge(IDsOfNodes)
2528 ## Creates a linear or quadratic face (this is determined
2529 # by the number of given nodes).
2530 # @param IDsOfNodes the list of node IDs for creation of the element.
2531 # The order of nodes in this list should correspond to the description
2532 # of MED. \n This description is located by the following link:
2533 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2534 # @return the Id of the new face
2535 # @ingroup l2_modif_add
2536 def AddFace(self, IDsOfNodes):
2537 return self.editor.AddFace(IDsOfNodes)
2539 ## Adds a polygonal face to the mesh by the list of node IDs
2540 # @param IdsOfNodes the list of node IDs for creation of the element.
2541 # @return the Id of the new face
2542 # @ingroup l2_modif_add
2543 def AddPolygonalFace(self, IdsOfNodes):
2544 return self.editor.AddPolygonalFace(IdsOfNodes)
2546 ## Creates both simple and quadratic volume (this is determined
2547 # by the number of given nodes).
2548 # @param IDsOfNodes the list of node IDs for creation of the element.
2549 # The order of nodes in this list should correspond to the description
2550 # of MED. \n This description is located by the following link:
2551 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2552 # @return the Id of the new volumic element
2553 # @ingroup l2_modif_add
2554 def AddVolume(self, IDsOfNodes):
2555 return self.editor.AddVolume(IDsOfNodes)
2557 ## Creates a volume of many faces, giving nodes for each face.
2558 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2559 # @param Quantities the list of integer values, Quantities[i]
2560 # gives the quantity of nodes in face number i.
2561 # @return the Id of the new volumic element
2562 # @ingroup l2_modif_add
2563 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2564 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2566 ## Creates a volume of many faces, giving the IDs of the existing faces.
2567 # @param IdsOfFaces the list of face IDs for volume creation.
2569 # Note: The created volume will refer only to the nodes
2570 # of the given faces, not to the faces themselves.
2571 # @return the Id of the new volumic element
2572 # @ingroup l2_modif_add
2573 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2574 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2577 ## @brief Binds a node to a vertex
2578 # @param NodeID a node ID
2579 # @param Vertex a vertex or vertex ID
2580 # @return True if succeed else raises an exception
2581 # @ingroup l2_modif_add
2582 def SetNodeOnVertex(self, NodeID, Vertex):
2583 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2584 VertexID = Vertex.GetSubShapeIndices()[0]
2588 self.editor.SetNodeOnVertex(NodeID, VertexID)
2589 except SALOME.SALOME_Exception, inst:
2590 raise ValueError, inst.details.text
2594 ## @brief Stores the node position on an edge
2595 # @param NodeID a node ID
2596 # @param Edge an edge or edge ID
2597 # @param paramOnEdge a parameter on the edge where the node is located
2598 # @return True if succeed else raises an exception
2599 # @ingroup l2_modif_add
2600 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2601 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2602 EdgeID = Edge.GetSubShapeIndices()[0]
2606 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2607 except SALOME.SALOME_Exception, inst:
2608 raise ValueError, inst.details.text
2611 ## @brief Stores node position on a face
2612 # @param NodeID a node ID
2613 # @param Face a face or face ID
2614 # @param u U parameter on the face where the node is located
2615 # @param v V parameter on the face where the node is located
2616 # @return True if succeed else raises an exception
2617 # @ingroup l2_modif_add
2618 def SetNodeOnFace(self, NodeID, Face, u, v):
2619 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2620 FaceID = Face.GetSubShapeIndices()[0]
2624 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2625 except SALOME.SALOME_Exception, inst:
2626 raise ValueError, inst.details.text
2629 ## @brief Binds a node to a solid
2630 # @param NodeID a node ID
2631 # @param Solid a solid or solid ID
2632 # @return True if succeed else raises an exception
2633 # @ingroup l2_modif_add
2634 def SetNodeInVolume(self, NodeID, Solid):
2635 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2636 SolidID = Solid.GetSubShapeIndices()[0]
2640 self.editor.SetNodeInVolume(NodeID, SolidID)
2641 except SALOME.SALOME_Exception, inst:
2642 raise ValueError, inst.details.text
2645 ## @brief Bind an element to a shape
2646 # @param ElementID an element ID
2647 # @param Shape a shape or shape ID
2648 # @return True if succeed else raises an exception
2649 # @ingroup l2_modif_add
2650 def SetMeshElementOnShape(self, ElementID, Shape):
2651 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2652 ShapeID = Shape.GetSubShapeIndices()[0]
2656 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2657 except SALOME.SALOME_Exception, inst:
2658 raise ValueError, inst.details.text
2662 ## Moves the node with the given id
2663 # @param NodeID the id of the node
2664 # @param x a new X coordinate
2665 # @param y a new Y coordinate
2666 # @param z a new Z coordinate
2667 # @return True if succeed else False
2668 # @ingroup l2_modif_movenode
2669 def MoveNode(self, NodeID, x, y, z):
2670 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2671 self.mesh.SetParameters(Parameters)
2672 return self.editor.MoveNode(NodeID, x, y, z)
2674 ## Finds the node closest to a point and moves it to a point location
2675 # @param x the X coordinate of a point
2676 # @param y the Y coordinate of a point
2677 # @param z the Z coordinate of a point
2678 # @param NodeID if specified (>0), the node with this ID is moved,
2679 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2680 # @return the ID of a node
2681 # @ingroup l2_modif_throughp
2682 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2683 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2684 self.mesh.SetParameters(Parameters)
2685 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2687 ## Finds the node closest to a point
2688 # @param x the X coordinate of a point
2689 # @param y the Y coordinate of a point
2690 # @param z the Z coordinate of a point
2691 # @return the ID of a node
2692 # @ingroup l2_modif_throughp
2693 def FindNodeClosestTo(self, x, y, z):
2694 #preview = self.mesh.GetMeshEditPreviewer()
2695 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2696 return self.editor.FindNodeClosestTo(x, y, z)
2698 ## Finds the elements where a point lays IN or ON
2699 # @param x the X coordinate of a point
2700 # @param y the Y coordinate of a point
2701 # @param z the Z coordinate of a point
2702 # @param elementType type of elements to find (SMESH.ALL type
2703 # means elements of any type excluding nodes and 0D elements)
2704 # @return list of IDs of found elements
2705 # @ingroup l2_modif_throughp
2706 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2707 return self.editor.FindElementsByPoint(x, y, z, elementType)
2709 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2710 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2712 def GetPointState(self, x, y, z):
2713 return self.editor.GetPointState(x, y, z)
2715 ## Finds the node closest to a point and moves it to a point location
2716 # @param x the X coordinate of a point
2717 # @param y the Y coordinate of a point
2718 # @param z the Z coordinate of a point
2719 # @return the ID of a moved node
2720 # @ingroup l2_modif_throughp
2721 def MeshToPassThroughAPoint(self, x, y, z):
2722 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2724 ## Replaces two neighbour triangles sharing Node1-Node2 link
2725 # with the triangles built on the same 4 nodes but having other common link.
2726 # @param NodeID1 the ID of the first node
2727 # @param NodeID2 the ID of the second node
2728 # @return false if proper faces were not found
2729 # @ingroup l2_modif_invdiag
2730 def InverseDiag(self, NodeID1, NodeID2):
2731 return self.editor.InverseDiag(NodeID1, NodeID2)
2733 ## Replaces two neighbour triangles sharing Node1-Node2 link
2734 # with a quadrangle built on the same 4 nodes.
2735 # @param NodeID1 the ID of the first node
2736 # @param NodeID2 the ID of the second node
2737 # @return false if proper faces were not found
2738 # @ingroup l2_modif_unitetri
2739 def DeleteDiag(self, NodeID1, NodeID2):
2740 return self.editor.DeleteDiag(NodeID1, NodeID2)
2742 ## Reorients elements by ids
2743 # @param IDsOfElements if undefined reorients all mesh elements
2744 # @return True if succeed else False
2745 # @ingroup l2_modif_changori
2746 def Reorient(self, IDsOfElements=None):
2747 if IDsOfElements == None:
2748 IDsOfElements = self.GetElementsId()
2749 return self.editor.Reorient(IDsOfElements)
2751 ## Reorients all elements of the object
2752 # @param theObject mesh, submesh or group
2753 # @return True if succeed else False
2754 # @ingroup l2_modif_changori
2755 def ReorientObject(self, theObject):
2756 if ( isinstance( theObject, Mesh )):
2757 theObject = theObject.GetMesh()
2758 return self.editor.ReorientObject(theObject)
2760 ## Fuses the neighbouring triangles into quadrangles.
2761 # @param IDsOfElements The triangles to be fused,
2762 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2763 # @param MaxAngle is the maximum angle between element normals at which the fusion
2764 # is still performed; theMaxAngle is mesured in radians.
2765 # Also it could be a name of variable which defines angle in degrees.
2766 # @return TRUE in case of success, FALSE otherwise.
2767 # @ingroup l2_modif_unitetri
2768 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2770 if isinstance(MaxAngle,str):
2772 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2774 MaxAngle = DegreesToRadians(MaxAngle)
2775 if IDsOfElements == []:
2776 IDsOfElements = self.GetElementsId()
2777 self.mesh.SetParameters(Parameters)
2779 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2780 Functor = theCriterion
2782 Functor = self.smeshpyD.GetFunctor(theCriterion)
2783 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2785 ## Fuses the neighbouring triangles of the object into quadrangles
2786 # @param theObject is mesh, submesh or group
2787 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2788 # @param MaxAngle a max angle between element normals at which the fusion
2789 # is still performed; theMaxAngle is mesured in radians.
2790 # @return TRUE in case of success, FALSE otherwise.
2791 # @ingroup l2_modif_unitetri
2792 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2793 if ( isinstance( theObject, Mesh )):
2794 theObject = theObject.GetMesh()
2795 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2797 ## Splits quadrangles into triangles.
2798 # @param IDsOfElements the faces to be splitted.
2799 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2800 # @return TRUE in case of success, FALSE otherwise.
2801 # @ingroup l2_modif_cutquadr
2802 def QuadToTri (self, IDsOfElements, theCriterion):
2803 if IDsOfElements == []:
2804 IDsOfElements = self.GetElementsId()
2805 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2807 ## Splits quadrangles into triangles.
2808 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2809 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2810 # @return TRUE in case of success, FALSE otherwise.
2811 # @ingroup l2_modif_cutquadr
2812 def QuadToTriObject (self, theObject, theCriterion):
2813 if ( isinstance( theObject, Mesh )):
2814 theObject = theObject.GetMesh()
2815 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2817 ## Splits quadrangles into triangles.
2818 # @param IDsOfElements the faces to be splitted
2819 # @param Diag13 is used to choose a diagonal for splitting.
2820 # @return TRUE in case of success, FALSE otherwise.
2821 # @ingroup l2_modif_cutquadr
2822 def SplitQuad (self, IDsOfElements, Diag13):
2823 if IDsOfElements == []:
2824 IDsOfElements = self.GetElementsId()
2825 return self.editor.SplitQuad(IDsOfElements, Diag13)
2827 ## Splits quadrangles into triangles.
2828 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2829 # @param Diag13 is used to choose a diagonal for splitting.
2830 # @return TRUE in case of success, FALSE otherwise.
2831 # @ingroup l2_modif_cutquadr
2832 def SplitQuadObject (self, theObject, Diag13):
2833 if ( isinstance( theObject, Mesh )):
2834 theObject = theObject.GetMesh()
2835 return self.editor.SplitQuadObject(theObject, Diag13)
2837 ## Finds a better splitting of the given quadrangle.
2838 # @param IDOfQuad the ID of the quadrangle to be splitted.
2839 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2840 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2841 # diagonal is better, 0 if error occurs.
2842 # @ingroup l2_modif_cutquadr
2843 def BestSplit (self, IDOfQuad, theCriterion):
2844 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2846 ## Splits volumic elements into tetrahedrons
2847 # @param elemIDs either list of elements or mesh or group or submesh
2848 # @param method flags passing splitting method: Hex_5Tet, Hex_6Tet, Hex_24Tet
2849 # Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc
2850 # @ingroup l2_modif_cutquadr
2851 def SplitVolumesIntoTetra(self, elemIDs, method=Hex_5Tet ):
2852 if isinstance( elemIDs, Mesh ):
2853 elemIDs = elemIDs.GetMesh()
2854 if ( isinstance( elemIDs, list )):
2855 elemIDs = self.editor.MakeIDSource(elemIDs, SMESH.VOLUME)
2856 self.editor.SplitVolumesIntoTetra(elemIDs, method)
2858 ## Splits quadrangle faces near triangular facets of volumes
2860 # @ingroup l1_auxiliary
2861 def SplitQuadsNearTriangularFacets(self):
2862 faces_array = self.GetElementsByType(SMESH.FACE)
2863 for face_id in faces_array:
2864 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2865 quad_nodes = self.mesh.GetElemNodes(face_id)
2866 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2867 isVolumeFound = False
2868 for node1_elem in node1_elems:
2869 if not isVolumeFound:
2870 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2871 nb_nodes = self.GetElemNbNodes(node1_elem)
2872 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2873 volume_elem = node1_elem
2874 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2875 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2876 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2877 isVolumeFound = True
2878 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2879 self.SplitQuad([face_id], False) # diagonal 2-4
2880 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2881 isVolumeFound = True
2882 self.SplitQuad([face_id], True) # diagonal 1-3
2883 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2884 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2885 isVolumeFound = True
2886 self.SplitQuad([face_id], True) # diagonal 1-3
2888 ## @brief Splits hexahedrons into tetrahedrons.
2890 # This operation uses pattern mapping functionality for splitting.
2891 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2892 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2893 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2894 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2895 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2896 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2897 # @return TRUE in case of success, FALSE otherwise.
2898 # @ingroup l1_auxiliary
2899 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2900 # Pattern: 5.---------.6
2905 # (0,0,1) 4.---------.7 * |
2912 # (0,0,0) 0.---------.3
2913 pattern_tetra = "!!! Nb of points: \n 8 \n\
2923 !!! Indices of points of 6 tetras: \n\
2931 pattern = self.smeshpyD.GetPattern()
2932 isDone = pattern.LoadFromFile(pattern_tetra)
2934 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2937 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2938 isDone = pattern.MakeMesh(self.mesh, False, False)
2939 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2941 # split quafrangle faces near triangular facets of volumes
2942 self.SplitQuadsNearTriangularFacets()
2946 ## @brief Split hexahedrons into prisms.
2948 # Uses the pattern mapping functionality for splitting.
2949 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2950 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2951 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2952 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2953 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2954 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2955 # @return TRUE in case of success, FALSE otherwise.
2956 # @ingroup l1_auxiliary
2957 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2958 # Pattern: 5.---------.6
2963 # (0,0,1) 4.---------.7 |
2970 # (0,0,0) 0.---------.3
2971 pattern_prism = "!!! Nb of points: \n 8 \n\
2981 !!! Indices of points of 2 prisms: \n\
2985 pattern = self.smeshpyD.GetPattern()
2986 isDone = pattern.LoadFromFile(pattern_prism)
2988 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2991 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2992 isDone = pattern.MakeMesh(self.mesh, False, False)
2993 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2995 # Splits quafrangle faces near triangular facets of volumes
2996 self.SplitQuadsNearTriangularFacets()
3000 ## Smoothes elements
3001 # @param IDsOfElements the list if ids of elements to smooth
3002 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3003 # Note that nodes built on edges and boundary nodes are always fixed.
3004 # @param MaxNbOfIterations the maximum number of iterations
3005 # @param MaxAspectRatio varies in range [1.0, inf]
3006 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3007 # @return TRUE in case of success, FALSE otherwise.
3008 # @ingroup l2_modif_smooth
3009 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
3010 MaxNbOfIterations, MaxAspectRatio, Method):
3011 if IDsOfElements == []:
3012 IDsOfElements = self.GetElementsId()
3013 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
3014 self.mesh.SetParameters(Parameters)
3015 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
3016 MaxNbOfIterations, MaxAspectRatio, Method)
3018 ## Smoothes elements which belong to the given object
3019 # @param theObject the object to smooth
3020 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3021 # Note that nodes built on edges and boundary nodes are always fixed.
3022 # @param MaxNbOfIterations the maximum number of iterations
3023 # @param MaxAspectRatio varies in range [1.0, inf]
3024 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3025 # @return TRUE in case of success, FALSE otherwise.
3026 # @ingroup l2_modif_smooth
3027 def SmoothObject(self, theObject, IDsOfFixedNodes,
3028 MaxNbOfIterations, MaxAspectRatio, Method):
3029 if ( isinstance( theObject, Mesh )):
3030 theObject = theObject.GetMesh()
3031 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
3032 MaxNbOfIterations, MaxAspectRatio, Method)
3034 ## Parametrically smoothes the given elements
3035 # @param IDsOfElements the list if ids of elements to smooth
3036 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3037 # Note that nodes built on edges and boundary nodes are always fixed.
3038 # @param MaxNbOfIterations the maximum number of iterations
3039 # @param MaxAspectRatio varies in range [1.0, inf]
3040 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3041 # @return TRUE in case of success, FALSE otherwise.
3042 # @ingroup l2_modif_smooth
3043 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
3044 MaxNbOfIterations, MaxAspectRatio, Method):
3045 if IDsOfElements == []:
3046 IDsOfElements = self.GetElementsId()
3047 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
3048 self.mesh.SetParameters(Parameters)
3049 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
3050 MaxNbOfIterations, MaxAspectRatio, Method)
3052 ## Parametrically smoothes the elements which belong to the given object
3053 # @param theObject the object to smooth
3054 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3055 # Note that nodes built on edges and boundary nodes are always fixed.
3056 # @param MaxNbOfIterations the maximum number of iterations
3057 # @param MaxAspectRatio varies in range [1.0, inf]
3058 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3059 # @return TRUE in case of success, FALSE otherwise.
3060 # @ingroup l2_modif_smooth
3061 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
3062 MaxNbOfIterations, MaxAspectRatio, Method):
3063 if ( isinstance( theObject, Mesh )):
3064 theObject = theObject.GetMesh()
3065 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
3066 MaxNbOfIterations, MaxAspectRatio, Method)
3068 ## Converts the mesh to quadratic, deletes old elements, replacing
3069 # them with quadratic with the same id.
3070 # @param theForce3d new node creation method:
3071 # 0 - the medium node lies at the geometrical entity from which the mesh element is built
3072 # 1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element
3073 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
3074 # @ingroup l2_modif_tofromqu
3075 def ConvertToQuadratic(self, theForce3d, theSubMesh=None):
3077 self.editor.ConvertToQuadraticObject(theForce3d,theSubMesh)
3079 self.editor.ConvertToQuadratic(theForce3d)
3081 ## Converts the mesh from quadratic to ordinary,
3082 # deletes old quadratic elements, \n replacing
3083 # them with ordinary mesh elements with the same id.
3084 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
3085 # @ingroup l2_modif_tofromqu
3086 def ConvertFromQuadratic(self, theSubMesh=None):
3088 self.editor.ConvertFromQuadraticObject(theSubMesh)
3090 return self.editor.ConvertFromQuadratic()
3092 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
3093 # @return TRUE if operation has been completed successfully, FALSE otherwise
3094 # @ingroup l2_modif_edit
3095 def Make2DMeshFrom3D(self):
3096 return self.editor. Make2DMeshFrom3D()
3098 ## Creates missing boundary elements
3099 # @param elements - elements whose boundary is to be checked:
3100 # mesh, group, sub-mesh or list of elements
3101 # if elements is mesh, it must be the mesh whose MakeBoundaryMesh() is called
3102 # @param dimension - defines type of boundary elements to create:
3103 # SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D
3104 # SMESH.BND_1DFROM3D creates mesh edges on all borders of free facets of 3D cells
3105 # @param groupName - a name of group to store created boundary elements in,
3106 # "" means not to create the group
3107 # @param meshName - a name of new mesh to store created boundary elements in,
3108 # "" means not to create the new mesh
3109 # @param toCopyElements - if true, the checked elements will be copied into
3110 # the new mesh else only boundary elements will be copied into the new mesh
3111 # @param toCopyExistingBondary - if true, not only new but also pre-existing
3112 # boundary elements will be copied into the new mesh
3113 # @return tuple (mesh, group) where bondary elements were added to
3114 # @ingroup l2_modif_edit
3115 def MakeBoundaryMesh(self, elements, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3116 toCopyElements=False, toCopyExistingBondary=False):
3117 if isinstance( elements, Mesh ):
3118 elements = elements.GetMesh()
3119 if ( isinstance( elements, list )):
3120 elemType = SMESH.ALL
3121 if elements: elemType = self.GetElementType( elements[0], iselem=True)
3122 elements = self.editor.MakeIDSource(elements, elemType)
3123 mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName,
3124 toCopyElements,toCopyExistingBondary)
3125 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3129 # @brief Creates missing boundary elements around either the whole mesh or
3130 # groups of 2D elements
3131 # @param dimension - defines type of boundary elements to create
3132 # @param groupName - a name of group to store all boundary elements in,
3133 # "" means not to create the group
3134 # @param meshName - a name of a new mesh, which is a copy of the initial
3135 # mesh + created boundary elements; "" means not to create the new mesh
3136 # @param toCopyAll - if true, the whole initial mesh will be copied into
3137 # the new mesh else only boundary elements will be copied into the new mesh
3138 # @param groups - groups of 2D elements to make boundary around
3139 # @retval tuple( long, mesh, groups )
3140 # long - number of added boundary elements
3141 # mesh - the mesh where elements were added to
3142 # group - the group of boundary elements or None
3144 def MakeBoundaryElements(self, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3145 toCopyAll=False, groups=[]):
3146 nb, mesh, group = self.editor.MakeBoundaryElements(dimension,groupName,meshName,
3148 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3149 return nb, mesh, group
3151 ## Renumber mesh nodes
3152 # @ingroup l2_modif_renumber
3153 def RenumberNodes(self):
3154 self.editor.RenumberNodes()
3156 ## Renumber mesh elements
3157 # @ingroup l2_modif_renumber
3158 def RenumberElements(self):
3159 self.editor.RenumberElements()
3161 ## Generates new elements by rotation of the elements around the axis
3162 # @param IDsOfElements the list of ids of elements to sweep
3163 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3164 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
3165 # @param NbOfSteps the number of steps
3166 # @param Tolerance tolerance
3167 # @param MakeGroups forces the generation of new groups from existing ones
3168 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3169 # of all steps, else - size of each step
3170 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3171 # @ingroup l2_modif_extrurev
3172 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
3173 MakeGroups=False, TotalAngle=False):
3175 if isinstance(AngleInRadians,str):
3177 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3179 AngleInRadians = DegreesToRadians(AngleInRadians)
3180 if IDsOfElements == []:
3181 IDsOfElements = self.GetElementsId()
3182 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3183 Axis = self.smeshpyD.GetAxisStruct(Axis)
3184 Axis,AxisParameters = ParseAxisStruct(Axis)
3185 if TotalAngle and NbOfSteps:
3186 AngleInRadians /= NbOfSteps
3187 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3188 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3189 self.mesh.SetParameters(Parameters)
3191 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
3192 AngleInRadians, NbOfSteps, Tolerance)
3193 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
3196 ## Generates new elements by rotation of the elements of object around the axis
3197 # @param theObject object which elements should be sweeped.
3198 # It can be a mesh, a sub mesh or a group.
3199 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3200 # @param AngleInRadians the angle of Rotation
3201 # @param NbOfSteps number of steps
3202 # @param Tolerance tolerance
3203 # @param MakeGroups forces the generation of new groups from existing ones
3204 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3205 # of all steps, else - size of each step
3206 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3207 # @ingroup l2_modif_extrurev
3208 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3209 MakeGroups=False, TotalAngle=False):
3211 if isinstance(AngleInRadians,str):
3213 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3215 AngleInRadians = DegreesToRadians(AngleInRadians)
3216 if ( isinstance( theObject, Mesh )):
3217 theObject = theObject.GetMesh()
3218 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3219 Axis = self.smeshpyD.GetAxisStruct(Axis)
3220 Axis,AxisParameters = ParseAxisStruct(Axis)
3221 if TotalAngle and NbOfSteps:
3222 AngleInRadians /= NbOfSteps
3223 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3224 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3225 self.mesh.SetParameters(Parameters)
3227 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
3228 NbOfSteps, Tolerance)
3229 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3232 ## Generates new elements by rotation of the elements of object around the axis
3233 # @param theObject object which elements should be sweeped.
3234 # It can be a mesh, a sub mesh or a group.
3235 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3236 # @param AngleInRadians the angle of Rotation
3237 # @param NbOfSteps number of steps
3238 # @param Tolerance tolerance
3239 # @param MakeGroups forces the generation of new groups from existing ones
3240 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3241 # of all steps, else - size of each step
3242 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3243 # @ingroup l2_modif_extrurev
3244 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3245 MakeGroups=False, TotalAngle=False):
3247 if isinstance(AngleInRadians,str):
3249 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3251 AngleInRadians = DegreesToRadians(AngleInRadians)
3252 if ( isinstance( theObject, Mesh )):
3253 theObject = theObject.GetMesh()
3254 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3255 Axis = self.smeshpyD.GetAxisStruct(Axis)
3256 Axis,AxisParameters = ParseAxisStruct(Axis)
3257 if TotalAngle and NbOfSteps:
3258 AngleInRadians /= NbOfSteps
3259 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3260 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3261 self.mesh.SetParameters(Parameters)
3263 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
3264 NbOfSteps, Tolerance)
3265 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3268 ## Generates new elements by rotation of the elements of object around the axis
3269 # @param theObject object which elements should be sweeped.
3270 # It can be a mesh, a sub mesh or a group.
3271 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3272 # @param AngleInRadians the angle of Rotation
3273 # @param NbOfSteps number of steps
3274 # @param Tolerance tolerance
3275 # @param MakeGroups forces the generation of new groups from existing ones
3276 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3277 # of all steps, else - size of each step
3278 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3279 # @ingroup l2_modif_extrurev
3280 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3281 MakeGroups=False, TotalAngle=False):
3283 if isinstance(AngleInRadians,str):
3285 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3287 AngleInRadians = DegreesToRadians(AngleInRadians)
3288 if ( isinstance( theObject, Mesh )):
3289 theObject = theObject.GetMesh()
3290 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3291 Axis = self.smeshpyD.GetAxisStruct(Axis)
3292 Axis,AxisParameters = ParseAxisStruct(Axis)
3293 if TotalAngle and NbOfSteps:
3294 AngleInRadians /= NbOfSteps
3295 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3296 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3297 self.mesh.SetParameters(Parameters)
3299 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
3300 NbOfSteps, Tolerance)
3301 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3304 ## Generates new elements by extrusion of the elements with given ids
3305 # @param IDsOfElements the list of elements ids for extrusion
3306 # @param StepVector vector or DirStruct, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3307 # @param NbOfSteps the number of steps
3308 # @param MakeGroups forces the generation of new groups from existing ones
3309 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3310 # @ingroup l2_modif_extrurev
3311 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
3312 if IDsOfElements == []:
3313 IDsOfElements = self.GetElementsId()
3314 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3315 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3316 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3317 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3318 Parameters = StepVectorParameters + var_separator + Parameters
3319 self.mesh.SetParameters(Parameters)
3321 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
3322 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
3325 ## Generates new elements by extrusion of the elements with given ids
3326 # @param IDsOfElements is ids of elements
3327 # @param StepVector vector, defining the direction and value of extrusion
3328 # @param NbOfSteps the number of steps
3329 # @param ExtrFlags sets flags for extrusion
3330 # @param SewTolerance uses for comparing locations of nodes if flag
3331 # EXTRUSION_FLAG_SEW is set
3332 # @param MakeGroups forces the generation of new groups from existing ones
3333 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3334 # @ingroup l2_modif_extrurev
3335 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
3336 ExtrFlags, SewTolerance, MakeGroups=False):
3337 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3338 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3340 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
3341 ExtrFlags, SewTolerance)
3342 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
3343 ExtrFlags, SewTolerance)
3346 ## Generates new elements by extrusion of the elements which belong to the object
3347 # @param theObject the object which elements should be processed.
3348 # It can be a mesh, a sub mesh or a group.
3349 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3350 # @param NbOfSteps the number of steps
3351 # @param MakeGroups forces the generation of new groups from existing ones
3352 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3353 # @ingroup l2_modif_extrurev
3354 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3355 if ( isinstance( theObject, Mesh )):
3356 theObject = theObject.GetMesh()
3357 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3358 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3359 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3360 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3361 Parameters = StepVectorParameters + var_separator + Parameters
3362 self.mesh.SetParameters(Parameters)
3364 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3365 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
3368 ## Generates new elements by extrusion of the elements which belong to the object
3369 # @param theObject object which elements should be processed.
3370 # It can be a mesh, a sub mesh or a group.
3371 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3372 # @param NbOfSteps the number of steps
3373 # @param MakeGroups to generate 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 ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3377 if ( isinstance( theObject, Mesh )):
3378 theObject = theObject.GetMesh()
3379 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3380 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3381 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3382 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3383 Parameters = StepVectorParameters + var_separator + Parameters
3384 self.mesh.SetParameters(Parameters)
3386 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3387 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3390 ## Generates new elements by extrusion of the elements which belong to the object
3391 # @param theObject object which elements should be processed.
3392 # It can be a mesh, a sub mesh or a group.
3393 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3394 # @param NbOfSteps the number of steps
3395 # @param MakeGroups forces the generation of new groups from existing ones
3396 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3397 # @ingroup l2_modif_extrurev
3398 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3399 if ( isinstance( theObject, Mesh )):
3400 theObject = theObject.GetMesh()
3401 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3402 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3403 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3404 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3405 Parameters = StepVectorParameters + var_separator + Parameters
3406 self.mesh.SetParameters(Parameters)
3408 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3409 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3414 ## Generates new elements by extrusion of the given elements
3415 # The path of extrusion must be a meshed edge.
3416 # @param Base mesh or group, or submesh, or list of ids of elements for extrusion
3417 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3418 # @param NodeStart the start node from Path. Defines the direction of extrusion
3419 # @param HasAngles allows the shape to be rotated around the path
3420 # to get the resulting mesh in a helical fashion
3421 # @param Angles list of angles in radians
3422 # @param LinearVariation forces the computation of rotation angles as linear
3423 # variation of the given Angles along path steps
3424 # @param HasRefPoint allows using the reference point
3425 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3426 # The User can specify any point as the Reference Point.
3427 # @param MakeGroups forces the generation of new groups from existing ones
3428 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3429 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3430 # only SMESH::Extrusion_Error otherwise
3431 # @ingroup l2_modif_extrurev
3432 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3433 HasAngles, Angles, LinearVariation,
3434 HasRefPoint, RefPoint, MakeGroups, ElemType):
3435 Angles,AnglesParameters = ParseAngles(Angles)
3436 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3437 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3438 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3440 Parameters = AnglesParameters + var_separator + RefPointParameters
3441 self.mesh.SetParameters(Parameters)
3443 if (isinstance(Path, Mesh)): Path = Path.GetMesh()
3445 if isinstance(Base, list):
3447 if Base == []: IDsOfElements = self.GetElementsId()
3448 else: IDsOfElements = Base
3449 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3450 HasAngles, Angles, LinearVariation,
3451 HasRefPoint, RefPoint, MakeGroups, ElemType)
3453 if isinstance(Base, Mesh): Base = Base.GetMesh()
3454 if isinstance(Base, SMESH._objref_SMESH_Mesh) or isinstance(Base, SMESH._objref_SMESH_Group) or isinstance(Base, SMESH._objref_SMESH_subMesh):
3455 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3456 HasAngles, Angles, LinearVariation,
3457 HasRefPoint, RefPoint, MakeGroups, ElemType)
3459 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3462 ## Generates new elements by extrusion of the given elements
3463 # The path of extrusion must be a meshed edge.
3464 # @param IDsOfElements ids of elements
3465 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3466 # @param PathShape shape(edge) defines the sub-mesh for the path
3467 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3468 # @param HasAngles allows the shape to be rotated around the path
3469 # to get the resulting mesh in a helical fashion
3470 # @param Angles list of angles in radians
3471 # @param HasRefPoint allows using the reference point
3472 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3473 # The User can specify any point as the Reference Point.
3474 # @param MakeGroups forces the generation of new groups from existing ones
3475 # @param LinearVariation forces the computation of rotation angles as linear
3476 # variation of the given Angles along path steps
3477 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3478 # only SMESH::Extrusion_Error otherwise
3479 # @ingroup l2_modif_extrurev
3480 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3481 HasAngles, Angles, HasRefPoint, RefPoint,
3482 MakeGroups=False, LinearVariation=False):
3483 Angles,AnglesParameters = ParseAngles(Angles)
3484 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3485 if IDsOfElements == []:
3486 IDsOfElements = self.GetElementsId()
3487 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3488 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3490 if ( isinstance( PathMesh, Mesh )):
3491 PathMesh = PathMesh.GetMesh()
3492 if HasAngles and Angles and LinearVariation:
3493 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3495 Parameters = AnglesParameters + var_separator + RefPointParameters
3496 self.mesh.SetParameters(Parameters)
3498 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3499 PathShape, NodeStart, HasAngles,
3500 Angles, HasRefPoint, RefPoint)
3501 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3502 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3504 ## Generates new elements by extrusion of the elements which belong to the object
3505 # The path of extrusion must be a meshed edge.
3506 # @param theObject the object which elements should be processed.
3507 # It can be a mesh, a sub mesh or a group.
3508 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3509 # @param PathShape shape(edge) defines the sub-mesh for the path
3510 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3511 # @param HasAngles allows the shape to be rotated around the path
3512 # to get the resulting mesh in a helical fashion
3513 # @param Angles list of angles
3514 # @param HasRefPoint allows using the reference point
3515 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3516 # The User can specify any point as the Reference Point.
3517 # @param MakeGroups forces the generation of new groups from existing ones
3518 # @param LinearVariation forces the computation of rotation angles as linear
3519 # variation of the given Angles along path steps
3520 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3521 # only SMESH::Extrusion_Error otherwise
3522 # @ingroup l2_modif_extrurev
3523 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3524 HasAngles, Angles, HasRefPoint, RefPoint,
3525 MakeGroups=False, LinearVariation=False):
3526 Angles,AnglesParameters = ParseAngles(Angles)
3527 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3528 if ( isinstance( theObject, Mesh )):
3529 theObject = theObject.GetMesh()
3530 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3531 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3532 if ( isinstance( PathMesh, Mesh )):
3533 PathMesh = PathMesh.GetMesh()
3534 if HasAngles and Angles and LinearVariation:
3535 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3537 Parameters = AnglesParameters + var_separator + RefPointParameters
3538 self.mesh.SetParameters(Parameters)
3540 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3541 PathShape, NodeStart, HasAngles,
3542 Angles, HasRefPoint, RefPoint)
3543 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3544 NodeStart, HasAngles, Angles, HasRefPoint,
3547 ## Generates new elements by extrusion of the elements which belong to the object
3548 # The path of extrusion must be a meshed edge.
3549 # @param theObject the object which elements should be processed.
3550 # It can be a mesh, a sub mesh or a group.
3551 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3552 # @param PathShape shape(edge) defines the sub-mesh for the path
3553 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3554 # @param HasAngles allows the shape to be rotated around the path
3555 # to get the resulting mesh in a helical fashion
3556 # @param Angles list of angles
3557 # @param HasRefPoint allows using the reference point
3558 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3559 # The User can specify any point as the Reference Point.
3560 # @param MakeGroups forces the generation of new groups from existing ones
3561 # @param LinearVariation forces the computation of rotation angles as linear
3562 # variation of the given Angles along path steps
3563 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3564 # only SMESH::Extrusion_Error otherwise
3565 # @ingroup l2_modif_extrurev
3566 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3567 HasAngles, Angles, HasRefPoint, RefPoint,
3568 MakeGroups=False, LinearVariation=False):
3569 Angles,AnglesParameters = ParseAngles(Angles)
3570 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3571 if ( isinstance( theObject, Mesh )):
3572 theObject = theObject.GetMesh()
3573 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3574 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3575 if ( isinstance( PathMesh, Mesh )):
3576 PathMesh = PathMesh.GetMesh()
3577 if HasAngles and Angles and LinearVariation:
3578 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3580 Parameters = AnglesParameters + var_separator + RefPointParameters
3581 self.mesh.SetParameters(Parameters)
3583 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3584 PathShape, NodeStart, HasAngles,
3585 Angles, HasRefPoint, RefPoint)
3586 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3587 NodeStart, HasAngles, Angles, HasRefPoint,
3590 ## Generates new elements by extrusion of the elements which belong to the object
3591 # The path of extrusion must be a meshed edge.
3592 # @param theObject the object which elements should be processed.
3593 # It can be a mesh, a sub mesh or a group.
3594 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3595 # @param PathShape shape(edge) defines the sub-mesh for the path
3596 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3597 # @param HasAngles allows the shape to be rotated around the path
3598 # to get the resulting mesh in a helical fashion
3599 # @param Angles list of angles
3600 # @param HasRefPoint allows using the reference point
3601 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3602 # The User can specify any point as the Reference Point.
3603 # @param MakeGroups forces the generation of new groups from existing ones
3604 # @param LinearVariation forces the computation of rotation angles as linear
3605 # variation of the given Angles along path steps
3606 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3607 # only SMESH::Extrusion_Error otherwise
3608 # @ingroup l2_modif_extrurev
3609 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3610 HasAngles, Angles, HasRefPoint, RefPoint,
3611 MakeGroups=False, LinearVariation=False):
3612 Angles,AnglesParameters = ParseAngles(Angles)
3613 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3614 if ( isinstance( theObject, Mesh )):
3615 theObject = theObject.GetMesh()
3616 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3617 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3618 if ( isinstance( PathMesh, Mesh )):
3619 PathMesh = PathMesh.GetMesh()
3620 if HasAngles and Angles and LinearVariation:
3621 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3623 Parameters = AnglesParameters + var_separator + RefPointParameters
3624 self.mesh.SetParameters(Parameters)
3626 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3627 PathShape, NodeStart, HasAngles,
3628 Angles, HasRefPoint, RefPoint)
3629 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3630 NodeStart, HasAngles, Angles, HasRefPoint,
3633 ## Creates a symmetrical copy of mesh elements
3634 # @param IDsOfElements list of elements ids
3635 # @param Mirror is AxisStruct or geom object(point, line, plane)
3636 # @param theMirrorType is POINT, AXIS or PLANE
3637 # If the Mirror is a geom object this parameter is unnecessary
3638 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3639 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3640 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3641 # @ingroup l2_modif_trsf
3642 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3643 if IDsOfElements == []:
3644 IDsOfElements = self.GetElementsId()
3645 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3646 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3647 Mirror,Parameters = ParseAxisStruct(Mirror)
3648 self.mesh.SetParameters(Parameters)
3649 if Copy and MakeGroups:
3650 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3651 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3654 ## Creates a new mesh by a symmetrical copy of mesh elements
3655 # @param IDsOfElements the list of elements ids
3656 # @param Mirror is AxisStruct or geom object (point, line, plane)
3657 # @param theMirrorType is POINT, AXIS or PLANE
3658 # If the Mirror is a geom object this parameter is unnecessary
3659 # @param MakeGroups to generate new groups from existing ones
3660 # @param NewMeshName a name of the new mesh to create
3661 # @return instance of Mesh class
3662 # @ingroup l2_modif_trsf
3663 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3664 if IDsOfElements == []:
3665 IDsOfElements = self.GetElementsId()
3666 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3667 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3668 Mirror,Parameters = ParseAxisStruct(Mirror)
3669 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3670 MakeGroups, NewMeshName)
3671 mesh.SetParameters(Parameters)
3672 return Mesh(self.smeshpyD,self.geompyD,mesh)
3674 ## Creates a symmetrical copy of the object
3675 # @param theObject mesh, submesh or group
3676 # @param Mirror 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 copying the element (Copy is 1) or replacing it with its mirror (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 MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3684 if ( isinstance( theObject, Mesh )):
3685 theObject = theObject.GetMesh()
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.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3692 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3695 ## Creates a new mesh by a symmetrical copy of the object
3696 # @param theObject mesh, submesh or group
3697 # @param Mirror AxisStruct or geom object (point, line, plane)
3698 # @param theMirrorType POINT, AXIS or PLANE
3699 # If the Mirror is a geom object this parameter is unnecessary
3700 # @param MakeGroups forces the generation of new groups from existing ones
3701 # @param NewMeshName the name of the new mesh to create
3702 # @return instance of Mesh class
3703 # @ingroup l2_modif_trsf
3704 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3705 if ( isinstance( theObject, Mesh )):
3706 theObject = theObject.GetMesh()
3707 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3708 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3709 Mirror,Parameters = ParseAxisStruct(Mirror)
3710 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3711 MakeGroups, NewMeshName)
3712 mesh.SetParameters(Parameters)
3713 return Mesh( self.smeshpyD,self.geompyD,mesh )
3715 ## Translates the elements
3716 # @param IDsOfElements list of elements ids
3717 # @param Vector the direction of translation (DirStruct or vector)
3718 # @param Copy allows copying the translated elements
3719 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3720 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3721 # @ingroup l2_modif_trsf
3722 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3723 if IDsOfElements == []:
3724 IDsOfElements = self.GetElementsId()
3725 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3726 Vector = self.smeshpyD.GetDirStruct(Vector)
3727 Vector,Parameters = ParseDirStruct(Vector)
3728 self.mesh.SetParameters(Parameters)
3729 if Copy and MakeGroups:
3730 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3731 self.editor.Translate(IDsOfElements, Vector, Copy)
3734 ## Creates a new mesh of translated elements
3735 # @param IDsOfElements list of elements ids
3736 # @param Vector the direction of translation (DirStruct or vector)
3737 # @param MakeGroups forces the generation of new groups from existing ones
3738 # @param NewMeshName the name of the newly created mesh
3739 # @return instance of Mesh class
3740 # @ingroup l2_modif_trsf
3741 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3742 if IDsOfElements == []:
3743 IDsOfElements = self.GetElementsId()
3744 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3745 Vector = self.smeshpyD.GetDirStruct(Vector)
3746 Vector,Parameters = ParseDirStruct(Vector)
3747 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3748 mesh.SetParameters(Parameters)
3749 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3751 ## Translates the object
3752 # @param theObject the object to translate (mesh, submesh, or group)
3753 # @param Vector direction of translation (DirStruct or geom vector)
3754 # @param Copy allows copying the translated elements
3755 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3756 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3757 # @ingroup l2_modif_trsf
3758 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3759 if ( isinstance( theObject, Mesh )):
3760 theObject = theObject.GetMesh()
3761 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3762 Vector = self.smeshpyD.GetDirStruct(Vector)
3763 Vector,Parameters = ParseDirStruct(Vector)
3764 self.mesh.SetParameters(Parameters)
3765 if Copy and MakeGroups:
3766 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3767 self.editor.TranslateObject(theObject, Vector, Copy)
3770 ## Creates a new mesh from the translated object
3771 # @param theObject the object to translate (mesh, submesh, or group)
3772 # @param Vector the direction of translation (DirStruct or geom vector)
3773 # @param MakeGroups forces the generation of new groups from existing ones
3774 # @param NewMeshName the name of the newly created mesh
3775 # @return instance of Mesh class
3776 # @ingroup l2_modif_trsf
3777 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3778 if (isinstance(theObject, Mesh)):
3779 theObject = theObject.GetMesh()
3780 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3781 Vector = self.smeshpyD.GetDirStruct(Vector)
3782 Vector,Parameters = ParseDirStruct(Vector)
3783 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3784 mesh.SetParameters(Parameters)
3785 return Mesh( self.smeshpyD, self.geompyD, mesh )
3789 ## Scales the object
3790 # @param theObject - the object to translate (mesh, submesh, or group)
3791 # @param thePoint - base point for scale
3792 # @param theScaleFact - list of 1-3 scale factors for axises
3793 # @param Copy - allows copying the translated elements
3794 # @param MakeGroups - forces the generation of new groups from existing
3796 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3797 # empty list otherwise
3798 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3799 if ( isinstance( theObject, Mesh )):
3800 theObject = theObject.GetMesh()
3801 if ( isinstance( theObject, list )):
3802 theObject = self.GetIDSource(theObject, SMESH.ALL)
3804 thePoint, Parameters = ParsePointStruct(thePoint)
3805 self.mesh.SetParameters(Parameters)
3807 if Copy and MakeGroups:
3808 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3809 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3812 ## Creates a new mesh from the translated object
3813 # @param theObject - the object to translate (mesh, submesh, or group)
3814 # @param thePoint - base point for scale
3815 # @param theScaleFact - list of 1-3 scale factors for axises
3816 # @param MakeGroups - forces the generation of new groups from existing ones
3817 # @param NewMeshName - the name of the newly created mesh
3818 # @return instance of Mesh class
3819 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3820 if (isinstance(theObject, Mesh)):
3821 theObject = theObject.GetMesh()
3822 if ( isinstance( theObject, list )):
3823 theObject = self.GetIDSource(theObject,SMESH.ALL)
3825 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3826 MakeGroups, NewMeshName)
3827 #mesh.SetParameters(Parameters)
3828 return Mesh( self.smeshpyD, self.geompyD, mesh )
3832 ## Rotates the elements
3833 # @param IDsOfElements list of elements ids
3834 # @param Axis the axis of rotation (AxisStruct or geom line)
3835 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3836 # @param Copy allows copying the rotated elements
3837 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3838 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3839 # @ingroup l2_modif_trsf
3840 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3842 if isinstance(AngleInRadians,str):
3844 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3846 AngleInRadians = DegreesToRadians(AngleInRadians)
3847 if IDsOfElements == []:
3848 IDsOfElements = self.GetElementsId()
3849 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3850 Axis = self.smeshpyD.GetAxisStruct(Axis)
3851 Axis,AxisParameters = ParseAxisStruct(Axis)
3852 Parameters = AxisParameters + var_separator + Parameters
3853 self.mesh.SetParameters(Parameters)
3854 if Copy and MakeGroups:
3855 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3856 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3859 ## Creates a new mesh of rotated elements
3860 # @param IDsOfElements list of element ids
3861 # @param Axis the axis of rotation (AxisStruct or geom line)
3862 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3863 # @param MakeGroups forces the generation of new groups from existing ones
3864 # @param NewMeshName the name of the newly created mesh
3865 # @return instance of Mesh class
3866 # @ingroup l2_modif_trsf
3867 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3869 if isinstance(AngleInRadians,str):
3871 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3873 AngleInRadians = DegreesToRadians(AngleInRadians)
3874 if IDsOfElements == []:
3875 IDsOfElements = self.GetElementsId()
3876 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3877 Axis = self.smeshpyD.GetAxisStruct(Axis)
3878 Axis,AxisParameters = ParseAxisStruct(Axis)
3879 Parameters = AxisParameters + var_separator + Parameters
3880 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3881 MakeGroups, NewMeshName)
3882 mesh.SetParameters(Parameters)
3883 return Mesh( self.smeshpyD, self.geompyD, mesh )
3885 ## Rotates the object
3886 # @param theObject the object to rotate( mesh, submesh, or group)
3887 # @param Axis the axis of rotation (AxisStruct or geom line)
3888 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3889 # @param Copy allows copying the rotated elements
3890 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3891 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3892 # @ingroup l2_modif_trsf
3893 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3895 if isinstance(AngleInRadians,str):
3897 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3899 AngleInRadians = DegreesToRadians(AngleInRadians)
3900 if (isinstance(theObject, Mesh)):
3901 theObject = theObject.GetMesh()
3902 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3903 Axis = self.smeshpyD.GetAxisStruct(Axis)
3904 Axis,AxisParameters = ParseAxisStruct(Axis)
3905 Parameters = AxisParameters + ":" + Parameters
3906 self.mesh.SetParameters(Parameters)
3907 if Copy and MakeGroups:
3908 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3909 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3912 ## Creates a new mesh from the rotated object
3913 # @param theObject the object to rotate (mesh, submesh, or group)
3914 # @param Axis the axis of rotation (AxisStruct or geom line)
3915 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3916 # @param MakeGroups forces the generation of new groups from existing ones
3917 # @param NewMeshName the name of the newly created mesh
3918 # @return instance of Mesh class
3919 # @ingroup l2_modif_trsf
3920 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3922 if isinstance(AngleInRadians,str):
3924 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3926 AngleInRadians = DegreesToRadians(AngleInRadians)
3927 if (isinstance( theObject, Mesh )):
3928 theObject = theObject.GetMesh()
3929 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3930 Axis = self.smeshpyD.GetAxisStruct(Axis)
3931 Axis,AxisParameters = ParseAxisStruct(Axis)
3932 Parameters = AxisParameters + ":" + Parameters
3933 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3934 MakeGroups, NewMeshName)
3935 mesh.SetParameters(Parameters)
3936 return Mesh( self.smeshpyD, self.geompyD, mesh )
3938 ## Finds groups of ajacent nodes within Tolerance.
3939 # @param Tolerance the value of tolerance
3940 # @return the list of groups of nodes
3941 # @ingroup l2_modif_trsf
3942 def FindCoincidentNodes (self, Tolerance):
3943 return self.editor.FindCoincidentNodes(Tolerance)
3945 ## Finds groups of ajacent nodes within Tolerance.
3946 # @param Tolerance the value of tolerance
3947 # @param SubMeshOrGroup SubMesh or Group
3948 # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
3949 # @return the list of groups of nodes
3950 # @ingroup l2_modif_trsf
3951 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
3952 if (isinstance( SubMeshOrGroup, Mesh )):
3953 SubMeshOrGroup = SubMeshOrGroup.GetMesh()
3954 if not isinstance( exceptNodes, list):
3955 exceptNodes = [ exceptNodes ]
3956 if exceptNodes and isinstance( exceptNodes[0], int):
3957 exceptNodes = [ self.GetIDSource( exceptNodes, SMESH.NODE)]
3958 return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes)
3961 # @param GroupsOfNodes the list of groups of nodes
3962 # @ingroup l2_modif_trsf
3963 def MergeNodes (self, GroupsOfNodes):
3964 self.editor.MergeNodes(GroupsOfNodes)
3966 ## Finds the elements built on the same nodes.
3967 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3968 # @return a list of groups of equal elements
3969 # @ingroup l2_modif_trsf
3970 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3971 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3972 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3973 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3975 ## Merges elements in each given group.
3976 # @param GroupsOfElementsID groups of elements for merging
3977 # @ingroup l2_modif_trsf
3978 def MergeElements(self, GroupsOfElementsID):
3979 self.editor.MergeElements(GroupsOfElementsID)
3981 ## Leaves one element and removes all other elements built on the same nodes.
3982 # @ingroup l2_modif_trsf
3983 def MergeEqualElements(self):
3984 self.editor.MergeEqualElements()
3986 ## Sews free borders
3987 # @return SMESH::Sew_Error
3988 # @ingroup l2_modif_trsf
3989 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3990 FirstNodeID2, SecondNodeID2, LastNodeID2,
3991 CreatePolygons, CreatePolyedrs):
3992 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3993 FirstNodeID2, SecondNodeID2, LastNodeID2,
3994 CreatePolygons, CreatePolyedrs)
3996 ## Sews conform free borders
3997 # @return SMESH::Sew_Error
3998 # @ingroup l2_modif_trsf
3999 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
4000 FirstNodeID2, SecondNodeID2):
4001 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
4002 FirstNodeID2, SecondNodeID2)
4004 ## Sews border to side
4005 # @return SMESH::Sew_Error
4006 # @ingroup l2_modif_trsf
4007 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
4008 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
4009 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
4010 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
4012 ## Sews two sides of a mesh. The nodes belonging to Side1 are
4013 # merged with the nodes of elements of Side2.
4014 # The number of elements in theSide1 and in theSide2 must be
4015 # equal and they should have similar nodal connectivity.
4016 # The nodes to merge should belong to side borders and
4017 # the first node should be linked to the second.
4018 # @return SMESH::Sew_Error
4019 # @ingroup l2_modif_trsf
4020 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
4021 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
4022 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
4023 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
4024 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
4025 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
4027 ## Sets new nodes for the given element.
4028 # @param ide the element id
4029 # @param newIDs nodes ids
4030 # @return If the number of nodes does not correspond to the type of element - returns false
4031 # @ingroup l2_modif_edit
4032 def ChangeElemNodes(self, ide, newIDs):
4033 return self.editor.ChangeElemNodes(ide, newIDs)
4035 ## If during the last operation of MeshEditor some nodes were
4036 # created, this method returns the list of their IDs, \n
4037 # if new nodes were not created - returns empty list
4038 # @return the list of integer values (can be empty)
4039 # @ingroup l1_auxiliary
4040 def GetLastCreatedNodes(self):
4041 return self.editor.GetLastCreatedNodes()
4043 ## If during the last operation of MeshEditor some elements were
4044 # created this method returns the list of their IDs, \n
4045 # if new elements were not created - returns empty list
4046 # @return the list of integer values (can be empty)
4047 # @ingroup l1_auxiliary
4048 def GetLastCreatedElems(self):
4049 return self.editor.GetLastCreatedElems()
4051 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4052 # @param theNodes identifiers of nodes to be doubled
4053 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
4054 # nodes. If list of element identifiers is empty then nodes are doubled but
4055 # they not assigned to elements
4056 # @return TRUE if operation has been completed successfully, FALSE otherwise
4057 # @ingroup l2_modif_edit
4058 def DoubleNodes(self, theNodes, theModifiedElems):
4059 return self.editor.DoubleNodes(theNodes, theModifiedElems)
4061 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4062 # This method provided for convenience works as DoubleNodes() described above.
4063 # @param theNodeId identifiers of node to be doubled
4064 # @param theModifiedElems identifiers of elements to be updated
4065 # @return TRUE if operation has been completed successfully, FALSE otherwise
4066 # @ingroup l2_modif_edit
4067 def DoubleNode(self, theNodeId, theModifiedElems):
4068 return self.editor.DoubleNode(theNodeId, theModifiedElems)
4070 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4071 # This method provided for convenience works as DoubleNodes() described above.
4072 # @param theNodes group of nodes to be doubled
4073 # @param theModifiedElems group of elements to be updated.
4074 # @param theMakeGroup forces the generation of a group containing new nodes.
4075 # @return TRUE or a created group if operation has been completed successfully,
4076 # FALSE or None otherwise
4077 # @ingroup l2_modif_edit
4078 def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
4080 return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
4081 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
4083 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4084 # This method provided for convenience works as DoubleNodes() described above.
4085 # @param theNodes list of groups of nodes to be doubled
4086 # @param theModifiedElems list of groups of elements to be updated.
4087 # @return TRUE if operation has been completed successfully, FALSE otherwise
4088 # @ingroup l2_modif_edit
4089 def DoubleNodeGroups(self, theNodes, theModifiedElems, theMakeGroup=False):
4091 return self.editor.DoubleNodeGroupsNew(theNodes, theModifiedElems)
4092 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
4094 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4095 # @param theElems - the list of elements (edges or faces) to be replicated
4096 # The nodes for duplication could be found from these elements
4097 # @param theNodesNot - list of nodes to NOT replicate
4098 # @param theAffectedElems - the list of elements (cells and edges) to which the
4099 # replicated nodes should be associated to.
4100 # @return TRUE if operation has been completed successfully, FALSE otherwise
4101 # @ingroup l2_modif_edit
4102 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
4103 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
4105 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4106 # @param theElems - the list of elements (edges or faces) to be replicated
4107 # The nodes for duplication could be found from these elements
4108 # @param theNodesNot - list of nodes to NOT replicate
4109 # @param theShape - shape to detect affected elements (element which geometric center
4110 # located on or inside shape).
4111 # The replicated nodes should be associated to affected elements.
4112 # @return TRUE if operation has been completed successfully, FALSE otherwise
4113 # @ingroup l2_modif_edit
4114 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
4115 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
4117 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4118 # This method provided for convenience works as DoubleNodes() described above.
4119 # @param theElems - group of of elements (edges or faces) to be replicated
4120 # @param theNodesNot - group of nodes not to replicated
4121 # @param theAffectedElems - group of elements to which the replicated nodes
4122 # should be associated to.
4123 # @param theMakeGroup forces the generation of a group containing new elements.
4124 # @return TRUE or a created group if operation has been completed successfully,
4125 # FALSE or None otherwise
4126 # @ingroup l2_modif_edit
4127 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4129 return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
4130 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
4132 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4133 # This method provided for convenience works as DoubleNodes() described above.
4134 # @param theElems - group of of elements (edges or faces) to be replicated
4135 # @param theNodesNot - group of nodes not to replicated
4136 # @param theShape - shape to detect affected elements (element which geometric center
4137 # located on or inside shape).
4138 # The replicated nodes should be associated to affected elements.
4139 # @ingroup l2_modif_edit
4140 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
4141 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
4143 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4144 # This method provided for convenience works as DoubleNodes() described above.
4145 # @param theElems - list of groups of elements (edges or faces) to be replicated
4146 # @param theNodesNot - list of groups of nodes not to replicated
4147 # @param theAffectedElems - group of elements to which the replicated nodes
4148 # should be associated to.
4149 # @param theMakeGroup forces the generation of a group containing new elements.
4150 # @return TRUE or a created group if operation has been completed successfully,
4151 # FALSE or None otherwise
4152 # @ingroup l2_modif_edit
4153 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4155 return self.editor.DoubleNodeElemGroupsNew(theElems, theNodesNot, theAffectedElems)
4156 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
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 - list of groups of elements (edges or faces) to be replicated
4161 # @param theNodesNot - list of groups of nodes not to replicated
4162 # @param theShape - shape to detect affected elements (element which geometric center
4163 # located on or inside shape).
4164 # The replicated nodes should be associated to affected elements.
4165 # @return TRUE if operation has been completed successfully, FALSE otherwise
4166 # @ingroup l2_modif_edit
4167 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
4168 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
4170 ## Double nodes on shared faces between groups of volumes and create flat elements on demand.
4171 # The list of groups must describe a partition of the mesh volumes.
4172 # The nodes of the internal faces at the boundaries of the groups are doubled.
4173 # In option, the internal faces are replaced by flat elements.
4174 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4175 # @param theDomains - list of groups of volumes
4176 # @param createJointElems - if TRUE, create the elements
4177 # @return TRUE if operation has been completed successfully, FALSE otherwise
4178 def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems ):
4179 return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems )
4181 ## Double nodes on some external faces and create flat elements.
4182 # Flat elements are mainly used by some types of mechanic calculations.
4184 # Each group of the list must be constituted of faces.
4185 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4186 # @param theGroupsOfFaces - list of groups of faces
4187 # @return TRUE if operation has been completed successfully, FALSE otherwise
4188 def CreateFlatElementsOnFacesGroups(self, theGroupsOfFaces ):
4189 return self.editor.CreateFlatElementsOnFacesGroups( theGroupsOfFaces )
4191 def _valueFromFunctor(self, funcType, elemId):
4192 fn = self.smeshpyD.GetFunctor(funcType)
4193 fn.SetMesh(self.mesh)
4194 if fn.GetElementType() == self.GetElementType(elemId, True):
4195 val = fn.GetValue(elemId)
4200 ## Get length of 1D element.
4201 # @param elemId mesh element ID
4202 # @return element's length value
4203 # @ingroup l1_measurements
4204 def GetLength(self, elemId):
4205 return self._valueFromFunctor(SMESH.FT_Length, elemId)
4207 ## Get area of 2D element.
4208 # @param elemId mesh element ID
4209 # @return element's area value
4210 # @ingroup l1_measurements
4211 def GetArea(self, elemId):
4212 return self._valueFromFunctor(SMESH.FT_Area, elemId)
4214 ## Get volume of 3D element.
4215 # @param elemId mesh element ID
4216 # @return element's volume value
4217 # @ingroup l1_measurements
4218 def GetVolume(self, elemId):
4219 return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
4221 ## Get maximum element length.
4222 # @param elemId mesh element ID
4223 # @return element's maximum length value
4224 # @ingroup l1_measurements
4225 def GetMaxElementLength(self, elemId):
4226 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4227 ftype = SMESH.FT_MaxElementLength3D
4229 ftype = SMESH.FT_MaxElementLength2D
4230 return self._valueFromFunctor(ftype, elemId)
4232 ## Get aspect ratio of 2D or 3D element.
4233 # @param elemId mesh element ID
4234 # @return element's aspect ratio value
4235 # @ingroup l1_measurements
4236 def GetAspectRatio(self, elemId):
4237 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4238 ftype = SMESH.FT_AspectRatio3D
4240 ftype = SMESH.FT_AspectRatio
4241 return self._valueFromFunctor(ftype, elemId)
4243 ## Get warping angle of 2D element.
4244 # @param elemId mesh element ID
4245 # @return element's warping angle value
4246 # @ingroup l1_measurements
4247 def GetWarping(self, elemId):
4248 return self._valueFromFunctor(SMESH.FT_Warping, elemId)
4250 ## Get minimum angle of 2D element.
4251 # @param elemId mesh element ID
4252 # @return element's minimum angle value
4253 # @ingroup l1_measurements
4254 def GetMinimumAngle(self, elemId):
4255 return self._valueFromFunctor(SMESH.FT_MinimumAngle, elemId)
4257 ## Get taper of 2D element.
4258 # @param elemId mesh element ID
4259 # @return element's taper value
4260 # @ingroup l1_measurements
4261 def GetTaper(self, elemId):
4262 return self._valueFromFunctor(SMESH.FT_Taper, elemId)
4264 ## Get skew of 2D element.
4265 # @param elemId mesh element ID
4266 # @return element's skew value
4267 # @ingroup l1_measurements
4268 def GetSkew(self, elemId):
4269 return self._valueFromFunctor(SMESH.FT_Skew, elemId)
4271 ## The mother class to define algorithm, it is not recommended to use it directly.
4274 # @ingroup l2_algorithms
4275 class Mesh_Algorithm:
4276 # @class Mesh_Algorithm
4277 # @brief Class Mesh_Algorithm
4279 #def __init__(self,smesh):
4287 ## Finds a hypothesis in the study by its type name and parameters.
4288 # Finds only the hypotheses created in smeshpyD engine.
4289 # @return SMESH.SMESH_Hypothesis
4290 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
4291 study = smeshpyD.GetCurrentStudy()
4292 #to do: find component by smeshpyD object, not by its data type
4293 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4294 if scomp is not None:
4295 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
4296 # Check if the root label of the hypotheses exists
4297 if res and hypRoot is not None:
4298 iter = study.NewChildIterator(hypRoot)
4299 # Check all published hypotheses
4301 hypo_so_i = iter.Value()
4302 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
4303 if attr is not None:
4304 anIOR = attr.Value()
4305 hypo_o_i = salome.orb.string_to_object(anIOR)
4306 if hypo_o_i is not None:
4307 # Check if this is a hypothesis
4308 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
4309 if hypo_i is not None:
4310 # Check if the hypothesis belongs to current engine
4311 if smeshpyD.GetObjectId(hypo_i) > 0:
4312 # Check if this is the required hypothesis
4313 if hypo_i.GetName() == hypname:
4315 if CompareMethod(hypo_i, args):
4329 ## Finds the algorithm in the study by its type name.
4330 # Finds only the algorithms, which have been created in smeshpyD engine.
4331 # @return SMESH.SMESH_Algo
4332 def FindAlgorithm (self, algoname, smeshpyD):
4333 study = smeshpyD.GetCurrentStudy()
4334 #to do: find component by smeshpyD object, not by its data type
4335 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4336 if scomp is not None:
4337 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
4338 # Check if the root label of the algorithms exists
4339 if res and hypRoot is not None:
4340 iter = study.NewChildIterator(hypRoot)
4341 # Check all published algorithms
4343 algo_so_i = iter.Value()
4344 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
4345 if attr is not None:
4346 anIOR = attr.Value()
4347 algo_o_i = salome.orb.string_to_object(anIOR)
4348 if algo_o_i is not None:
4349 # Check if this is an algorithm
4350 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
4351 if algo_i is not None:
4352 # Checks if the algorithm belongs to the current engine
4353 if smeshpyD.GetObjectId(algo_i) > 0:
4354 # Check if this is the required algorithm
4355 if algo_i.GetName() == algoname:
4368 ## If the algorithm is global, returns 0; \n
4369 # else returns the submesh associated to this algorithm.
4370 def GetSubMesh(self):
4373 ## Returns the wrapped mesher.
4374 def GetAlgorithm(self):
4377 ## Gets the list of hypothesis that can be used with this algorithm
4378 def GetCompatibleHypothesis(self):
4381 mylist = self.algo.GetCompatibleHypothesis()
4384 ## Gets the name of the algorithm
4388 ## Sets the name to the algorithm
4389 def SetName(self, name):
4390 self.mesh.smeshpyD.SetName(self.algo, name)
4392 ## Gets the id of the algorithm
4394 return self.algo.GetId()
4397 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
4399 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
4400 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
4402 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
4404 self.Assign(algo, mesh, geom)
4408 def Assign(self, algo, mesh, geom):
4410 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
4419 name = GetName(geom)
4423 if not name and geom.GetShapeType() != geompyDC.GEOM.COMPOUND:
4424 # for all groups SubShapeName() returns "Compound_-1"
4425 name = mesh.geompyD.SubShapeName(geom, piece)
4427 name = "%s_%s"%(geom.GetShapeType(), id(geom)%10000)
4428 # publish geom of sub-mesh (issue 0021122)
4429 if not self.geom.IsSame( self.mesh.geom ) and not self.geom.GetStudyEntry():
4430 studyID = self.mesh.smeshpyD.GetCurrentStudy()._get_StudyId()
4431 if studyID != self.mesh.geompyD.myStudyId:
4432 self.mesh.geompyD.init_geom( self.mesh.smeshpyD.GetCurrentStudy())
4433 self.mesh.geompyD.addToStudyInFather( self.mesh.geom, self.geom, name )
4435 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
4437 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
4438 TreatHypoStatus( status, algo.GetName(), name, True )
4440 def CompareHyp (self, hyp, args):
4441 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
4444 def CompareEqualHyp (self, hyp, args):
4448 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
4449 UseExisting=0, CompareMethod=""):
4452 if CompareMethod == "": CompareMethod = self.CompareHyp
4453 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
4456 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
4462 a = a + s + str(args[i])
4466 self.mesh.smeshpyD.SetName(hypo, hyp + a)
4470 geomName = GetName(self.geom)
4471 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
4472 TreatHypoStatus( status, GetName(hypo), geomName, 0 )
4475 ## Returns entry of the shape to mesh in the study
4476 def MainShapeEntry(self):
4478 if not self.mesh or not self.mesh.GetMesh(): return entry
4479 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
4480 study = self.mesh.smeshpyD.GetCurrentStudy()
4481 ior = salome.orb.object_to_string( self.mesh.GetShape() )
4482 sobj = study.FindObjectIOR(ior)
4483 if sobj: entry = sobj.GetID()
4484 if not entry: return ""
4487 ## Defines "ViscousLayers" hypothesis to give parameters of layers of prisms to build
4488 # near mesh boundary. This hypothesis can be used by several 3D algorithms:
4489 # NETGEN 3D, GHS3D, Hexahedron(i,j,k)
4490 # @param thickness total thickness of layers of prisms
4491 # @param numberOfLayers number of layers of prisms
4492 # @param stretchFactor factor (>1.0) of growth of layer thickness towards inside of mesh
4493 # @param ignoreFaces geometrical face (or their ids) not to generate layers on
4494 # @ingroup l3_hypos_additi
4495 def ViscousLayers(self, thickness, numberOfLayers, stretchFactor, ignoreFaces=[]):
4496 if not isinstance(self.algo, SMESH._objref_SMESH_3D_Algo):
4497 raise TypeError, "ViscousLayers are supported by 3D algorithms only"
4498 if not "ViscousLayers" in self.GetCompatibleHypothesis():
4499 raise TypeError, "ViscousLayers are not supported by %s"%self.algo.GetName()
4500 if ignoreFaces and isinstance( ignoreFaces[0], geompyDC.GEOM._objref_GEOM_Object ):
4501 ignoreFaces = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, f) for f in ignoreFaces ]
4502 hyp = self.Hypothesis("ViscousLayers",
4503 [thickness, numberOfLayers, stretchFactor, ignoreFaces])
4504 hyp.SetTotalThickness(thickness)
4505 hyp.SetNumberLayers(numberOfLayers)
4506 hyp.SetStretchFactor(stretchFactor)
4507 hyp.SetIgnoreFaces(ignoreFaces)
4510 # Public class: Mesh_Segment
4511 # --------------------------
4513 ## Class to define a segment 1D algorithm for discretization
4516 # @ingroup l3_algos_basic
4517 class Mesh_Segment(Mesh_Algorithm):
4519 ## Private constructor.
4520 def __init__(self, mesh, geom=0):
4521 Mesh_Algorithm.__init__(self)
4522 self.Create(mesh, geom, "Regular_1D")
4524 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
4525 # @param l for the length of segments that cut an edge
4526 # @param UseExisting if ==true - searches for an existing hypothesis created with
4527 # the same parameters, else (default) - creates a new one
4528 # @param p precision, used for calculation of the number of segments.
4529 # The precision should be a positive, meaningful value within the range [0,1].
4530 # In general, the number of segments is calculated with the formula:
4531 # nb = ceil((edge_length / l) - p)
4532 # Function ceil rounds its argument to the higher integer.
4533 # So, p=0 means rounding of (edge_length / l) to the higher integer,
4534 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
4535 # p=1 means rounding of (edge_length / l) to the lower integer.
4536 # Default value is 1e-07.
4537 # @return an instance of StdMeshers_LocalLength hypothesis
4538 # @ingroup l3_hypos_1dhyps
4539 def LocalLength(self, l, UseExisting=0, p=1e-07):
4540 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
4541 CompareMethod=self.CompareLocalLength)
4547 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
4548 def CompareLocalLength(self, hyp, args):
4549 if IsEqual(hyp.GetLength(), args[0]):
4550 return IsEqual(hyp.GetPrecision(), args[1])
4553 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
4554 # @param length is optional maximal allowed length of segment, if it is omitted
4555 # the preestimated length is used that depends on geometry size
4556 # @param UseExisting if ==true - searches for an existing hypothesis created with
4557 # the same parameters, else (default) - create a new one
4558 # @return an instance of StdMeshers_MaxLength hypothesis
4559 # @ingroup l3_hypos_1dhyps
4560 def MaxSize(self, length=0.0, UseExisting=0):
4561 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
4564 hyp.SetLength(length)
4566 # set preestimated length
4567 gen = self.mesh.smeshpyD
4568 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
4569 self.mesh.GetMesh(), self.mesh.GetShape(),
4571 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
4573 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
4576 hyp.SetUsePreestimatedLength( length == 0.0 )
4579 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
4580 # @param n for the number of segments that cut an edge
4581 # @param s for the scale factor (optional)
4582 # @param reversedEdges is a list of edges to mesh using reversed orientation
4583 # @param UseExisting if ==true - searches for an existing hypothesis created with
4584 # the same parameters, else (default) - create a new one
4585 # @return an instance of StdMeshers_NumberOfSegments hypothesis
4586 # @ingroup l3_hypos_1dhyps
4587 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4588 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4589 reversedEdges, UseExisting = [], reversedEdges
4590 entry = self.MainShapeEntry()
4591 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4592 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4594 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
4595 UseExisting=UseExisting,
4596 CompareMethod=self.CompareNumberOfSegments)
4598 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
4599 UseExisting=UseExisting,
4600 CompareMethod=self.CompareNumberOfSegments)
4601 hyp.SetDistrType( 1 )
4602 hyp.SetScaleFactor(s)
4603 hyp.SetNumberOfSegments(n)
4604 hyp.SetReversedEdges( reversedEdges )
4605 hyp.SetObjectEntry( entry )
4609 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4610 def CompareNumberOfSegments(self, hyp, args):
4611 if hyp.GetNumberOfSegments() == args[0]:
4613 if hyp.GetReversedEdges() == args[1]:
4614 if not args[1] or hyp.GetObjectEntry() == args[2]:
4617 if hyp.GetReversedEdges() == args[2]:
4618 if not args[2] or hyp.GetObjectEntry() == args[3]:
4619 if hyp.GetDistrType() == 1:
4620 if IsEqual(hyp.GetScaleFactor(), args[1]):
4624 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4625 # @param start defines the length of the first segment
4626 # @param end defines the length of the last segment
4627 # @param reversedEdges is a list of edges to mesh using reversed orientation
4628 # @param UseExisting if ==true - searches for an existing hypothesis created with
4629 # the same parameters, else (default) - creates a new one
4630 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4631 # @ingroup l3_hypos_1dhyps
4632 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4633 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4634 reversedEdges, UseExisting = [], reversedEdges
4635 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4636 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4637 entry = self.MainShapeEntry()
4638 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
4639 UseExisting=UseExisting,
4640 CompareMethod=self.CompareArithmetic1D)
4641 hyp.SetStartLength(start)
4642 hyp.SetEndLength(end)
4643 hyp.SetReversedEdges( reversedEdges )
4644 hyp.SetObjectEntry( entry )
4648 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4649 def CompareArithmetic1D(self, hyp, args):
4650 if IsEqual(hyp.GetLength(1), args[0]):
4651 if IsEqual(hyp.GetLength(0), args[1]):
4652 if hyp.GetReversedEdges() == args[2]:
4653 if not args[2] or hyp.GetObjectEntry() == args[3]:
4658 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4659 # on curve from 0 to 1 (additionally it is neecessary to check
4660 # orientation of edges and create list of reversed edges if it is
4661 # needed) and sets numbers of segments between given points (default
4662 # values are equals 1
4663 # @param points defines the list of parameters on curve
4664 # @param nbSegs defines the list of numbers of segments
4665 # @param reversedEdges is a list of edges to mesh using reversed orientation
4666 # @param UseExisting if ==true - searches for an existing hypothesis created with
4667 # the same parameters, else (default) - creates a new one
4668 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4669 # @ingroup l3_hypos_1dhyps
4670 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4671 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4672 reversedEdges, UseExisting = [], reversedEdges
4673 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4674 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4675 entry = self.MainShapeEntry()
4676 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
4677 UseExisting=UseExisting,
4678 CompareMethod=self.CompareFixedPoints1D)
4679 hyp.SetPoints(points)
4680 hyp.SetNbSegments(nbSegs)
4681 hyp.SetReversedEdges(reversedEdges)
4682 hyp.SetObjectEntry(entry)
4686 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4687 ## as the given arguments
4688 def CompareFixedPoints1D(self, hyp, args):
4689 if hyp.GetPoints() == args[0]:
4690 if hyp.GetNbSegments() == args[1]:
4691 if hyp.GetReversedEdges() == args[2]:
4692 if not args[2] or hyp.GetObjectEntry() == args[3]:
4698 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4699 # @param start defines the length of the first segment
4700 # @param end defines the length of the last segment
4701 # @param reversedEdges is a list of edges to mesh using reversed orientation
4702 # @param UseExisting if ==true - searches for an existing hypothesis created with
4703 # the same parameters, else (default) - creates a new one
4704 # @return an instance of StdMeshers_StartEndLength hypothesis
4705 # @ingroup l3_hypos_1dhyps
4706 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4707 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4708 reversedEdges, UseExisting = [], reversedEdges
4709 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4710 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4711 entry = self.MainShapeEntry()
4712 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
4713 UseExisting=UseExisting,
4714 CompareMethod=self.CompareStartEndLength)
4715 hyp.SetStartLength(start)
4716 hyp.SetEndLength(end)
4717 hyp.SetReversedEdges( reversedEdges )
4718 hyp.SetObjectEntry( entry )
4721 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4722 def CompareStartEndLength(self, hyp, args):
4723 if IsEqual(hyp.GetLength(1), args[0]):
4724 if IsEqual(hyp.GetLength(0), args[1]):
4725 if hyp.GetReversedEdges() == args[2]:
4726 if not args[2] or hyp.GetObjectEntry() == args[3]:
4730 ## Defines "Deflection1D" hypothesis
4731 # @param d for the deflection
4732 # @param UseExisting if ==true - searches for an existing hypothesis created with
4733 # the same parameters, else (default) - create a new one
4734 # @ingroup l3_hypos_1dhyps
4735 def Deflection1D(self, d, UseExisting=0):
4736 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4737 CompareMethod=self.CompareDeflection1D)
4738 hyp.SetDeflection(d)
4741 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4742 def CompareDeflection1D(self, hyp, args):
4743 return IsEqual(hyp.GetDeflection(), args[0])
4745 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4746 # the opposite side in case of quadrangular faces
4747 # @ingroup l3_hypos_additi
4748 def Propagation(self):
4749 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4751 ## Defines "AutomaticLength" hypothesis
4752 # @param fineness for the fineness [0-1]
4753 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4754 # same parameters, else (default) - create a new one
4755 # @ingroup l3_hypos_1dhyps
4756 def AutomaticLength(self, fineness=0, UseExisting=0):
4757 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4758 CompareMethod=self.CompareAutomaticLength)
4759 hyp.SetFineness( fineness )
4762 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4763 def CompareAutomaticLength(self, hyp, args):
4764 return IsEqual(hyp.GetFineness(), args[0])
4766 ## Defines "SegmentLengthAroundVertex" hypothesis
4767 # @param length for the segment length
4768 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4769 # Any other integer value means that the hypothesis will be set on the
4770 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4771 # @param UseExisting if ==true - searches for an existing hypothesis created with
4772 # the same parameters, else (default) - creates a new one
4773 # @ingroup l3_algos_segmarv
4774 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4776 store_geom = self.geom
4777 if type(vertex) is types.IntType:
4778 if vertex == 0 or vertex == 1:
4779 vertex = self.mesh.geompyD.ExtractShapes(self.geom, geompyDC.ShapeType["VERTEX"],True)[vertex]
4787 if self.geom is None:
4788 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4790 name = GetName(self.geom)
4793 piece = self.mesh.geom
4794 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
4795 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
4797 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4799 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4801 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4802 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4804 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4805 CompareMethod=self.CompareLengthNearVertex)
4806 self.geom = store_geom
4807 hyp.SetLength( length )
4810 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4811 # @ingroup l3_algos_segmarv
4812 def CompareLengthNearVertex(self, hyp, args):
4813 return IsEqual(hyp.GetLength(), args[0])
4815 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4816 # If the 2D mesher sees that all boundary edges are quadratic,
4817 # it generates quadratic faces, else it generates linear faces using
4818 # medium nodes as if they are vertices.
4819 # The 3D mesher generates quadratic volumes only if all boundary faces
4820 # are quadratic, else it fails.
4822 # @ingroup l3_hypos_additi
4823 def QuadraticMesh(self):
4824 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4827 # Public class: Mesh_CompositeSegment
4828 # --------------------------
4830 ## Defines a segment 1D algorithm for discretization
4832 # @ingroup l3_algos_basic
4833 class Mesh_CompositeSegment(Mesh_Segment):
4835 ## Private constructor.
4836 def __init__(self, mesh, geom=0):
4837 self.Create(mesh, geom, "CompositeSegment_1D")
4840 # Public class: Mesh_Segment_Python
4841 # ---------------------------------
4843 ## Defines a segment 1D algorithm for discretization with python function
4845 # @ingroup l3_algos_basic
4846 class Mesh_Segment_Python(Mesh_Segment):
4848 ## Private constructor.
4849 def __init__(self, mesh, geom=0):
4850 import Python1dPlugin
4851 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4853 ## Defines "PythonSplit1D" hypothesis
4854 # @param n for the number of segments that cut an edge
4855 # @param func for the python function that calculates the length of all segments
4856 # @param UseExisting if ==true - searches for the existing hypothesis created with
4857 # the same parameters, else (default) - creates a new one
4858 # @ingroup l3_hypos_1dhyps
4859 def PythonSplit1D(self, n, func, UseExisting=0):
4860 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4861 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4862 hyp.SetNumberOfSegments(n)
4863 hyp.SetPythonLog10RatioFunction(func)
4866 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4867 def ComparePythonSplit1D(self, hyp, args):
4868 #if hyp.GetNumberOfSegments() == args[0]:
4869 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4873 # Public class: Mesh_Triangle
4874 # ---------------------------
4876 ## Defines a triangle 2D algorithm
4878 # @ingroup l3_algos_basic
4879 class Mesh_Triangle(Mesh_Algorithm):
4888 ## Private constructor.
4889 def __init__(self, mesh, algoType, geom=0):
4890 Mesh_Algorithm.__init__(self)
4892 self.algoType = algoType
4893 if algoType == MEFISTO:
4894 self.Create(mesh, geom, "MEFISTO_2D")
4896 elif algoType == BLSURF:
4898 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4899 #self.SetPhysicalMesh() - PAL19680
4900 elif algoType == NETGEN:
4902 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4904 elif algoType == NETGEN_2D:
4906 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4909 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4910 # @param area for the maximum area of each triangle
4911 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4912 # same parameters, else (default) - creates a new one
4914 # Only for algoType == MEFISTO || NETGEN_2D
4915 # @ingroup l3_hypos_2dhyps
4916 def MaxElementArea(self, area, UseExisting=0):
4917 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4918 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4919 CompareMethod=self.CompareMaxElementArea)
4920 elif self.algoType == NETGEN:
4921 hyp = self.Parameters(SIMPLE)
4922 hyp.SetMaxElementArea(area)
4925 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4926 def CompareMaxElementArea(self, hyp, args):
4927 return IsEqual(hyp.GetMaxElementArea(), args[0])
4929 ## Defines "LengthFromEdges" hypothesis to build triangles
4930 # based on the length of the edges taken from the wire
4932 # Only for algoType == MEFISTO || NETGEN_2D
4933 # @ingroup l3_hypos_2dhyps
4934 def LengthFromEdges(self):
4935 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4936 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4938 elif self.algoType == NETGEN:
4939 hyp = self.Parameters(SIMPLE)
4940 hyp.LengthFromEdges()
4943 ## Sets a way to define size of mesh elements to generate.
4944 # @param thePhysicalMesh is: DefaultSize or Custom.
4945 # @ingroup l3_hypos_blsurf
4946 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4947 # Parameter of BLSURF algo
4948 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4950 ## Sets size of mesh elements to generate.
4951 # @ingroup l3_hypos_blsurf
4952 def SetPhySize(self, theVal):
4953 # Parameter of BLSURF algo
4954 self.SetPhysicalMesh(1) #Custom - else why to set the size?
4955 self.Parameters().SetPhySize(theVal)
4957 ## Sets lower boundary of mesh element size (PhySize).
4958 # @ingroup l3_hypos_blsurf
4959 def SetPhyMin(self, theVal=-1):
4960 # Parameter of BLSURF algo
4961 self.Parameters().SetPhyMin(theVal)
4963 ## Sets upper boundary of mesh element size (PhySize).
4964 # @ingroup l3_hypos_blsurf
4965 def SetPhyMax(self, theVal=-1):
4966 # Parameter of BLSURF algo
4967 self.Parameters().SetPhyMax(theVal)
4969 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4970 # @param theGeometricMesh is: 0 (None) or 1 (Custom)
4971 # @ingroup l3_hypos_blsurf
4972 def SetGeometricMesh(self, theGeometricMesh=0):
4973 # Parameter of BLSURF algo
4974 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4975 self.params.SetGeometricMesh(theGeometricMesh)
4977 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4978 # @ingroup l3_hypos_blsurf
4979 def SetAngleMeshS(self, theVal=_angleMeshS):
4980 # Parameter of BLSURF algo
4981 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4982 self.params.SetAngleMeshS(theVal)
4984 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4985 # @ingroup l3_hypos_blsurf
4986 def SetAngleMeshC(self, theVal=_angleMeshS):
4987 # Parameter of BLSURF algo
4988 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4989 self.params.SetAngleMeshC(theVal)
4991 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4992 # @ingroup l3_hypos_blsurf
4993 def SetGeoMin(self, theVal=-1):
4994 # Parameter of BLSURF algo
4995 self.Parameters().SetGeoMin(theVal)
4997 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4998 # @ingroup l3_hypos_blsurf
4999 def SetGeoMax(self, theVal=-1):
5000 # Parameter of BLSURF algo
5001 self.Parameters().SetGeoMax(theVal)
5003 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
5004 # @ingroup l3_hypos_blsurf
5005 def SetGradation(self, theVal=_gradation):
5006 # Parameter of BLSURF algo
5007 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
5008 self.params.SetGradation(theVal)
5010 ## Sets topology usage way.
5011 # @param way defines how mesh conformity is assured <ul>
5012 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
5013 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
5014 # @ingroup l3_hypos_blsurf
5015 def SetTopology(self, way):
5016 # Parameter of BLSURF algo
5017 self.Parameters().SetTopology(way)
5019 ## To respect geometrical edges or not.
5020 # @ingroup l3_hypos_blsurf
5021 def SetDecimesh(self, toIgnoreEdges=False):
5022 # Parameter of BLSURF algo
5023 self.Parameters().SetDecimesh(toIgnoreEdges)
5025 ## Sets verbosity level in the range 0 to 100.
5026 # @ingroup l3_hypos_blsurf
5027 def SetVerbosity(self, level):
5028 # Parameter of BLSURF algo
5029 self.Parameters().SetVerbosity(level)
5031 ## Sets advanced option value.
5032 # @ingroup l3_hypos_blsurf
5033 def SetOptionValue(self, optionName, level):
5034 # Parameter of BLSURF algo
5035 self.Parameters().SetOptionValue(optionName,level)
5037 ## 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 ]
5038 # @param theFace : face on which the attractor will be defined
5039 # @param theAttractor : geometrical object frome which the mesh size "h" decreases exponentially
5040 # @param theStartSize : mesh size on theAttractor
5041 # @param theEndSize : maximum size that will be reached on theFace
5042 # @param theInfluenceDistance : influence of the attractor ( the size grow slower on theFace if it's high)
5043 # @param theConstantSizeDistance : distance until which the mesh size will be kept constant on theFace
5044 # @ingroup l3_hypos_blsurf
5045 def SetAttractorGeom(self, theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance):
5046 # Parameter of BLSURF algo
5047 self.Parameters().SetAttractorGeom(otheFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance)
5049 ## Sets QuadAllowed flag.
5050 # Only for algoType == NETGEN(NETGEN_1D2D) || NETGEN_2D || BLSURF
5051 # @ingroup l3_hypos_netgen l3_hypos_blsurf
5052 def SetQuadAllowed(self, toAllow=True):
5053 if self.algoType == NETGEN_2D:
5056 hasSimpleHyps = False
5057 simpleHyps = ["QuadranglePreference","LengthFromEdges","MaxElementArea"]
5058 for hyp in self.mesh.GetHypothesisList( self.geom ):
5059 if hyp.GetName() in simpleHyps:
5060 hasSimpleHyps = True
5061 if hyp.GetName() == "QuadranglePreference":
5062 if not toAllow: # remove QuadranglePreference
5063 self.mesh.RemoveHypothesis( self.geom, hyp )
5069 if toAllow: # add QuadranglePreference
5070 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
5075 if self.Parameters():
5076 self.params.SetQuadAllowed(toAllow)
5079 ## Defines hypothesis having several parameters
5081 # @ingroup l3_hypos_netgen
5082 def Parameters(self, which=SOLE):
5084 if self.algoType == NETGEN:
5086 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
5087 "libNETGENEngine.so", UseExisting=0)
5089 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
5090 "libNETGENEngine.so", UseExisting=0)
5091 elif self.algoType == MEFISTO:
5092 print "Mefisto algo support no multi-parameter hypothesis"
5093 elif self.algoType == NETGEN_2D:
5094 self.params = self.Hypothesis("NETGEN_Parameters_2D_ONLY", [],
5095 "libNETGENEngine.so", UseExisting=0)
5096 elif self.algoType == BLSURF:
5097 self.params = self.Hypothesis("BLSURF_Parameters", [],
5098 "libBLSURFEngine.so", UseExisting=0)
5100 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
5105 # Only for algoType == NETGEN
5106 # @ingroup l3_hypos_netgen
5107 def SetMaxSize(self, theSize):
5108 if self.Parameters():
5109 self.params.SetMaxSize(theSize)
5111 ## Sets SecondOrder flag
5113 # Only for algoType == NETGEN
5114 # @ingroup l3_hypos_netgen
5115 def SetSecondOrder(self, theVal):
5116 if self.Parameters():
5117 self.params.SetSecondOrder(theVal)
5119 ## Sets Optimize flag
5121 # Only for algoType == NETGEN
5122 # @ingroup l3_hypos_netgen
5123 def SetOptimize(self, theVal):
5124 if self.Parameters():
5125 self.params.SetOptimize(theVal)
5128 # @param theFineness is:
5129 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5131 # Only for algoType == NETGEN
5132 # @ingroup l3_hypos_netgen
5133 def SetFineness(self, theFineness):
5134 if self.Parameters():
5135 self.params.SetFineness(theFineness)
5139 # Only for algoType == NETGEN
5140 # @ingroup l3_hypos_netgen
5141 def SetGrowthRate(self, theRate):
5142 if self.Parameters():
5143 self.params.SetGrowthRate(theRate)
5145 ## Sets NbSegPerEdge
5147 # Only for algoType == NETGEN
5148 # @ingroup l3_hypos_netgen
5149 def SetNbSegPerEdge(self, theVal):
5150 if self.Parameters():
5151 self.params.SetNbSegPerEdge(theVal)
5153 ## Sets NbSegPerRadius
5155 # Only for algoType == NETGEN
5156 # @ingroup l3_hypos_netgen
5157 def SetNbSegPerRadius(self, theVal):
5158 if self.Parameters():
5159 self.params.SetNbSegPerRadius(theVal)
5161 ## Sets number of segments overriding value set by SetLocalLength()
5163 # Only for algoType == NETGEN
5164 # @ingroup l3_hypos_netgen
5165 def SetNumberOfSegments(self, theVal):
5166 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5168 ## Sets number of segments overriding value set by SetNumberOfSegments()
5170 # Only for algoType == NETGEN
5171 # @ingroup l3_hypos_netgen
5172 def SetLocalLength(self, theVal):
5173 self.Parameters(SIMPLE).SetLocalLength(theVal)
5178 # Public class: Mesh_Quadrangle
5179 # -----------------------------
5181 ## Defines a quadrangle 2D algorithm
5183 # @ingroup l3_algos_basic
5184 class Mesh_Quadrangle(Mesh_Algorithm):
5188 ## Private constructor.
5189 def __init__(self, mesh, geom=0):
5190 Mesh_Algorithm.__init__(self)
5191 self.Create(mesh, geom, "Quadrangle_2D")
5194 ## Defines "QuadrangleParameters" hypothesis
5195 # @param quadType defines the algorithm of transition between differently descretized
5196 # sides of a geometrical face:
5197 # - QUAD_STANDARD - both triangles and quadrangles are possible in the transition
5198 # area along the finer meshed sides.
5199 # - QUAD_TRIANGLE_PREF - only triangles are built in the transition area along the
5200 # finer meshed sides.
5201 # - QUAD_QUADRANGLE_PREF - only quadrangles are built in the transition area along
5202 # the finer meshed sides, iff the total quantity of segments on
5203 # all four sides of the face is even (divisible by 2).
5204 # - QUAD_QUADRANGLE_PREF_REVERSED - same as QUAD_QUADRANGLE_PREF but the transition
5205 # area is located along the coarser meshed sides.
5206 # - QUAD_REDUCED - only quadrangles are built and the transition between the sides
5207 # is made gradually, layer by layer. This type has a limitation on
5208 # the number of segments: one pair of opposite sides must have the
5209 # same number of segments, the other pair must have an even difference
5210 # between the numbers of segments on the sides.
5211 # @param triangleVertex: vertex of a trilateral geometrical face, around which triangles
5212 # will be created while other elements will be quadrangles.
5213 # Vertex can be either a GEOM_Object or a vertex ID within the
5215 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5216 # the same parameters, else (default) - creates a new one
5217 # @ingroup l3_hypos_quad
5218 def QuadrangleParameters(self, quadType=StdMeshers.QUAD_STANDARD, triangleVertex=0, UseExisting=0):
5219 vertexID = triangleVertex
5220 if isinstance( triangleVertex, geompyDC.GEOM._objref_GEOM_Object ):
5221 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, triangleVertex )
5223 compFun = lambda hyp,args: \
5224 hyp.GetQuadType() == args[0] and \
5225 ( hyp.GetTriaVertex()==args[1] or ( hyp.GetTriaVertex()<1 and args[1]<1))
5226 self.params = self.Hypothesis("QuadrangleParams", [quadType,vertexID],
5227 UseExisting = UseExisting, CompareMethod=compFun)
5229 if self.params.GetQuadType() != quadType:
5230 self.params.SetQuadType(quadType)
5232 self.params.SetTriaVertex( vertexID )
5235 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5236 # quadrangles are built in the transition area along the finer meshed sides,
5237 # iff the total quantity of segments on all four sides of the face is even.
5238 # @param reversed if True, transition area is located along the coarser meshed sides.
5239 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5240 # the same parameters, else (default) - creates a new one
5241 # @ingroup l3_hypos_quad
5242 def QuadranglePreference(self, reversed=False, UseExisting=0):
5244 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF_REVERSED,UseExisting=UseExisting)
5245 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF,UseExisting=UseExisting)
5247 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5248 # triangles are built in the transition area along the finer meshed sides.
5249 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5250 # the same parameters, else (default) - creates a new one
5251 # @ingroup l3_hypos_quad
5252 def TrianglePreference(self, UseExisting=0):
5253 return self.QuadrangleParameters(QUAD_TRIANGLE_PREF,UseExisting=UseExisting)
5255 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5256 # quadrangles are built and the transition between the sides is made gradually,
5257 # layer by layer. This type has a limitation on the number of segments: one pair
5258 # of opposite sides must have the same number of segments, the other pair must
5259 # have an even difference between the numbers of segments on the sides.
5260 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5261 # the same parameters, else (default) - creates a new one
5262 # @ingroup l3_hypos_quad
5263 def Reduced(self, UseExisting=0):
5264 return self.QuadrangleParameters(QUAD_REDUCED,UseExisting=UseExisting)
5266 ## Defines "QuadrangleParams" hypothesis with QUAD_STANDARD type of quadrangulation
5267 # @param vertex: vertex of a trilateral geometrical face, around which triangles
5268 # will be created while other elements will be quadrangles.
5269 # Vertex can be either a GEOM_Object or a vertex ID within the
5271 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5272 # the same parameters, else (default) - creates a new one
5273 # @ingroup l3_hypos_quad
5274 def TriangleVertex(self, vertex, UseExisting=0):
5275 return self.QuadrangleParameters(QUAD_STANDARD,vertex,UseExisting)
5278 # Public class: Mesh_Tetrahedron
5279 # ------------------------------
5281 ## Defines a tetrahedron 3D algorithm
5283 # @ingroup l3_algos_basic
5284 class Mesh_Tetrahedron(Mesh_Algorithm):
5289 ## Private constructor.
5290 def __init__(self, mesh, algoType, geom=0):
5291 Mesh_Algorithm.__init__(self)
5293 if algoType == NETGEN:
5295 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
5298 elif algoType == FULL_NETGEN:
5300 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5303 elif algoType == GHS3D:
5305 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
5308 elif algoType == GHS3DPRL:
5309 CheckPlugin(GHS3DPRL)
5310 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
5313 self.algoType = algoType
5315 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
5316 # @param vol for the maximum volume of each tetrahedron
5317 # @param UseExisting if ==true - searches for the existing hypothesis created with
5318 # the same parameters, else (default) - creates a new one
5319 # @ingroup l3_hypos_maxvol
5320 def MaxElementVolume(self, vol, UseExisting=0):
5321 if self.algoType == NETGEN:
5322 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
5323 CompareMethod=self.CompareMaxElementVolume)
5324 hyp.SetMaxElementVolume(vol)
5326 elif self.algoType == FULL_NETGEN:
5327 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
5330 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
5331 def CompareMaxElementVolume(self, hyp, args):
5332 return IsEqual(hyp.GetMaxElementVolume(), args[0])
5334 ## Defines hypothesis having several parameters
5336 # @ingroup l3_hypos_netgen
5337 def Parameters(self, which=SOLE):
5340 if self.algoType == FULL_NETGEN:
5342 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
5343 "libNETGENEngine.so", UseExisting=0)
5345 self.params = self.Hypothesis("NETGEN_Parameters", [],
5346 "libNETGENEngine.so", UseExisting=0)
5348 elif self.algoType == NETGEN:
5349 self.params = self.Hypothesis("NETGEN_Parameters_3D", [],
5350 "libNETGENEngine.so", UseExisting=0)
5352 elif self.algoType == GHS3D:
5353 self.params = self.Hypothesis("GHS3D_Parameters", [],
5354 "libGHS3DEngine.so", UseExisting=0)
5356 elif self.algoType == GHS3DPRL:
5357 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
5358 "libGHS3DPRLEngine.so", UseExisting=0)
5360 print "Warning: %s supports no multi-parameter hypothesis"%self.algo.GetName()
5365 # Parameter of FULL_NETGEN and NETGEN
5366 # @ingroup l3_hypos_netgen
5367 def SetMaxSize(self, theSize):
5368 self.Parameters().SetMaxSize(theSize)
5370 ## Sets SecondOrder flag
5371 # Parameter of FULL_NETGEN
5372 # @ingroup l3_hypos_netgen
5373 def SetSecondOrder(self, theVal):
5374 self.Parameters().SetSecondOrder(theVal)
5376 ## Sets Optimize flag
5377 # Parameter of FULL_NETGEN and NETGEN
5378 # @ingroup l3_hypos_netgen
5379 def SetOptimize(self, theVal):
5380 self.Parameters().SetOptimize(theVal)
5383 # @param theFineness is:
5384 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5385 # Parameter of FULL_NETGEN
5386 # @ingroup l3_hypos_netgen
5387 def SetFineness(self, theFineness):
5388 self.Parameters().SetFineness(theFineness)
5391 # Parameter of FULL_NETGEN
5392 # @ingroup l3_hypos_netgen
5393 def SetGrowthRate(self, theRate):
5394 self.Parameters().SetGrowthRate(theRate)
5396 ## Sets NbSegPerEdge
5397 # Parameter of FULL_NETGEN
5398 # @ingroup l3_hypos_netgen
5399 def SetNbSegPerEdge(self, theVal):
5400 self.Parameters().SetNbSegPerEdge(theVal)
5402 ## Sets NbSegPerRadius
5403 # Parameter of FULL_NETGEN
5404 # @ingroup l3_hypos_netgen
5405 def SetNbSegPerRadius(self, theVal):
5406 self.Parameters().SetNbSegPerRadius(theVal)
5408 ## Sets number of segments overriding value set by SetLocalLength()
5409 # Only for algoType == NETGEN_FULL
5410 # @ingroup l3_hypos_netgen
5411 def SetNumberOfSegments(self, theVal):
5412 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5414 ## Sets number of segments overriding value set by SetNumberOfSegments()
5415 # Only for algoType == NETGEN_FULL
5416 # @ingroup l3_hypos_netgen
5417 def SetLocalLength(self, theVal):
5418 self.Parameters(SIMPLE).SetLocalLength(theVal)
5420 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
5421 # Overrides value set by LengthFromEdges()
5422 # Only for algoType == NETGEN_FULL
5423 # @ingroup l3_hypos_netgen
5424 def MaxElementArea(self, area):
5425 self.Parameters(SIMPLE).SetMaxElementArea(area)
5427 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
5428 # Overrides value set by MaxElementArea()
5429 # Only for algoType == NETGEN_FULL
5430 # @ingroup l3_hypos_netgen
5431 def LengthFromEdges(self):
5432 self.Parameters(SIMPLE).LengthFromEdges()
5434 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
5435 # Overrides value set by MaxElementVolume()
5436 # Only for algoType == NETGEN_FULL
5437 # @ingroup l3_hypos_netgen
5438 def LengthFromFaces(self):
5439 self.Parameters(SIMPLE).LengthFromFaces()
5441 ## To mesh "holes" in a solid or not. Default is to mesh.
5442 # @ingroup l3_hypos_ghs3dh
5443 def SetToMeshHoles(self, toMesh):
5444 # Parameter of GHS3D
5445 self.Parameters().SetToMeshHoles(toMesh)
5447 ## Set Optimization level:
5448 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
5449 # Strong_Optimization.
5450 # Default is Standard_Optimization
5451 # @ingroup l3_hypos_ghs3dh
5452 def SetOptimizationLevel(self, level):
5453 # Parameter of GHS3D
5454 self.Parameters().SetOptimizationLevel(level)
5456 ## Maximal size of memory to be used by the algorithm (in Megabytes).
5457 # @ingroup l3_hypos_ghs3dh
5458 def SetMaximumMemory(self, MB):
5459 # Advanced parameter of GHS3D
5460 self.Parameters().SetMaximumMemory(MB)
5462 ## Initial size of memory to be used by the algorithm (in Megabytes) in
5463 # automatic memory adjustment mode.
5464 # @ingroup l3_hypos_ghs3dh
5465 def SetInitialMemory(self, MB):
5466 # Advanced parameter of GHS3D
5467 self.Parameters().SetInitialMemory(MB)
5469 ## Path to working directory.
5470 # @ingroup l3_hypos_ghs3dh
5471 def SetWorkingDirectory(self, path):
5472 # Advanced parameter of GHS3D
5473 self.Parameters().SetWorkingDirectory(path)
5475 ## To keep working files or remove them. Log file remains in case of errors anyway.
5476 # @ingroup l3_hypos_ghs3dh
5477 def SetKeepFiles(self, toKeep):
5478 # Advanced parameter of GHS3D and GHS3DPRL
5479 self.Parameters().SetKeepFiles(toKeep)
5481 ## To set verbose level [0-10]. <ul>
5482 #<li> 0 - no standard output,
5483 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
5484 # indicates when the final mesh is being saved. In addition the software
5485 # gives indication regarding the CPU time.
5486 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
5487 # histogram of the skin mesh, quality statistics histogram together with
5488 # the characteristics of the final mesh.</ul>
5489 # @ingroup l3_hypos_ghs3dh
5490 def SetVerboseLevel(self, level):
5491 # Advanced parameter of GHS3D
5492 self.Parameters().SetVerboseLevel(level)
5494 ## To create new nodes.
5495 # @ingroup l3_hypos_ghs3dh
5496 def SetToCreateNewNodes(self, toCreate):
5497 # Advanced parameter of GHS3D
5498 self.Parameters().SetToCreateNewNodes(toCreate)
5500 ## To use boundary recovery version which tries to create mesh on a very poor
5501 # quality surface mesh.
5502 # @ingroup l3_hypos_ghs3dh
5503 def SetToUseBoundaryRecoveryVersion(self, toUse):
5504 # Advanced parameter of GHS3D
5505 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
5507 ## Sets command line option as text.
5508 # @ingroup l3_hypos_ghs3dh
5509 def SetTextOption(self, option):
5510 # Advanced parameter of GHS3D
5511 self.Parameters().SetTextOption(option)
5513 ## Sets MED files name and path.
5514 def SetMEDName(self, value):
5515 self.Parameters().SetMEDName(value)
5517 ## Sets the number of partition of the initial mesh
5518 def SetNbPart(self, value):
5519 self.Parameters().SetNbPart(value)
5521 ## When big mesh, start tepal in background
5522 def SetBackground(self, value):
5523 self.Parameters().SetBackground(value)
5525 # Public class: Mesh_Hexahedron
5526 # ------------------------------
5528 ## Defines a hexahedron 3D algorithm
5530 # @ingroup l3_algos_basic
5531 class Mesh_Hexahedron(Mesh_Algorithm):
5536 ## Private constructor.
5537 def __init__(self, mesh, algoType=Hexa, geom=0):
5538 Mesh_Algorithm.__init__(self)
5540 self.algoType = algoType
5542 if algoType == Hexa:
5543 self.Create(mesh, geom, "Hexa_3D")
5546 elif algoType == Hexotic:
5547 CheckPlugin(Hexotic)
5548 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
5551 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
5552 # @ingroup l3_hypos_hexotic
5553 def MinMaxQuad(self, min=3, max=8, quad=True):
5554 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
5556 self.params.SetHexesMinLevel(min)
5557 self.params.SetHexesMaxLevel(max)
5558 self.params.SetHexoticQuadrangles(quad)
5561 # Deprecated, only for compatibility!
5562 # Public class: Mesh_Netgen
5563 # ------------------------------
5565 ## Defines a NETGEN-based 2D or 3D algorithm
5566 # that needs no discrete boundary (i.e. independent)
5568 # This class is deprecated, only for compatibility!
5571 # @ingroup l3_algos_basic
5572 class Mesh_Netgen(Mesh_Algorithm):
5576 ## Private constructor.
5577 def __init__(self, mesh, is3D, geom=0):
5578 Mesh_Algorithm.__init__(self)
5584 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5588 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
5591 ## Defines the hypothesis containing parameters of the algorithm
5592 def Parameters(self):
5594 hyp = self.Hypothesis("NETGEN_Parameters", [],
5595 "libNETGENEngine.so", UseExisting=0)
5597 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
5598 "libNETGENEngine.so", UseExisting=0)
5601 # Public class: Mesh_Projection1D
5602 # ------------------------------
5604 ## Defines a projection 1D algorithm
5605 # @ingroup l3_algos_proj
5607 class Mesh_Projection1D(Mesh_Algorithm):
5609 ## Private constructor.
5610 def __init__(self, mesh, geom=0):
5611 Mesh_Algorithm.__init__(self)
5612 self.Create(mesh, geom, "Projection_1D")
5614 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
5615 # a mesh pattern is taken, and, optionally, the association of vertices
5616 # between the source edge and a target edge (to which a hypothesis is assigned)
5617 # @param edge from which nodes distribution is taken
5618 # @param mesh from which nodes distribution is taken (optional)
5619 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
5620 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
5621 # to associate with \a srcV (optional)
5622 # @param UseExisting if ==true - searches for the existing hypothesis created with
5623 # the same parameters, else (default) - creates a new one
5624 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
5625 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
5627 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
5628 hyp.SetSourceEdge( edge )
5629 if not mesh is None and isinstance(mesh, Mesh):
5630 mesh = mesh.GetMesh()
5631 hyp.SetSourceMesh( mesh )
5632 hyp.SetVertexAssociation( srcV, tgtV )
5635 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
5636 #def CompareSourceEdge(self, hyp, args):
5637 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
5641 # Public class: Mesh_Projection2D
5642 # ------------------------------
5644 ## Defines a projection 2D algorithm
5645 # @ingroup l3_algos_proj
5647 class Mesh_Projection2D(Mesh_Algorithm):
5649 ## Private constructor.
5650 def __init__(self, mesh, geom=0):
5651 Mesh_Algorithm.__init__(self)
5652 self.Create(mesh, geom, "Projection_2D")
5654 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
5655 # a mesh pattern is taken, and, optionally, the association of vertices
5656 # between the source face and the target face (to which a hypothesis is assigned)
5657 # @param face from which the mesh pattern is taken
5658 # @param mesh from which the mesh pattern is taken (optional)
5659 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
5660 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
5661 # to associate with \a srcV1 (optional)
5662 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
5663 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
5664 # to associate with \a srcV2 (optional)
5665 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
5666 # the same parameters, else (default) - forces the creation a new one
5668 # Note: all association vertices must belong to one edge of a face
5669 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
5670 srcV2=None, tgtV2=None, UseExisting=0):
5671 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
5673 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
5674 hyp.SetSourceFace( face )
5675 if not mesh is None and isinstance(mesh, Mesh):
5676 mesh = mesh.GetMesh()
5677 hyp.SetSourceMesh( mesh )
5678 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5681 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
5682 #def CompareSourceFace(self, hyp, args):
5683 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
5686 # Public class: Mesh_Projection3D
5687 # ------------------------------
5689 ## Defines a projection 3D algorithm
5690 # @ingroup l3_algos_proj
5692 class Mesh_Projection3D(Mesh_Algorithm):
5694 ## Private constructor.
5695 def __init__(self, mesh, geom=0):
5696 Mesh_Algorithm.__init__(self)
5697 self.Create(mesh, geom, "Projection_3D")
5699 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
5700 # the mesh pattern is taken, and, optionally, the association of vertices
5701 # between the source and the target solid (to which a hipothesis is assigned)
5702 # @param solid from where the mesh pattern is taken
5703 # @param mesh from where the mesh pattern is taken (optional)
5704 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
5705 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
5706 # to associate with \a srcV1 (optional)
5707 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
5708 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
5709 # to associate with \a srcV2 (optional)
5710 # @param UseExisting - if ==true - searches for the existing hypothesis created with
5711 # the same parameters, else (default) - creates a new one
5713 # Note: association vertices must belong to one edge of a solid
5714 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
5715 srcV2=0, tgtV2=0, UseExisting=0):
5716 hyp = self.Hypothesis("ProjectionSource3D",
5717 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
5719 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
5720 hyp.SetSource3DShape( solid )
5721 if not mesh is None and isinstance(mesh, Mesh):
5722 mesh = mesh.GetMesh()
5723 hyp.SetSourceMesh( mesh )
5724 if srcV1 and srcV2 and tgtV1 and tgtV2:
5725 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5726 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
5729 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
5730 #def CompareSourceShape3D(self, hyp, args):
5731 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
5735 # Public class: Mesh_Prism
5736 # ------------------------
5738 ## Defines a 3D extrusion algorithm
5739 # @ingroup l3_algos_3dextr
5741 class Mesh_Prism3D(Mesh_Algorithm):
5743 ## Private constructor.
5744 def __init__(self, mesh, geom=0):
5745 Mesh_Algorithm.__init__(self)
5746 self.Create(mesh, geom, "Prism_3D")
5748 # Public class: Mesh_RadialPrism
5749 # -------------------------------
5751 ## Defines a Radial Prism 3D algorithm
5752 # @ingroup l3_algos_radialp
5754 class Mesh_RadialPrism3D(Mesh_Algorithm):
5756 ## Private constructor.
5757 def __init__(self, mesh, geom=0):
5758 Mesh_Algorithm.__init__(self)
5759 self.Create(mesh, geom, "RadialPrism_3D")
5761 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
5762 self.nbLayers = None
5764 ## Return 3D hypothesis holding the 1D one
5765 def Get3DHypothesis(self):
5766 return self.distribHyp
5768 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5769 # hypothesis. Returns the created hypothesis
5770 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5771 #print "OwnHypothesis",hypType
5772 if not self.nbLayers is None:
5773 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5774 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5775 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5776 self.mesh.smeshpyD.SetCurrentStudy( None )
5777 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5778 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5779 self.distribHyp.SetLayerDistribution( hyp )
5782 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
5783 # prisms to build between the inner and outer shells
5784 # @param n number of layers
5785 # @param UseExisting if ==true - searches for the existing hypothesis created with
5786 # the same parameters, else (default) - creates a new one
5787 def NumberOfLayers(self, n, UseExisting=0):
5788 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5789 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
5790 CompareMethod=self.CompareNumberOfLayers)
5791 self.nbLayers.SetNumberOfLayers( n )
5792 return self.nbLayers
5794 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5795 def CompareNumberOfLayers(self, hyp, args):
5796 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5798 ## Defines "LocalLength" hypothesis, specifying the segment length
5799 # to build between the inner and the outer shells
5800 # @param l the length of segments
5801 # @param p the precision of rounding
5802 def LocalLength(self, l, p=1e-07):
5803 hyp = self.OwnHypothesis("LocalLength", [l,p])
5808 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
5809 # prisms to build between the inner and the outer shells.
5810 # @param n the number of layers
5811 # @param s the scale factor (optional)
5812 def NumberOfSegments(self, n, s=[]):
5814 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5816 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5817 hyp.SetDistrType( 1 )
5818 hyp.SetScaleFactor(s)
5819 hyp.SetNumberOfSegments(n)
5822 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5823 # to build between the inner and the outer shells with a length that changes in arithmetic progression
5824 # @param start the length of the first segment
5825 # @param end the length of the last segment
5826 def Arithmetic1D(self, start, end ):
5827 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5828 hyp.SetLength(start, 1)
5829 hyp.SetLength(end , 0)
5832 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5833 # to build between the inner and the outer shells as geometric length increasing
5834 # @param start for the length of the first segment
5835 # @param end for the length of the last segment
5836 def StartEndLength(self, start, end):
5837 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5838 hyp.SetLength(start, 1)
5839 hyp.SetLength(end , 0)
5842 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5843 # to build between the inner and outer shells
5844 # @param fineness defines the quality of the mesh within the range [0-1]
5845 def AutomaticLength(self, fineness=0):
5846 hyp = self.OwnHypothesis("AutomaticLength")
5847 hyp.SetFineness( fineness )
5850 # Public class: Mesh_RadialQuadrangle1D2D
5851 # -------------------------------
5853 ## Defines a Radial Quadrangle 1D2D algorithm
5854 # @ingroup l2_algos_radialq
5856 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
5858 ## Private constructor.
5859 def __init__(self, mesh, geom=0):
5860 Mesh_Algorithm.__init__(self)
5861 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5863 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
5864 self.nbLayers = None
5866 ## Return 2D hypothesis holding the 1D one
5867 def Get2DHypothesis(self):
5868 return self.distribHyp
5870 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5871 # hypothesis. Returns the created hypothesis
5872 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5873 #print "OwnHypothesis",hypType
5875 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5876 if self.distribHyp is None:
5877 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5879 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5880 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5881 self.mesh.smeshpyD.SetCurrentStudy( None )
5882 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5883 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5884 self.distribHyp.SetLayerDistribution( hyp )
5887 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
5888 # @param n number of layers
5889 # @param UseExisting if ==true - searches for the existing hypothesis created with
5890 # the same parameters, else (default) - creates a new one
5891 def NumberOfLayers(self, n, UseExisting=0):
5893 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5894 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5895 CompareMethod=self.CompareNumberOfLayers)
5896 self.nbLayers.SetNumberOfLayers( n )
5897 return self.nbLayers
5899 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5900 def CompareNumberOfLayers(self, hyp, args):
5901 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5903 ## Defines "LocalLength" hypothesis, specifying the segment length
5904 # @param l the length of segments
5905 # @param p the precision of rounding
5906 def LocalLength(self, l, p=1e-07):
5907 hyp = self.OwnHypothesis("LocalLength", [l,p])
5912 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5913 # @param n the number of layers
5914 # @param s the scale factor (optional)
5915 def NumberOfSegments(self, n, s=[]):
5917 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5919 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5920 hyp.SetDistrType( 1 )
5921 hyp.SetScaleFactor(s)
5922 hyp.SetNumberOfSegments(n)
5925 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5926 # with a length that changes in arithmetic progression
5927 # @param start the length of the first segment
5928 # @param end the length of the last segment
5929 def Arithmetic1D(self, start, end ):
5930 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5931 hyp.SetLength(start, 1)
5932 hyp.SetLength(end , 0)
5935 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5936 # as geometric length increasing
5937 # @param start for the length of the first segment
5938 # @param end for the length of the last segment
5939 def StartEndLength(self, start, end):
5940 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5941 hyp.SetLength(start, 1)
5942 hyp.SetLength(end , 0)
5945 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5946 # @param fineness defines the quality of the mesh within the range [0-1]
5947 def AutomaticLength(self, fineness=0):
5948 hyp = self.OwnHypothesis("AutomaticLength")
5949 hyp.SetFineness( fineness )
5953 # Public class: Mesh_UseExistingElements
5954 # --------------------------------------
5955 ## Defines a Radial Quadrangle 1D2D algorithm
5956 # @ingroup l3_algos_basic
5958 class Mesh_UseExistingElements(Mesh_Algorithm):
5960 def __init__(self, dim, mesh, geom=0):
5962 self.Create(mesh, geom, "Import_1D")
5964 self.Create(mesh, geom, "Import_1D2D")
5967 ## Defines "Source edges" hypothesis, specifying groups of edges to import
5968 # @param groups list of groups of edges
5969 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
5970 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
5971 # @param UseExisting if ==true - searches for the existing hypothesis created with
5972 # the same parameters, else (default) - creates a new one
5973 def SourceEdges(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
5974 if self.algo.GetName() == "Import_2D":
5975 raise ValueError, "algoritm dimension mismatch"
5976 hyp = self.Hypothesis("ImportSource1D", [groups, toCopyMesh, toCopyGroups],
5977 UseExisting=UseExisting, CompareMethod=self._compareHyp)
5978 hyp.SetSourceEdges(groups)
5979 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
5982 ## Defines "Source faces" hypothesis, specifying groups of faces to import
5983 # @param groups list of groups of faces
5984 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
5985 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
5986 # @param UseExisting if ==true - searches for the existing hypothesis created with
5987 # the same parameters, else (default) - creates a new one
5988 def SourceFaces(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
5989 if self.algo.GetName() == "Import_1D":
5990 raise ValueError, "algoritm dimension mismatch"
5991 hyp = self.Hypothesis("ImportSource2D", [groups, toCopyMesh, toCopyGroups],
5992 UseExisting=UseExisting, CompareMethod=self._compareHyp)
5993 hyp.SetSourceFaces(groups)
5994 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
5997 def _compareHyp(self,hyp,args):
5998 if hasattr( hyp, "GetSourceEdges"):
5999 entries = hyp.GetSourceEdges()
6001 entries = hyp.GetSourceFaces()
6003 toCopyMesh,toCopyGroups = hyp.GetCopySourceMesh()
6004 if len(entries)==len(groups) and toCopyMesh==args[1] and toCopyGroups==args[2]:
6006 study = self.mesh.smeshpyD.GetCurrentStudy()
6009 ior = salome.orb.object_to_string(g)
6010 sobj = study.FindObjectIOR(ior)
6011 if sobj: entries2.append( sobj.GetID() )
6016 return entries == entries2
6020 # Private class: Mesh_UseExisting
6021 # -------------------------------
6022 class Mesh_UseExisting(Mesh_Algorithm):
6024 def __init__(self, dim, mesh, geom=0):
6026 self.Create(mesh, geom, "UseExisting_1D")
6028 self.Create(mesh, geom, "UseExisting_2D")
6031 import salome_notebook
6032 notebook = salome_notebook.notebook
6034 ##Return values of the notebook variables
6035 def ParseParameters(last, nbParams,nbParam, value):
6039 listSize = len(last)
6040 for n in range(0,nbParams):
6042 if counter < listSize:
6043 strResult = strResult + last[counter]
6045 strResult = strResult + ""
6047 if isinstance(value, str):
6048 if notebook.isVariable(value):
6049 result = notebook.get(value)
6050 strResult=strResult+value
6052 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
6054 strResult=strResult+str(value)
6056 if nbParams - 1 != counter:
6057 strResult=strResult+var_separator #":"
6059 return result, strResult
6061 #Wrapper class for StdMeshers_LocalLength hypothesis
6062 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
6064 ## Set Length parameter value
6065 # @param length numerical value or name of variable from notebook
6066 def SetLength(self, length):
6067 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
6068 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6069 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
6071 ## Set Precision parameter value
6072 # @param precision numerical value or name of variable from notebook
6073 def SetPrecision(self, precision):
6074 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
6075 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6076 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
6078 #Registering the new proxy for LocalLength
6079 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
6082 #Wrapper class for StdMeshers_LayerDistribution hypothesis
6083 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
6085 def SetLayerDistribution(self, hypo):
6086 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
6087 hypo.ClearParameters();
6088 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
6090 #Registering the new proxy for LayerDistribution
6091 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
6093 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
6094 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
6096 ## Set Length parameter value
6097 # @param length numerical value or name of variable from notebook
6098 def SetLength(self, length):
6099 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
6100 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
6101 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
6103 #Registering the new proxy for SegmentLengthAroundVertex
6104 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
6107 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
6108 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
6110 ## Set Length parameter value
6111 # @param length numerical value or name of variable from notebook
6112 # @param isStart true is length is Start Length, otherwise false
6113 def SetLength(self, length, isStart):
6117 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
6118 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
6119 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
6121 #Registering the new proxy for Arithmetic1D
6122 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
6124 #Wrapper class for StdMeshers_Deflection1D hypothesis
6125 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
6127 ## Set Deflection parameter value
6128 # @param deflection numerical value or name of variable from notebook
6129 def SetDeflection(self, deflection):
6130 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
6131 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
6132 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
6134 #Registering the new proxy for Deflection1D
6135 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
6137 #Wrapper class for StdMeshers_StartEndLength hypothesis
6138 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
6140 ## Set Length parameter value
6141 # @param length numerical value or name of variable from notebook
6142 # @param isStart true is length is Start Length, otherwise false
6143 def SetLength(self, length, isStart):
6147 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
6148 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
6149 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
6151 #Registering the new proxy for StartEndLength
6152 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
6154 #Wrapper class for StdMeshers_MaxElementArea hypothesis
6155 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
6157 ## Set Max Element Area parameter value
6158 # @param area numerical value or name of variable from notebook
6159 def SetMaxElementArea(self, area):
6160 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
6161 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
6162 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
6164 #Registering the new proxy for MaxElementArea
6165 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
6168 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
6169 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
6171 ## Set Max Element Volume parameter value
6172 # @param volume numerical value or name of variable from notebook
6173 def SetMaxElementVolume(self, volume):
6174 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
6175 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
6176 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
6178 #Registering the new proxy for MaxElementVolume
6179 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
6182 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
6183 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
6185 ## Set Number Of Layers parameter value
6186 # @param nbLayers numerical value or name of variable from notebook
6187 def SetNumberOfLayers(self, nbLayers):
6188 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
6189 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
6190 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
6192 #Registering the new proxy for NumberOfLayers
6193 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
6195 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
6196 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
6198 ## Set Number Of Segments parameter value
6199 # @param nbSeg numerical value or name of variable from notebook
6200 def SetNumberOfSegments(self, nbSeg):
6201 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
6202 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
6203 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6204 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
6206 ## Set Scale Factor parameter value
6207 # @param factor numerical value or name of variable from notebook
6208 def SetScaleFactor(self, factor):
6209 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
6210 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6211 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
6213 #Registering the new proxy for NumberOfSegments
6214 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
6216 if not noNETGENPlugin:
6217 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
6218 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
6220 ## Set Max Size parameter value
6221 # @param maxsize numerical value or name of variable from notebook
6222 def SetMaxSize(self, maxsize):
6223 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6224 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
6225 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6226 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
6228 ## Set Growth Rate parameter value
6229 # @param value numerical value or name of variable from notebook
6230 def SetGrowthRate(self, value):
6231 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6232 value, parameters = ParseParameters(lastParameters,4,2,value)
6233 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6234 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
6236 ## Set Number of Segments per Edge parameter value
6237 # @param value numerical value or name of variable from notebook
6238 def SetNbSegPerEdge(self, value):
6239 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6240 value, parameters = ParseParameters(lastParameters,4,3,value)
6241 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6242 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
6244 ## Set Number of Segments per Radius parameter value
6245 # @param value numerical value or name of variable from notebook
6246 def SetNbSegPerRadius(self, value):
6247 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6248 value, parameters = ParseParameters(lastParameters,4,4,value)
6249 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6250 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
6252 #Registering the new proxy for NETGENPlugin_Hypothesis
6253 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
6256 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
6257 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
6260 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
6261 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
6263 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
6264 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
6266 ## Set Number of Segments parameter value
6267 # @param nbSeg numerical value or name of variable from notebook
6268 def SetNumberOfSegments(self, nbSeg):
6269 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6270 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
6271 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6272 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
6274 ## Set Local Length parameter value
6275 # @param length numerical value or name of variable from notebook
6276 def SetLocalLength(self, length):
6277 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6278 length, parameters = ParseParameters(lastParameters,2,1,length)
6279 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6280 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
6282 ## Set Max Element Area parameter value
6283 # @param area numerical value or name of variable from notebook
6284 def SetMaxElementArea(self, area):
6285 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6286 area, parameters = ParseParameters(lastParameters,2,2,area)
6287 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6288 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
6290 def LengthFromEdges(self):
6291 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6293 value, parameters = ParseParameters(lastParameters,2,2,value)
6294 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6295 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
6297 #Registering the new proxy for NETGEN_SimpleParameters_2D
6298 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
6301 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
6302 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
6303 ## Set Max Element Volume parameter value
6304 # @param volume numerical value or name of variable from notebook
6305 def SetMaxElementVolume(self, volume):
6306 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6307 volume, parameters = ParseParameters(lastParameters,3,3,volume)
6308 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6309 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
6311 def LengthFromFaces(self):
6312 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6314 value, parameters = ParseParameters(lastParameters,3,3,value)
6315 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6316 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
6318 #Registering the new proxy for NETGEN_SimpleParameters_3D
6319 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
6321 pass # if not noNETGENPlugin:
6323 class Pattern(SMESH._objref_SMESH_Pattern):
6325 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
6327 if isinstance(theNodeIndexOnKeyPoint1,str):
6329 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
6331 theNodeIndexOnKeyPoint1 -= 1
6332 theMesh.SetParameters(Parameters)
6333 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
6335 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
6338 if isinstance(theNode000Index,str):
6340 if isinstance(theNode001Index,str):
6342 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
6344 theNode000Index -= 1
6346 theNode001Index -= 1
6347 theMesh.SetParameters(Parameters)
6348 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
6350 #Registering the new proxy for Pattern
6351 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)