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 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
749 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
750 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
751 # @param Treshold the threshold value (range of ids as string, shape, numeric)
752 # @param UnaryOp FT_LogicalNOT or FT_Undefined
753 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
754 # FT_Undefined (must be for the last criterion of all criteria)
755 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
756 # FT_LyingOnGeom, FT_CoplanarFaces criteria
757 # @return SMESH.Filter.Criterion
758 # @ingroup l1_controls
759 def GetCriterion(self,elementType,
761 Compare = FT_EqualTo,
763 UnaryOp=FT_Undefined,
764 BinaryOp=FT_Undefined,
766 aCriterion = self.GetEmptyCriterion()
767 aCriterion.TypeOfElement = elementType
768 aCriterion.Type = self.EnumToLong(CritType)
769 aCriterion.Tolerance = Tolerance
773 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
774 aCriterion.Compare = self.EnumToLong(Compare)
775 elif Compare == "=" or Compare == "==":
776 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
778 aCriterion.Compare = self.EnumToLong(FT_LessThan)
780 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
782 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
785 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
786 FT_BelongToCylinder, FT_LyingOnGeom]:
787 # Checks the treshold
788 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
789 aCriterion.ThresholdStr = GetName(aTreshold)
790 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
792 print "Error: The treshold should be a shape."
794 if isinstance(UnaryOp,float):
795 aCriterion.Tolerance = UnaryOp
796 UnaryOp = FT_Undefined
798 elif CritType == FT_RangeOfIds:
799 # Checks the treshold
800 if isinstance(aTreshold, str):
801 aCriterion.ThresholdStr = aTreshold
803 print "Error: The treshold should be a string."
805 elif CritType == FT_CoplanarFaces:
806 # Checks the treshold
807 if isinstance(aTreshold, int):
808 aCriterion.ThresholdID = "%s"%aTreshold
809 elif isinstance(aTreshold, str):
812 raise ValueError, "Invalid ID of mesh face: '%s'"%aTreshold
813 aCriterion.ThresholdID = aTreshold
816 "The treshold should be an ID of mesh face and not '%s'"%aTreshold
817 elif CritType == FT_ElemGeomType:
818 # Checks the treshold
820 aCriterion.Threshold = self.EnumToLong(aTreshold)
822 if isinstance(aTreshold, int):
823 aCriterion.Threshold = aTreshold
825 print "Error: The treshold should be an integer or SMESH.GeometryType."
829 elif CritType == FT_GroupColor:
830 # Checks the treshold
832 aCriterion.ThresholdStr = self.ColorToString(aTreshold)
834 print "Error: The threshold value should be of SALOMEDS.Color type"
837 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
838 FT_FreeFaces, FT_LinearOrQuadratic,
839 FT_BareBorderFace, FT_BareBorderVolume,
840 FT_OverConstrainedFace, FT_OverConstrainedVolume]:
841 # At this point the treshold is unnecessary
842 if aTreshold == FT_LogicalNOT:
843 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
844 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
845 aCriterion.BinaryOp = aTreshold
849 aTreshold = float(aTreshold)
850 aCriterion.Threshold = aTreshold
852 print "Error: The treshold should be a number."
855 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
856 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
858 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
859 aCriterion.BinaryOp = self.EnumToLong(Treshold)
861 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
862 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
864 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
865 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
869 ## Creates a filter with the given parameters
870 # @param elementType the type of elements in the group
871 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
872 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
873 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
874 # @param UnaryOp FT_LogicalNOT or FT_Undefined
875 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
876 # FT_LyingOnGeom, FT_CoplanarFaces criteria
877 # @return SMESH_Filter
878 # @ingroup l1_controls
879 def GetFilter(self,elementType,
880 CritType=FT_Undefined,
883 UnaryOp=FT_Undefined,
885 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined,Tolerance)
886 aFilterMgr = self.CreateFilterManager()
887 aFilter = aFilterMgr.CreateFilter()
889 aCriteria.append(aCriterion)
890 aFilter.SetCriteria(aCriteria)
891 aFilterMgr.UnRegister()
894 ## Creates a numerical functor by its type
895 # @param theCriterion FT_...; functor type
896 # @return SMESH_NumericalFunctor
897 # @ingroup l1_controls
898 def GetFunctor(self,theCriterion):
899 aFilterMgr = self.CreateFilterManager()
900 if theCriterion == FT_AspectRatio:
901 return aFilterMgr.CreateAspectRatio()
902 elif theCriterion == FT_AspectRatio3D:
903 return aFilterMgr.CreateAspectRatio3D()
904 elif theCriterion == FT_Warping:
905 return aFilterMgr.CreateWarping()
906 elif theCriterion == FT_MinimumAngle:
907 return aFilterMgr.CreateMinimumAngle()
908 elif theCriterion == FT_Taper:
909 return aFilterMgr.CreateTaper()
910 elif theCriterion == FT_Skew:
911 return aFilterMgr.CreateSkew()
912 elif theCriterion == FT_Area:
913 return aFilterMgr.CreateArea()
914 elif theCriterion == FT_Volume3D:
915 return aFilterMgr.CreateVolume3D()
916 elif theCriterion == FT_MaxElementLength2D:
917 return aFilterMgr.CreateMaxElementLength2D()
918 elif theCriterion == FT_MaxElementLength3D:
919 return aFilterMgr.CreateMaxElementLength3D()
920 elif theCriterion == FT_MultiConnection:
921 return aFilterMgr.CreateMultiConnection()
922 elif theCriterion == FT_MultiConnection2D:
923 return aFilterMgr.CreateMultiConnection2D()
924 elif theCriterion == FT_Length:
925 return aFilterMgr.CreateLength()
926 elif theCriterion == FT_Length2D:
927 return aFilterMgr.CreateLength2D()
929 print "Error: given parameter is not numerucal functor type."
931 ## Creates hypothesis
932 # @param theHType mesh hypothesis type (string)
933 # @param theLibName mesh plug-in library name
934 # @return created hypothesis instance
935 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
936 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
938 ## Gets the mesh stattistic
939 # @return dictionary type element - count of elements
940 # @ingroup l1_meshinfo
941 def GetMeshInfo(self, obj):
942 if isinstance( obj, Mesh ):
945 if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource):
946 values = obj.GetMeshInfo()
947 for i in range(SMESH.Entity_Last._v):
948 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
952 ## Get minimum distance between two objects
954 # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
955 # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
957 # @param src1 first source object
958 # @param src2 second source object
959 # @param id1 node/element id from the first source
960 # @param id2 node/element id from the second (or first) source
961 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
962 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
963 # @return minimum distance value
964 # @sa GetMinDistance()
965 # @ingroup l1_measurements
966 def MinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
967 result = self.GetMinDistance(src1, src2, id1, id2, isElem1, isElem2)
971 result = result.value
974 ## Get measure structure specifying minimum distance data between two objects
976 # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
977 # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
979 # @param src1 first source object
980 # @param src2 second source object
981 # @param id1 node/element id from the first source
982 # @param id2 node/element id from the second (or first) source
983 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
984 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
985 # @return Measure structure or None if input data is invalid
987 # @ingroup l1_measurements
988 def GetMinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
989 if isinstance(src1, Mesh): src1 = src1.mesh
990 if isinstance(src2, Mesh): src2 = src2.mesh
991 if src2 is None and id2 != 0: src2 = src1
992 if not hasattr(src1, "_narrow"): return None
993 src1 = src1._narrow(SMESH.SMESH_IDSource)
994 if not src1: return None
997 e = m.GetMeshEditor()
999 src1 = e.MakeIDSource([id1], SMESH.FACE)
1001 src1 = e.MakeIDSource([id1], SMESH.NODE)
1003 if hasattr(src2, "_narrow"):
1004 src2 = src2._narrow(SMESH.SMESH_IDSource)
1005 if src2 and id2 != 0:
1007 e = m.GetMeshEditor()
1009 src2 = e.MakeIDSource([id2], SMESH.FACE)
1011 src2 = e.MakeIDSource([id2], SMESH.NODE)
1014 aMeasurements = self.CreateMeasurements()
1015 result = aMeasurements.MinDistance(src1, src2)
1016 aMeasurements.UnRegister()
1019 ## Get bounding box of the specified object(s)
1020 # @param objects single source object or list of source objects
1021 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
1022 # @sa GetBoundingBox()
1023 # @ingroup l1_measurements
1024 def BoundingBox(self, objects):
1025 result = self.GetBoundingBox(objects)
1029 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
1032 ## Get measure structure specifying bounding box data of the specified object(s)
1033 # @param objects single source object or list of source objects
1034 # @return Measure structure
1036 # @ingroup l1_measurements
1037 def GetBoundingBox(self, objects):
1038 if isinstance(objects, tuple):
1039 objects = list(objects)
1040 if not isinstance(objects, list):
1044 if isinstance(o, Mesh):
1045 srclist.append(o.mesh)
1046 elif hasattr(o, "_narrow"):
1047 src = o._narrow(SMESH.SMESH_IDSource)
1048 if src: srclist.append(src)
1051 aMeasurements = self.CreateMeasurements()
1052 result = aMeasurements.BoundingBox(srclist)
1053 aMeasurements.UnRegister()
1057 #Registering the new proxy for SMESH_Gen
1058 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
1061 # Public class: Mesh
1062 # ==================
1064 ## This class allows defining and managing a mesh.
1065 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
1066 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
1067 # new nodes and elements and by changing the existing entities), to get information
1068 # about a mesh and to export a mesh into different formats.
1077 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
1078 # sets the GUI name of this mesh to \a name.
1079 # @param smeshpyD an instance of smeshDC class
1080 # @param geompyD an instance of geompyDC class
1081 # @param obj Shape to be meshed or SMESH_Mesh object
1082 # @param name Study name of the mesh
1083 # @ingroup l2_construct
1084 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
1085 self.smeshpyD=smeshpyD
1086 self.geompyD=geompyD
1090 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
1092 # publish geom of mesh (issue 0021122)
1093 if not self.geom.GetStudyEntry():
1094 studyID = smeshpyD.GetCurrentStudy()._get_StudyId()
1095 if studyID != geompyD.myStudyId:
1096 geompyD.init_geom( smeshpyD.GetCurrentStudy())
1098 geo_name = "%s_%s"%(self.geom.GetShapeType(), id(self.geom)%100)
1099 geompyD.addToStudy( self.geom, geo_name )
1100 self.mesh = self.smeshpyD.CreateMesh(self.geom)
1102 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
1105 self.mesh = self.smeshpyD.CreateEmptyMesh()
1107 self.smeshpyD.SetName(self.mesh, name)
1109 self.smeshpyD.SetName(self.mesh, GetName(obj))
1112 self.geom = self.mesh.GetShapeToMesh()
1114 self.editor = self.mesh.GetMeshEditor()
1116 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
1117 # @param theMesh a SMESH_Mesh object
1118 # @ingroup l2_construct
1119 def SetMesh(self, theMesh):
1121 self.geom = self.mesh.GetShapeToMesh()
1123 ## Returns the mesh, that is an instance of SMESH_Mesh interface
1124 # @return a SMESH_Mesh object
1125 # @ingroup l2_construct
1129 ## Gets the name of the mesh
1130 # @return the name of the mesh as a string
1131 # @ingroup l2_construct
1133 name = GetName(self.GetMesh())
1136 ## Sets a name to the mesh
1137 # @param name a new name of the mesh
1138 # @ingroup l2_construct
1139 def SetName(self, name):
1140 self.smeshpyD.SetName(self.GetMesh(), name)
1142 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
1143 # The subMesh object gives access to the IDs of nodes and elements.
1144 # @param theSubObject a geometrical object (shape)
1145 # @param theName a name for the submesh
1146 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
1147 # @ingroup l2_submeshes
1148 def GetSubMesh(self, theSubObject, theName):
1149 submesh = self.mesh.GetSubMesh(theSubObject, theName)
1152 ## Returns the shape associated to the mesh
1153 # @return a GEOM_Object
1154 # @ingroup l2_construct
1158 ## Associates the given shape to the mesh (entails the recreation of the mesh)
1159 # @param geom the shape to be meshed (GEOM_Object)
1160 # @ingroup l2_construct
1161 def SetShape(self, geom):
1162 self.mesh = self.smeshpyD.CreateMesh(geom)
1164 ## Returns true if the hypotheses are defined well
1165 # @param theSubObject a subshape of a mesh shape
1166 # @return True or False
1167 # @ingroup l2_construct
1168 def IsReadyToCompute(self, theSubObject):
1169 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
1171 ## Returns errors of hypotheses definition.
1172 # The list of errors is empty if everything is OK.
1173 # @param theSubObject a subshape of a mesh shape
1174 # @return a list of errors
1175 # @ingroup l2_construct
1176 def GetAlgoState(self, theSubObject):
1177 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
1179 ## Returns a geometrical object on which the given element was built.
1180 # The returned geometrical object, if not nil, is either found in the
1181 # study or published by this method with the given name
1182 # @param theElementID the id of the mesh element
1183 # @param theGeomName the user-defined name of the geometrical object
1184 # @return GEOM::GEOM_Object instance
1185 # @ingroup l2_construct
1186 def GetGeometryByMeshElement(self, theElementID, theGeomName):
1187 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
1189 ## Returns the mesh dimension depending on the dimension of the underlying shape
1190 # @return mesh dimension as an integer value [0,3]
1191 # @ingroup l1_auxiliary
1192 def MeshDimension(self):
1193 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
1194 if len( shells ) > 0 :
1196 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
1198 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
1204 ## Creates a segment discretization 1D algorithm.
1205 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
1206 # \n If the optional \a geom parameter is not set, this algorithm is global.
1207 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1208 # @param algo the type of the required algorithm. Possible values are:
1210 # - smesh.PYTHON for discretization via a python function,
1211 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
1212 # @param geom If defined is the subshape to be meshed
1213 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
1214 # @ingroup l3_algos_basic
1215 def Segment(self, algo=REGULAR, geom=0):
1216 ## if Segment(geom) is called by mistake
1217 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
1218 algo, geom = geom, algo
1219 if not algo: algo = REGULAR
1222 return Mesh_Segment(self, geom)
1223 elif algo == PYTHON:
1224 return Mesh_Segment_Python(self, geom)
1225 elif algo == COMPOSITE:
1226 return Mesh_CompositeSegment(self, geom)
1228 return Mesh_Segment(self, geom)
1230 ## Creates 1D algorithm importing segments conatined in groups of other mesh.
1231 # If the optional \a geom parameter is not set, this algorithm is global.
1232 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1233 # @param geom If defined the subshape is to be meshed
1234 # @return an instance of Mesh_UseExistingElements class
1235 # @ingroup l3_algos_basic
1236 def UseExisting1DElements(self, geom=0):
1237 return Mesh_UseExistingElements(1,self, geom)
1239 ## Creates 2D algorithm importing faces conatined in groups of other mesh.
1240 # If the optional \a geom parameter is not set, this algorithm is global.
1241 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1242 # @param geom If defined the subshape is to be meshed
1243 # @return an instance of Mesh_UseExistingElements class
1244 # @ingroup l3_algos_basic
1245 def UseExisting2DElements(self, geom=0):
1246 return Mesh_UseExistingElements(2,self, geom)
1248 ## Enables creation of nodes and segments usable by 2D algoritms.
1249 # The added nodes and segments must be bound to edges and vertices by
1250 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
1251 # If the optional \a geom parameter is not set, this algorithm is global.
1252 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1253 # @param geom the subshape to be manually meshed
1254 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
1255 # @ingroup l3_algos_basic
1256 def UseExistingSegments(self, geom=0):
1257 algo = Mesh_UseExisting(1,self,geom)
1258 return algo.GetAlgorithm()
1260 ## Enables creation of nodes and faces usable by 3D algoritms.
1261 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
1262 # and SetMeshElementOnShape()
1263 # If the optional \a geom parameter is not set, this algorithm is global.
1264 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1265 # @param geom the subshape to be manually meshed
1266 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1267 # @ingroup l3_algos_basic
1268 def UseExistingFaces(self, geom=0):
1269 algo = Mesh_UseExisting(2,self,geom)
1270 return algo.GetAlgorithm()
1272 ## Creates a triangle 2D algorithm for faces.
1273 # If the optional \a geom parameter is not set, this algorithm is global.
1274 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1275 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1276 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1277 # @return an instance of Mesh_Triangle algorithm
1278 # @ingroup l3_algos_basic
1279 def Triangle(self, algo=MEFISTO, geom=0):
1280 ## if Triangle(geom) is called by mistake
1281 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1284 return Mesh_Triangle(self, algo, geom)
1286 ## Creates a quadrangle 2D algorithm for faces.
1287 # If the optional \a geom parameter is not set, this algorithm is global.
1288 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1289 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1290 # @param algo values are: smesh.QUADRANGLE || smesh.RADIAL_QUAD
1291 # @return an instance of Mesh_Quadrangle algorithm
1292 # @ingroup l3_algos_basic
1293 def Quadrangle(self, geom=0, algo=QUADRANGLE):
1294 if algo==RADIAL_QUAD:
1295 return Mesh_RadialQuadrangle1D2D(self,geom)
1297 return Mesh_Quadrangle(self, geom)
1299 ## Creates a tetrahedron 3D algorithm for solids.
1300 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1301 # If the optional \a geom parameter is not set, this algorithm is global.
1302 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1303 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1304 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1305 # @return an instance of Mesh_Tetrahedron algorithm
1306 # @ingroup l3_algos_basic
1307 def Tetrahedron(self, algo=NETGEN, geom=0):
1308 ## if Tetrahedron(geom) is called by mistake
1309 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1310 algo, geom = geom, algo
1311 if not algo: algo = NETGEN
1313 return Mesh_Tetrahedron(self, algo, geom)
1315 ## Creates a hexahedron 3D algorithm for solids.
1316 # If the optional \a geom parameter is not set, this algorithm is global.
1317 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1318 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1319 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1320 # @return an instance of Mesh_Hexahedron algorithm
1321 # @ingroup l3_algos_basic
1322 def Hexahedron(self, algo=Hexa, geom=0):
1323 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1324 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1325 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1326 elif geom == 0: algo, geom = Hexa, algo
1327 return Mesh_Hexahedron(self, algo, geom)
1329 ## Deprecated, used only for compatibility!
1330 # @return an instance of Mesh_Netgen algorithm
1331 # @ingroup l3_algos_basic
1332 def Netgen(self, is3D, geom=0):
1333 return Mesh_Netgen(self, is3D, geom)
1335 ## Creates a projection 1D algorithm for edges.
1336 # If the optional \a geom parameter is not set, this algorithm is global.
1337 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1338 # @param geom If defined, the subshape to be meshed
1339 # @return an instance of Mesh_Projection1D algorithm
1340 # @ingroup l3_algos_proj
1341 def Projection1D(self, geom=0):
1342 return Mesh_Projection1D(self, geom)
1344 ## Creates a projection 2D algorithm for faces.
1345 # If the optional \a geom parameter is not set, this algorithm is global.
1346 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1347 # @param geom If defined, the subshape to be meshed
1348 # @return an instance of Mesh_Projection2D algorithm
1349 # @ingroup l3_algos_proj
1350 def Projection2D(self, geom=0):
1351 return Mesh_Projection2D(self, geom)
1353 ## Creates a projection 3D algorithm for solids.
1354 # If the optional \a geom parameter is not set, this algorithm is global.
1355 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1356 # @param geom If defined, the subshape to be meshed
1357 # @return an instance of Mesh_Projection3D algorithm
1358 # @ingroup l3_algos_proj
1359 def Projection3D(self, geom=0):
1360 return Mesh_Projection3D(self, geom)
1362 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1363 # If the optional \a geom parameter is not set, this algorithm is global.
1364 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1365 # @param geom If defined, the subshape to be meshed
1366 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1367 # @ingroup l3_algos_radialp l3_algos_3dextr
1368 def Prism(self, geom=0):
1372 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1373 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1374 if nbSolids == 0 or nbSolids == nbShells:
1375 return Mesh_Prism3D(self, geom)
1376 return Mesh_RadialPrism3D(self, geom)
1378 ## Evaluates size of prospective mesh on a shape
1379 # @return a list where i-th element is a number of elements of i-th SMESH.EntityType
1380 # To know predicted number of e.g. edges, inquire it this way
1381 # Evaluate()[ EnumToLong( Entity_Edge )]
1382 def Evaluate(self, geom=0):
1383 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1385 geom = self.mesh.GetShapeToMesh()
1388 return self.smeshpyD.Evaluate(self.mesh, geom)
1391 ## Computes the mesh and returns the status of the computation
1392 # @param geom geomtrical shape on which mesh data should be computed
1393 # @param discardModifs if True and the mesh has been edited since
1394 # a last total re-compute and that may prevent successful partial re-compute,
1395 # then the mesh is cleaned before Compute()
1396 # @return True or False
1397 # @ingroup l2_construct
1398 def Compute(self, geom=0, discardModifs=False):
1399 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1401 geom = self.mesh.GetShapeToMesh()
1406 if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693
1408 ok = self.smeshpyD.Compute(self.mesh, geom)
1409 except SALOME.SALOME_Exception, ex:
1410 print "Mesh computation failed, exception caught:"
1411 print " ", ex.details.text
1414 print "Mesh computation failed, exception caught:"
1415 traceback.print_exc()
1419 # Treat compute errors
1420 computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
1421 for err in computeErrors:
1423 if self.mesh.HasShapeToMesh():
1425 mainIOR = salome.orb.object_to_string(geom)
1426 for sname in salome.myStudyManager.GetOpenStudies():
1427 s = salome.myStudyManager.GetStudyByName(sname)
1429 mainSO = s.FindObjectIOR(mainIOR)
1430 if not mainSO: continue
1431 if err.subShapeID == 1:
1432 shapeText = ' on "%s"' % mainSO.GetName()
1433 subIt = s.NewChildIterator(mainSO)
1435 subSO = subIt.Value()
1437 obj = subSO.GetObject()
1438 if not obj: continue
1439 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
1441 ids = go.GetSubShapeIndices()
1442 if len(ids) == 1 and ids[0] == err.subShapeID:
1443 shapeText = ' on "%s"' % subSO.GetName()
1446 shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
1448 shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID)
1450 shapeText = " on subshape #%s" % (err.subShapeID)
1452 shapeText = " on subshape #%s" % (err.subShapeID)
1454 stdErrors = ["OK", #COMPERR_OK
1455 "Invalid input mesh", #COMPERR_BAD_INPUT_MESH
1456 "std::exception", #COMPERR_STD_EXCEPTION
1457 "OCC exception", #COMPERR_OCC_EXCEPTION
1458 "SALOME exception", #COMPERR_SLM_EXCEPTION
1459 "Unknown exception", #COMPERR_EXCEPTION
1460 "Memory allocation problem", #COMPERR_MEMORY_PB
1461 "Algorithm failed", #COMPERR_ALGO_FAILED
1462 "Unexpected geometry"]#COMPERR_BAD_SHAPE
1464 if err.code < len(stdErrors): errText = stdErrors[err.code]
1466 errText = "code %s" % -err.code
1467 if errText: errText += ". "
1468 errText += err.comment
1469 if allReasons != "":allReasons += "\n"
1470 allReasons += '"%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
1474 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1476 if err.isGlobalAlgo:
1484 reason = '%s %sD algorithm is missing' % (glob, dim)
1485 elif err.state == HYP_MISSING:
1486 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1487 % (glob, dim, name, dim))
1488 elif err.state == HYP_NOTCONFORM:
1489 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1490 elif err.state == HYP_BAD_PARAMETER:
1491 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1492 % ( glob, dim, name ))
1493 elif err.state == HYP_BAD_GEOMETRY:
1494 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1495 'geometry' % ( glob, dim, name ))
1497 reason = "For unknown reason."+\
1498 " Revise Mesh.Compute() implementation in smeshDC.py!"
1500 if allReasons != "":allReasons += "\n"
1501 allReasons += reason
1503 if allReasons != "":
1504 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1508 print '"' + GetName(self.mesh) + '"',"has not been computed."
1511 if salome.sg.hasDesktop():
1512 smeshgui = salome.ImportComponentGUI("SMESH")
1513 smeshgui.Init(self.mesh.GetStudyId())
1514 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1515 salome.sg.updateObjBrowser(1)
1519 ## Return submesh objects list in meshing order
1520 # @return list of list of submesh objects
1521 # @ingroup l2_construct
1522 def GetMeshOrder(self):
1523 return self.mesh.GetMeshOrder()
1525 ## Return submesh objects list in meshing order
1526 # @return list of list of submesh objects
1527 # @ingroup l2_construct
1528 def SetMeshOrder(self, submeshes):
1529 return self.mesh.SetMeshOrder(submeshes)
1531 ## Removes all nodes and elements
1532 # @ingroup l2_construct
1535 if salome.sg.hasDesktop():
1536 smeshgui = salome.ImportComponentGUI("SMESH")
1537 smeshgui.Init(self.mesh.GetStudyId())
1538 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1539 salome.sg.updateObjBrowser(1)
1541 ## Removes all nodes and elements of indicated shape
1542 # @ingroup l2_construct
1543 def ClearSubMesh(self, geomId):
1544 self.mesh.ClearSubMesh(geomId)
1545 if salome.sg.hasDesktop():
1546 smeshgui = salome.ImportComponentGUI("SMESH")
1547 smeshgui.Init(self.mesh.GetStudyId())
1548 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1549 salome.sg.updateObjBrowser(1)
1551 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1552 # @param fineness [0,-1] defines mesh fineness
1553 # @return True or False
1554 # @ingroup l3_algos_basic
1555 def AutomaticTetrahedralization(self, fineness=0):
1556 dim = self.MeshDimension()
1558 self.RemoveGlobalHypotheses()
1559 self.Segment().AutomaticLength(fineness)
1561 self.Triangle().LengthFromEdges()
1564 self.Tetrahedron(NETGEN)
1566 return self.Compute()
1568 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1569 # @param fineness [0,-1] defines mesh fineness
1570 # @return True or False
1571 # @ingroup l3_algos_basic
1572 def AutomaticHexahedralization(self, fineness=0):
1573 dim = self.MeshDimension()
1574 # assign the hypotheses
1575 self.RemoveGlobalHypotheses()
1576 self.Segment().AutomaticLength(fineness)
1583 return self.Compute()
1585 ## Assigns a hypothesis
1586 # @param hyp a hypothesis to assign
1587 # @param geom a subhape of mesh geometry
1588 # @return SMESH.Hypothesis_Status
1589 # @ingroup l2_hypotheses
1590 def AddHypothesis(self, hyp, geom=0):
1591 if isinstance( hyp, Mesh_Algorithm ):
1592 hyp = hyp.GetAlgorithm()
1597 geom = self.mesh.GetShapeToMesh()
1599 status = self.mesh.AddHypothesis(geom, hyp)
1600 isAlgo = hyp._narrow( SMESH_Algo )
1601 hyp_name = GetName( hyp )
1604 geom_name = GetName( geom )
1605 TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1608 ## Unassigns a hypothesis
1609 # @param hyp a hypothesis to unassign
1610 # @param geom a subshape of mesh geometry
1611 # @return SMESH.Hypothesis_Status
1612 # @ingroup l2_hypotheses
1613 def RemoveHypothesis(self, hyp, geom=0):
1614 if isinstance( hyp, Mesh_Algorithm ):
1615 hyp = hyp.GetAlgorithm()
1620 status = self.mesh.RemoveHypothesis(geom, hyp)
1623 ## Gets the list of hypotheses added on a geometry
1624 # @param geom a subshape of mesh geometry
1625 # @return the sequence of SMESH_Hypothesis
1626 # @ingroup l2_hypotheses
1627 def GetHypothesisList(self, geom):
1628 return self.mesh.GetHypothesisList( geom )
1630 ## Removes all global hypotheses
1631 # @ingroup l2_hypotheses
1632 def RemoveGlobalHypotheses(self):
1633 current_hyps = self.mesh.GetHypothesisList( self.geom )
1634 for hyp in current_hyps:
1635 self.mesh.RemoveHypothesis( self.geom, hyp )
1639 ## Creates a mesh group based on the geometric object \a grp
1640 # and gives a \a name, \n if this parameter is not defined
1641 # the name is the same as the geometric group name \n
1642 # Note: Works like GroupOnGeom().
1643 # @param grp a geometric group, a vertex, an edge, a face or a solid
1644 # @param name the name of the mesh group
1645 # @return SMESH_GroupOnGeom
1646 # @ingroup l2_grps_create
1647 def Group(self, grp, name=""):
1648 return self.GroupOnGeom(grp, name)
1650 ## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead.
1651 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1652 ## allowing to overwrite the file if it exists or add the exported data to its contents
1653 # @param f the file name
1654 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1655 # @param opt boolean parameter for creating/not creating
1656 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1657 # @param overwrite boolean parameter for overwriting/not overwriting the file
1658 # @ingroup l2_impexp
1659 def ExportToMED(self, f, version, opt=0, overwrite=1):
1660 self.mesh.ExportToMEDX(f, opt, version, overwrite)
1662 ## Exports the mesh in a file in MED format and chooses the \a version of MED format
1663 ## allowing to overwrite the file if it exists or add the exported data to its contents
1664 # @param f is the file name
1665 # @param auto_groups boolean parameter for creating/not creating
1666 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1667 # the typical use is auto_groups=false.
1668 # @param version MED format version(MED_V2_1 or MED_V2_2)
1669 # @param overwrite boolean parameter for overwriting/not overwriting the file
1670 # @ingroup l2_impexp
1671 def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1):
1672 self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
1674 ## Exports the mesh in a file in DAT format
1675 # @param f the file name
1676 # @ingroup l2_impexp
1677 def ExportDAT(self, f):
1678 self.mesh.ExportDAT(f)
1680 ## Exports the mesh in a file in UNV format
1681 # @param f the file name
1682 # @ingroup l2_impexp
1683 def ExportUNV(self, f):
1684 self.mesh.ExportUNV(f)
1686 ## Export the mesh in a file in STL format
1687 # @param f the file name
1688 # @param ascii defines the file encoding
1689 # @ingroup l2_impexp
1690 def ExportSTL(self, f, ascii=1):
1691 self.mesh.ExportSTL(f, ascii)
1694 # Operations with groups:
1695 # ----------------------
1697 ## Creates an empty mesh group
1698 # @param elementType the type of elements in the group
1699 # @param name the name of the mesh group
1700 # @return SMESH_Group
1701 # @ingroup l2_grps_create
1702 def CreateEmptyGroup(self, elementType, name):
1703 return self.mesh.CreateGroup(elementType, name)
1705 ## Creates a mesh group based on the geometrical object \a grp
1706 # and gives a \a name, \n if this parameter is not defined
1707 # the name is the same as the geometrical group name
1708 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1709 # @param name the name of the mesh group
1710 # @param typ the type of elements in the group. If not set, it is
1711 # automatically detected by the type of the geometry
1712 # @return SMESH_GroupOnGeom
1713 # @ingroup l2_grps_create
1714 def GroupOnGeom(self, grp, name="", typ=None):
1716 name = grp.GetName()
1719 tgeo = str(grp.GetShapeType())
1720 if tgeo == "VERTEX":
1722 elif tgeo == "EDGE":
1724 elif tgeo == "FACE":
1726 elif tgeo == "SOLID":
1728 elif tgeo == "SHELL":
1730 elif tgeo == "COMPOUND":
1731 try: # it raises on a compound of compounds
1732 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1733 print "Mesh.Group: empty geometric group", GetName( grp )
1738 if grp.GetType() == 37: # GEOMImpl_Types.hxx: #define GEOM_GROUP 37
1740 tgeo = self.geompyD.GetType(grp)
1741 if tgeo == geompyDC.ShapeType["VERTEX"]:
1743 elif tgeo == geompyDC.ShapeType["EDGE"]:
1745 elif tgeo == geompyDC.ShapeType["FACE"]:
1747 elif tgeo == geompyDC.ShapeType["SOLID"]:
1753 for elemType, shapeType in [[VOLUME,"SOLID"],[FACE,"FACE"],
1754 [EDGE,"EDGE"],[NODE,"VERTEX"]]:
1755 if self.geompyD.SubShapeAll(grp,geompyDC.ShapeType[shapeType]):
1763 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1766 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1768 ## Creates a mesh group by the given ids of elements
1769 # @param groupName the name of the mesh group
1770 # @param elementType the type of elements in the group
1771 # @param elemIDs the list of ids
1772 # @return SMESH_Group
1773 # @ingroup l2_grps_create
1774 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1775 group = self.mesh.CreateGroup(elementType, groupName)
1779 ## Creates a mesh group by the given conditions
1780 # @param groupName the name of the mesh group
1781 # @param elementType the type of elements in the group
1782 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1783 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1784 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1785 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1786 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
1787 # FT_LyingOnGeom, FT_CoplanarFaces criteria
1788 # @return SMESH_Group
1789 # @ingroup l2_grps_create
1793 CritType=FT_Undefined,
1796 UnaryOp=FT_Undefined,
1798 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined,Tolerance)
1799 group = self.MakeGroupByCriterion(groupName, aCriterion)
1802 ## Creates a mesh group by the given criterion
1803 # @param groupName the name of the mesh group
1804 # @param Criterion the instance of Criterion class
1805 # @return SMESH_Group
1806 # @ingroup l2_grps_create
1807 def MakeGroupByCriterion(self, groupName, Criterion):
1808 aFilterMgr = self.smeshpyD.CreateFilterManager()
1809 aFilter = aFilterMgr.CreateFilter()
1811 aCriteria.append(Criterion)
1812 aFilter.SetCriteria(aCriteria)
1813 group = self.MakeGroupByFilter(groupName, aFilter)
1814 aFilterMgr.UnRegister()
1817 ## Creates a mesh group by the given criteria (list of criteria)
1818 # @param groupName the name of the mesh group
1819 # @param theCriteria the list of criteria
1820 # @return SMESH_Group
1821 # @ingroup l2_grps_create
1822 def MakeGroupByCriteria(self, groupName, theCriteria):
1823 aFilterMgr = self.smeshpyD.CreateFilterManager()
1824 aFilter = aFilterMgr.CreateFilter()
1825 aFilter.SetCriteria(theCriteria)
1826 group = self.MakeGroupByFilter(groupName, aFilter)
1827 aFilterMgr.UnRegister()
1830 ## Creates a mesh group by the given filter
1831 # @param groupName the name of the mesh group
1832 # @param theFilter the instance of Filter class
1833 # @return SMESH_Group
1834 # @ingroup l2_grps_create
1835 def MakeGroupByFilter(self, groupName, theFilter):
1836 group = self.CreateEmptyGroup(theFilter.GetElementType(), groupName)
1837 theFilter.SetMesh( self.mesh )
1838 group.AddFrom( theFilter )
1841 ## Passes mesh elements through the given filter and return IDs of fitting elements
1842 # @param theFilter SMESH_Filter
1843 # @return a list of ids
1844 # @ingroup l1_controls
1845 def GetIdsFromFilter(self, theFilter):
1846 theFilter.SetMesh( self.mesh )
1847 return theFilter.GetIDs()
1849 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1850 # Returns a list of special structures (borders).
1851 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1852 # @ingroup l1_controls
1853 def GetFreeBorders(self):
1854 aFilterMgr = self.smeshpyD.CreateFilterManager()
1855 aPredicate = aFilterMgr.CreateFreeEdges()
1856 aPredicate.SetMesh(self.mesh)
1857 aBorders = aPredicate.GetBorders()
1858 aFilterMgr.UnRegister()
1862 # @ingroup l2_grps_delete
1863 def RemoveGroup(self, group):
1864 self.mesh.RemoveGroup(group)
1866 ## Removes a group with its contents
1867 # @ingroup l2_grps_delete
1868 def RemoveGroupWithContents(self, group):
1869 self.mesh.RemoveGroupWithContents(group)
1871 ## Gets the list of groups existing in the mesh
1872 # @return a sequence of SMESH_GroupBase
1873 # @ingroup l2_grps_create
1874 def GetGroups(self):
1875 return self.mesh.GetGroups()
1877 ## Gets the number of groups existing in the mesh
1878 # @return the quantity of groups as an integer value
1879 # @ingroup l2_grps_create
1881 return self.mesh.NbGroups()
1883 ## Gets the list of names of groups existing in the mesh
1884 # @return list of strings
1885 # @ingroup l2_grps_create
1886 def GetGroupNames(self):
1887 groups = self.GetGroups()
1889 for group in groups:
1890 names.append(group.GetName())
1893 ## Produces a union of two groups
1894 # A new group is created. All mesh elements that are
1895 # present in the initial groups are added to the new one
1896 # @return an instance of SMESH_Group
1897 # @ingroup l2_grps_operon
1898 def UnionGroups(self, group1, group2, name):
1899 return self.mesh.UnionGroups(group1, group2, name)
1901 ## Produces a union list of groups
1902 # New group is created. All mesh elements that are present in
1903 # initial groups are added to the new one
1904 # @return an instance of SMESH_Group
1905 # @ingroup l2_grps_operon
1906 def UnionListOfGroups(self, groups, name):
1907 return self.mesh.UnionListOfGroups(groups, name)
1909 ## Prodices an intersection of two groups
1910 # A new group is created. All mesh elements that are common
1911 # for the two initial groups are added to the new one.
1912 # @return an instance of SMESH_Group
1913 # @ingroup l2_grps_operon
1914 def IntersectGroups(self, group1, group2, name):
1915 return self.mesh.IntersectGroups(group1, group2, name)
1917 ## Produces an intersection of groups
1918 # New group is created. All mesh elements that are present in all
1919 # initial groups simultaneously are added to the new one
1920 # @return an instance of SMESH_Group
1921 # @ingroup l2_grps_operon
1922 def IntersectListOfGroups(self, groups, name):
1923 return self.mesh.IntersectListOfGroups(groups, name)
1925 ## Produces a cut of two groups
1926 # A new group is created. All mesh elements that are present in
1927 # the main group but are not present in the tool group are added to the new one
1928 # @return an instance of SMESH_Group
1929 # @ingroup l2_grps_operon
1930 def CutGroups(self, main_group, tool_group, name):
1931 return self.mesh.CutGroups(main_group, tool_group, name)
1933 ## Produces a cut of groups
1934 # A new group is created. All mesh elements that are present in main groups
1935 # but do not present in tool groups are added to the new one
1936 # @return an instance of SMESH_Group
1937 # @ingroup l2_grps_operon
1938 def CutListOfGroups(self, main_groups, tool_groups, name):
1939 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1941 ## Produces a group of elements of specified type using list of existing groups
1942 # A new group is created. System
1943 # 1) extracts all nodes on which groups elements are built
1944 # 2) combines all elements of specified dimension laying on these nodes
1945 # @return an instance of SMESH_Group
1946 # @ingroup l2_grps_operon
1947 def CreateDimGroup(self, groups, elem_type, name):
1948 return self.mesh.CreateDimGroup(groups, elem_type, name)
1951 ## Convert group on geom into standalone group
1952 # @ingroup l2_grps_delete
1953 def ConvertToStandalone(self, group):
1954 return self.mesh.ConvertToStandalone(group)
1956 # Get some info about mesh:
1957 # ------------------------
1959 ## Returns the log of nodes and elements added or removed
1960 # since the previous clear of the log.
1961 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1962 # @return list of log_block structures:
1967 # @ingroup l1_auxiliary
1968 def GetLog(self, clearAfterGet):
1969 return self.mesh.GetLog(clearAfterGet)
1971 ## Clears the log of nodes and elements added or removed since the previous
1972 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1973 # @ingroup l1_auxiliary
1975 self.mesh.ClearLog()
1977 ## Toggles auto color mode on the object.
1978 # @param theAutoColor the flag which toggles auto color mode.
1979 # @ingroup l1_auxiliary
1980 def SetAutoColor(self, theAutoColor):
1981 self.mesh.SetAutoColor(theAutoColor)
1983 ## Gets flag of object auto color mode.
1984 # @return True or False
1985 # @ingroup l1_auxiliary
1986 def GetAutoColor(self):
1987 return self.mesh.GetAutoColor()
1989 ## Gets the internal ID
1990 # @return integer value, which is the internal Id of the mesh
1991 # @ingroup l1_auxiliary
1993 return self.mesh.GetId()
1996 # @return integer value, which is the study Id of the mesh
1997 # @ingroup l1_auxiliary
1998 def GetStudyId(self):
1999 return self.mesh.GetStudyId()
2001 ## Checks the group names for duplications.
2002 # Consider the maximum group name length stored in MED file.
2003 # @return True or False
2004 # @ingroup l1_auxiliary
2005 def HasDuplicatedGroupNamesMED(self):
2006 return self.mesh.HasDuplicatedGroupNamesMED()
2008 ## Obtains the mesh editor tool
2009 # @return an instance of SMESH_MeshEditor
2010 # @ingroup l1_modifying
2011 def GetMeshEditor(self):
2012 return self.mesh.GetMeshEditor()
2014 ## Wrap a list of IDs of elements or nodes into SMESH_IDSource which
2015 # can be passed as argument to accepting mesh, group or sub-mesh
2016 # @return an instance of SMESH_IDSource
2017 # @ingroup l1_auxiliary
2018 def GetIDSource(self, ids, elemType):
2019 return self.GetMeshEditor().MakeIDSource(ids, elemType)
2022 # @return an instance of SALOME_MED::MESH
2023 # @ingroup l1_auxiliary
2024 def GetMEDMesh(self):
2025 return self.mesh.GetMEDMesh()
2028 # Get informations about mesh contents:
2029 # ------------------------------------
2031 ## Gets the mesh stattistic
2032 # @return dictionary type element - count of elements
2033 # @ingroup l1_meshinfo
2034 def GetMeshInfo(self, obj = None):
2035 if not obj: obj = self.mesh
2036 return self.smeshpyD.GetMeshInfo(obj)
2038 ## Returns the number of nodes in the mesh
2039 # @return an integer value
2040 # @ingroup l1_meshinfo
2042 return self.mesh.NbNodes()
2044 ## Returns the number of elements in the mesh
2045 # @return an integer value
2046 # @ingroup l1_meshinfo
2047 def NbElements(self):
2048 return self.mesh.NbElements()
2050 ## Returns the number of 0d elements in the mesh
2051 # @return an integer value
2052 # @ingroup l1_meshinfo
2053 def Nb0DElements(self):
2054 return self.mesh.Nb0DElements()
2056 ## Returns the number of edges in the mesh
2057 # @return an integer value
2058 # @ingroup l1_meshinfo
2060 return self.mesh.NbEdges()
2062 ## Returns the number of edges with the given order in the mesh
2063 # @param elementOrder the order of elements:
2064 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2065 # @return an integer value
2066 # @ingroup l1_meshinfo
2067 def NbEdgesOfOrder(self, elementOrder):
2068 return self.mesh.NbEdgesOfOrder(elementOrder)
2070 ## Returns the number of faces in the mesh
2071 # @return an integer value
2072 # @ingroup l1_meshinfo
2074 return self.mesh.NbFaces()
2076 ## Returns the number of faces with the given order in the mesh
2077 # @param elementOrder the order of elements:
2078 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2079 # @return an integer value
2080 # @ingroup l1_meshinfo
2081 def NbFacesOfOrder(self, elementOrder):
2082 return self.mesh.NbFacesOfOrder(elementOrder)
2084 ## Returns the number of triangles in the mesh
2085 # @return an integer value
2086 # @ingroup l1_meshinfo
2087 def NbTriangles(self):
2088 return self.mesh.NbTriangles()
2090 ## Returns the number of triangles with the given order in the mesh
2091 # @param elementOrder is the order of elements:
2092 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2093 # @return an integer value
2094 # @ingroup l1_meshinfo
2095 def NbTrianglesOfOrder(self, elementOrder):
2096 return self.mesh.NbTrianglesOfOrder(elementOrder)
2098 ## Returns the number of quadrangles in the mesh
2099 # @return an integer value
2100 # @ingroup l1_meshinfo
2101 def NbQuadrangles(self):
2102 return self.mesh.NbQuadrangles()
2104 ## Returns the number of quadrangles with the given order in the mesh
2105 # @param elementOrder the order of elements:
2106 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2107 # @return an integer value
2108 # @ingroup l1_meshinfo
2109 def NbQuadranglesOfOrder(self, elementOrder):
2110 return self.mesh.NbQuadranglesOfOrder(elementOrder)
2112 ## Returns the number of polygons in the mesh
2113 # @return an integer value
2114 # @ingroup l1_meshinfo
2115 def NbPolygons(self):
2116 return self.mesh.NbPolygons()
2118 ## Returns the number of volumes in the mesh
2119 # @return an integer value
2120 # @ingroup l1_meshinfo
2121 def NbVolumes(self):
2122 return self.mesh.NbVolumes()
2124 ## Returns the number of volumes with the given order in the mesh
2125 # @param elementOrder the order of elements:
2126 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2127 # @return an integer value
2128 # @ingroup l1_meshinfo
2129 def NbVolumesOfOrder(self, elementOrder):
2130 return self.mesh.NbVolumesOfOrder(elementOrder)
2132 ## Returns the number of tetrahedrons in the mesh
2133 # @return an integer value
2134 # @ingroup l1_meshinfo
2136 return self.mesh.NbTetras()
2138 ## Returns the number of tetrahedrons with the given order in the mesh
2139 # @param elementOrder the order of elements:
2140 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2141 # @return an integer value
2142 # @ingroup l1_meshinfo
2143 def NbTetrasOfOrder(self, elementOrder):
2144 return self.mesh.NbTetrasOfOrder(elementOrder)
2146 ## Returns the number of hexahedrons in the mesh
2147 # @return an integer value
2148 # @ingroup l1_meshinfo
2150 return self.mesh.NbHexas()
2152 ## Returns the number of hexahedrons with the given order in the mesh
2153 # @param elementOrder the order of elements:
2154 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2155 # @return an integer value
2156 # @ingroup l1_meshinfo
2157 def NbHexasOfOrder(self, elementOrder):
2158 return self.mesh.NbHexasOfOrder(elementOrder)
2160 ## Returns the number of pyramids in the mesh
2161 # @return an integer value
2162 # @ingroup l1_meshinfo
2163 def NbPyramids(self):
2164 return self.mesh.NbPyramids()
2166 ## Returns the number of pyramids with the given order in the mesh
2167 # @param elementOrder the order of elements:
2168 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2169 # @return an integer value
2170 # @ingroup l1_meshinfo
2171 def NbPyramidsOfOrder(self, elementOrder):
2172 return self.mesh.NbPyramidsOfOrder(elementOrder)
2174 ## Returns the number of prisms in the mesh
2175 # @return an integer value
2176 # @ingroup l1_meshinfo
2178 return self.mesh.NbPrisms()
2180 ## Returns the number of prisms with the given order in the mesh
2181 # @param elementOrder the order of elements:
2182 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2183 # @return an integer value
2184 # @ingroup l1_meshinfo
2185 def NbPrismsOfOrder(self, elementOrder):
2186 return self.mesh.NbPrismsOfOrder(elementOrder)
2188 ## Returns the number of polyhedrons in the mesh
2189 # @return an integer value
2190 # @ingroup l1_meshinfo
2191 def NbPolyhedrons(self):
2192 return self.mesh.NbPolyhedrons()
2194 ## Returns the number of submeshes in the mesh
2195 # @return an integer value
2196 # @ingroup l1_meshinfo
2197 def NbSubMesh(self):
2198 return self.mesh.NbSubMesh()
2200 ## Returns the list of mesh elements IDs
2201 # @return the list of integer values
2202 # @ingroup l1_meshinfo
2203 def GetElementsId(self):
2204 return self.mesh.GetElementsId()
2206 ## Returns the list of IDs of mesh elements with the given type
2207 # @param elementType the required type of elements (SMESH.NODE, SMESH.EDGE, SMESH.FACE or SMESH.VOLUME)
2208 # @return list of integer values
2209 # @ingroup l1_meshinfo
2210 def GetElementsByType(self, elementType):
2211 return self.mesh.GetElementsByType(elementType)
2213 ## Returns the list of mesh nodes IDs
2214 # @return the list of integer values
2215 # @ingroup l1_meshinfo
2216 def GetNodesId(self):
2217 return self.mesh.GetNodesId()
2219 # Get the information about mesh elements:
2220 # ------------------------------------
2222 ## Returns the type of mesh element
2223 # @return the value from SMESH::ElementType enumeration
2224 # @ingroup l1_meshinfo
2225 def GetElementType(self, id, iselem):
2226 return self.mesh.GetElementType(id, iselem)
2228 ## Returns the geometric type of mesh element
2229 # @return the value from SMESH::EntityType enumeration
2230 # @ingroup l1_meshinfo
2231 def GetElementGeomType(self, id):
2232 return self.mesh.GetElementGeomType(id)
2234 ## Returns the list of submesh elements IDs
2235 # @param Shape a geom object(subshape) IOR
2236 # Shape must be the subshape of a ShapeToMesh()
2237 # @return the list of integer values
2238 # @ingroup l1_meshinfo
2239 def GetSubMeshElementsId(self, Shape):
2240 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2241 ShapeID = Shape.GetSubShapeIndices()[0]
2244 return self.mesh.GetSubMeshElementsId(ShapeID)
2246 ## Returns the list of submesh nodes IDs
2247 # @param Shape a geom object(subshape) IOR
2248 # Shape must be the subshape of a ShapeToMesh()
2249 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
2250 # @return the list of integer values
2251 # @ingroup l1_meshinfo
2252 def GetSubMeshNodesId(self, Shape, all):
2253 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2254 ShapeID = Shape.GetSubShapeIndices()[0]
2257 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2259 ## Returns type of elements on given shape
2260 # @param Shape a geom object(subshape) IOR
2261 # Shape must be a subshape of a ShapeToMesh()
2262 # @return element type
2263 # @ingroup l1_meshinfo
2264 def GetSubMeshElementType(self, Shape):
2265 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2266 ShapeID = Shape.GetSubShapeIndices()[0]
2269 return self.mesh.GetSubMeshElementType(ShapeID)
2271 ## Gets the mesh description
2272 # @return string value
2273 # @ingroup l1_meshinfo
2275 return self.mesh.Dump()
2278 # Get the information about nodes and elements of a mesh by its IDs:
2279 # -----------------------------------------------------------
2281 ## Gets XYZ coordinates of a node
2282 # \n If there is no nodes for the given ID - returns an empty list
2283 # @return a list of double precision values
2284 # @ingroup l1_meshinfo
2285 def GetNodeXYZ(self, id):
2286 return self.mesh.GetNodeXYZ(id)
2288 ## Returns list of IDs of inverse elements for the given node
2289 # \n If there is no node for the given ID - returns an empty list
2290 # @return a list of integer values
2291 # @ingroup l1_meshinfo
2292 def GetNodeInverseElements(self, id):
2293 return self.mesh.GetNodeInverseElements(id)
2295 ## @brief Returns the position of a node on the shape
2296 # @return SMESH::NodePosition
2297 # @ingroup l1_meshinfo
2298 def GetNodePosition(self,NodeID):
2299 return self.mesh.GetNodePosition(NodeID)
2301 ## If the given element is a node, returns the ID of shape
2302 # \n If there is no node for the given ID - returns -1
2303 # @return an integer value
2304 # @ingroup l1_meshinfo
2305 def GetShapeID(self, id):
2306 return self.mesh.GetShapeID(id)
2308 ## Returns the ID of the result shape after
2309 # FindShape() from SMESH_MeshEditor for the given element
2310 # \n If there is no element for the given ID - returns -1
2311 # @return an integer value
2312 # @ingroup l1_meshinfo
2313 def GetShapeIDForElem(self,id):
2314 return self.mesh.GetShapeIDForElem(id)
2316 ## Returns the number of nodes for the given element
2317 # \n If there is no element for the given ID - returns -1
2318 # @return an integer value
2319 # @ingroup l1_meshinfo
2320 def GetElemNbNodes(self, id):
2321 return self.mesh.GetElemNbNodes(id)
2323 ## Returns the node ID the given index for the given element
2324 # \n If there is no element for the given ID - returns -1
2325 # \n If there is no node for the given index - returns -2
2326 # @return an integer value
2327 # @ingroup l1_meshinfo
2328 def GetElemNode(self, id, index):
2329 return self.mesh.GetElemNode(id, index)
2331 ## Returns the IDs of nodes of the given element
2332 # @return a list of integer values
2333 # @ingroup l1_meshinfo
2334 def GetElemNodes(self, id):
2335 return self.mesh.GetElemNodes(id)
2337 ## Returns true if the given node is the medium node in the given quadratic element
2338 # @ingroup l1_meshinfo
2339 def IsMediumNode(self, elementID, nodeID):
2340 return self.mesh.IsMediumNode(elementID, nodeID)
2342 ## Returns true if the given node is the medium node in one of quadratic elements
2343 # @ingroup l1_meshinfo
2344 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2345 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2347 ## Returns the number of edges for the given element
2348 # @ingroup l1_meshinfo
2349 def ElemNbEdges(self, id):
2350 return self.mesh.ElemNbEdges(id)
2352 ## Returns the number of faces for the given element
2353 # @ingroup l1_meshinfo
2354 def ElemNbFaces(self, id):
2355 return self.mesh.ElemNbFaces(id)
2357 ## Returns nodes of given face (counted from zero) for given volumic element.
2358 # @ingroup l1_meshinfo
2359 def GetElemFaceNodes(self,elemId, faceIndex):
2360 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2362 ## Returns an element based on all given nodes.
2363 # @ingroup l1_meshinfo
2364 def FindElementByNodes(self,nodes):
2365 return self.mesh.FindElementByNodes(nodes)
2367 ## Returns true if the given element is a polygon
2368 # @ingroup l1_meshinfo
2369 def IsPoly(self, id):
2370 return self.mesh.IsPoly(id)
2372 ## Returns true if the given element is quadratic
2373 # @ingroup l1_meshinfo
2374 def IsQuadratic(self, id):
2375 return self.mesh.IsQuadratic(id)
2377 ## Returns XYZ coordinates of the barycenter of the given element
2378 # \n If there is no element for the given ID - returns an empty list
2379 # @return a list of three double values
2380 # @ingroup l1_meshinfo
2381 def BaryCenter(self, id):
2382 return self.mesh.BaryCenter(id)
2385 # Get mesh measurements information:
2386 # ------------------------------------
2388 ## Get minimum distance between two nodes, elements or distance to the origin
2389 # @param id1 first node/element id
2390 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2391 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2392 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2393 # @return minimum distance value
2394 # @sa GetMinDistance()
2395 def MinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2396 aMeasure = self.GetMinDistance(id1, id2, isElem1, isElem2)
2397 return aMeasure.value
2399 ## Get measure structure specifying minimum distance data between two objects
2400 # @param id1 first node/element id
2401 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2402 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2403 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2404 # @return Measure structure
2406 def GetMinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2408 id1 = self.editor.MakeIDSource([id1], SMESH.FACE)
2410 id1 = self.editor.MakeIDSource([id1], SMESH.NODE)
2413 id2 = self.editor.MakeIDSource([id2], SMESH.FACE)
2415 id2 = self.editor.MakeIDSource([id2], SMESH.NODE)
2420 aMeasurements = self.smeshpyD.CreateMeasurements()
2421 aMeasure = aMeasurements.MinDistance(id1, id2)
2422 aMeasurements.UnRegister()
2425 ## Get bounding box of the specified object(s)
2426 # @param objects single source object or list of source objects or list of nodes/elements IDs
2427 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2428 # @c False specifies that @a objects are nodes
2429 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
2430 # @sa GetBoundingBox()
2431 def BoundingBox(self, objects=None, isElem=False):
2432 result = self.GetBoundingBox(objects, isElem)
2436 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
2439 ## Get measure structure specifying bounding box data of the specified object(s)
2440 # @param objects single source object or list of source objects or list of nodes/elements IDs
2441 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2442 # @c False specifies that @a objects are nodes
2443 # @return Measure structure
2445 def GetBoundingBox(self, IDs=None, isElem=False):
2448 elif isinstance(IDs, tuple):
2450 if not isinstance(IDs, list):
2452 if len(IDs) > 0 and isinstance(IDs[0], int):
2456 if isinstance(o, Mesh):
2457 srclist.append(o.mesh)
2458 elif hasattr(o, "_narrow"):
2459 src = o._narrow(SMESH.SMESH_IDSource)
2460 if src: srclist.append(src)
2462 elif isinstance(o, list):
2464 srclist.append(self.editor.MakeIDSource(o, SMESH.FACE))
2466 srclist.append(self.editor.MakeIDSource(o, SMESH.NODE))
2469 aMeasurements = self.smeshpyD.CreateMeasurements()
2470 aMeasure = aMeasurements.BoundingBox(srclist)
2471 aMeasurements.UnRegister()
2474 # Mesh edition (SMESH_MeshEditor functionality):
2475 # ---------------------------------------------
2477 ## Removes the elements from the mesh by ids
2478 # @param IDsOfElements is a list of ids of elements to remove
2479 # @return True or False
2480 # @ingroup l2_modif_del
2481 def RemoveElements(self, IDsOfElements):
2482 return self.editor.RemoveElements(IDsOfElements)
2484 ## Removes nodes from mesh by ids
2485 # @param IDsOfNodes is a list of ids of nodes to remove
2486 # @return True or False
2487 # @ingroup l2_modif_del
2488 def RemoveNodes(self, IDsOfNodes):
2489 return self.editor.RemoveNodes(IDsOfNodes)
2491 ## Removes all orphan (free) nodes from mesh
2492 # @return number of the removed nodes
2493 # @ingroup l2_modif_del
2494 def RemoveOrphanNodes(self):
2495 return self.editor.RemoveOrphanNodes()
2497 ## Add a node to the mesh by coordinates
2498 # @return Id of the new node
2499 # @ingroup l2_modif_add
2500 def AddNode(self, x, y, z):
2501 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2502 self.mesh.SetParameters(Parameters)
2503 return self.editor.AddNode( x, y, z)
2505 ## Creates a 0D element on a node with given number.
2506 # @param IDOfNode the ID of node for creation of the element.
2507 # @return the Id of the new 0D element
2508 # @ingroup l2_modif_add
2509 def Add0DElement(self, IDOfNode):
2510 return self.editor.Add0DElement(IDOfNode)
2512 ## Creates a linear or quadratic edge (this is determined
2513 # by the number of given nodes).
2514 # @param IDsOfNodes the list of node IDs for creation of the element.
2515 # The order of nodes in this list should correspond to the description
2516 # of MED. \n This description is located by the following link:
2517 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2518 # @return the Id of the new edge
2519 # @ingroup l2_modif_add
2520 def AddEdge(self, IDsOfNodes):
2521 return self.editor.AddEdge(IDsOfNodes)
2523 ## Creates a linear or quadratic face (this is determined
2524 # by the number of given nodes).
2525 # @param IDsOfNodes the list of node IDs for creation of the element.
2526 # The order of nodes in this list should correspond to the description
2527 # of MED. \n This description is located by the following link:
2528 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2529 # @return the Id of the new face
2530 # @ingroup l2_modif_add
2531 def AddFace(self, IDsOfNodes):
2532 return self.editor.AddFace(IDsOfNodes)
2534 ## Adds a polygonal face to the mesh by the list of node IDs
2535 # @param IdsOfNodes the list of node IDs for creation of the element.
2536 # @return the Id of the new face
2537 # @ingroup l2_modif_add
2538 def AddPolygonalFace(self, IdsOfNodes):
2539 return self.editor.AddPolygonalFace(IdsOfNodes)
2541 ## Creates both simple and quadratic volume (this is determined
2542 # by the number of given nodes).
2543 # @param IDsOfNodes the list of node IDs for creation of the element.
2544 # The order of nodes in this list should correspond to the description
2545 # of MED. \n This description is located by the following link:
2546 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2547 # @return the Id of the new volumic element
2548 # @ingroup l2_modif_add
2549 def AddVolume(self, IDsOfNodes):
2550 return self.editor.AddVolume(IDsOfNodes)
2552 ## Creates a volume of many faces, giving nodes for each face.
2553 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2554 # @param Quantities the list of integer values, Quantities[i]
2555 # gives the quantity of nodes in face number i.
2556 # @return the Id of the new volumic element
2557 # @ingroup l2_modif_add
2558 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2559 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2561 ## Creates a volume of many faces, giving the IDs of the existing faces.
2562 # @param IdsOfFaces the list of face IDs for volume creation.
2564 # Note: The created volume will refer only to the nodes
2565 # of the given faces, not to the faces themselves.
2566 # @return the Id of the new volumic element
2567 # @ingroup l2_modif_add
2568 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2569 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2572 ## @brief Binds a node to a vertex
2573 # @param NodeID a node ID
2574 # @param Vertex a vertex or vertex ID
2575 # @return True if succeed else raises an exception
2576 # @ingroup l2_modif_add
2577 def SetNodeOnVertex(self, NodeID, Vertex):
2578 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2579 VertexID = Vertex.GetSubShapeIndices()[0]
2583 self.editor.SetNodeOnVertex(NodeID, VertexID)
2584 except SALOME.SALOME_Exception, inst:
2585 raise ValueError, inst.details.text
2589 ## @brief Stores the node position on an edge
2590 # @param NodeID a node ID
2591 # @param Edge an edge or edge ID
2592 # @param paramOnEdge a parameter on the edge where the node is located
2593 # @return True if succeed else raises an exception
2594 # @ingroup l2_modif_add
2595 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2596 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2597 EdgeID = Edge.GetSubShapeIndices()[0]
2601 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2602 except SALOME.SALOME_Exception, inst:
2603 raise ValueError, inst.details.text
2606 ## @brief Stores node position on a face
2607 # @param NodeID a node ID
2608 # @param Face a face or face ID
2609 # @param u U parameter on the face where the node is located
2610 # @param v V parameter on the face where the node is located
2611 # @return True if succeed else raises an exception
2612 # @ingroup l2_modif_add
2613 def SetNodeOnFace(self, NodeID, Face, u, v):
2614 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2615 FaceID = Face.GetSubShapeIndices()[0]
2619 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2620 except SALOME.SALOME_Exception, inst:
2621 raise ValueError, inst.details.text
2624 ## @brief Binds a node to a solid
2625 # @param NodeID a node ID
2626 # @param Solid a solid or solid ID
2627 # @return True if succeed else raises an exception
2628 # @ingroup l2_modif_add
2629 def SetNodeInVolume(self, NodeID, Solid):
2630 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2631 SolidID = Solid.GetSubShapeIndices()[0]
2635 self.editor.SetNodeInVolume(NodeID, SolidID)
2636 except SALOME.SALOME_Exception, inst:
2637 raise ValueError, inst.details.text
2640 ## @brief Bind an element to a shape
2641 # @param ElementID an element ID
2642 # @param Shape a shape or shape ID
2643 # @return True if succeed else raises an exception
2644 # @ingroup l2_modif_add
2645 def SetMeshElementOnShape(self, ElementID, Shape):
2646 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2647 ShapeID = Shape.GetSubShapeIndices()[0]
2651 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2652 except SALOME.SALOME_Exception, inst:
2653 raise ValueError, inst.details.text
2657 ## Moves the node with the given id
2658 # @param NodeID the id of the node
2659 # @param x a new X coordinate
2660 # @param y a new Y coordinate
2661 # @param z a new Z coordinate
2662 # @return True if succeed else False
2663 # @ingroup l2_modif_movenode
2664 def MoveNode(self, NodeID, x, y, z):
2665 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2666 self.mesh.SetParameters(Parameters)
2667 return self.editor.MoveNode(NodeID, x, y, z)
2669 ## Finds the node closest to a point and moves it to a point location
2670 # @param x the X coordinate of a point
2671 # @param y the Y coordinate of a point
2672 # @param z the Z coordinate of a point
2673 # @param NodeID if specified (>0), the node with this ID is moved,
2674 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2675 # @return the ID of a node
2676 # @ingroup l2_modif_throughp
2677 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2678 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2679 self.mesh.SetParameters(Parameters)
2680 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2682 ## Finds the node closest to a point
2683 # @param x the X coordinate of a point
2684 # @param y the Y coordinate of a point
2685 # @param z the Z coordinate of a point
2686 # @return the ID of a node
2687 # @ingroup l2_modif_throughp
2688 def FindNodeClosestTo(self, x, y, z):
2689 #preview = self.mesh.GetMeshEditPreviewer()
2690 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2691 return self.editor.FindNodeClosestTo(x, y, z)
2693 ## Finds the elements where a point lays IN or ON
2694 # @param x the X coordinate of a point
2695 # @param y the Y coordinate of a point
2696 # @param z the Z coordinate of a point
2697 # @param elementType type of elements to find (SMESH.ALL type
2698 # means elements of any type excluding nodes and 0D elements)
2699 # @return list of IDs of found elements
2700 # @ingroup l2_modif_throughp
2701 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2702 return self.editor.FindElementsByPoint(x, y, z, elementType)
2704 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2705 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2707 def GetPointState(self, x, y, z):
2708 return self.editor.GetPointState(x, y, z)
2710 ## Finds the node closest to a point and moves it to a point location
2711 # @param x the X coordinate of a point
2712 # @param y the Y coordinate of a point
2713 # @param z the Z coordinate of a point
2714 # @return the ID of a moved node
2715 # @ingroup l2_modif_throughp
2716 def MeshToPassThroughAPoint(self, x, y, z):
2717 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2719 ## Replaces two neighbour triangles sharing Node1-Node2 link
2720 # with the triangles built on the same 4 nodes but having other common link.
2721 # @param NodeID1 the ID of the first node
2722 # @param NodeID2 the ID of the second node
2723 # @return false if proper faces were not found
2724 # @ingroup l2_modif_invdiag
2725 def InverseDiag(self, NodeID1, NodeID2):
2726 return self.editor.InverseDiag(NodeID1, NodeID2)
2728 ## Replaces two neighbour triangles sharing Node1-Node2 link
2729 # with a quadrangle built on the same 4 nodes.
2730 # @param NodeID1 the ID of the first node
2731 # @param NodeID2 the ID of the second node
2732 # @return false if proper faces were not found
2733 # @ingroup l2_modif_unitetri
2734 def DeleteDiag(self, NodeID1, NodeID2):
2735 return self.editor.DeleteDiag(NodeID1, NodeID2)
2737 ## Reorients elements by ids
2738 # @param IDsOfElements if undefined reorients all mesh elements
2739 # @return True if succeed else False
2740 # @ingroup l2_modif_changori
2741 def Reorient(self, IDsOfElements=None):
2742 if IDsOfElements == None:
2743 IDsOfElements = self.GetElementsId()
2744 return self.editor.Reorient(IDsOfElements)
2746 ## Reorients all elements of the object
2747 # @param theObject mesh, submesh or group
2748 # @return True if succeed else False
2749 # @ingroup l2_modif_changori
2750 def ReorientObject(self, theObject):
2751 if ( isinstance( theObject, Mesh )):
2752 theObject = theObject.GetMesh()
2753 return self.editor.ReorientObject(theObject)
2755 ## Fuses the neighbouring triangles into quadrangles.
2756 # @param IDsOfElements The triangles to be fused,
2757 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2758 # @param MaxAngle is the maximum angle between element normals at which the fusion
2759 # is still performed; theMaxAngle is mesured in radians.
2760 # Also it could be a name of variable which defines angle in degrees.
2761 # @return TRUE in case of success, FALSE otherwise.
2762 # @ingroup l2_modif_unitetri
2763 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2765 if isinstance(MaxAngle,str):
2767 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2769 MaxAngle = DegreesToRadians(MaxAngle)
2770 if IDsOfElements == []:
2771 IDsOfElements = self.GetElementsId()
2772 self.mesh.SetParameters(Parameters)
2774 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2775 Functor = theCriterion
2777 Functor = self.smeshpyD.GetFunctor(theCriterion)
2778 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2780 ## Fuses the neighbouring triangles of the object into quadrangles
2781 # @param theObject is mesh, submesh or group
2782 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2783 # @param MaxAngle a max angle between element normals at which the fusion
2784 # is still performed; theMaxAngle is mesured in radians.
2785 # @return TRUE in case of success, FALSE otherwise.
2786 # @ingroup l2_modif_unitetri
2787 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2788 if ( isinstance( theObject, Mesh )):
2789 theObject = theObject.GetMesh()
2790 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2792 ## Splits quadrangles into triangles.
2793 # @param IDsOfElements the faces to be splitted.
2794 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2795 # @return TRUE in case of success, FALSE otherwise.
2796 # @ingroup l2_modif_cutquadr
2797 def QuadToTri (self, IDsOfElements, theCriterion):
2798 if IDsOfElements == []:
2799 IDsOfElements = self.GetElementsId()
2800 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2802 ## Splits quadrangles into triangles.
2803 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2804 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2805 # @return TRUE in case of success, FALSE otherwise.
2806 # @ingroup l2_modif_cutquadr
2807 def QuadToTriObject (self, theObject, theCriterion):
2808 if ( isinstance( theObject, Mesh )):
2809 theObject = theObject.GetMesh()
2810 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2812 ## Splits quadrangles into triangles.
2813 # @param IDsOfElements the faces to be splitted
2814 # @param Diag13 is used to choose a diagonal for splitting.
2815 # @return TRUE in case of success, FALSE otherwise.
2816 # @ingroup l2_modif_cutquadr
2817 def SplitQuad (self, IDsOfElements, Diag13):
2818 if IDsOfElements == []:
2819 IDsOfElements = self.GetElementsId()
2820 return self.editor.SplitQuad(IDsOfElements, Diag13)
2822 ## Splits quadrangles into triangles.
2823 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2824 # @param Diag13 is used to choose a diagonal for splitting.
2825 # @return TRUE in case of success, FALSE otherwise.
2826 # @ingroup l2_modif_cutquadr
2827 def SplitQuadObject (self, theObject, Diag13):
2828 if ( isinstance( theObject, Mesh )):
2829 theObject = theObject.GetMesh()
2830 return self.editor.SplitQuadObject(theObject, Diag13)
2832 ## Finds a better splitting of the given quadrangle.
2833 # @param IDOfQuad the ID of the quadrangle to be splitted.
2834 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2835 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2836 # diagonal is better, 0 if error occurs.
2837 # @ingroup l2_modif_cutquadr
2838 def BestSplit (self, IDOfQuad, theCriterion):
2839 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2841 ## Splits volumic elements into tetrahedrons
2842 # @param elemIDs either list of elements or mesh or group or submesh
2843 # @param method flags passing splitting method: Hex_5Tet, Hex_6Tet, Hex_24Tet
2844 # Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc
2845 # @ingroup l2_modif_cutquadr
2846 def SplitVolumesIntoTetra(self, elemIDs, method=Hex_5Tet ):
2847 if isinstance( elemIDs, Mesh ):
2848 elemIDs = elemIDs.GetMesh()
2849 if ( isinstance( elemIDs, list )):
2850 elemIDs = self.editor.MakeIDSource(elemIDs, SMESH.VOLUME)
2851 self.editor.SplitVolumesIntoTetra(elemIDs, method)
2853 ## Splits quadrangle faces near triangular facets of volumes
2855 # @ingroup l1_auxiliary
2856 def SplitQuadsNearTriangularFacets(self):
2857 faces_array = self.GetElementsByType(SMESH.FACE)
2858 for face_id in faces_array:
2859 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2860 quad_nodes = self.mesh.GetElemNodes(face_id)
2861 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2862 isVolumeFound = False
2863 for node1_elem in node1_elems:
2864 if not isVolumeFound:
2865 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2866 nb_nodes = self.GetElemNbNodes(node1_elem)
2867 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2868 volume_elem = node1_elem
2869 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2870 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2871 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2872 isVolumeFound = True
2873 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2874 self.SplitQuad([face_id], False) # diagonal 2-4
2875 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2876 isVolumeFound = True
2877 self.SplitQuad([face_id], True) # diagonal 1-3
2878 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2879 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2880 isVolumeFound = True
2881 self.SplitQuad([face_id], True) # diagonal 1-3
2883 ## @brief Splits hexahedrons into tetrahedrons.
2885 # This operation uses pattern mapping functionality for splitting.
2886 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2887 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2888 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2889 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2890 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2891 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2892 # @return TRUE in case of success, FALSE otherwise.
2893 # @ingroup l1_auxiliary
2894 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2895 # Pattern: 5.---------.6
2900 # (0,0,1) 4.---------.7 * |
2907 # (0,0,0) 0.---------.3
2908 pattern_tetra = "!!! Nb of points: \n 8 \n\
2918 !!! Indices of points of 6 tetras: \n\
2926 pattern = self.smeshpyD.GetPattern()
2927 isDone = pattern.LoadFromFile(pattern_tetra)
2929 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2932 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2933 isDone = pattern.MakeMesh(self.mesh, False, False)
2934 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2936 # split quafrangle faces near triangular facets of volumes
2937 self.SplitQuadsNearTriangularFacets()
2941 ## @brief Split hexahedrons into prisms.
2943 # Uses the pattern mapping functionality for splitting.
2944 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2945 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2946 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2947 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2948 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2949 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2950 # @return TRUE in case of success, FALSE otherwise.
2951 # @ingroup l1_auxiliary
2952 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2953 # Pattern: 5.---------.6
2958 # (0,0,1) 4.---------.7 |
2965 # (0,0,0) 0.---------.3
2966 pattern_prism = "!!! Nb of points: \n 8 \n\
2976 !!! Indices of points of 2 prisms: \n\
2980 pattern = self.smeshpyD.GetPattern()
2981 isDone = pattern.LoadFromFile(pattern_prism)
2983 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2986 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2987 isDone = pattern.MakeMesh(self.mesh, False, False)
2988 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2990 # Splits quafrangle faces near triangular facets of volumes
2991 self.SplitQuadsNearTriangularFacets()
2995 ## Smoothes elements
2996 # @param IDsOfElements the list if ids of elements to smooth
2997 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2998 # Note that nodes built on edges and boundary nodes are always fixed.
2999 # @param MaxNbOfIterations the maximum number of iterations
3000 # @param MaxAspectRatio varies in range [1.0, inf]
3001 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3002 # @return TRUE in case of success, FALSE otherwise.
3003 # @ingroup l2_modif_smooth
3004 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
3005 MaxNbOfIterations, MaxAspectRatio, Method):
3006 if IDsOfElements == []:
3007 IDsOfElements = self.GetElementsId()
3008 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
3009 self.mesh.SetParameters(Parameters)
3010 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
3011 MaxNbOfIterations, MaxAspectRatio, Method)
3013 ## Smoothes elements which belong to the given object
3014 # @param theObject the object to smooth
3015 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3016 # Note that nodes built on edges and boundary nodes are always fixed.
3017 # @param MaxNbOfIterations the maximum number of iterations
3018 # @param MaxAspectRatio varies in range [1.0, inf]
3019 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3020 # @return TRUE in case of success, FALSE otherwise.
3021 # @ingroup l2_modif_smooth
3022 def SmoothObject(self, theObject, IDsOfFixedNodes,
3023 MaxNbOfIterations, MaxAspectRatio, Method):
3024 if ( isinstance( theObject, Mesh )):
3025 theObject = theObject.GetMesh()
3026 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
3027 MaxNbOfIterations, MaxAspectRatio, Method)
3029 ## Parametrically smoothes the given elements
3030 # @param IDsOfElements the list if ids of elements to smooth
3031 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3032 # Note that nodes built on edges and boundary nodes are always fixed.
3033 # @param MaxNbOfIterations the maximum number of iterations
3034 # @param MaxAspectRatio varies in range [1.0, inf]
3035 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3036 # @return TRUE in case of success, FALSE otherwise.
3037 # @ingroup l2_modif_smooth
3038 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
3039 MaxNbOfIterations, MaxAspectRatio, Method):
3040 if IDsOfElements == []:
3041 IDsOfElements = self.GetElementsId()
3042 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
3043 self.mesh.SetParameters(Parameters)
3044 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
3045 MaxNbOfIterations, MaxAspectRatio, Method)
3047 ## Parametrically smoothes the elements which belong to the given object
3048 # @param theObject the object to smooth
3049 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3050 # Note that nodes built on edges and boundary nodes are always fixed.
3051 # @param MaxNbOfIterations the maximum number of iterations
3052 # @param MaxAspectRatio varies in range [1.0, inf]
3053 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3054 # @return TRUE in case of success, FALSE otherwise.
3055 # @ingroup l2_modif_smooth
3056 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
3057 MaxNbOfIterations, MaxAspectRatio, Method):
3058 if ( isinstance( theObject, Mesh )):
3059 theObject = theObject.GetMesh()
3060 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
3061 MaxNbOfIterations, MaxAspectRatio, Method)
3063 ## Converts the mesh to quadratic, deletes old elements, replacing
3064 # them with quadratic with the same id.
3065 # @param theForce3d new node creation method:
3066 # 0 - the medium node lies at the geometrical entity from which the mesh element is built
3067 # 1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element
3068 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
3069 # @ingroup l2_modif_tofromqu
3070 def ConvertToQuadratic(self, theForce3d, theSubMesh=None):
3072 self.editor.ConvertToQuadraticObject(theForce3d,theSubMesh)
3074 self.editor.ConvertToQuadratic(theForce3d)
3076 ## Converts the mesh from quadratic to ordinary,
3077 # deletes old quadratic elements, \n replacing
3078 # them with ordinary mesh elements with the same id.
3079 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
3080 # @ingroup l2_modif_tofromqu
3081 def ConvertFromQuadratic(self, theSubMesh=None):
3083 self.editor.ConvertFromQuadraticObject(theSubMesh)
3085 return self.editor.ConvertFromQuadratic()
3087 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
3088 # @return TRUE if operation has been completed successfully, FALSE otherwise
3089 # @ingroup l2_modif_edit
3090 def Make2DMeshFrom3D(self):
3091 return self.editor. Make2DMeshFrom3D()
3093 ## Creates missing boundary elements
3094 # @param elements - elements whose boundary is to be checked:
3095 # mesh, group, sub-mesh or list of elements
3096 # if elements is mesh, it must be the mesh whose MakeBoundaryMesh() is called
3097 # @param dimension - defines type of boundary elements to create:
3098 # SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D
3099 # SMESH.BND_1DFROM3D creates mesh edges on all borders of free facets of 3D cells
3100 # @param groupName - a name of group to store created boundary elements in,
3101 # "" means not to create the group
3102 # @param meshName - a name of new mesh to store created boundary elements in,
3103 # "" means not to create the new mesh
3104 # @param toCopyElements - if true, the checked elements will be copied into
3105 # the new mesh else only boundary elements will be copied into the new mesh
3106 # @param toCopyExistingBondary - if true, not only new but also pre-existing
3107 # boundary elements will be copied into the new mesh
3108 # @return tuple (mesh, group) where bondary elements were added to
3109 # @ingroup l2_modif_edit
3110 def MakeBoundaryMesh(self, elements, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3111 toCopyElements=False, toCopyExistingBondary=False):
3112 if isinstance( elements, Mesh ):
3113 elements = elements.GetMesh()
3114 if ( isinstance( elements, list )):
3115 elemType = SMESH.ALL
3116 if elements: elemType = self.GetElementType( elements[0], iselem=True)
3117 elements = self.editor.MakeIDSource(elements, elemType)
3118 mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName,
3119 toCopyElements,toCopyExistingBondary)
3120 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3124 # @brief Creates missing boundary elements around either the whole mesh or
3125 # groups of 2D elements
3126 # @param dimension - defines type of boundary elements to create
3127 # @param groupName - a name of group to store all boundary elements in,
3128 # "" means not to create the group
3129 # @param meshName - a name of a new mesh, which is a copy of the initial
3130 # mesh + created boundary elements; "" means not to create the new mesh
3131 # @param toCopyAll - if true, the whole initial mesh will be copied into
3132 # the new mesh else only boundary elements will be copied into the new mesh
3133 # @param groups - groups of 2D elements to make boundary around
3134 # @retval tuple( long, mesh, groups )
3135 # long - number of added boundary elements
3136 # mesh - the mesh where elements were added to
3137 # group - the group of boundary elements or None
3139 def MakeBoundaryElements(self, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3140 toCopyAll=False, groups=[]):
3141 nb, mesh, group = self.editor.MakeBoundaryElements(dimension,groupName,meshName,
3143 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3144 return nb, mesh, group
3146 ## Renumber mesh nodes
3147 # @ingroup l2_modif_renumber
3148 def RenumberNodes(self):
3149 self.editor.RenumberNodes()
3151 ## Renumber mesh elements
3152 # @ingroup l2_modif_renumber
3153 def RenumberElements(self):
3154 self.editor.RenumberElements()
3156 ## Generates new elements by rotation of the elements around the axis
3157 # @param IDsOfElements the list of ids of elements to sweep
3158 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3159 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
3160 # @param NbOfSteps the number of steps
3161 # @param Tolerance tolerance
3162 # @param MakeGroups forces the generation of new groups from existing ones
3163 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3164 # of all steps, else - size of each step
3165 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3166 # @ingroup l2_modif_extrurev
3167 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
3168 MakeGroups=False, TotalAngle=False):
3170 if isinstance(AngleInRadians,str):
3172 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3174 AngleInRadians = DegreesToRadians(AngleInRadians)
3175 if IDsOfElements == []:
3176 IDsOfElements = self.GetElementsId()
3177 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3178 Axis = self.smeshpyD.GetAxisStruct(Axis)
3179 Axis,AxisParameters = ParseAxisStruct(Axis)
3180 if TotalAngle and NbOfSteps:
3181 AngleInRadians /= NbOfSteps
3182 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3183 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3184 self.mesh.SetParameters(Parameters)
3186 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
3187 AngleInRadians, NbOfSteps, Tolerance)
3188 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
3191 ## Generates new elements by rotation of the elements of object around the axis
3192 # @param theObject object which elements should be sweeped.
3193 # It can be a mesh, a sub mesh or a group.
3194 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3195 # @param AngleInRadians the angle of Rotation
3196 # @param NbOfSteps number of steps
3197 # @param Tolerance tolerance
3198 # @param MakeGroups forces the generation of new groups from existing ones
3199 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3200 # of all steps, else - size of each step
3201 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3202 # @ingroup l2_modif_extrurev
3203 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3204 MakeGroups=False, TotalAngle=False):
3206 if isinstance(AngleInRadians,str):
3208 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3210 AngleInRadians = DegreesToRadians(AngleInRadians)
3211 if ( isinstance( theObject, Mesh )):
3212 theObject = theObject.GetMesh()
3213 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3214 Axis = self.smeshpyD.GetAxisStruct(Axis)
3215 Axis,AxisParameters = ParseAxisStruct(Axis)
3216 if TotalAngle and NbOfSteps:
3217 AngleInRadians /= NbOfSteps
3218 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3219 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3220 self.mesh.SetParameters(Parameters)
3222 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
3223 NbOfSteps, Tolerance)
3224 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3227 ## Generates new elements by rotation of the elements of object around the axis
3228 # @param theObject object which elements should be sweeped.
3229 # It can be a mesh, a sub mesh or a group.
3230 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3231 # @param AngleInRadians the angle of Rotation
3232 # @param NbOfSteps number of steps
3233 # @param Tolerance tolerance
3234 # @param MakeGroups forces the generation of new groups from existing ones
3235 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3236 # of all steps, else - size of each step
3237 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3238 # @ingroup l2_modif_extrurev
3239 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3240 MakeGroups=False, TotalAngle=False):
3242 if isinstance(AngleInRadians,str):
3244 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3246 AngleInRadians = DegreesToRadians(AngleInRadians)
3247 if ( isinstance( theObject, Mesh )):
3248 theObject = theObject.GetMesh()
3249 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3250 Axis = self.smeshpyD.GetAxisStruct(Axis)
3251 Axis,AxisParameters = ParseAxisStruct(Axis)
3252 if TotalAngle and NbOfSteps:
3253 AngleInRadians /= NbOfSteps
3254 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3255 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3256 self.mesh.SetParameters(Parameters)
3258 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
3259 NbOfSteps, Tolerance)
3260 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3263 ## Generates new elements by rotation of the elements of object around the axis
3264 # @param theObject object which elements should be sweeped.
3265 # It can be a mesh, a sub mesh or a group.
3266 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3267 # @param AngleInRadians the angle of Rotation
3268 # @param NbOfSteps number of steps
3269 # @param Tolerance tolerance
3270 # @param MakeGroups forces the generation of new groups from existing ones
3271 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3272 # of all steps, else - size of each step
3273 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3274 # @ingroup l2_modif_extrurev
3275 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3276 MakeGroups=False, TotalAngle=False):
3278 if isinstance(AngleInRadians,str):
3280 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3282 AngleInRadians = DegreesToRadians(AngleInRadians)
3283 if ( isinstance( theObject, Mesh )):
3284 theObject = theObject.GetMesh()
3285 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3286 Axis = self.smeshpyD.GetAxisStruct(Axis)
3287 Axis,AxisParameters = ParseAxisStruct(Axis)
3288 if TotalAngle and NbOfSteps:
3289 AngleInRadians /= NbOfSteps
3290 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3291 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3292 self.mesh.SetParameters(Parameters)
3294 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
3295 NbOfSteps, Tolerance)
3296 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3299 ## Generates new elements by extrusion of the elements with given ids
3300 # @param IDsOfElements the list of elements ids for extrusion
3301 # @param StepVector vector or DirStruct, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3302 # @param NbOfSteps the number of steps
3303 # @param MakeGroups forces the generation of new groups from existing ones
3304 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3305 # @ingroup l2_modif_extrurev
3306 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
3307 if IDsOfElements == []:
3308 IDsOfElements = self.GetElementsId()
3309 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3310 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3311 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3312 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3313 Parameters = StepVectorParameters + var_separator + Parameters
3314 self.mesh.SetParameters(Parameters)
3316 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
3317 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
3320 ## Generates new elements by extrusion of the elements with given ids
3321 # @param IDsOfElements is ids of elements
3322 # @param StepVector vector, defining the direction and value of extrusion
3323 # @param NbOfSteps the number of steps
3324 # @param ExtrFlags sets flags for extrusion
3325 # @param SewTolerance uses for comparing locations of nodes if flag
3326 # EXTRUSION_FLAG_SEW is set
3327 # @param MakeGroups forces the generation of new groups from existing ones
3328 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3329 # @ingroup l2_modif_extrurev
3330 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
3331 ExtrFlags, SewTolerance, MakeGroups=False):
3332 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3333 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3335 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
3336 ExtrFlags, SewTolerance)
3337 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
3338 ExtrFlags, SewTolerance)
3341 ## Generates new elements by extrusion of the elements which belong to the object
3342 # @param theObject the object which elements should be processed.
3343 # It can be a mesh, a sub mesh or a group.
3344 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3345 # @param NbOfSteps the number of steps
3346 # @param MakeGroups forces the generation of new groups from existing ones
3347 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3348 # @ingroup l2_modif_extrurev
3349 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3350 if ( isinstance( theObject, Mesh )):
3351 theObject = theObject.GetMesh()
3352 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3353 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3354 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3355 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3356 Parameters = StepVectorParameters + var_separator + Parameters
3357 self.mesh.SetParameters(Parameters)
3359 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3360 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
3363 ## Generates new elements by extrusion of the elements which belong to the object
3364 # @param theObject object which elements should be processed.
3365 # It can be a mesh, a sub mesh or a group.
3366 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3367 # @param NbOfSteps the number of steps
3368 # @param MakeGroups to generate new groups from existing ones
3369 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3370 # @ingroup l2_modif_extrurev
3371 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3372 if ( isinstance( theObject, Mesh )):
3373 theObject = theObject.GetMesh()
3374 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3375 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3376 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3377 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3378 Parameters = StepVectorParameters + var_separator + Parameters
3379 self.mesh.SetParameters(Parameters)
3381 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3382 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3385 ## Generates new elements by extrusion of the elements which belong to the object
3386 # @param theObject object which elements should be processed.
3387 # It can be a mesh, a sub mesh or a group.
3388 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3389 # @param NbOfSteps the number of steps
3390 # @param MakeGroups forces the generation of new groups from existing ones
3391 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3392 # @ingroup l2_modif_extrurev
3393 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3394 if ( isinstance( theObject, Mesh )):
3395 theObject = theObject.GetMesh()
3396 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3397 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3398 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3399 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3400 Parameters = StepVectorParameters + var_separator + Parameters
3401 self.mesh.SetParameters(Parameters)
3403 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3404 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3409 ## Generates new elements by extrusion of the given elements
3410 # The path of extrusion must be a meshed edge.
3411 # @param Base mesh or group, or submesh, or list of ids of elements for extrusion
3412 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3413 # @param NodeStart the start node from Path. Defines the direction of extrusion
3414 # @param HasAngles allows the shape to be rotated around the path
3415 # to get the resulting mesh in a helical fashion
3416 # @param Angles list of angles in radians
3417 # @param LinearVariation forces the computation of rotation angles as linear
3418 # variation of the given Angles along path steps
3419 # @param HasRefPoint allows using the reference point
3420 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3421 # The User can specify any point as the Reference Point.
3422 # @param MakeGroups forces the generation of new groups from existing ones
3423 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3424 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3425 # only SMESH::Extrusion_Error otherwise
3426 # @ingroup l2_modif_extrurev
3427 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3428 HasAngles, Angles, LinearVariation,
3429 HasRefPoint, RefPoint, MakeGroups, ElemType):
3430 Angles,AnglesParameters = ParseAngles(Angles)
3431 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3432 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3433 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3435 Parameters = AnglesParameters + var_separator + RefPointParameters
3436 self.mesh.SetParameters(Parameters)
3438 if (isinstance(Path, Mesh)): Path = Path.GetMesh()
3440 if isinstance(Base, list):
3442 if Base == []: IDsOfElements = self.GetElementsId()
3443 else: IDsOfElements = Base
3444 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3445 HasAngles, Angles, LinearVariation,
3446 HasRefPoint, RefPoint, MakeGroups, ElemType)
3448 if isinstance(Base, Mesh): Base = Base.GetMesh()
3449 if isinstance(Base, SMESH._objref_SMESH_Mesh) or isinstance(Base, SMESH._objref_SMESH_Group) or isinstance(Base, SMESH._objref_SMESH_subMesh):
3450 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3451 HasAngles, Angles, LinearVariation,
3452 HasRefPoint, RefPoint, MakeGroups, ElemType)
3454 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3457 ## Generates new elements by extrusion of the given elements
3458 # The path of extrusion must be a meshed edge.
3459 # @param IDsOfElements ids of elements
3460 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3461 # @param PathShape shape(edge) defines the sub-mesh for the path
3462 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3463 # @param HasAngles allows the shape to be rotated around the path
3464 # to get the resulting mesh in a helical fashion
3465 # @param Angles list of angles in radians
3466 # @param HasRefPoint allows using the reference point
3467 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3468 # The User can specify any point as the Reference Point.
3469 # @param MakeGroups forces the generation of new groups from existing ones
3470 # @param LinearVariation forces the computation of rotation angles as linear
3471 # variation of the given Angles along path steps
3472 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3473 # only SMESH::Extrusion_Error otherwise
3474 # @ingroup l2_modif_extrurev
3475 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3476 HasAngles, Angles, HasRefPoint, RefPoint,
3477 MakeGroups=False, LinearVariation=False):
3478 Angles,AnglesParameters = ParseAngles(Angles)
3479 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3480 if IDsOfElements == []:
3481 IDsOfElements = self.GetElementsId()
3482 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3483 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3485 if ( isinstance( PathMesh, Mesh )):
3486 PathMesh = PathMesh.GetMesh()
3487 if HasAngles and Angles and LinearVariation:
3488 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3490 Parameters = AnglesParameters + var_separator + RefPointParameters
3491 self.mesh.SetParameters(Parameters)
3493 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3494 PathShape, NodeStart, HasAngles,
3495 Angles, HasRefPoint, RefPoint)
3496 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3497 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3499 ## Generates new elements by extrusion of the elements which belong to the object
3500 # The path of extrusion must be a meshed edge.
3501 # @param theObject the object which elements should be processed.
3502 # It can be a mesh, a sub mesh or a group.
3503 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3504 # @param PathShape shape(edge) defines the sub-mesh for the path
3505 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3506 # @param HasAngles allows the shape to be rotated around the path
3507 # to get the resulting mesh in a helical fashion
3508 # @param Angles list of angles
3509 # @param HasRefPoint allows using the reference point
3510 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3511 # The User can specify any point as the Reference Point.
3512 # @param MakeGroups forces the generation of new groups from existing ones
3513 # @param LinearVariation forces the computation of rotation angles as linear
3514 # variation of the given Angles along path steps
3515 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3516 # only SMESH::Extrusion_Error otherwise
3517 # @ingroup l2_modif_extrurev
3518 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3519 HasAngles, Angles, HasRefPoint, RefPoint,
3520 MakeGroups=False, LinearVariation=False):
3521 Angles,AnglesParameters = ParseAngles(Angles)
3522 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3523 if ( isinstance( theObject, Mesh )):
3524 theObject = theObject.GetMesh()
3525 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3526 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3527 if ( isinstance( PathMesh, Mesh )):
3528 PathMesh = PathMesh.GetMesh()
3529 if HasAngles and Angles and LinearVariation:
3530 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3532 Parameters = AnglesParameters + var_separator + RefPointParameters
3533 self.mesh.SetParameters(Parameters)
3535 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3536 PathShape, NodeStart, HasAngles,
3537 Angles, HasRefPoint, RefPoint)
3538 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3539 NodeStart, HasAngles, Angles, HasRefPoint,
3542 ## Generates new elements by extrusion of the elements which belong to the object
3543 # The path of extrusion must be a meshed edge.
3544 # @param theObject the object which elements should be processed.
3545 # It can be a mesh, a sub mesh or a group.
3546 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3547 # @param PathShape shape(edge) defines the sub-mesh for the path
3548 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3549 # @param HasAngles allows the shape to be rotated around the path
3550 # to get the resulting mesh in a helical fashion
3551 # @param Angles list of angles
3552 # @param HasRefPoint allows using the reference point
3553 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3554 # The User can specify any point as the Reference Point.
3555 # @param MakeGroups forces the generation of new groups from existing ones
3556 # @param LinearVariation forces the computation of rotation angles as linear
3557 # variation of the given Angles along path steps
3558 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3559 # only SMESH::Extrusion_Error otherwise
3560 # @ingroup l2_modif_extrurev
3561 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3562 HasAngles, Angles, HasRefPoint, RefPoint,
3563 MakeGroups=False, LinearVariation=False):
3564 Angles,AnglesParameters = ParseAngles(Angles)
3565 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3566 if ( isinstance( theObject, Mesh )):
3567 theObject = theObject.GetMesh()
3568 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3569 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3570 if ( isinstance( PathMesh, Mesh )):
3571 PathMesh = PathMesh.GetMesh()
3572 if HasAngles and Angles and LinearVariation:
3573 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3575 Parameters = AnglesParameters + var_separator + RefPointParameters
3576 self.mesh.SetParameters(Parameters)
3578 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3579 PathShape, NodeStart, HasAngles,
3580 Angles, HasRefPoint, RefPoint)
3581 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3582 NodeStart, HasAngles, Angles, HasRefPoint,
3585 ## Generates new elements by extrusion of the elements which belong to the object
3586 # The path of extrusion must be a meshed edge.
3587 # @param theObject the object which elements should be processed.
3588 # It can be a mesh, a sub mesh or a group.
3589 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3590 # @param PathShape shape(edge) defines the sub-mesh for the path
3591 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3592 # @param HasAngles allows the shape to be rotated around the path
3593 # to get the resulting mesh in a helical fashion
3594 # @param Angles list of angles
3595 # @param HasRefPoint allows using the reference point
3596 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3597 # The User can specify any point as the Reference Point.
3598 # @param MakeGroups forces the generation of new groups from existing ones
3599 # @param LinearVariation forces the computation of rotation angles as linear
3600 # variation of the given Angles along path steps
3601 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3602 # only SMESH::Extrusion_Error otherwise
3603 # @ingroup l2_modif_extrurev
3604 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3605 HasAngles, Angles, HasRefPoint, RefPoint,
3606 MakeGroups=False, LinearVariation=False):
3607 Angles,AnglesParameters = ParseAngles(Angles)
3608 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3609 if ( isinstance( theObject, Mesh )):
3610 theObject = theObject.GetMesh()
3611 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3612 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3613 if ( isinstance( PathMesh, Mesh )):
3614 PathMesh = PathMesh.GetMesh()
3615 if HasAngles and Angles and LinearVariation:
3616 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3618 Parameters = AnglesParameters + var_separator + RefPointParameters
3619 self.mesh.SetParameters(Parameters)
3621 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3622 PathShape, NodeStart, HasAngles,
3623 Angles, HasRefPoint, RefPoint)
3624 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3625 NodeStart, HasAngles, Angles, HasRefPoint,
3628 ## Creates a symmetrical copy of mesh elements
3629 # @param IDsOfElements list of elements ids
3630 # @param Mirror is AxisStruct or geom object(point, line, plane)
3631 # @param theMirrorType is POINT, AXIS or PLANE
3632 # If the Mirror is a geom object this parameter is unnecessary
3633 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3634 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3635 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3636 # @ingroup l2_modif_trsf
3637 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3638 if IDsOfElements == []:
3639 IDsOfElements = self.GetElementsId()
3640 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3641 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3642 Mirror,Parameters = ParseAxisStruct(Mirror)
3643 self.mesh.SetParameters(Parameters)
3644 if Copy and MakeGroups:
3645 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3646 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3649 ## Creates a new mesh by a symmetrical copy of mesh elements
3650 # @param IDsOfElements the list of elements ids
3651 # @param Mirror is AxisStruct or geom object (point, line, plane)
3652 # @param theMirrorType is POINT, AXIS or PLANE
3653 # If the Mirror is a geom object this parameter is unnecessary
3654 # @param MakeGroups to generate new groups from existing ones
3655 # @param NewMeshName a name of the new mesh to create
3656 # @return instance of Mesh class
3657 # @ingroup l2_modif_trsf
3658 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3659 if IDsOfElements == []:
3660 IDsOfElements = self.GetElementsId()
3661 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3662 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3663 Mirror,Parameters = ParseAxisStruct(Mirror)
3664 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3665 MakeGroups, NewMeshName)
3666 mesh.SetParameters(Parameters)
3667 return Mesh(self.smeshpyD,self.geompyD,mesh)
3669 ## Creates a symmetrical copy of the object
3670 # @param theObject mesh, submesh or group
3671 # @param Mirror AxisStruct or geom object (point, line, plane)
3672 # @param theMirrorType is POINT, AXIS or PLANE
3673 # If the Mirror is a geom object this parameter is unnecessary
3674 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3675 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3676 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3677 # @ingroup l2_modif_trsf
3678 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3679 if ( isinstance( theObject, Mesh )):
3680 theObject = theObject.GetMesh()
3681 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3682 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3683 Mirror,Parameters = ParseAxisStruct(Mirror)
3684 self.mesh.SetParameters(Parameters)
3685 if Copy and MakeGroups:
3686 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3687 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3690 ## Creates a new mesh by a symmetrical copy of the object
3691 # @param theObject mesh, submesh or group
3692 # @param Mirror AxisStruct or geom object (point, line, plane)
3693 # @param theMirrorType POINT, AXIS or PLANE
3694 # If the Mirror is a geom object this parameter is unnecessary
3695 # @param MakeGroups forces the generation of new groups from existing ones
3696 # @param NewMeshName the name of the new mesh to create
3697 # @return instance of Mesh class
3698 # @ingroup l2_modif_trsf
3699 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3700 if ( isinstance( theObject, Mesh )):
3701 theObject = theObject.GetMesh()
3702 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3703 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3704 Mirror,Parameters = ParseAxisStruct(Mirror)
3705 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3706 MakeGroups, NewMeshName)
3707 mesh.SetParameters(Parameters)
3708 return Mesh( self.smeshpyD,self.geompyD,mesh )
3710 ## Translates the elements
3711 # @param IDsOfElements list of elements ids
3712 # @param Vector the direction of translation (DirStruct or vector)
3713 # @param Copy allows copying the translated elements
3714 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3715 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3716 # @ingroup l2_modif_trsf
3717 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3718 if IDsOfElements == []:
3719 IDsOfElements = self.GetElementsId()
3720 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3721 Vector = self.smeshpyD.GetDirStruct(Vector)
3722 Vector,Parameters = ParseDirStruct(Vector)
3723 self.mesh.SetParameters(Parameters)
3724 if Copy and MakeGroups:
3725 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3726 self.editor.Translate(IDsOfElements, Vector, Copy)
3729 ## Creates a new mesh of translated elements
3730 # @param IDsOfElements list of elements ids
3731 # @param Vector the direction of translation (DirStruct or vector)
3732 # @param MakeGroups forces the generation of new groups from existing ones
3733 # @param NewMeshName the name of the newly created mesh
3734 # @return instance of Mesh class
3735 # @ingroup l2_modif_trsf
3736 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3737 if IDsOfElements == []:
3738 IDsOfElements = self.GetElementsId()
3739 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3740 Vector = self.smeshpyD.GetDirStruct(Vector)
3741 Vector,Parameters = ParseDirStruct(Vector)
3742 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3743 mesh.SetParameters(Parameters)
3744 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3746 ## Translates the object
3747 # @param theObject the object to translate (mesh, submesh, or group)
3748 # @param Vector direction of translation (DirStruct or geom vector)
3749 # @param Copy allows copying the translated elements
3750 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3751 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3752 # @ingroup l2_modif_trsf
3753 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3754 if ( isinstance( theObject, Mesh )):
3755 theObject = theObject.GetMesh()
3756 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3757 Vector = self.smeshpyD.GetDirStruct(Vector)
3758 Vector,Parameters = ParseDirStruct(Vector)
3759 self.mesh.SetParameters(Parameters)
3760 if Copy and MakeGroups:
3761 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3762 self.editor.TranslateObject(theObject, Vector, Copy)
3765 ## Creates a new mesh from the translated object
3766 # @param theObject the object to translate (mesh, submesh, or group)
3767 # @param Vector the direction of translation (DirStruct or geom vector)
3768 # @param MakeGroups forces the generation of new groups from existing ones
3769 # @param NewMeshName the name of the newly created mesh
3770 # @return instance of Mesh class
3771 # @ingroup l2_modif_trsf
3772 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3773 if (isinstance(theObject, Mesh)):
3774 theObject = theObject.GetMesh()
3775 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3776 Vector = self.smeshpyD.GetDirStruct(Vector)
3777 Vector,Parameters = ParseDirStruct(Vector)
3778 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3779 mesh.SetParameters(Parameters)
3780 return Mesh( self.smeshpyD, self.geompyD, mesh )
3784 ## Scales the object
3785 # @param theObject - the object to translate (mesh, submesh, or group)
3786 # @param thePoint - base point for scale
3787 # @param theScaleFact - list of 1-3 scale factors for axises
3788 # @param Copy - allows copying the translated elements
3789 # @param MakeGroups - forces the generation of new groups from existing
3791 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3792 # empty list otherwise
3793 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3794 if ( isinstance( theObject, Mesh )):
3795 theObject = theObject.GetMesh()
3796 if ( isinstance( theObject, list )):
3797 theObject = self.GetIDSource(theObject, SMESH.ALL)
3799 thePoint, Parameters = ParsePointStruct(thePoint)
3800 self.mesh.SetParameters(Parameters)
3802 if Copy and MakeGroups:
3803 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3804 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3807 ## Creates a new mesh from the translated object
3808 # @param theObject - the object to translate (mesh, submesh, or group)
3809 # @param thePoint - base point for scale
3810 # @param theScaleFact - list of 1-3 scale factors for axises
3811 # @param MakeGroups - forces the generation of new groups from existing ones
3812 # @param NewMeshName - the name of the newly created mesh
3813 # @return instance of Mesh class
3814 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3815 if (isinstance(theObject, Mesh)):
3816 theObject = theObject.GetMesh()
3817 if ( isinstance( theObject, list )):
3818 theObject = self.GetIDSource(theObject,SMESH.ALL)
3820 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3821 MakeGroups, NewMeshName)
3822 #mesh.SetParameters(Parameters)
3823 return Mesh( self.smeshpyD, self.geompyD, mesh )
3827 ## Rotates the elements
3828 # @param IDsOfElements list of elements ids
3829 # @param Axis the axis of rotation (AxisStruct or geom line)
3830 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3831 # @param Copy allows copying the rotated elements
3832 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3833 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3834 # @ingroup l2_modif_trsf
3835 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3837 if isinstance(AngleInRadians,str):
3839 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3841 AngleInRadians = DegreesToRadians(AngleInRadians)
3842 if IDsOfElements == []:
3843 IDsOfElements = self.GetElementsId()
3844 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3845 Axis = self.smeshpyD.GetAxisStruct(Axis)
3846 Axis,AxisParameters = ParseAxisStruct(Axis)
3847 Parameters = AxisParameters + var_separator + Parameters
3848 self.mesh.SetParameters(Parameters)
3849 if Copy and MakeGroups:
3850 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3851 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3854 ## Creates a new mesh of rotated elements
3855 # @param IDsOfElements list of element ids
3856 # @param Axis the axis of rotation (AxisStruct or geom line)
3857 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3858 # @param MakeGroups forces the generation of new groups from existing ones
3859 # @param NewMeshName the name of the newly created mesh
3860 # @return instance of Mesh class
3861 # @ingroup l2_modif_trsf
3862 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3864 if isinstance(AngleInRadians,str):
3866 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3868 AngleInRadians = DegreesToRadians(AngleInRadians)
3869 if IDsOfElements == []:
3870 IDsOfElements = self.GetElementsId()
3871 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3872 Axis = self.smeshpyD.GetAxisStruct(Axis)
3873 Axis,AxisParameters = ParseAxisStruct(Axis)
3874 Parameters = AxisParameters + var_separator + Parameters
3875 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3876 MakeGroups, NewMeshName)
3877 mesh.SetParameters(Parameters)
3878 return Mesh( self.smeshpyD, self.geompyD, mesh )
3880 ## Rotates the object
3881 # @param theObject the object to rotate( mesh, submesh, or group)
3882 # @param Axis the axis of rotation (AxisStruct or geom line)
3883 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3884 # @param Copy allows copying the rotated elements
3885 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3886 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3887 # @ingroup l2_modif_trsf
3888 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3890 if isinstance(AngleInRadians,str):
3892 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3894 AngleInRadians = DegreesToRadians(AngleInRadians)
3895 if (isinstance(theObject, Mesh)):
3896 theObject = theObject.GetMesh()
3897 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3898 Axis = self.smeshpyD.GetAxisStruct(Axis)
3899 Axis,AxisParameters = ParseAxisStruct(Axis)
3900 Parameters = AxisParameters + ":" + Parameters
3901 self.mesh.SetParameters(Parameters)
3902 if Copy and MakeGroups:
3903 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3904 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3907 ## Creates a new mesh from the rotated object
3908 # @param theObject the object to rotate (mesh, submesh, or group)
3909 # @param Axis the axis of rotation (AxisStruct or geom line)
3910 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3911 # @param MakeGroups forces the generation of new groups from existing ones
3912 # @param NewMeshName the name of the newly created mesh
3913 # @return instance of Mesh class
3914 # @ingroup l2_modif_trsf
3915 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3917 if isinstance(AngleInRadians,str):
3919 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3921 AngleInRadians = DegreesToRadians(AngleInRadians)
3922 if (isinstance( theObject, Mesh )):
3923 theObject = theObject.GetMesh()
3924 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3925 Axis = self.smeshpyD.GetAxisStruct(Axis)
3926 Axis,AxisParameters = ParseAxisStruct(Axis)
3927 Parameters = AxisParameters + ":" + Parameters
3928 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3929 MakeGroups, NewMeshName)
3930 mesh.SetParameters(Parameters)
3931 return Mesh( self.smeshpyD, self.geompyD, mesh )
3933 ## Finds groups of ajacent nodes within Tolerance.
3934 # @param Tolerance the value of tolerance
3935 # @return the list of groups of nodes
3936 # @ingroup l2_modif_trsf
3937 def FindCoincidentNodes (self, Tolerance):
3938 return self.editor.FindCoincidentNodes(Tolerance)
3940 ## Finds groups of ajacent nodes within Tolerance.
3941 # @param Tolerance the value of tolerance
3942 # @param SubMeshOrGroup SubMesh or Group
3943 # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
3944 # @return the list of groups of nodes
3945 # @ingroup l2_modif_trsf
3946 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
3947 if (isinstance( SubMeshOrGroup, Mesh )):
3948 SubMeshOrGroup = SubMeshOrGroup.GetMesh()
3949 if not isinstance( exceptNodes, list):
3950 exceptNodes = [ exceptNodes ]
3951 if exceptNodes and isinstance( exceptNodes[0], int):
3952 exceptNodes = [ self.GetIDSource( exceptNodes, SMESH.NODE)]
3953 return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes)
3956 # @param GroupsOfNodes the list of groups of nodes
3957 # @ingroup l2_modif_trsf
3958 def MergeNodes (self, GroupsOfNodes):
3959 self.editor.MergeNodes(GroupsOfNodes)
3961 ## Finds the elements built on the same nodes.
3962 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3963 # @return a list of groups of equal elements
3964 # @ingroup l2_modif_trsf
3965 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3966 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3967 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3968 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3970 ## Merges elements in each given group.
3971 # @param GroupsOfElementsID groups of elements for merging
3972 # @ingroup l2_modif_trsf
3973 def MergeElements(self, GroupsOfElementsID):
3974 self.editor.MergeElements(GroupsOfElementsID)
3976 ## Leaves one element and removes all other elements built on the same nodes.
3977 # @ingroup l2_modif_trsf
3978 def MergeEqualElements(self):
3979 self.editor.MergeEqualElements()
3981 ## Sews free borders
3982 # @return SMESH::Sew_Error
3983 # @ingroup l2_modif_trsf
3984 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3985 FirstNodeID2, SecondNodeID2, LastNodeID2,
3986 CreatePolygons, CreatePolyedrs):
3987 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3988 FirstNodeID2, SecondNodeID2, LastNodeID2,
3989 CreatePolygons, CreatePolyedrs)
3991 ## Sews conform free borders
3992 # @return SMESH::Sew_Error
3993 # @ingroup l2_modif_trsf
3994 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3995 FirstNodeID2, SecondNodeID2):
3996 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3997 FirstNodeID2, SecondNodeID2)
3999 ## Sews border to side
4000 # @return SMESH::Sew_Error
4001 # @ingroup l2_modif_trsf
4002 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
4003 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
4004 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
4005 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
4007 ## Sews two sides of a mesh. The nodes belonging to Side1 are
4008 # merged with the nodes of elements of Side2.
4009 # The number of elements in theSide1 and in theSide2 must be
4010 # equal and they should have similar nodal connectivity.
4011 # The nodes to merge should belong to side borders and
4012 # the first node should be linked to the second.
4013 # @return SMESH::Sew_Error
4014 # @ingroup l2_modif_trsf
4015 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
4016 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
4017 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
4018 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
4019 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
4020 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
4022 ## Sets new nodes for the given element.
4023 # @param ide the element id
4024 # @param newIDs nodes ids
4025 # @return If the number of nodes does not correspond to the type of element - returns false
4026 # @ingroup l2_modif_edit
4027 def ChangeElemNodes(self, ide, newIDs):
4028 return self.editor.ChangeElemNodes(ide, newIDs)
4030 ## If during the last operation of MeshEditor some nodes were
4031 # created, this method returns the list of their IDs, \n
4032 # if new nodes were not created - returns empty list
4033 # @return the list of integer values (can be empty)
4034 # @ingroup l1_auxiliary
4035 def GetLastCreatedNodes(self):
4036 return self.editor.GetLastCreatedNodes()
4038 ## If during the last operation of MeshEditor some elements were
4039 # created this method returns the list of their IDs, \n
4040 # if new elements were not created - returns empty list
4041 # @return the list of integer values (can be empty)
4042 # @ingroup l1_auxiliary
4043 def GetLastCreatedElems(self):
4044 return self.editor.GetLastCreatedElems()
4046 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4047 # @param theNodes identifiers of nodes to be doubled
4048 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
4049 # nodes. If list of element identifiers is empty then nodes are doubled but
4050 # they not assigned to elements
4051 # @return TRUE if operation has been completed successfully, FALSE otherwise
4052 # @ingroup l2_modif_edit
4053 def DoubleNodes(self, theNodes, theModifiedElems):
4054 return self.editor.DoubleNodes(theNodes, theModifiedElems)
4056 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4057 # This method provided for convenience works as DoubleNodes() described above.
4058 # @param theNodeId identifiers of node to be doubled
4059 # @param theModifiedElems identifiers of elements to be updated
4060 # @return TRUE if operation has been completed successfully, FALSE otherwise
4061 # @ingroup l2_modif_edit
4062 def DoubleNode(self, theNodeId, theModifiedElems):
4063 return self.editor.DoubleNode(theNodeId, theModifiedElems)
4065 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4066 # This method provided for convenience works as DoubleNodes() described above.
4067 # @param theNodes group of nodes to be doubled
4068 # @param theModifiedElems group of elements to be updated.
4069 # @param theMakeGroup forces the generation of a group containing new nodes.
4070 # @return TRUE or a created group if operation has been completed successfully,
4071 # FALSE or None otherwise
4072 # @ingroup l2_modif_edit
4073 def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
4075 return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
4076 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
4078 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4079 # This method provided for convenience works as DoubleNodes() described above.
4080 # @param theNodes list of groups of nodes to be doubled
4081 # @param theModifiedElems list of groups of elements to be updated.
4082 # @return TRUE if operation has been completed successfully, FALSE otherwise
4083 # @ingroup l2_modif_edit
4084 def DoubleNodeGroups(self, theNodes, theModifiedElems, theMakeGroup=False):
4086 return self.editor.DoubleNodeGroupsNew(theNodes, theModifiedElems)
4087 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
4089 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4090 # @param theElems - the list of elements (edges or faces) to be replicated
4091 # The nodes for duplication could be found from these elements
4092 # @param theNodesNot - list of nodes to NOT replicate
4093 # @param theAffectedElems - the list of elements (cells and edges) to which the
4094 # replicated nodes should be associated to.
4095 # @return TRUE if operation has been completed successfully, FALSE otherwise
4096 # @ingroup l2_modif_edit
4097 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
4098 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
4100 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4101 # @param theElems - the list of elements (edges or faces) to be replicated
4102 # The nodes for duplication could be found from these elements
4103 # @param theNodesNot - list of nodes to NOT replicate
4104 # @param theShape - shape to detect affected elements (element which geometric center
4105 # located on or inside shape).
4106 # The replicated nodes should be associated to affected elements.
4107 # @return TRUE if operation has been completed successfully, FALSE otherwise
4108 # @ingroup l2_modif_edit
4109 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
4110 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
4112 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4113 # This method provided for convenience works as DoubleNodes() described above.
4114 # @param theElems - group of of elements (edges or faces) to be replicated
4115 # @param theNodesNot - group of nodes not to replicated
4116 # @param theAffectedElems - group of elements to which the replicated nodes
4117 # should be associated to.
4118 # @param theMakeGroup forces the generation of a group containing new elements.
4119 # @return TRUE or a created group if operation has been completed successfully,
4120 # FALSE or None otherwise
4121 # @ingroup l2_modif_edit
4122 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4124 return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
4125 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
4127 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4128 # This method provided for convenience works as DoubleNodes() described above.
4129 # @param theElems - group of of elements (edges or faces) to be replicated
4130 # @param theNodesNot - group of nodes not to replicated
4131 # @param theShape - shape to detect affected elements (element which geometric center
4132 # located on or inside shape).
4133 # The replicated nodes should be associated to affected elements.
4134 # @ingroup l2_modif_edit
4135 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
4136 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
4138 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4139 # This method provided for convenience works as DoubleNodes() described above.
4140 # @param theElems - list of groups of elements (edges or faces) to be replicated
4141 # @param theNodesNot - list of groups of nodes not to replicated
4142 # @param theAffectedElems - group of elements to which the replicated nodes
4143 # should be associated to.
4144 # @param theMakeGroup forces the generation of a group containing new elements.
4145 # @return TRUE or a created group if operation has been completed successfully,
4146 # FALSE or None otherwise
4147 # @ingroup l2_modif_edit
4148 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4150 return self.editor.DoubleNodeElemGroupsNew(theElems, theNodesNot, theAffectedElems)
4151 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
4153 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4154 # This method provided for convenience works as DoubleNodes() described above.
4155 # @param theElems - list of groups of elements (edges or faces) to be replicated
4156 # @param theNodesNot - list of groups of nodes not to replicated
4157 # @param theShape - shape to detect affected elements (element which geometric center
4158 # located on or inside shape).
4159 # The replicated nodes should be associated to affected elements.
4160 # @return TRUE if operation has been completed successfully, FALSE otherwise
4161 # @ingroup l2_modif_edit
4162 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
4163 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
4165 ## Double nodes on shared faces between groups of volumes and create flat elements on demand.
4166 # The list of groups must describe a partition of the mesh volumes.
4167 # The nodes of the internal faces at the boundaries of the groups are doubled.
4168 # In option, the internal faces are replaced by flat elements.
4169 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4170 # @param theDomains - list of groups of volumes
4171 # @param createJointElems - if TRUE, create the elements
4172 # @return TRUE if operation has been completed successfully, FALSE otherwise
4173 def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems ):
4174 return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems )
4176 ## Double nodes on some external faces and create flat elements.
4177 # Flat elements are mainly used by some types of mechanic calculations.
4179 # Each group of the list must be constituted of faces.
4180 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4181 # @param theGroupsOfFaces - list of groups of faces
4182 # @return TRUE if operation has been completed successfully, FALSE otherwise
4183 def CreateFlatElementsOnFacesGroups(self, theGroupsOfFaces ):
4184 return self.editor.CreateFlatElementsOnFacesGroups( theGroupsOfFaces )
4186 def _valueFromFunctor(self, funcType, elemId):
4187 fn = self.smeshpyD.GetFunctor(funcType)
4188 fn.SetMesh(self.mesh)
4189 if fn.GetElementType() == self.GetElementType(elemId, True):
4190 val = fn.GetValue(elemId)
4195 ## Get length of 1D element.
4196 # @param elemId mesh element ID
4197 # @return element's length value
4198 # @ingroup l1_measurements
4199 def GetLength(self, elemId):
4200 return self._valueFromFunctor(SMESH.FT_Length, elemId)
4202 ## Get area of 2D element.
4203 # @param elemId mesh element ID
4204 # @return element's area value
4205 # @ingroup l1_measurements
4206 def GetArea(self, elemId):
4207 return self._valueFromFunctor(SMESH.FT_Area, elemId)
4209 ## Get volume of 3D element.
4210 # @param elemId mesh element ID
4211 # @return element's volume value
4212 # @ingroup l1_measurements
4213 def GetVolume(self, elemId):
4214 return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
4216 ## Get maximum element length.
4217 # @param elemId mesh element ID
4218 # @return element's maximum length value
4219 # @ingroup l1_measurements
4220 def GetMaxElementLength(self, elemId):
4221 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4222 ftype = SMESH.FT_MaxElementLength3D
4224 ftype = SMESH.FT_MaxElementLength2D
4225 return self._valueFromFunctor(ftype, elemId)
4227 ## Get aspect ratio of 2D or 3D element.
4228 # @param elemId mesh element ID
4229 # @return element's aspect ratio value
4230 # @ingroup l1_measurements
4231 def GetAspectRatio(self, elemId):
4232 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4233 ftype = SMESH.FT_AspectRatio3D
4235 ftype = SMESH.FT_AspectRatio
4236 return self._valueFromFunctor(ftype, elemId)
4238 ## Get warping angle of 2D element.
4239 # @param elemId mesh element ID
4240 # @return element's warping angle value
4241 # @ingroup l1_measurements
4242 def GetWarping(self, elemId):
4243 return self._valueFromFunctor(SMESH.FT_Warping, elemId)
4245 ## Get minimum angle of 2D element.
4246 # @param elemId mesh element ID
4247 # @return element's minimum angle value
4248 # @ingroup l1_measurements
4249 def GetMinimumAngle(self, elemId):
4250 return self._valueFromFunctor(SMESH.FT_MinimumAngle, elemId)
4252 ## Get taper of 2D element.
4253 # @param elemId mesh element ID
4254 # @return element's taper value
4255 # @ingroup l1_measurements
4256 def GetTaper(self, elemId):
4257 return self._valueFromFunctor(SMESH.FT_Taper, elemId)
4259 ## Get skew of 2D element.
4260 # @param elemId mesh element ID
4261 # @return element's skew value
4262 # @ingroup l1_measurements
4263 def GetSkew(self, elemId):
4264 return self._valueFromFunctor(SMESH.FT_Skew, elemId)
4266 ## The mother class to define algorithm, it is not recommended to use it directly.
4269 # @ingroup l2_algorithms
4270 class Mesh_Algorithm:
4271 # @class Mesh_Algorithm
4272 # @brief Class Mesh_Algorithm
4274 #def __init__(self,smesh):
4282 ## Finds a hypothesis in the study by its type name and parameters.
4283 # Finds only the hypotheses created in smeshpyD engine.
4284 # @return SMESH.SMESH_Hypothesis
4285 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
4286 study = smeshpyD.GetCurrentStudy()
4287 #to do: find component by smeshpyD object, not by its data type
4288 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4289 if scomp is not None:
4290 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
4291 # Check if the root label of the hypotheses exists
4292 if res and hypRoot is not None:
4293 iter = study.NewChildIterator(hypRoot)
4294 # Check all published hypotheses
4296 hypo_so_i = iter.Value()
4297 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
4298 if attr is not None:
4299 anIOR = attr.Value()
4300 hypo_o_i = salome.orb.string_to_object(anIOR)
4301 if hypo_o_i is not None:
4302 # Check if this is a hypothesis
4303 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
4304 if hypo_i is not None:
4305 # Check if the hypothesis belongs to current engine
4306 if smeshpyD.GetObjectId(hypo_i) > 0:
4307 # Check if this is the required hypothesis
4308 if hypo_i.GetName() == hypname:
4310 if CompareMethod(hypo_i, args):
4324 ## Finds the algorithm in the study by its type name.
4325 # Finds only the algorithms, which have been created in smeshpyD engine.
4326 # @return SMESH.SMESH_Algo
4327 def FindAlgorithm (self, algoname, smeshpyD):
4328 study = smeshpyD.GetCurrentStudy()
4329 #to do: find component by smeshpyD object, not by its data type
4330 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4331 if scomp is not None:
4332 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
4333 # Check if the root label of the algorithms exists
4334 if res and hypRoot is not None:
4335 iter = study.NewChildIterator(hypRoot)
4336 # Check all published algorithms
4338 algo_so_i = iter.Value()
4339 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
4340 if attr is not None:
4341 anIOR = attr.Value()
4342 algo_o_i = salome.orb.string_to_object(anIOR)
4343 if algo_o_i is not None:
4344 # Check if this is an algorithm
4345 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
4346 if algo_i is not None:
4347 # Checks if the algorithm belongs to the current engine
4348 if smeshpyD.GetObjectId(algo_i) > 0:
4349 # Check if this is the required algorithm
4350 if algo_i.GetName() == algoname:
4363 ## If the algorithm is global, returns 0; \n
4364 # else returns the submesh associated to this algorithm.
4365 def GetSubMesh(self):
4368 ## Returns the wrapped mesher.
4369 def GetAlgorithm(self):
4372 ## Gets the list of hypothesis that can be used with this algorithm
4373 def GetCompatibleHypothesis(self):
4376 mylist = self.algo.GetCompatibleHypothesis()
4379 ## Gets the name of the algorithm
4383 ## Sets the name to the algorithm
4384 def SetName(self, name):
4385 self.mesh.smeshpyD.SetName(self.algo, name)
4387 ## Gets the id of the algorithm
4389 return self.algo.GetId()
4392 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
4394 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
4395 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
4397 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
4399 self.Assign(algo, mesh, geom)
4403 def Assign(self, algo, mesh, geom):
4405 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
4414 name = GetName(geom)
4418 if not name and geom.GetShapeType() != geompyDC.GEOM.COMPOUND:
4419 # for all groups SubShapeName() returns "Compound_-1"
4420 name = mesh.geompyD.SubShapeName(geom, piece)
4422 name = "%s_%s"%(geom.GetShapeType(), id(geom)%10000)
4423 # publish geom of sub-mesh (issue 0021122)
4424 if not self.geom.IsSame( self.mesh.geom ) and not self.geom.GetStudyEntry():
4425 studyID = self.mesh.smeshpyD.GetCurrentStudy()._get_StudyId()
4426 if studyID != self.mesh.geompyD.myStudyId:
4427 self.mesh.geompyD.init_geom( self.mesh.smeshpyD.GetCurrentStudy())
4428 self.mesh.geompyD.addToStudyInFather( self.mesh.geom, self.geom, name )
4430 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
4432 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
4433 TreatHypoStatus( status, algo.GetName(), name, True )
4435 def CompareHyp (self, hyp, args):
4436 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
4439 def CompareEqualHyp (self, hyp, args):
4443 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
4444 UseExisting=0, CompareMethod=""):
4447 if CompareMethod == "": CompareMethod = self.CompareHyp
4448 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
4451 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
4457 a = a + s + str(args[i])
4461 self.mesh.smeshpyD.SetName(hypo, hyp + a)
4465 geomName = GetName(self.geom)
4466 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
4467 TreatHypoStatus( status, GetName(hypo), geomName, 0 )
4470 ## Returns entry of the shape to mesh in the study
4471 def MainShapeEntry(self):
4473 if not self.mesh or not self.mesh.GetMesh(): return entry
4474 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
4475 study = self.mesh.smeshpyD.GetCurrentStudy()
4476 ior = salome.orb.object_to_string( self.mesh.GetShape() )
4477 sobj = study.FindObjectIOR(ior)
4478 if sobj: entry = sobj.GetID()
4479 if not entry: return ""
4482 ## Defines "ViscousLayers" hypothesis to give parameters of layers of prisms to build
4483 # near mesh boundary. This hypothesis can be used by several 3D algorithms:
4484 # NETGEN 3D, GHS3D, Hexahedron(i,j,k)
4485 # @param thickness total thickness of layers of prisms
4486 # @param numberOfLayers number of layers of prisms
4487 # @param stretchFactor factor (>1.0) of growth of layer thickness towards inside of mesh
4488 # @param ignoreFaces geometrical face (or their ids) not to generate layers on
4489 # @ingroup l3_hypos_additi
4490 def ViscousLayers(self, thickness, numberOfLayers, stretchFactor, ignoreFaces=[]):
4491 if not isinstance(self.algo, SMESH._objref_SMESH_3D_Algo):
4492 raise TypeError, "ViscousLayers are supported by 3D algorithms only"
4493 if not "ViscousLayers" in self.GetCompatibleHypothesis():
4494 raise TypeError, "ViscousLayers are not supported by %s"%self.algo.GetName()
4495 if ignoreFaces and isinstance( ignoreFaces[0], geompyDC.GEOM._objref_GEOM_Object ):
4496 ignoreFaces = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, f) for f in ignoreFaces ]
4497 hyp = self.Hypothesis("ViscousLayers",
4498 [thickness, numberOfLayers, stretchFactor, ignoreFaces])
4499 hyp.SetTotalThickness(thickness)
4500 hyp.SetNumberLayers(numberOfLayers)
4501 hyp.SetStretchFactor(stretchFactor)
4502 hyp.SetIgnoreFaces(ignoreFaces)
4505 # Public class: Mesh_Segment
4506 # --------------------------
4508 ## Class to define a segment 1D algorithm for discretization
4511 # @ingroup l3_algos_basic
4512 class Mesh_Segment(Mesh_Algorithm):
4514 ## Private constructor.
4515 def __init__(self, mesh, geom=0):
4516 Mesh_Algorithm.__init__(self)
4517 self.Create(mesh, geom, "Regular_1D")
4519 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
4520 # @param l for the length of segments that cut an edge
4521 # @param UseExisting if ==true - searches for an existing hypothesis created with
4522 # the same parameters, else (default) - creates a new one
4523 # @param p precision, used for calculation of the number of segments.
4524 # The precision should be a positive, meaningful value within the range [0,1].
4525 # In general, the number of segments is calculated with the formula:
4526 # nb = ceil((edge_length / l) - p)
4527 # Function ceil rounds its argument to the higher integer.
4528 # So, p=0 means rounding of (edge_length / l) to the higher integer,
4529 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
4530 # p=1 means rounding of (edge_length / l) to the lower integer.
4531 # Default value is 1e-07.
4532 # @return an instance of StdMeshers_LocalLength hypothesis
4533 # @ingroup l3_hypos_1dhyps
4534 def LocalLength(self, l, UseExisting=0, p=1e-07):
4535 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
4536 CompareMethod=self.CompareLocalLength)
4542 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
4543 def CompareLocalLength(self, hyp, args):
4544 if IsEqual(hyp.GetLength(), args[0]):
4545 return IsEqual(hyp.GetPrecision(), args[1])
4548 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
4549 # @param length is optional maximal allowed length of segment, if it is omitted
4550 # the preestimated length is used that depends on geometry size
4551 # @param UseExisting if ==true - searches for an existing hypothesis created with
4552 # the same parameters, else (default) - create a new one
4553 # @return an instance of StdMeshers_MaxLength hypothesis
4554 # @ingroup l3_hypos_1dhyps
4555 def MaxSize(self, length=0.0, UseExisting=0):
4556 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
4559 hyp.SetLength(length)
4561 # set preestimated length
4562 gen = self.mesh.smeshpyD
4563 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
4564 self.mesh.GetMesh(), self.mesh.GetShape(),
4566 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
4568 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
4571 hyp.SetUsePreestimatedLength( length == 0.0 )
4574 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
4575 # @param n for the number of segments that cut an edge
4576 # @param s for the scale factor (optional)
4577 # @param reversedEdges is a list of edges to mesh using reversed orientation
4578 # @param UseExisting if ==true - searches for an existing hypothesis created with
4579 # the same parameters, else (default) - create a new one
4580 # @return an instance of StdMeshers_NumberOfSegments hypothesis
4581 # @ingroup l3_hypos_1dhyps
4582 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4583 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4584 reversedEdges, UseExisting = [], reversedEdges
4585 entry = self.MainShapeEntry()
4586 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4587 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4589 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
4590 UseExisting=UseExisting,
4591 CompareMethod=self.CompareNumberOfSegments)
4593 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
4594 UseExisting=UseExisting,
4595 CompareMethod=self.CompareNumberOfSegments)
4596 hyp.SetDistrType( 1 )
4597 hyp.SetScaleFactor(s)
4598 hyp.SetNumberOfSegments(n)
4599 hyp.SetReversedEdges( reversedEdges )
4600 hyp.SetObjectEntry( entry )
4604 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4605 def CompareNumberOfSegments(self, hyp, args):
4606 if hyp.GetNumberOfSegments() == args[0]:
4608 if hyp.GetReversedEdges() == args[1]:
4609 if not args[1] or hyp.GetObjectEntry() == args[2]:
4612 if hyp.GetReversedEdges() == args[2]:
4613 if not args[2] or hyp.GetObjectEntry() == args[3]:
4614 if hyp.GetDistrType() == 1:
4615 if IsEqual(hyp.GetScaleFactor(), args[1]):
4619 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4620 # @param start defines the length of the first segment
4621 # @param end defines the length of the last segment
4622 # @param reversedEdges is a list of edges to mesh using reversed orientation
4623 # @param UseExisting if ==true - searches for an existing hypothesis created with
4624 # the same parameters, else (default) - creates a new one
4625 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4626 # @ingroup l3_hypos_1dhyps
4627 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4628 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4629 reversedEdges, UseExisting = [], reversedEdges
4630 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4631 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4632 entry = self.MainShapeEntry()
4633 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
4634 UseExisting=UseExisting,
4635 CompareMethod=self.CompareArithmetic1D)
4636 hyp.SetStartLength(start)
4637 hyp.SetEndLength(end)
4638 hyp.SetReversedEdges( reversedEdges )
4639 hyp.SetObjectEntry( entry )
4643 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4644 def CompareArithmetic1D(self, hyp, args):
4645 if IsEqual(hyp.GetLength(1), args[0]):
4646 if IsEqual(hyp.GetLength(0), args[1]):
4647 if hyp.GetReversedEdges() == args[2]:
4648 if not args[2] or hyp.GetObjectEntry() == args[3]:
4653 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4654 # on curve from 0 to 1 (additionally it is neecessary to check
4655 # orientation of edges and create list of reversed edges if it is
4656 # needed) and sets numbers of segments between given points (default
4657 # values are equals 1
4658 # @param points defines the list of parameters on curve
4659 # @param nbSegs defines the list of numbers of segments
4660 # @param reversedEdges is a list of edges to mesh using reversed orientation
4661 # @param UseExisting if ==true - searches for an existing hypothesis created with
4662 # the same parameters, else (default) - creates a new one
4663 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4664 # @ingroup l3_hypos_1dhyps
4665 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4666 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4667 reversedEdges, UseExisting = [], reversedEdges
4668 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4669 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4670 entry = self.MainShapeEntry()
4671 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
4672 UseExisting=UseExisting,
4673 CompareMethod=self.CompareFixedPoints1D)
4674 hyp.SetPoints(points)
4675 hyp.SetNbSegments(nbSegs)
4676 hyp.SetReversedEdges(reversedEdges)
4677 hyp.SetObjectEntry(entry)
4681 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4682 ## as the given arguments
4683 def CompareFixedPoints1D(self, hyp, args):
4684 if hyp.GetPoints() == args[0]:
4685 if hyp.GetNbSegments() == args[1]:
4686 if hyp.GetReversedEdges() == args[2]:
4687 if not args[2] or hyp.GetObjectEntry() == args[3]:
4693 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4694 # @param start defines the length of the first segment
4695 # @param end defines the length of the last segment
4696 # @param reversedEdges is a list of edges to mesh using reversed orientation
4697 # @param UseExisting if ==true - searches for an existing hypothesis created with
4698 # the same parameters, else (default) - creates a new one
4699 # @return an instance of StdMeshers_StartEndLength hypothesis
4700 # @ingroup l3_hypos_1dhyps
4701 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4702 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4703 reversedEdges, UseExisting = [], reversedEdges
4704 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4705 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4706 entry = self.MainShapeEntry()
4707 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
4708 UseExisting=UseExisting,
4709 CompareMethod=self.CompareStartEndLength)
4710 hyp.SetStartLength(start)
4711 hyp.SetEndLength(end)
4712 hyp.SetReversedEdges( reversedEdges )
4713 hyp.SetObjectEntry( entry )
4716 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4717 def CompareStartEndLength(self, hyp, args):
4718 if IsEqual(hyp.GetLength(1), args[0]):
4719 if IsEqual(hyp.GetLength(0), args[1]):
4720 if hyp.GetReversedEdges() == args[2]:
4721 if not args[2] or hyp.GetObjectEntry() == args[3]:
4725 ## Defines "Deflection1D" hypothesis
4726 # @param d for the deflection
4727 # @param UseExisting if ==true - searches for an existing hypothesis created with
4728 # the same parameters, else (default) - create a new one
4729 # @ingroup l3_hypos_1dhyps
4730 def Deflection1D(self, d, UseExisting=0):
4731 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4732 CompareMethod=self.CompareDeflection1D)
4733 hyp.SetDeflection(d)
4736 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4737 def CompareDeflection1D(self, hyp, args):
4738 return IsEqual(hyp.GetDeflection(), args[0])
4740 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4741 # the opposite side in case of quadrangular faces
4742 # @ingroup l3_hypos_additi
4743 def Propagation(self):
4744 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4746 ## Defines "AutomaticLength" hypothesis
4747 # @param fineness for the fineness [0-1]
4748 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4749 # same parameters, else (default) - create a new one
4750 # @ingroup l3_hypos_1dhyps
4751 def AutomaticLength(self, fineness=0, UseExisting=0):
4752 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4753 CompareMethod=self.CompareAutomaticLength)
4754 hyp.SetFineness( fineness )
4757 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4758 def CompareAutomaticLength(self, hyp, args):
4759 return IsEqual(hyp.GetFineness(), args[0])
4761 ## Defines "SegmentLengthAroundVertex" hypothesis
4762 # @param length for the segment length
4763 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4764 # Any other integer value means that the hypothesis will be set on the
4765 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4766 # @param UseExisting if ==true - searches for an existing hypothesis created with
4767 # the same parameters, else (default) - creates a new one
4768 # @ingroup l3_algos_segmarv
4769 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4771 store_geom = self.geom
4772 if type(vertex) is types.IntType:
4773 if vertex == 0 or vertex == 1:
4774 vertex = self.mesh.geompyD.ExtractShapes(self.geom, geompyDC.ShapeType["VERTEX"],True)[vertex]
4782 if self.geom is None:
4783 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4785 name = GetName(self.geom)
4788 piece = self.mesh.geom
4789 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
4790 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
4792 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4794 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4796 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4797 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4799 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4800 CompareMethod=self.CompareLengthNearVertex)
4801 self.geom = store_geom
4802 hyp.SetLength( length )
4805 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4806 # @ingroup l3_algos_segmarv
4807 def CompareLengthNearVertex(self, hyp, args):
4808 return IsEqual(hyp.GetLength(), args[0])
4810 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4811 # If the 2D mesher sees that all boundary edges are quadratic,
4812 # it generates quadratic faces, else it generates linear faces using
4813 # medium nodes as if they are vertices.
4814 # The 3D mesher generates quadratic volumes only if all boundary faces
4815 # are quadratic, else it fails.
4817 # @ingroup l3_hypos_additi
4818 def QuadraticMesh(self):
4819 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4822 # Public class: Mesh_CompositeSegment
4823 # --------------------------
4825 ## Defines a segment 1D algorithm for discretization
4827 # @ingroup l3_algos_basic
4828 class Mesh_CompositeSegment(Mesh_Segment):
4830 ## Private constructor.
4831 def __init__(self, mesh, geom=0):
4832 self.Create(mesh, geom, "CompositeSegment_1D")
4835 # Public class: Mesh_Segment_Python
4836 # ---------------------------------
4838 ## Defines a segment 1D algorithm for discretization with python function
4840 # @ingroup l3_algos_basic
4841 class Mesh_Segment_Python(Mesh_Segment):
4843 ## Private constructor.
4844 def __init__(self, mesh, geom=0):
4845 import Python1dPlugin
4846 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4848 ## Defines "PythonSplit1D" hypothesis
4849 # @param n for the number of segments that cut an edge
4850 # @param func for the python function that calculates the length of all segments
4851 # @param UseExisting if ==true - searches for the existing hypothesis created with
4852 # the same parameters, else (default) - creates a new one
4853 # @ingroup l3_hypos_1dhyps
4854 def PythonSplit1D(self, n, func, UseExisting=0):
4855 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4856 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4857 hyp.SetNumberOfSegments(n)
4858 hyp.SetPythonLog10RatioFunction(func)
4861 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4862 def ComparePythonSplit1D(self, hyp, args):
4863 #if hyp.GetNumberOfSegments() == args[0]:
4864 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4868 # Public class: Mesh_Triangle
4869 # ---------------------------
4871 ## Defines a triangle 2D algorithm
4873 # @ingroup l3_algos_basic
4874 class Mesh_Triangle(Mesh_Algorithm):
4883 ## Private constructor.
4884 def __init__(self, mesh, algoType, geom=0):
4885 Mesh_Algorithm.__init__(self)
4887 self.algoType = algoType
4888 if algoType == MEFISTO:
4889 self.Create(mesh, geom, "MEFISTO_2D")
4891 elif algoType == BLSURF:
4893 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4894 #self.SetPhysicalMesh() - PAL19680
4895 elif algoType == NETGEN:
4897 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4899 elif algoType == NETGEN_2D:
4901 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4904 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4905 # @param area for the maximum area of each triangle
4906 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4907 # same parameters, else (default) - creates a new one
4909 # Only for algoType == MEFISTO || NETGEN_2D
4910 # @ingroup l3_hypos_2dhyps
4911 def MaxElementArea(self, area, UseExisting=0):
4912 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4913 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4914 CompareMethod=self.CompareMaxElementArea)
4915 elif self.algoType == NETGEN:
4916 hyp = self.Parameters(SIMPLE)
4917 hyp.SetMaxElementArea(area)
4920 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4921 def CompareMaxElementArea(self, hyp, args):
4922 return IsEqual(hyp.GetMaxElementArea(), args[0])
4924 ## Defines "LengthFromEdges" hypothesis to build triangles
4925 # based on the length of the edges taken from the wire
4927 # Only for algoType == MEFISTO || NETGEN_2D
4928 # @ingroup l3_hypos_2dhyps
4929 def LengthFromEdges(self):
4930 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4931 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4933 elif self.algoType == NETGEN:
4934 hyp = self.Parameters(SIMPLE)
4935 hyp.LengthFromEdges()
4938 ## Sets a way to define size of mesh elements to generate.
4939 # @param thePhysicalMesh is: DefaultSize or Custom.
4940 # @ingroup l3_hypos_blsurf
4941 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4942 # Parameter of BLSURF algo
4943 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4945 ## Sets size of mesh elements to generate.
4946 # @ingroup l3_hypos_blsurf
4947 def SetPhySize(self, theVal):
4948 # Parameter of BLSURF algo
4949 self.SetPhysicalMesh(1) #Custom - else why to set the size?
4950 self.Parameters().SetPhySize(theVal)
4952 ## Sets lower boundary of mesh element size (PhySize).
4953 # @ingroup l3_hypos_blsurf
4954 def SetPhyMin(self, theVal=-1):
4955 # Parameter of BLSURF algo
4956 self.Parameters().SetPhyMin(theVal)
4958 ## Sets upper boundary of mesh element size (PhySize).
4959 # @ingroup l3_hypos_blsurf
4960 def SetPhyMax(self, theVal=-1):
4961 # Parameter of BLSURF algo
4962 self.Parameters().SetPhyMax(theVal)
4964 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4965 # @param theGeometricMesh is: 0 (None) or 1 (Custom)
4966 # @ingroup l3_hypos_blsurf
4967 def SetGeometricMesh(self, theGeometricMesh=0):
4968 # Parameter of BLSURF algo
4969 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4970 self.params.SetGeometricMesh(theGeometricMesh)
4972 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4973 # @ingroup l3_hypos_blsurf
4974 def SetAngleMeshS(self, theVal=_angleMeshS):
4975 # Parameter of BLSURF algo
4976 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4977 self.params.SetAngleMeshS(theVal)
4979 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4980 # @ingroup l3_hypos_blsurf
4981 def SetAngleMeshC(self, theVal=_angleMeshS):
4982 # Parameter of BLSURF algo
4983 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4984 self.params.SetAngleMeshC(theVal)
4986 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4987 # @ingroup l3_hypos_blsurf
4988 def SetGeoMin(self, theVal=-1):
4989 # Parameter of BLSURF algo
4990 self.Parameters().SetGeoMin(theVal)
4992 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4993 # @ingroup l3_hypos_blsurf
4994 def SetGeoMax(self, theVal=-1):
4995 # Parameter of BLSURF algo
4996 self.Parameters().SetGeoMax(theVal)
4998 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4999 # @ingroup l3_hypos_blsurf
5000 def SetGradation(self, theVal=_gradation):
5001 # Parameter of BLSURF algo
5002 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
5003 self.params.SetGradation(theVal)
5005 ## Sets topology usage way.
5006 # @param way defines how mesh conformity is assured <ul>
5007 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
5008 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
5009 # @ingroup l3_hypos_blsurf
5010 def SetTopology(self, way):
5011 # Parameter of BLSURF algo
5012 self.Parameters().SetTopology(way)
5014 ## To respect geometrical edges or not.
5015 # @ingroup l3_hypos_blsurf
5016 def SetDecimesh(self, toIgnoreEdges=False):
5017 # Parameter of BLSURF algo
5018 self.Parameters().SetDecimesh(toIgnoreEdges)
5020 ## Sets verbosity level in the range 0 to 100.
5021 # @ingroup l3_hypos_blsurf
5022 def SetVerbosity(self, level):
5023 # Parameter of BLSURF algo
5024 self.Parameters().SetVerbosity(level)
5026 ## Sets advanced option value.
5027 # @ingroup l3_hypos_blsurf
5028 def SetOptionValue(self, optionName, level):
5029 # Parameter of BLSURF algo
5030 self.Parameters().SetOptionValue(optionName,level)
5032 ## 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 ]
5033 # @param theFace : face on which the attractor will be defined
5034 # @param theAttractor : geometrical object frome which the mesh size "h" decreases exponentially
5035 # @param theStartSize : mesh size on theAttractor
5036 # @param theEndSize : maximum size that will be reached on theFace
5037 # @param theInfluenceDistance : influence of the attractor ( the size grow slower on theFace if it's high)
5038 # @param theConstantSizeDistance : distance until which the mesh size will be kept constant on theFace
5039 # @ingroup l3_hypos_blsurf
5040 def SetAttractorGeom(self, theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance):
5041 # Parameter of BLSURF algo
5042 self.Parameters().SetAttractorGeom(otheFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance)
5044 ## Sets QuadAllowed flag.
5045 # Only for algoType == NETGEN(NETGEN_1D2D) || NETGEN_2D || BLSURF
5046 # @ingroup l3_hypos_netgen l3_hypos_blsurf
5047 def SetQuadAllowed(self, toAllow=True):
5048 if self.algoType == NETGEN_2D:
5051 hasSimpleHyps = False
5052 simpleHyps = ["QuadranglePreference","LengthFromEdges","MaxElementArea"]
5053 for hyp in self.mesh.GetHypothesisList( self.geom ):
5054 if hyp.GetName() in simpleHyps:
5055 hasSimpleHyps = True
5056 if hyp.GetName() == "QuadranglePreference":
5057 if not toAllow: # remove QuadranglePreference
5058 self.mesh.RemoveHypothesis( self.geom, hyp )
5064 if toAllow: # add QuadranglePreference
5065 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
5070 if self.Parameters():
5071 self.params.SetQuadAllowed(toAllow)
5074 ## Defines hypothesis having several parameters
5076 # @ingroup l3_hypos_netgen
5077 def Parameters(self, which=SOLE):
5079 if self.algoType == NETGEN:
5081 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
5082 "libNETGENEngine.so", UseExisting=0)
5084 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
5085 "libNETGENEngine.so", UseExisting=0)
5086 elif self.algoType == MEFISTO:
5087 print "Mefisto algo support no multi-parameter hypothesis"
5088 elif self.algoType == NETGEN_2D:
5089 self.params = self.Hypothesis("NETGEN_Parameters_2D_ONLY", [],
5090 "libNETGENEngine.so", UseExisting=0)
5091 elif self.algoType == BLSURF:
5092 self.params = self.Hypothesis("BLSURF_Parameters", [],
5093 "libBLSURFEngine.so", UseExisting=0)
5095 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
5100 # Only for algoType == NETGEN
5101 # @ingroup l3_hypos_netgen
5102 def SetMaxSize(self, theSize):
5103 if self.Parameters():
5104 self.params.SetMaxSize(theSize)
5106 ## Sets SecondOrder flag
5108 # Only for algoType == NETGEN
5109 # @ingroup l3_hypos_netgen
5110 def SetSecondOrder(self, theVal):
5111 if self.Parameters():
5112 self.params.SetSecondOrder(theVal)
5114 ## Sets Optimize flag
5116 # Only for algoType == NETGEN
5117 # @ingroup l3_hypos_netgen
5118 def SetOptimize(self, theVal):
5119 if self.Parameters():
5120 self.params.SetOptimize(theVal)
5123 # @param theFineness is:
5124 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5126 # Only for algoType == NETGEN
5127 # @ingroup l3_hypos_netgen
5128 def SetFineness(self, theFineness):
5129 if self.Parameters():
5130 self.params.SetFineness(theFineness)
5134 # Only for algoType == NETGEN
5135 # @ingroup l3_hypos_netgen
5136 def SetGrowthRate(self, theRate):
5137 if self.Parameters():
5138 self.params.SetGrowthRate(theRate)
5140 ## Sets NbSegPerEdge
5142 # Only for algoType == NETGEN
5143 # @ingroup l3_hypos_netgen
5144 def SetNbSegPerEdge(self, theVal):
5145 if self.Parameters():
5146 self.params.SetNbSegPerEdge(theVal)
5148 ## Sets NbSegPerRadius
5150 # Only for algoType == NETGEN
5151 # @ingroup l3_hypos_netgen
5152 def SetNbSegPerRadius(self, theVal):
5153 if self.Parameters():
5154 self.params.SetNbSegPerRadius(theVal)
5156 ## Sets number of segments overriding value set by SetLocalLength()
5158 # Only for algoType == NETGEN
5159 # @ingroup l3_hypos_netgen
5160 def SetNumberOfSegments(self, theVal):
5161 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5163 ## Sets number of segments overriding value set by SetNumberOfSegments()
5165 # Only for algoType == NETGEN
5166 # @ingroup l3_hypos_netgen
5167 def SetLocalLength(self, theVal):
5168 self.Parameters(SIMPLE).SetLocalLength(theVal)
5173 # Public class: Mesh_Quadrangle
5174 # -----------------------------
5176 ## Defines a quadrangle 2D algorithm
5178 # @ingroup l3_algos_basic
5179 class Mesh_Quadrangle(Mesh_Algorithm):
5183 ## Private constructor.
5184 def __init__(self, mesh, geom=0):
5185 Mesh_Algorithm.__init__(self)
5186 self.Create(mesh, geom, "Quadrangle_2D")
5189 ## Defines "QuadrangleParameters" hypothesis
5190 # @param quadType defines the algorithm of transition between differently descretized
5191 # sides of a geometrical face:
5192 # - QUAD_STANDARD - both triangles and quadrangles are possible in the transition
5193 # area along the finer meshed sides.
5194 # - QUAD_TRIANGLE_PREF - only triangles are built in the transition area along the
5195 # finer meshed sides.
5196 # - QUAD_QUADRANGLE_PREF - only quadrangles are built in the transition area along
5197 # the finer meshed sides, iff the total quantity of segments on
5198 # all four sides of the face is even (divisible by 2).
5199 # - QUAD_QUADRANGLE_PREF_REVERSED - same as QUAD_QUADRANGLE_PREF but the transition
5200 # area is located along the coarser meshed sides.
5201 # - QUAD_REDUCED - only quadrangles are built and the transition between the sides
5202 # is made gradually, layer by layer. This type has a limitation on
5203 # the number of segments: one pair of opposite sides must have the
5204 # same number of segments, the other pair must have an even difference
5205 # between the numbers of segments on the sides.
5206 # @param triangleVertex: vertex of a trilateral geometrical face, around which triangles
5207 # will be created while other elements will be quadrangles.
5208 # Vertex can be either a GEOM_Object or a vertex ID within the
5210 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5211 # the same parameters, else (default) - creates a new one
5212 # @ingroup l3_hypos_quad
5213 def QuadrangleParameters(self, quadType=StdMeshers.QUAD_STANDARD, triangleVertex=0, UseExisting=0):
5214 vertexID = triangleVertex
5215 if isinstance( triangleVertex, geompyDC.GEOM._objref_GEOM_Object ):
5216 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, triangleVertex )
5218 compFun = lambda hyp,args: \
5219 hyp.GetQuadType() == args[0] and \
5220 ( hyp.GetTriaVertex()==args[1] or ( hyp.GetTriaVertex()<1 and args[1]<1))
5221 self.params = self.Hypothesis("QuadrangleParams", [quadType,vertexID],
5222 UseExisting = UseExisting, CompareMethod=compFun)
5224 if self.params.GetQuadType() != quadType:
5225 self.params.SetQuadType(quadType)
5227 self.params.SetTriaVertex( vertexID )
5230 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5231 # quadrangles are built in the transition area along the finer meshed sides,
5232 # iff the total quantity of segments on all four sides of the face is even.
5233 # @param reversed if True, transition area is located along the coarser meshed sides.
5234 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5235 # the same parameters, else (default) - creates a new one
5236 # @ingroup l3_hypos_quad
5237 def QuadranglePreference(self, reversed=False, UseExisting=0):
5239 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF_REVERSED,UseExisting=UseExisting)
5240 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF,UseExisting=UseExisting)
5242 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5243 # triangles are built in the transition area along the finer meshed sides.
5244 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5245 # the same parameters, else (default) - creates a new one
5246 # @ingroup l3_hypos_quad
5247 def TrianglePreference(self, UseExisting=0):
5248 return self.QuadrangleParameters(QUAD_TRIANGLE_PREF,UseExisting=UseExisting)
5250 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5251 # quadrangles are built and the transition between the sides is made gradually,
5252 # layer by layer. This type has a limitation on the number of segments: one pair
5253 # of opposite sides must have the same number of segments, the other pair must
5254 # have an even difference between the numbers of segments on the sides.
5255 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5256 # the same parameters, else (default) - creates a new one
5257 # @ingroup l3_hypos_quad
5258 def Reduced(self, UseExisting=0):
5259 return self.QuadrangleParameters(QUAD_REDUCED,UseExisting=UseExisting)
5261 ## Defines "QuadrangleParams" hypothesis with QUAD_STANDARD type of quadrangulation
5262 # @param vertex: vertex of a trilateral geometrical face, around which triangles
5263 # will be created while other elements will be quadrangles.
5264 # Vertex can be either a GEOM_Object or a vertex ID within the
5266 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5267 # the same parameters, else (default) - creates a new one
5268 # @ingroup l3_hypos_quad
5269 def TriangleVertex(self, vertex, UseExisting=0):
5270 return self.QuadrangleParameters(QUAD_STANDARD,vertex,UseExisting)
5273 # Public class: Mesh_Tetrahedron
5274 # ------------------------------
5276 ## Defines a tetrahedron 3D algorithm
5278 # @ingroup l3_algos_basic
5279 class Mesh_Tetrahedron(Mesh_Algorithm):
5284 ## Private constructor.
5285 def __init__(self, mesh, algoType, geom=0):
5286 Mesh_Algorithm.__init__(self)
5288 if algoType == NETGEN:
5290 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
5293 elif algoType == FULL_NETGEN:
5295 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5298 elif algoType == GHS3D:
5300 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
5303 elif algoType == GHS3DPRL:
5304 CheckPlugin(GHS3DPRL)
5305 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
5308 self.algoType = algoType
5310 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
5311 # @param vol for the maximum volume of each tetrahedron
5312 # @param UseExisting if ==true - searches for the existing hypothesis created with
5313 # the same parameters, else (default) - creates a new one
5314 # @ingroup l3_hypos_maxvol
5315 def MaxElementVolume(self, vol, UseExisting=0):
5316 if self.algoType == NETGEN:
5317 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
5318 CompareMethod=self.CompareMaxElementVolume)
5319 hyp.SetMaxElementVolume(vol)
5321 elif self.algoType == FULL_NETGEN:
5322 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
5325 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
5326 def CompareMaxElementVolume(self, hyp, args):
5327 return IsEqual(hyp.GetMaxElementVolume(), args[0])
5329 ## Defines hypothesis having several parameters
5331 # @ingroup l3_hypos_netgen
5332 def Parameters(self, which=SOLE):
5335 if self.algoType == FULL_NETGEN:
5337 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
5338 "libNETGENEngine.so", UseExisting=0)
5340 self.params = self.Hypothesis("NETGEN_Parameters", [],
5341 "libNETGENEngine.so", UseExisting=0)
5343 elif self.algoType == NETGEN:
5344 self.params = self.Hypothesis("NETGEN_Parameters_3D", [],
5345 "libNETGENEngine.so", UseExisting=0)
5347 elif self.algoType == GHS3D:
5348 self.params = self.Hypothesis("GHS3D_Parameters", [],
5349 "libGHS3DEngine.so", UseExisting=0)
5351 elif self.algoType == GHS3DPRL:
5352 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
5353 "libGHS3DPRLEngine.so", UseExisting=0)
5355 print "Warning: %s supports no multi-parameter hypothesis"%self.algo.GetName()
5360 # Parameter of FULL_NETGEN and NETGEN
5361 # @ingroup l3_hypos_netgen
5362 def SetMaxSize(self, theSize):
5363 self.Parameters().SetMaxSize(theSize)
5365 ## Sets SecondOrder flag
5366 # Parameter of FULL_NETGEN
5367 # @ingroup l3_hypos_netgen
5368 def SetSecondOrder(self, theVal):
5369 self.Parameters().SetSecondOrder(theVal)
5371 ## Sets Optimize flag
5372 # Parameter of FULL_NETGEN and NETGEN
5373 # @ingroup l3_hypos_netgen
5374 def SetOptimize(self, theVal):
5375 self.Parameters().SetOptimize(theVal)
5378 # @param theFineness is:
5379 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5380 # Parameter of FULL_NETGEN
5381 # @ingroup l3_hypos_netgen
5382 def SetFineness(self, theFineness):
5383 self.Parameters().SetFineness(theFineness)
5386 # Parameter of FULL_NETGEN
5387 # @ingroup l3_hypos_netgen
5388 def SetGrowthRate(self, theRate):
5389 self.Parameters().SetGrowthRate(theRate)
5391 ## Sets NbSegPerEdge
5392 # Parameter of FULL_NETGEN
5393 # @ingroup l3_hypos_netgen
5394 def SetNbSegPerEdge(self, theVal):
5395 self.Parameters().SetNbSegPerEdge(theVal)
5397 ## Sets NbSegPerRadius
5398 # Parameter of FULL_NETGEN
5399 # @ingroup l3_hypos_netgen
5400 def SetNbSegPerRadius(self, theVal):
5401 self.Parameters().SetNbSegPerRadius(theVal)
5403 ## Sets number of segments overriding value set by SetLocalLength()
5404 # Only for algoType == NETGEN_FULL
5405 # @ingroup l3_hypos_netgen
5406 def SetNumberOfSegments(self, theVal):
5407 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5409 ## Sets number of segments overriding value set by SetNumberOfSegments()
5410 # Only for algoType == NETGEN_FULL
5411 # @ingroup l3_hypos_netgen
5412 def SetLocalLength(self, theVal):
5413 self.Parameters(SIMPLE).SetLocalLength(theVal)
5415 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
5416 # Overrides value set by LengthFromEdges()
5417 # Only for algoType == NETGEN_FULL
5418 # @ingroup l3_hypos_netgen
5419 def MaxElementArea(self, area):
5420 self.Parameters(SIMPLE).SetMaxElementArea(area)
5422 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
5423 # Overrides value set by MaxElementArea()
5424 # Only for algoType == NETGEN_FULL
5425 # @ingroup l3_hypos_netgen
5426 def LengthFromEdges(self):
5427 self.Parameters(SIMPLE).LengthFromEdges()
5429 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
5430 # Overrides value set by MaxElementVolume()
5431 # Only for algoType == NETGEN_FULL
5432 # @ingroup l3_hypos_netgen
5433 def LengthFromFaces(self):
5434 self.Parameters(SIMPLE).LengthFromFaces()
5436 ## To mesh "holes" in a solid or not. Default is to mesh.
5437 # @ingroup l3_hypos_ghs3dh
5438 def SetToMeshHoles(self, toMesh):
5439 # Parameter of GHS3D
5440 self.Parameters().SetToMeshHoles(toMesh)
5442 ## Set Optimization level:
5443 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
5444 # Strong_Optimization.
5445 # Default is Standard_Optimization
5446 # @ingroup l3_hypos_ghs3dh
5447 def SetOptimizationLevel(self, level):
5448 # Parameter of GHS3D
5449 self.Parameters().SetOptimizationLevel(level)
5451 ## Maximal size of memory to be used by the algorithm (in Megabytes).
5452 # @ingroup l3_hypos_ghs3dh
5453 def SetMaximumMemory(self, MB):
5454 # Advanced parameter of GHS3D
5455 self.Parameters().SetMaximumMemory(MB)
5457 ## Initial size of memory to be used by the algorithm (in Megabytes) in
5458 # automatic memory adjustment mode.
5459 # @ingroup l3_hypos_ghs3dh
5460 def SetInitialMemory(self, MB):
5461 # Advanced parameter of GHS3D
5462 self.Parameters().SetInitialMemory(MB)
5464 ## Path to working directory.
5465 # @ingroup l3_hypos_ghs3dh
5466 def SetWorkingDirectory(self, path):
5467 # Advanced parameter of GHS3D
5468 self.Parameters().SetWorkingDirectory(path)
5470 ## To keep working files or remove them. Log file remains in case of errors anyway.
5471 # @ingroup l3_hypos_ghs3dh
5472 def SetKeepFiles(self, toKeep):
5473 # Advanced parameter of GHS3D and GHS3DPRL
5474 self.Parameters().SetKeepFiles(toKeep)
5476 ## To set verbose level [0-10]. <ul>
5477 #<li> 0 - no standard output,
5478 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
5479 # indicates when the final mesh is being saved. In addition the software
5480 # gives indication regarding the CPU time.
5481 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
5482 # histogram of the skin mesh, quality statistics histogram together with
5483 # the characteristics of the final mesh.</ul>
5484 # @ingroup l3_hypos_ghs3dh
5485 def SetVerboseLevel(self, level):
5486 # Advanced parameter of GHS3D
5487 self.Parameters().SetVerboseLevel(level)
5489 ## To create new nodes.
5490 # @ingroup l3_hypos_ghs3dh
5491 def SetToCreateNewNodes(self, toCreate):
5492 # Advanced parameter of GHS3D
5493 self.Parameters().SetToCreateNewNodes(toCreate)
5495 ## To use boundary recovery version which tries to create mesh on a very poor
5496 # quality surface mesh.
5497 # @ingroup l3_hypos_ghs3dh
5498 def SetToUseBoundaryRecoveryVersion(self, toUse):
5499 # Advanced parameter of GHS3D
5500 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
5502 ## Sets command line option as text.
5503 # @ingroup l3_hypos_ghs3dh
5504 def SetTextOption(self, option):
5505 # Advanced parameter of GHS3D
5506 self.Parameters().SetTextOption(option)
5508 ## Sets MED files name and path.
5509 def SetMEDName(self, value):
5510 self.Parameters().SetMEDName(value)
5512 ## Sets the number of partition of the initial mesh
5513 def SetNbPart(self, value):
5514 self.Parameters().SetNbPart(value)
5516 ## When big mesh, start tepal in background
5517 def SetBackground(self, value):
5518 self.Parameters().SetBackground(value)
5520 # Public class: Mesh_Hexahedron
5521 # ------------------------------
5523 ## Defines a hexahedron 3D algorithm
5525 # @ingroup l3_algos_basic
5526 class Mesh_Hexahedron(Mesh_Algorithm):
5531 ## Private constructor.
5532 def __init__(self, mesh, algoType=Hexa, geom=0):
5533 Mesh_Algorithm.__init__(self)
5535 self.algoType = algoType
5537 if algoType == Hexa:
5538 self.Create(mesh, geom, "Hexa_3D")
5541 elif algoType == Hexotic:
5542 CheckPlugin(Hexotic)
5543 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
5546 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
5547 # @ingroup l3_hypos_hexotic
5548 def MinMaxQuad(self, min=3, max=8, quad=True):
5549 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
5551 self.params.SetHexesMinLevel(min)
5552 self.params.SetHexesMaxLevel(max)
5553 self.params.SetHexoticQuadrangles(quad)
5556 # Deprecated, only for compatibility!
5557 # Public class: Mesh_Netgen
5558 # ------------------------------
5560 ## Defines a NETGEN-based 2D or 3D algorithm
5561 # that needs no discrete boundary (i.e. independent)
5563 # This class is deprecated, only for compatibility!
5566 # @ingroup l3_algos_basic
5567 class Mesh_Netgen(Mesh_Algorithm):
5571 ## Private constructor.
5572 def __init__(self, mesh, is3D, geom=0):
5573 Mesh_Algorithm.__init__(self)
5579 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5583 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
5586 ## Defines the hypothesis containing parameters of the algorithm
5587 def Parameters(self):
5589 hyp = self.Hypothesis("NETGEN_Parameters", [],
5590 "libNETGENEngine.so", UseExisting=0)
5592 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
5593 "libNETGENEngine.so", UseExisting=0)
5596 # Public class: Mesh_Projection1D
5597 # ------------------------------
5599 ## Defines a projection 1D algorithm
5600 # @ingroup l3_algos_proj
5602 class Mesh_Projection1D(Mesh_Algorithm):
5604 ## Private constructor.
5605 def __init__(self, mesh, geom=0):
5606 Mesh_Algorithm.__init__(self)
5607 self.Create(mesh, geom, "Projection_1D")
5609 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
5610 # a mesh pattern is taken, and, optionally, the association of vertices
5611 # between the source edge and a target edge (to which a hypothesis is assigned)
5612 # @param edge from which nodes distribution is taken
5613 # @param mesh from which nodes distribution is taken (optional)
5614 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
5615 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
5616 # to associate with \a srcV (optional)
5617 # @param UseExisting if ==true - searches for the existing hypothesis created with
5618 # the same parameters, else (default) - creates a new one
5619 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
5620 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
5622 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
5623 hyp.SetSourceEdge( edge )
5624 if not mesh is None and isinstance(mesh, Mesh):
5625 mesh = mesh.GetMesh()
5626 hyp.SetSourceMesh( mesh )
5627 hyp.SetVertexAssociation( srcV, tgtV )
5630 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
5631 #def CompareSourceEdge(self, hyp, args):
5632 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
5636 # Public class: Mesh_Projection2D
5637 # ------------------------------
5639 ## Defines a projection 2D algorithm
5640 # @ingroup l3_algos_proj
5642 class Mesh_Projection2D(Mesh_Algorithm):
5644 ## Private constructor.
5645 def __init__(self, mesh, geom=0):
5646 Mesh_Algorithm.__init__(self)
5647 self.Create(mesh, geom, "Projection_2D")
5649 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
5650 # a mesh pattern is taken, and, optionally, the association of vertices
5651 # between the source face and the target face (to which a hypothesis is assigned)
5652 # @param face from which the mesh pattern is taken
5653 # @param mesh from which the mesh pattern is taken (optional)
5654 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
5655 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
5656 # to associate with \a srcV1 (optional)
5657 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
5658 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
5659 # to associate with \a srcV2 (optional)
5660 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
5661 # the same parameters, else (default) - forces the creation a new one
5663 # Note: all association vertices must belong to one edge of a face
5664 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
5665 srcV2=None, tgtV2=None, UseExisting=0):
5666 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
5668 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
5669 hyp.SetSourceFace( face )
5670 if not mesh is None and isinstance(mesh, Mesh):
5671 mesh = mesh.GetMesh()
5672 hyp.SetSourceMesh( mesh )
5673 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5676 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
5677 #def CompareSourceFace(self, hyp, args):
5678 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
5681 # Public class: Mesh_Projection3D
5682 # ------------------------------
5684 ## Defines a projection 3D algorithm
5685 # @ingroup l3_algos_proj
5687 class Mesh_Projection3D(Mesh_Algorithm):
5689 ## Private constructor.
5690 def __init__(self, mesh, geom=0):
5691 Mesh_Algorithm.__init__(self)
5692 self.Create(mesh, geom, "Projection_3D")
5694 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
5695 # the mesh pattern is taken, and, optionally, the association of vertices
5696 # between the source and the target solid (to which a hipothesis is assigned)
5697 # @param solid from where the mesh pattern is taken
5698 # @param mesh from where the mesh pattern is taken (optional)
5699 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
5700 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
5701 # to associate with \a srcV1 (optional)
5702 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
5703 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
5704 # to associate with \a srcV2 (optional)
5705 # @param UseExisting - if ==true - searches for the existing hypothesis created with
5706 # the same parameters, else (default) - creates a new one
5708 # Note: association vertices must belong to one edge of a solid
5709 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
5710 srcV2=0, tgtV2=0, UseExisting=0):
5711 hyp = self.Hypothesis("ProjectionSource3D",
5712 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
5714 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
5715 hyp.SetSource3DShape( solid )
5716 if not mesh is None and isinstance(mesh, Mesh):
5717 mesh = mesh.GetMesh()
5718 hyp.SetSourceMesh( mesh )
5719 if srcV1 and srcV2 and tgtV1 and tgtV2:
5720 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5721 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
5724 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
5725 #def CompareSourceShape3D(self, hyp, args):
5726 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
5730 # Public class: Mesh_Prism
5731 # ------------------------
5733 ## Defines a 3D extrusion algorithm
5734 # @ingroup l3_algos_3dextr
5736 class Mesh_Prism3D(Mesh_Algorithm):
5738 ## Private constructor.
5739 def __init__(self, mesh, geom=0):
5740 Mesh_Algorithm.__init__(self)
5741 self.Create(mesh, geom, "Prism_3D")
5743 # Public class: Mesh_RadialPrism
5744 # -------------------------------
5746 ## Defines a Radial Prism 3D algorithm
5747 # @ingroup l3_algos_radialp
5749 class Mesh_RadialPrism3D(Mesh_Algorithm):
5751 ## Private constructor.
5752 def __init__(self, mesh, geom=0):
5753 Mesh_Algorithm.__init__(self)
5754 self.Create(mesh, geom, "RadialPrism_3D")
5756 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
5757 self.nbLayers = None
5759 ## Return 3D hypothesis holding the 1D one
5760 def Get3DHypothesis(self):
5761 return self.distribHyp
5763 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5764 # hypothesis. Returns the created hypothesis
5765 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5766 #print "OwnHypothesis",hypType
5767 if not self.nbLayers is None:
5768 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5769 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5770 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5771 self.mesh.smeshpyD.SetCurrentStudy( None )
5772 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5773 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5774 self.distribHyp.SetLayerDistribution( hyp )
5777 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
5778 # prisms to build between the inner and outer shells
5779 # @param n number of layers
5780 # @param UseExisting if ==true - searches for the existing hypothesis created with
5781 # the same parameters, else (default) - creates a new one
5782 def NumberOfLayers(self, n, UseExisting=0):
5783 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5784 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
5785 CompareMethod=self.CompareNumberOfLayers)
5786 self.nbLayers.SetNumberOfLayers( n )
5787 return self.nbLayers
5789 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5790 def CompareNumberOfLayers(self, hyp, args):
5791 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5793 ## Defines "LocalLength" hypothesis, specifying the segment length
5794 # to build between the inner and the outer shells
5795 # @param l the length of segments
5796 # @param p the precision of rounding
5797 def LocalLength(self, l, p=1e-07):
5798 hyp = self.OwnHypothesis("LocalLength", [l,p])
5803 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
5804 # prisms to build between the inner and the outer shells.
5805 # @param n the number of layers
5806 # @param s the scale factor (optional)
5807 def NumberOfSegments(self, n, s=[]):
5809 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5811 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5812 hyp.SetDistrType( 1 )
5813 hyp.SetScaleFactor(s)
5814 hyp.SetNumberOfSegments(n)
5817 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5818 # to build between the inner and the outer shells with a length that changes in arithmetic progression
5819 # @param start the length of the first segment
5820 # @param end the length of the last segment
5821 def Arithmetic1D(self, start, end ):
5822 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5823 hyp.SetLength(start, 1)
5824 hyp.SetLength(end , 0)
5827 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5828 # to build between the inner and the outer shells as geometric length increasing
5829 # @param start for the length of the first segment
5830 # @param end for the length of the last segment
5831 def StartEndLength(self, start, end):
5832 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5833 hyp.SetLength(start, 1)
5834 hyp.SetLength(end , 0)
5837 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5838 # to build between the inner and outer shells
5839 # @param fineness defines the quality of the mesh within the range [0-1]
5840 def AutomaticLength(self, fineness=0):
5841 hyp = self.OwnHypothesis("AutomaticLength")
5842 hyp.SetFineness( fineness )
5845 # Public class: Mesh_RadialQuadrangle1D2D
5846 # -------------------------------
5848 ## Defines a Radial Quadrangle 1D2D algorithm
5849 # @ingroup l2_algos_radialq
5851 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
5853 ## Private constructor.
5854 def __init__(self, mesh, geom=0):
5855 Mesh_Algorithm.__init__(self)
5856 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5858 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
5859 self.nbLayers = None
5861 ## Return 2D hypothesis holding the 1D one
5862 def Get2DHypothesis(self):
5863 return self.distribHyp
5865 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5866 # hypothesis. Returns the created hypothesis
5867 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5868 #print "OwnHypothesis",hypType
5870 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5871 if self.distribHyp is None:
5872 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5874 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5875 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5876 self.mesh.smeshpyD.SetCurrentStudy( None )
5877 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5878 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5879 self.distribHyp.SetLayerDistribution( hyp )
5882 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
5883 # @param n number of layers
5884 # @param UseExisting if ==true - searches for the existing hypothesis created with
5885 # the same parameters, else (default) - creates a new one
5886 def NumberOfLayers(self, n, UseExisting=0):
5888 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5889 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5890 CompareMethod=self.CompareNumberOfLayers)
5891 self.nbLayers.SetNumberOfLayers( n )
5892 return self.nbLayers
5894 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5895 def CompareNumberOfLayers(self, hyp, args):
5896 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5898 ## Defines "LocalLength" hypothesis, specifying the segment length
5899 # @param l the length of segments
5900 # @param p the precision of rounding
5901 def LocalLength(self, l, p=1e-07):
5902 hyp = self.OwnHypothesis("LocalLength", [l,p])
5907 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5908 # @param n the number of layers
5909 # @param s the scale factor (optional)
5910 def NumberOfSegments(self, n, s=[]):
5912 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5914 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5915 hyp.SetDistrType( 1 )
5916 hyp.SetScaleFactor(s)
5917 hyp.SetNumberOfSegments(n)
5920 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5921 # with a length that changes in arithmetic progression
5922 # @param start the length of the first segment
5923 # @param end the length of the last segment
5924 def Arithmetic1D(self, start, end ):
5925 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5926 hyp.SetLength(start, 1)
5927 hyp.SetLength(end , 0)
5930 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5931 # as geometric length increasing
5932 # @param start for the length of the first segment
5933 # @param end for the length of the last segment
5934 def StartEndLength(self, start, end):
5935 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5936 hyp.SetLength(start, 1)
5937 hyp.SetLength(end , 0)
5940 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5941 # @param fineness defines the quality of the mesh within the range [0-1]
5942 def AutomaticLength(self, fineness=0):
5943 hyp = self.OwnHypothesis("AutomaticLength")
5944 hyp.SetFineness( fineness )
5948 # Public class: Mesh_UseExistingElements
5949 # --------------------------------------
5950 ## Defines a Radial Quadrangle 1D2D algorithm
5951 # @ingroup l3_algos_basic
5953 class Mesh_UseExistingElements(Mesh_Algorithm):
5955 def __init__(self, dim, mesh, geom=0):
5957 self.Create(mesh, geom, "Import_1D")
5959 self.Create(mesh, geom, "Import_1D2D")
5962 ## Defines "Source edges" hypothesis, specifying groups of edges to import
5963 # @param groups list of groups of edges
5964 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
5965 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
5966 # @param UseExisting if ==true - searches for the existing hypothesis created with
5967 # the same parameters, else (default) - creates a new one
5968 def SourceEdges(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
5969 if self.algo.GetName() == "Import_2D":
5970 raise ValueError, "algoritm dimension mismatch"
5971 hyp = self.Hypothesis("ImportSource1D", [groups, toCopyMesh, toCopyGroups],
5972 UseExisting=UseExisting, CompareMethod=self._compareHyp)
5973 hyp.SetSourceEdges(groups)
5974 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
5977 ## Defines "Source faces" hypothesis, specifying groups of faces to import
5978 # @param groups list of groups of faces
5979 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
5980 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
5981 # @param UseExisting if ==true - searches for the existing hypothesis created with
5982 # the same parameters, else (default) - creates a new one
5983 def SourceFaces(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
5984 if self.algo.GetName() == "Import_1D":
5985 raise ValueError, "algoritm dimension mismatch"
5986 hyp = self.Hypothesis("ImportSource2D", [groups, toCopyMesh, toCopyGroups],
5987 UseExisting=UseExisting, CompareMethod=self._compareHyp)
5988 hyp.SetSourceFaces(groups)
5989 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
5992 def _compareHyp(self,hyp,args):
5993 if hasattr( hyp, "GetSourceEdges"):
5994 entries = hyp.GetSourceEdges()
5996 entries = hyp.GetSourceFaces()
5998 toCopyMesh,toCopyGroups = hyp.GetCopySourceMesh()
5999 if len(entries)==len(groups) and toCopyMesh==args[1] and toCopyGroups==args[2]:
6001 study = self.mesh.smeshpyD.GetCurrentStudy()
6004 ior = salome.orb.object_to_string(g)
6005 sobj = study.FindObjectIOR(ior)
6006 if sobj: entries2.append( sobj.GetID() )
6011 return entries == entries2
6015 # Private class: Mesh_UseExisting
6016 # -------------------------------
6017 class Mesh_UseExisting(Mesh_Algorithm):
6019 def __init__(self, dim, mesh, geom=0):
6021 self.Create(mesh, geom, "UseExisting_1D")
6023 self.Create(mesh, geom, "UseExisting_2D")
6026 import salome_notebook
6027 notebook = salome_notebook.notebook
6029 ##Return values of the notebook variables
6030 def ParseParameters(last, nbParams,nbParam, value):
6034 listSize = len(last)
6035 for n in range(0,nbParams):
6037 if counter < listSize:
6038 strResult = strResult + last[counter]
6040 strResult = strResult + ""
6042 if isinstance(value, str):
6043 if notebook.isVariable(value):
6044 result = notebook.get(value)
6045 strResult=strResult+value
6047 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
6049 strResult=strResult+str(value)
6051 if nbParams - 1 != counter:
6052 strResult=strResult+var_separator #":"
6054 return result, strResult
6056 #Wrapper class for StdMeshers_LocalLength hypothesis
6057 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
6059 ## Set Length parameter value
6060 # @param length numerical value or name of variable from notebook
6061 def SetLength(self, length):
6062 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
6063 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6064 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
6066 ## Set Precision parameter value
6067 # @param precision numerical value or name of variable from notebook
6068 def SetPrecision(self, precision):
6069 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
6070 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6071 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
6073 #Registering the new proxy for LocalLength
6074 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
6077 #Wrapper class for StdMeshers_LayerDistribution hypothesis
6078 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
6080 def SetLayerDistribution(self, hypo):
6081 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
6082 hypo.ClearParameters();
6083 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
6085 #Registering the new proxy for LayerDistribution
6086 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
6088 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
6089 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
6091 ## Set Length parameter value
6092 # @param length numerical value or name of variable from notebook
6093 def SetLength(self, length):
6094 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
6095 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
6096 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
6098 #Registering the new proxy for SegmentLengthAroundVertex
6099 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
6102 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
6103 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
6105 ## Set Length parameter value
6106 # @param length numerical value or name of variable from notebook
6107 # @param isStart true is length is Start Length, otherwise false
6108 def SetLength(self, length, isStart):
6112 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
6113 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
6114 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
6116 #Registering the new proxy for Arithmetic1D
6117 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
6119 #Wrapper class for StdMeshers_Deflection1D hypothesis
6120 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
6122 ## Set Deflection parameter value
6123 # @param deflection numerical value or name of variable from notebook
6124 def SetDeflection(self, deflection):
6125 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
6126 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
6127 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
6129 #Registering the new proxy for Deflection1D
6130 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
6132 #Wrapper class for StdMeshers_StartEndLength hypothesis
6133 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
6135 ## Set Length parameter value
6136 # @param length numerical value or name of variable from notebook
6137 # @param isStart true is length is Start Length, otherwise false
6138 def SetLength(self, length, isStart):
6142 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
6143 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
6144 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
6146 #Registering the new proxy for StartEndLength
6147 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
6149 #Wrapper class for StdMeshers_MaxElementArea hypothesis
6150 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
6152 ## Set Max Element Area parameter value
6153 # @param area numerical value or name of variable from notebook
6154 def SetMaxElementArea(self, area):
6155 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
6156 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
6157 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
6159 #Registering the new proxy for MaxElementArea
6160 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
6163 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
6164 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
6166 ## Set Max Element Volume parameter value
6167 # @param volume numerical value or name of variable from notebook
6168 def SetMaxElementVolume(self, volume):
6169 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
6170 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
6171 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
6173 #Registering the new proxy for MaxElementVolume
6174 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
6177 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
6178 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
6180 ## Set Number Of Layers parameter value
6181 # @param nbLayers numerical value or name of variable from notebook
6182 def SetNumberOfLayers(self, nbLayers):
6183 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
6184 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
6185 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
6187 #Registering the new proxy for NumberOfLayers
6188 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
6190 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
6191 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
6193 ## Set Number Of Segments parameter value
6194 # @param nbSeg numerical value or name of variable from notebook
6195 def SetNumberOfSegments(self, nbSeg):
6196 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
6197 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
6198 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6199 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
6201 ## Set Scale Factor parameter value
6202 # @param factor numerical value or name of variable from notebook
6203 def SetScaleFactor(self, factor):
6204 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
6205 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6206 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
6208 #Registering the new proxy for NumberOfSegments
6209 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
6211 if not noNETGENPlugin:
6212 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
6213 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
6215 ## Set Max Size parameter value
6216 # @param maxsize numerical value or name of variable from notebook
6217 def SetMaxSize(self, maxsize):
6218 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6219 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
6220 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6221 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
6223 ## Set Growth Rate parameter value
6224 # @param value numerical value or name of variable from notebook
6225 def SetGrowthRate(self, value):
6226 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6227 value, parameters = ParseParameters(lastParameters,4,2,value)
6228 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6229 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
6231 ## Set Number of Segments per Edge parameter value
6232 # @param value numerical value or name of variable from notebook
6233 def SetNbSegPerEdge(self, value):
6234 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6235 value, parameters = ParseParameters(lastParameters,4,3,value)
6236 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6237 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
6239 ## Set Number of Segments per Radius parameter value
6240 # @param value numerical value or name of variable from notebook
6241 def SetNbSegPerRadius(self, value):
6242 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6243 value, parameters = ParseParameters(lastParameters,4,4,value)
6244 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6245 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
6247 #Registering the new proxy for NETGENPlugin_Hypothesis
6248 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
6251 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
6252 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
6255 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
6256 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
6258 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
6259 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
6261 ## Set Number of Segments parameter value
6262 # @param nbSeg numerical value or name of variable from notebook
6263 def SetNumberOfSegments(self, nbSeg):
6264 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6265 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
6266 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6267 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
6269 ## Set Local Length parameter value
6270 # @param length numerical value or name of variable from notebook
6271 def SetLocalLength(self, length):
6272 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6273 length, parameters = ParseParameters(lastParameters,2,1,length)
6274 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6275 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
6277 ## Set Max Element Area parameter value
6278 # @param area numerical value or name of variable from notebook
6279 def SetMaxElementArea(self, area):
6280 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6281 area, parameters = ParseParameters(lastParameters,2,2,area)
6282 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6283 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
6285 def LengthFromEdges(self):
6286 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6288 value, parameters = ParseParameters(lastParameters,2,2,value)
6289 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6290 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
6292 #Registering the new proxy for NETGEN_SimpleParameters_2D
6293 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
6296 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
6297 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
6298 ## Set Max Element Volume parameter value
6299 # @param volume numerical value or name of variable from notebook
6300 def SetMaxElementVolume(self, volume):
6301 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6302 volume, parameters = ParseParameters(lastParameters,3,3,volume)
6303 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6304 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
6306 def LengthFromFaces(self):
6307 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6309 value, parameters = ParseParameters(lastParameters,3,3,value)
6310 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6311 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
6313 #Registering the new proxy for NETGEN_SimpleParameters_3D
6314 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
6316 pass # if not noNETGENPlugin:
6318 class Pattern(SMESH._objref_SMESH_Pattern):
6320 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
6322 if isinstance(theNodeIndexOnKeyPoint1,str):
6324 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
6326 theNodeIndexOnKeyPoint1 -= 1
6327 theMesh.SetParameters(Parameters)
6328 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
6330 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
6333 if isinstance(theNode000Index,str):
6335 if isinstance(theNode001Index,str):
6337 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
6339 theNode000Index -= 1
6341 theNode001Index -= 1
6342 theMesh.SetParameters(Parameters)
6343 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
6345 #Registering the new proxy for Pattern
6346 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)