1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 # Author : Francis KLOSS, OCC
30 ## @defgroup l1_auxiliary Auxiliary methods and structures
31 ## @defgroup l1_creating Creating meshes
33 ## @defgroup l2_impexp Importing and exporting meshes
34 ## @defgroup l2_construct Constructing meshes
35 ## @defgroup l2_algorithms Defining Algorithms
37 ## @defgroup l3_algos_basic Basic meshing algorithms
38 ## @defgroup l3_algos_proj Projection Algorithms
39 ## @defgroup l3_algos_radialp Radial Prism
40 ## @defgroup l3_algos_segmarv Segments around Vertex
41 ## @defgroup l3_algos_3dextr 3D extrusion meshing algorithm
44 ## @defgroup l2_hypotheses Defining hypotheses
46 ## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
47 ## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
48 ## @defgroup l3_hypos_maxvol Max Element Volume hypothesis
49 ## @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
50 ## @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
51 ## @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
52 ## @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
53 ## @defgroup l3_hypos_quad Quadrangle Parameters hypothesis
54 ## @defgroup l3_hypos_additi Additional Hypotheses
57 ## @defgroup l2_submeshes Constructing submeshes
58 ## @defgroup l2_compounds Building Compounds
59 ## @defgroup l2_editing Editing Meshes
62 ## @defgroup l1_meshinfo Mesh Information
63 ## @defgroup l1_controls Quality controls and Filtering
64 ## @defgroup l1_grouping Grouping elements
66 ## @defgroup l2_grps_create Creating groups
67 ## @defgroup l2_grps_edit Editing groups
68 ## @defgroup l2_grps_operon Using operations on groups
69 ## @defgroup l2_grps_delete Deleting Groups
72 ## @defgroup l1_modifying Modifying meshes
74 ## @defgroup l2_modif_add Adding nodes and elements
75 ## @defgroup l2_modif_del Removing nodes and elements
76 ## @defgroup l2_modif_edit Modifying nodes and elements
77 ## @defgroup l2_modif_renumber Renumbering nodes and elements
78 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
79 ## @defgroup l2_modif_movenode Moving nodes
80 ## @defgroup l2_modif_throughp Mesh through point
81 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
82 ## @defgroup l2_modif_unitetri Uniting triangles
83 ## @defgroup l2_modif_changori Changing orientation of elements
84 ## @defgroup l2_modif_cutquadr Cutting quadrangles
85 ## @defgroup l2_modif_smooth Smoothing
86 ## @defgroup l2_modif_extrurev Extrusion and Revolution
87 ## @defgroup l2_modif_patterns Pattern mapping
88 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
95 import SMESH # This is necessary for back compatibility
103 # import NETGENPlugin module if possible
111 # import GHS3DPlugin module if possible
119 # import GHS3DPRLPlugin module if possible
122 import GHS3DPRLPlugin
127 # import HexoticPlugin module if possible
135 # import BLSURFPlugin module if possible
143 ## @addtogroup l1_auxiliary
146 # Types of algorithms
159 NETGEN_1D2D3D = FULL_NETGEN
160 NETGEN_FULL = FULL_NETGEN
168 # MirrorType enumeration
169 POINT = SMESH_MeshEditor.POINT
170 AXIS = SMESH_MeshEditor.AXIS
171 PLANE = SMESH_MeshEditor.PLANE
173 # Smooth_Method enumeration
174 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
175 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
177 # Fineness enumeration (for NETGEN)
185 # Optimization level of GHS3D
187 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
188 # V4.1 (partialy redefines V3.1). Issue 0020574
189 None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization, Strong_Optimization = 0,1,2,3,4
191 # Topology treatment way of BLSURF
192 FromCAD, PreProcess, PreProcessPlus = 0,1,2
194 # Element size flag of BLSURF
195 DefaultSize, DefaultGeom, Custom = 0,0,1
197 PrecisionConfusion = 1e-07
199 # TopAbs_State enumeration
200 [TopAbs_IN, TopAbs_OUT, TopAbs_ON, TopAbs_UNKNOWN] = range(4)
202 # Methods of splitting a hexahedron into tetrahedra
203 Hex_5Tet, Hex_6Tet, Hex_24Tet = 1, 2, 3
205 # import items of enum QuadType
206 for e in StdMeshers.QuadType._items: exec('%s = StdMeshers.%s'%(e,e))
208 ## Converts an angle from degrees to radians
209 def DegreesToRadians(AngleInDegrees):
211 return AngleInDegrees * pi / 180.0
213 # Salome notebook variable separator
216 # Parametrized substitute for PointStruct
217 class PointStructStr:
226 def __init__(self, xStr, yStr, zStr):
230 if isinstance(xStr, str) and notebook.isVariable(xStr):
231 self.x = notebook.get(xStr)
234 if isinstance(yStr, str) and notebook.isVariable(yStr):
235 self.y = notebook.get(yStr)
238 if isinstance(zStr, str) and notebook.isVariable(zStr):
239 self.z = notebook.get(zStr)
243 # Parametrized substitute for PointStruct (with 6 parameters)
244 class PointStructStr6:
259 def __init__(self, x1Str, x2Str, y1Str, y2Str, z1Str, z2Str):
266 if isinstance(x1Str, str) and notebook.isVariable(x1Str):
267 self.x1 = notebook.get(x1Str)
270 if isinstance(x2Str, str) and notebook.isVariable(x2Str):
271 self.x2 = notebook.get(x2Str)
274 if isinstance(y1Str, str) and notebook.isVariable(y1Str):
275 self.y1 = notebook.get(y1Str)
278 if isinstance(y2Str, str) and notebook.isVariable(y2Str):
279 self.y2 = notebook.get(y2Str)
282 if isinstance(z1Str, str) and notebook.isVariable(z1Str):
283 self.z1 = notebook.get(z1Str)
286 if isinstance(z2Str, str) and notebook.isVariable(z2Str):
287 self.z2 = notebook.get(z2Str)
291 # Parametrized substitute for AxisStruct
307 def __init__(self, xStr, yStr, zStr, dxStr, dyStr, dzStr):
314 if isinstance(xStr, str) and notebook.isVariable(xStr):
315 self.x = notebook.get(xStr)
318 if isinstance(yStr, str) and notebook.isVariable(yStr):
319 self.y = notebook.get(yStr)
322 if isinstance(zStr, str) and notebook.isVariable(zStr):
323 self.z = notebook.get(zStr)
326 if isinstance(dxStr, str) and notebook.isVariable(dxStr):
327 self.dx = notebook.get(dxStr)
330 if isinstance(dyStr, str) and notebook.isVariable(dyStr):
331 self.dy = notebook.get(dyStr)
334 if isinstance(dzStr, str) and notebook.isVariable(dzStr):
335 self.dz = notebook.get(dzStr)
339 # Parametrized substitute for DirStruct
342 def __init__(self, pointStruct):
343 self.pointStruct = pointStruct
345 # Returns list of variable values from salome notebook
346 def ParsePointStruct(Point):
347 Parameters = 2*var_separator
348 if isinstance(Point, PointStructStr):
349 Parameters = str(Point.xStr) + var_separator + str(Point.yStr) + var_separator + str(Point.zStr)
350 Point = PointStruct(Point.x, Point.y, Point.z)
351 return Point, Parameters
353 # Returns list of variable values from salome notebook
354 def ParseDirStruct(Dir):
355 Parameters = 2*var_separator
356 if isinstance(Dir, DirStructStr):
357 pntStr = Dir.pointStruct
358 if isinstance(pntStr, PointStructStr6):
359 Parameters = str(pntStr.x1Str) + var_separator + str(pntStr.x2Str) + var_separator
360 Parameters += str(pntStr.y1Str) + var_separator + str(pntStr.y2Str) + var_separator
361 Parameters += str(pntStr.z1Str) + var_separator + str(pntStr.z2Str)
362 Point = PointStruct(pntStr.x2 - pntStr.x1, pntStr.y2 - pntStr.y1, pntStr.z2 - pntStr.z1)
364 Parameters = str(pntStr.xStr) + var_separator + str(pntStr.yStr) + var_separator + str(pntStr.zStr)
365 Point = PointStruct(pntStr.x, pntStr.y, pntStr.z)
366 Dir = DirStruct(Point)
367 return Dir, Parameters
369 # Returns list of variable values from salome notebook
370 def ParseAxisStruct(Axis):
371 Parameters = 5*var_separator
372 if isinstance(Axis, AxisStructStr):
373 Parameters = str(Axis.xStr) + var_separator + str(Axis.yStr) + var_separator + str(Axis.zStr) + var_separator
374 Parameters += str(Axis.dxStr) + var_separator + str(Axis.dyStr) + var_separator + str(Axis.dzStr)
375 Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz)
376 return Axis, Parameters
378 ## Return list of variable values from salome notebook
379 def ParseAngles(list):
382 for parameter in list:
383 if isinstance(parameter,str) and notebook.isVariable(parameter):
384 Result.append(DegreesToRadians(notebook.get(parameter)))
387 Result.append(parameter)
390 Parameters = Parameters + str(parameter)
391 Parameters = Parameters + var_separator
393 Parameters = Parameters[:len(Parameters)-1]
394 return Result, Parameters
396 def IsEqual(val1, val2, tol=PrecisionConfusion):
397 if abs(val1 - val2) < tol:
407 if isinstance(obj, SALOMEDS._objref_SObject):
410 ior = salome.orb.object_to_string(obj)
413 studies = salome.myStudyManager.GetOpenStudies()
414 for sname in studies:
415 s = salome.myStudyManager.GetStudyByName(sname)
417 sobj = s.FindObjectIOR(ior)
418 if not sobj: continue
419 return sobj.GetName()
420 if hasattr(obj, "GetName"):
421 # unknown CORBA object, having GetName() method
424 # unknown CORBA object, no GetName() method
427 if hasattr(obj, "GetName"):
428 # unknown non-CORBA object, having GetName() method
431 raise RuntimeError, "Null or invalid object"
433 ## Prints error message if a hypothesis was not assigned.
434 def TreatHypoStatus(status, hypName, geomName, isAlgo):
436 hypType = "algorithm"
438 hypType = "hypothesis"
440 if status == HYP_UNKNOWN_FATAL :
441 reason = "for unknown reason"
442 elif status == HYP_INCOMPATIBLE :
443 reason = "this hypothesis mismatches the algorithm"
444 elif status == HYP_NOTCONFORM :
445 reason = "a non-conform mesh would be built"
446 elif status == HYP_ALREADY_EXIST :
447 if isAlgo: return # it does not influence anything
448 reason = hypType + " of the same dimension is already assigned to this shape"
449 elif status == HYP_BAD_DIM :
450 reason = hypType + " mismatches the shape"
451 elif status == HYP_CONCURENT :
452 reason = "there are concurrent hypotheses on sub-shapes"
453 elif status == HYP_BAD_SUBSHAPE :
454 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
455 elif status == HYP_BAD_GEOMETRY:
456 reason = "geometry mismatches the expectation of the algorithm"
457 elif status == HYP_HIDDEN_ALGO:
458 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
459 elif status == HYP_HIDING_ALGO:
460 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
461 elif status == HYP_NEED_SHAPE:
462 reason = "Algorithm can't work without shape"
465 hypName = '"' + hypName + '"'
466 geomName= '"' + geomName+ '"'
467 if status < HYP_UNKNOWN_FATAL and not geomName =='""':
468 print hypName, "was assigned to", geomName,"but", reason
469 elif not geomName == '""':
470 print hypName, "was not assigned to",geomName,":", reason
472 print hypName, "was not assigned:", reason
475 ## Check meshing plugin availability
476 def CheckPlugin(plugin):
477 if plugin == NETGEN and noNETGENPlugin:
478 print "Warning: NETGENPlugin module unavailable"
480 elif plugin == GHS3D and noGHS3DPlugin:
481 print "Warning: GHS3DPlugin module unavailable"
483 elif plugin == GHS3DPRL and noGHS3DPRLPlugin:
484 print "Warning: GHS3DPRLPlugin module unavailable"
486 elif plugin == Hexotic and noHexoticPlugin:
487 print "Warning: HexoticPlugin module unavailable"
489 elif plugin == BLSURF and noBLSURFPlugin:
490 print "Warning: BLSURFPlugin module unavailable"
494 # end of l1_auxiliary
497 # All methods of this class are accessible directly from the smesh.py package.
498 class smeshDC(SMESH._objref_SMESH_Gen):
500 ## Sets the current study and Geometry component
501 # @ingroup l1_auxiliary
502 def init_smesh(self,theStudy,geompyD):
503 self.SetCurrentStudy(theStudy,geompyD)
505 ## Creates an empty Mesh. This mesh can have an underlying geometry.
506 # @param obj the Geometrical object on which the mesh is built. If not defined,
507 # the mesh will have no underlying geometry.
508 # @param name the name for the new mesh.
509 # @return an instance of Mesh class.
510 # @ingroup l2_construct
511 def Mesh(self, obj=0, name=0):
512 if isinstance(obj,str):
514 return Mesh(self,self.geompyD,obj,name)
516 ## Returns a long value from enumeration
517 # Should be used for SMESH.FunctorType enumeration
518 # @ingroup l1_controls
519 def EnumToLong(self,theItem):
522 ## Returns a string representation of the color.
523 # To be used with filters.
524 # @param c color value (SALOMEDS.Color)
525 # @ingroup l1_controls
526 def ColorToString(self,c):
528 if isinstance(c, SALOMEDS.Color):
529 val = "%s;%s;%s" % (c.R, c.G, c.B)
530 elif isinstance(c, str):
533 raise ValueError, "Color value should be of string or SALOMEDS.Color type"
536 ## Gets PointStruct from vertex
537 # @param theVertex a GEOM object(vertex)
538 # @return SMESH.PointStruct
539 # @ingroup l1_auxiliary
540 def GetPointStruct(self,theVertex):
541 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
542 return PointStruct(x,y,z)
544 ## Gets DirStruct from vector
545 # @param theVector a GEOM object(vector)
546 # @return SMESH.DirStruct
547 # @ingroup l1_auxiliary
548 def GetDirStruct(self,theVector):
549 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
550 if(len(vertices) != 2):
551 print "Error: vector object is incorrect."
553 p1 = self.geompyD.PointCoordinates(vertices[0])
554 p2 = self.geompyD.PointCoordinates(vertices[1])
555 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
556 dirst = DirStruct(pnt)
559 ## Makes DirStruct from a triplet
560 # @param x,y,z vector components
561 # @return SMESH.DirStruct
562 # @ingroup l1_auxiliary
563 def MakeDirStruct(self,x,y,z):
564 pnt = PointStruct(x,y,z)
565 return DirStruct(pnt)
567 ## Get AxisStruct from object
568 # @param theObj a GEOM object (line or plane)
569 # @return SMESH.AxisStruct
570 # @ingroup l1_auxiliary
571 def GetAxisStruct(self,theObj):
572 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
574 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
575 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
576 vertex1 = self.geompyD.PointCoordinates(vertex1)
577 vertex2 = self.geompyD.PointCoordinates(vertex2)
578 vertex3 = self.geompyD.PointCoordinates(vertex3)
579 vertex4 = self.geompyD.PointCoordinates(vertex4)
580 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
581 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
582 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] ]
583 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
585 elif len(edges) == 1:
586 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
587 p1 = self.geompyD.PointCoordinates( vertex1 )
588 p2 = self.geompyD.PointCoordinates( vertex2 )
589 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
593 # From SMESH_Gen interface:
594 # ------------------------
596 ## Sets the given name to the object
597 # @param obj the object to rename
598 # @param name a new object name
599 # @ingroup l1_auxiliary
600 def SetName(self, obj, name):
601 if isinstance( obj, Mesh ):
603 elif isinstance( obj, Mesh_Algorithm ):
604 obj = obj.GetAlgorithm()
605 ior = salome.orb.object_to_string(obj)
606 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
608 ## Sets the current mode
609 # @ingroup l1_auxiliary
610 def SetEmbeddedMode( self,theMode ):
611 #self.SetEmbeddedMode(theMode)
612 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
614 ## Gets the current mode
615 # @ingroup l1_auxiliary
616 def IsEmbeddedMode(self):
617 #return self.IsEmbeddedMode()
618 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
620 ## Sets the current study
621 # @ingroup l1_auxiliary
622 def SetCurrentStudy( self, theStudy, geompyD = None ):
623 #self.SetCurrentStudy(theStudy)
626 geompyD = geompy.geom
629 self.SetGeomEngine(geompyD)
630 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
632 ## Gets the current study
633 # @ingroup l1_auxiliary
634 def GetCurrentStudy(self):
635 #return self.GetCurrentStudy()
636 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
638 ## Creates a Mesh object importing data from the given UNV file
639 # @return an instance of Mesh class
641 def CreateMeshesFromUNV( self,theFileName ):
642 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
643 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
646 ## Creates a Mesh object(s) importing data from the given MED file
647 # @return a list of Mesh class instances
649 def CreateMeshesFromMED( self,theFileName ):
650 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
652 for iMesh in range(len(aSmeshMeshes)) :
653 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
654 aMeshes.append(aMesh)
655 return aMeshes, aStatus
657 ## Creates a Mesh object importing data from the given STL file
658 # @return an instance of Mesh class
660 def CreateMeshesFromSTL( self, theFileName ):
661 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
662 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
665 ## From SMESH_Gen interface
666 # @return the list of integer values
667 # @ingroup l1_auxiliary
668 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
669 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
671 ## From SMESH_Gen interface. Creates a pattern
672 # @return an instance of SMESH_Pattern
674 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
675 # @ingroup l2_modif_patterns
676 def GetPattern(self):
677 return SMESH._objref_SMESH_Gen.GetPattern(self)
679 ## Sets number of segments per diagonal of boundary box of geometry by which
680 # default segment length of appropriate 1D hypotheses is defined.
681 # Default value is 10
682 # @ingroup l1_auxiliary
683 def SetBoundaryBoxSegmentation(self, nbSegments):
684 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
686 ## Concatenate the given meshes into one mesh.
687 # @return an instance of Mesh class
688 # @param meshes the meshes to combine into one mesh
689 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
690 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
691 # @param mergeTolerance tolerance for merging nodes
692 # @param allGroups forces creation of groups of all elements
693 def Concatenate( self, meshes, uniteIdenticalGroups,
694 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
695 mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
696 for i,m in enumerate(meshes):
697 if isinstance(m, Mesh):
698 meshes[i] = m.GetMesh()
700 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
701 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
703 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
704 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
705 aSmeshMesh.SetParameters(Parameters)
706 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
709 # Filtering. Auxiliary functions:
710 # ------------------------------
712 ## Creates an empty criterion
713 # @return SMESH.Filter.Criterion
714 # @ingroup l1_controls
715 def GetEmptyCriterion(self):
716 Type = self.EnumToLong(FT_Undefined)
717 Compare = self.EnumToLong(FT_Undefined)
721 UnaryOp = self.EnumToLong(FT_Undefined)
722 BinaryOp = self.EnumToLong(FT_Undefined)
725 Precision = -1 ##@1e-07
726 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
727 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
729 ## Creates a criterion by the given parameters
730 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
731 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
732 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
733 # @param Treshold the threshold value (range of ids as string, shape, numeric)
734 # @param UnaryOp FT_LogicalNOT or FT_Undefined
735 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
736 # FT_Undefined (must be for the last criterion of all criteria)
737 # @return SMESH.Filter.Criterion
738 # @ingroup l1_controls
739 def GetCriterion(self,elementType,
741 Compare = FT_EqualTo,
743 UnaryOp=FT_Undefined,
744 BinaryOp=FT_Undefined):
745 aCriterion = self.GetEmptyCriterion()
746 aCriterion.TypeOfElement = elementType
747 aCriterion.Type = self.EnumToLong(CritType)
751 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
752 aCriterion.Compare = self.EnumToLong(Compare)
753 elif Compare == "=" or Compare == "==":
754 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
756 aCriterion.Compare = self.EnumToLong(FT_LessThan)
758 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
760 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
763 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
764 FT_BelongToCylinder, FT_LyingOnGeom]:
765 # Checks the treshold
766 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
767 aCriterion.ThresholdStr = GetName(aTreshold)
768 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
770 print "Error: The treshold should be a shape."
772 elif CritType == FT_RangeOfIds:
773 # Checks the treshold
774 if isinstance(aTreshold, str):
775 aCriterion.ThresholdStr = aTreshold
777 print "Error: The treshold should be a string."
779 elif CritType == FT_CoplanarFaces:
780 # Checks the treshold
781 if isinstance(aTreshold, int):
782 aCriterion.ThresholdID = "%s"%aTreshold
783 elif isinstance(aTreshold, str):
786 raise ValueError, "Invalid ID of mesh face: '%s'"%aTreshold
787 aCriterion.ThresholdID = aTreshold
790 "The treshold should be an ID of mesh face and not '%s'"%aTreshold
791 elif CritType == FT_ElemGeomType:
792 # Checks the treshold
794 aCriterion.Threshold = self.EnumToLong(aTreshold)
796 if isinstance(aTreshold, int):
797 aCriterion.Threshold = aTreshold
799 print "Error: The treshold should be an integer or SMESH.GeometryType."
803 elif CritType == FT_GroupColor:
804 # Checks the treshold
806 aCriterion.ThresholdStr = self.ColorToString(aTreshold)
808 print "Error: The threshold value should be of SALOMEDS.Color type"
811 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
812 FT_FreeFaces, FT_LinearOrQuadratic]:
813 # At this point the treshold is unnecessary
814 if aTreshold == FT_LogicalNOT:
815 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
816 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
817 aCriterion.BinaryOp = aTreshold
821 aTreshold = float(aTreshold)
822 aCriterion.Threshold = aTreshold
824 print "Error: The treshold should be a number."
827 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
828 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
830 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
831 aCriterion.BinaryOp = self.EnumToLong(Treshold)
833 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
834 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
836 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
837 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
841 ## Creates a filter with the given parameters
842 # @param elementType the type of elements in the group
843 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
844 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
845 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
846 # @param UnaryOp FT_LogicalNOT or FT_Undefined
847 # @return SMESH_Filter
848 # @ingroup l1_controls
849 def GetFilter(self,elementType,
850 CritType=FT_Undefined,
853 UnaryOp=FT_Undefined):
854 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
855 aFilterMgr = self.CreateFilterManager()
856 aFilter = aFilterMgr.CreateFilter()
858 aCriteria.append(aCriterion)
859 aFilter.SetCriteria(aCriteria)
862 ## Creates a numerical functor by its type
863 # @param theCriterion FT_...; functor type
864 # @return SMESH_NumericalFunctor
865 # @ingroup l1_controls
866 def GetFunctor(self,theCriterion):
867 aFilterMgr = self.CreateFilterManager()
868 if theCriterion == FT_AspectRatio:
869 return aFilterMgr.CreateAspectRatio()
870 elif theCriterion == FT_AspectRatio3D:
871 return aFilterMgr.CreateAspectRatio3D()
872 elif theCriterion == FT_Warping:
873 return aFilterMgr.CreateWarping()
874 elif theCriterion == FT_MinimumAngle:
875 return aFilterMgr.CreateMinimumAngle()
876 elif theCriterion == FT_Taper:
877 return aFilterMgr.CreateTaper()
878 elif theCriterion == FT_Skew:
879 return aFilterMgr.CreateSkew()
880 elif theCriterion == FT_Area:
881 return aFilterMgr.CreateArea()
882 elif theCriterion == FT_Volume3D:
883 return aFilterMgr.CreateVolume3D()
884 elif theCriterion == FT_MultiConnection:
885 return aFilterMgr.CreateMultiConnection()
886 elif theCriterion == FT_MultiConnection2D:
887 return aFilterMgr.CreateMultiConnection2D()
888 elif theCriterion == FT_Length:
889 return aFilterMgr.CreateLength()
890 elif theCriterion == FT_Length2D:
891 return aFilterMgr.CreateLength2D()
893 print "Error: given parameter is not numerucal functor type."
895 ## Creates hypothesis
896 # @param theHType mesh hypothesis type (string)
897 # @param theLibName mesh plug-in library name
898 # @return created hypothesis instance
899 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
900 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
902 ## Gets the mesh stattistic
903 # @return dictionary type element - count of elements
904 # @ingroup l1_meshinfo
905 def GetMeshInfo(self, obj):
906 if isinstance( obj, Mesh ):
909 if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource):
910 values = obj.GetMeshInfo()
911 for i in range(SMESH.Entity_Last._v):
912 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
917 #Registering the new proxy for SMESH_Gen
918 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
924 ## This class allows defining and managing a mesh.
925 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
926 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
927 # new nodes and elements and by changing the existing entities), to get information
928 # about a mesh and to export a mesh into different formats.
937 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
938 # sets the GUI name of this mesh to \a name.
939 # @param smeshpyD an instance of smeshDC class
940 # @param geompyD an instance of geompyDC class
941 # @param obj Shape to be meshed or SMESH_Mesh object
942 # @param name Study name of the mesh
943 # @ingroup l2_construct
944 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
945 self.smeshpyD=smeshpyD
950 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
952 self.mesh = self.smeshpyD.CreateMesh(self.geom)
953 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
956 self.mesh = self.smeshpyD.CreateEmptyMesh()
958 self.smeshpyD.SetName(self.mesh, name)
960 self.smeshpyD.SetName(self.mesh, GetName(obj))
963 self.geom = self.mesh.GetShapeToMesh()
965 self.editor = self.mesh.GetMeshEditor()
967 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
968 # @param theMesh a SMESH_Mesh object
969 # @ingroup l2_construct
970 def SetMesh(self, theMesh):
972 self.geom = self.mesh.GetShapeToMesh()
974 ## Returns the mesh, that is an instance of SMESH_Mesh interface
975 # @return a SMESH_Mesh object
976 # @ingroup l2_construct
980 ## Gets the name of the mesh
981 # @return the name of the mesh as a string
982 # @ingroup l2_construct
984 name = GetName(self.GetMesh())
987 ## Sets a name to the mesh
988 # @param name a new name of the mesh
989 # @ingroup l2_construct
990 def SetName(self, name):
991 self.smeshpyD.SetName(self.GetMesh(), name)
993 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
994 # The subMesh object gives access to the IDs of nodes and elements.
995 # @param theSubObject a geometrical object (shape)
996 # @param theName a name for the submesh
997 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
998 # @ingroup l2_submeshes
999 def GetSubMesh(self, theSubObject, theName):
1000 submesh = self.mesh.GetSubMesh(theSubObject, theName)
1003 ## Returns the shape associated to the mesh
1004 # @return a GEOM_Object
1005 # @ingroup l2_construct
1009 ## Associates the given shape to the mesh (entails the recreation of the mesh)
1010 # @param geom the shape to be meshed (GEOM_Object)
1011 # @ingroup l2_construct
1012 def SetShape(self, geom):
1013 self.mesh = self.smeshpyD.CreateMesh(geom)
1015 ## Returns true if the hypotheses are defined well
1016 # @param theSubObject a subshape of a mesh shape
1017 # @return True or False
1018 # @ingroup l2_construct
1019 def IsReadyToCompute(self, theSubObject):
1020 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
1022 ## Returns errors of hypotheses definition.
1023 # The list of errors is empty if everything is OK.
1024 # @param theSubObject a subshape of a mesh shape
1025 # @return a list of errors
1026 # @ingroup l2_construct
1027 def GetAlgoState(self, theSubObject):
1028 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
1030 ## Returns a geometrical object on which the given element was built.
1031 # The returned geometrical object, if not nil, is either found in the
1032 # study or published by this method with the given name
1033 # @param theElementID the id of the mesh element
1034 # @param theGeomName the user-defined name of the geometrical object
1035 # @return GEOM::GEOM_Object instance
1036 # @ingroup l2_construct
1037 def GetGeometryByMeshElement(self, theElementID, theGeomName):
1038 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
1040 ## Returns the mesh dimension depending on the dimension of the underlying shape
1041 # @return mesh dimension as an integer value [0,3]
1042 # @ingroup l1_auxiliary
1043 def MeshDimension(self):
1044 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
1045 if len( shells ) > 0 :
1047 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
1049 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
1055 ## Creates a segment discretization 1D algorithm.
1056 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
1057 # \n If the optional \a geom parameter is not set, this algorithm is global.
1058 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1059 # @param algo the type of the required algorithm. Possible values are:
1061 # - smesh.PYTHON for discretization via a python function,
1062 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
1063 # @param geom If defined is the subshape to be meshed
1064 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
1065 # @ingroup l3_algos_basic
1066 def Segment(self, algo=REGULAR, geom=0):
1067 ## if Segment(geom) is called by mistake
1068 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
1069 algo, geom = geom, algo
1070 if not algo: algo = REGULAR
1073 return Mesh_Segment(self, geom)
1074 elif algo == PYTHON:
1075 return Mesh_Segment_Python(self, geom)
1076 elif algo == COMPOSITE:
1077 return Mesh_CompositeSegment(self, geom)
1079 return Mesh_Segment(self, geom)
1081 ## Enables creation of nodes and segments usable by 2D algoritms.
1082 # The added nodes and segments must be bound to edges and vertices by
1083 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
1084 # If the optional \a geom parameter is not set, this algorithm is global.
1085 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1086 # @param geom the subshape to be manually meshed
1087 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
1088 # @ingroup l3_algos_basic
1089 def UseExistingSegments(self, geom=0):
1090 algo = Mesh_UseExisting(1,self,geom)
1091 return algo.GetAlgorithm()
1093 ## Enables creation of nodes and faces usable by 3D algoritms.
1094 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
1095 # and SetMeshElementOnShape()
1096 # If the optional \a geom parameter is not set, this algorithm is global.
1097 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1098 # @param geom the subshape to be manually meshed
1099 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1100 # @ingroup l3_algos_basic
1101 def UseExistingFaces(self, geom=0):
1102 algo = Mesh_UseExisting(2,self,geom)
1103 return algo.GetAlgorithm()
1105 ## Creates a triangle 2D algorithm for faces.
1106 # If the optional \a geom parameter is not set, this algorithm is global.
1107 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1108 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1109 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1110 # @return an instance of Mesh_Triangle algorithm
1111 # @ingroup l3_algos_basic
1112 def Triangle(self, algo=MEFISTO, geom=0):
1113 ## if Triangle(geom) is called by mistake
1114 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1117 return Mesh_Triangle(self, algo, geom)
1119 ## Creates a quadrangle 2D algorithm for faces.
1120 # If the optional \a geom parameter is not set, this algorithm is global.
1121 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1122 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1123 # @param algo values are: smesh.QUADRANGLE || smesh.RADIAL_QUAD
1124 # @return an instance of Mesh_Quadrangle algorithm
1125 # @ingroup l3_algos_basic
1126 def Quadrangle(self, geom=0, algo=QUADRANGLE):
1127 if algo==RADIAL_QUAD:
1128 return Mesh_RadialQuadrangle1D2D(self,geom)
1130 return Mesh_Quadrangle(self, geom)
1132 ## Creates a tetrahedron 3D algorithm for solids.
1133 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1134 # If the optional \a geom parameter is not set, this algorithm is global.
1135 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1136 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1137 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1138 # @return an instance of Mesh_Tetrahedron algorithm
1139 # @ingroup l3_algos_basic
1140 def Tetrahedron(self, algo=NETGEN, geom=0):
1141 ## if Tetrahedron(geom) is called by mistake
1142 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1143 algo, geom = geom, algo
1144 if not algo: algo = NETGEN
1146 return Mesh_Tetrahedron(self, algo, geom)
1148 ## Creates a hexahedron 3D algorithm for solids.
1149 # If the optional \a geom parameter is not set, this algorithm is global.
1150 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1151 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1152 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1153 # @return an instance of Mesh_Hexahedron algorithm
1154 # @ingroup l3_algos_basic
1155 def Hexahedron(self, algo=Hexa, geom=0):
1156 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1157 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1158 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1159 elif geom == 0: algo, geom = Hexa, algo
1160 return Mesh_Hexahedron(self, algo, geom)
1162 ## Deprecated, used only for compatibility!
1163 # @return an instance of Mesh_Netgen algorithm
1164 # @ingroup l3_algos_basic
1165 def Netgen(self, is3D, geom=0):
1166 return Mesh_Netgen(self, is3D, geom)
1168 ## Creates a projection 1D algorithm for edges.
1169 # If the optional \a geom parameter is not set, this algorithm is global.
1170 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1171 # @param geom If defined, the subshape to be meshed
1172 # @return an instance of Mesh_Projection1D algorithm
1173 # @ingroup l3_algos_proj
1174 def Projection1D(self, geom=0):
1175 return Mesh_Projection1D(self, geom)
1177 ## Creates a projection 2D algorithm for faces.
1178 # If the optional \a geom parameter is not set, this algorithm is global.
1179 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1180 # @param geom If defined, the subshape to be meshed
1181 # @return an instance of Mesh_Projection2D algorithm
1182 # @ingroup l3_algos_proj
1183 def Projection2D(self, geom=0):
1184 return Mesh_Projection2D(self, geom)
1186 ## Creates a projection 3D algorithm for solids.
1187 # If the optional \a geom parameter is not set, this algorithm is global.
1188 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1189 # @param geom If defined, the subshape to be meshed
1190 # @return an instance of Mesh_Projection3D algorithm
1191 # @ingroup l3_algos_proj
1192 def Projection3D(self, geom=0):
1193 return Mesh_Projection3D(self, geom)
1195 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1196 # If the optional \a geom parameter is not set, this algorithm is global.
1197 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1198 # @param geom If defined, the subshape to be meshed
1199 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1200 # @ingroup l3_algos_radialp l3_algos_3dextr
1201 def Prism(self, geom=0):
1205 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1206 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1207 if nbSolids == 0 or nbSolids == nbShells:
1208 return Mesh_Prism3D(self, geom)
1209 return Mesh_RadialPrism3D(self, geom)
1211 ## Evaluates size of prospective mesh on a shape
1212 # @return True or False
1213 def Evaluate(self, geom=0):
1214 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1216 geom = self.mesh.GetShapeToMesh()
1219 return self.smeshpyD.Evaluate(self.mesh, geom)
1222 ## Computes the mesh and returns the status of the computation
1223 # @param geom geomtrical shape on which mesh data should be computed
1224 # @param discardModifs if True and the mesh has been edited since
1225 # a last total re-compute and that may prevent successful partial re-compute,
1226 # then the mesh is cleaned before Compute()
1227 # @return True or False
1228 # @ingroup l2_construct
1229 def Compute(self, geom=0, discardModifs=False):
1230 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1232 geom = self.mesh.GetShapeToMesh()
1237 if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693
1239 ok = self.smeshpyD.Compute(self.mesh, geom)
1240 except SALOME.SALOME_Exception, ex:
1241 print "Mesh computation failed, exception caught:"
1242 print " ", ex.details.text
1245 print "Mesh computation failed, exception caught:"
1246 traceback.print_exc()
1250 # Treat compute errors
1251 computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
1252 for err in computeErrors:
1254 if self.mesh.HasShapeToMesh():
1256 mainIOR = salome.orb.object_to_string(geom)
1257 for sname in salome.myStudyManager.GetOpenStudies():
1258 s = salome.myStudyManager.GetStudyByName(sname)
1260 mainSO = s.FindObjectIOR(mainIOR)
1261 if not mainSO: continue
1262 if err.subShapeID == 1:
1263 shapeText = ' on "%s"' % mainSO.GetName()
1264 subIt = s.NewChildIterator(mainSO)
1266 subSO = subIt.Value()
1268 obj = subSO.GetObject()
1269 if not obj: continue
1270 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
1272 ids = go.GetSubShapeIndices()
1273 if len(ids) == 1 and ids[0] == err.subShapeID:
1274 shapeText = ' on "%s"' % subSO.GetName()
1277 shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
1279 shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID)
1281 shapeText = " on subshape #%s" % (err.subShapeID)
1283 shapeText = " on subshape #%s" % (err.subShapeID)
1285 stdErrors = ["OK", #COMPERR_OK
1286 "Invalid input mesh", #COMPERR_BAD_INPUT_MESH
1287 "std::exception", #COMPERR_STD_EXCEPTION
1288 "OCC exception", #COMPERR_OCC_EXCEPTION
1289 "SALOME exception", #COMPERR_SLM_EXCEPTION
1290 "Unknown exception", #COMPERR_EXCEPTION
1291 "Memory allocation problem", #COMPERR_MEMORY_PB
1292 "Algorithm failed", #COMPERR_ALGO_FAILED
1293 "Unexpected geometry"]#COMPERR_BAD_SHAPE
1295 if err.code < len(stdErrors): errText = stdErrors[err.code]
1297 errText = "code %s" % -err.code
1298 if errText: errText += ". "
1299 errText += err.comment
1300 if allReasons != "":allReasons += "\n"
1301 allReasons += '"%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
1305 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1307 if err.isGlobalAlgo:
1315 reason = '%s %sD algorithm is missing' % (glob, dim)
1316 elif err.state == HYP_MISSING:
1317 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1318 % (glob, dim, name, dim))
1319 elif err.state == HYP_NOTCONFORM:
1320 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1321 elif err.state == HYP_BAD_PARAMETER:
1322 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1323 % ( glob, dim, name ))
1324 elif err.state == HYP_BAD_GEOMETRY:
1325 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1326 'geometry' % ( glob, dim, name ))
1328 reason = "For unknown reason."+\
1329 " Revise Mesh.Compute() implementation in smeshDC.py!"
1331 if allReasons != "":allReasons += "\n"
1332 allReasons += reason
1334 if allReasons != "":
1335 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1339 print '"' + GetName(self.mesh) + '"',"has not been computed."
1342 if salome.sg.hasDesktop():
1343 smeshgui = salome.ImportComponentGUI("SMESH")
1344 smeshgui.Init(self.mesh.GetStudyId())
1345 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1346 salome.sg.updateObjBrowser(1)
1350 ## Return submesh objects list in meshing order
1351 # @return list of list of submesh objects
1352 # @ingroup l2_construct
1353 def GetMeshOrder(self):
1354 return self.mesh.GetMeshOrder()
1356 ## Return submesh objects list in meshing order
1357 # @return list of list of submesh objects
1358 # @ingroup l2_construct
1359 def SetMeshOrder(self, submeshes):
1360 return self.mesh.SetMeshOrder(submeshes)
1362 ## Removes all nodes and elements
1363 # @ingroup l2_construct
1366 if salome.sg.hasDesktop():
1367 smeshgui = salome.ImportComponentGUI("SMESH")
1368 smeshgui.Init(self.mesh.GetStudyId())
1369 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1370 salome.sg.updateObjBrowser(1)
1372 ## Removes all nodes and elements of indicated shape
1373 # @ingroup l2_construct
1374 def ClearSubMesh(self, geomId):
1375 self.mesh.ClearSubMesh(geomId)
1376 if salome.sg.hasDesktop():
1377 smeshgui = salome.ImportComponentGUI("SMESH")
1378 smeshgui.Init(self.mesh.GetStudyId())
1379 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1380 salome.sg.updateObjBrowser(1)
1382 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1383 # @param fineness [0,-1] defines mesh fineness
1384 # @return True or False
1385 # @ingroup l3_algos_basic
1386 def AutomaticTetrahedralization(self, fineness=0):
1387 dim = self.MeshDimension()
1389 self.RemoveGlobalHypotheses()
1390 self.Segment().AutomaticLength(fineness)
1392 self.Triangle().LengthFromEdges()
1395 self.Tetrahedron(NETGEN)
1397 return self.Compute()
1399 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1400 # @param fineness [0,-1] defines mesh fineness
1401 # @return True or False
1402 # @ingroup l3_algos_basic
1403 def AutomaticHexahedralization(self, fineness=0):
1404 dim = self.MeshDimension()
1405 # assign the hypotheses
1406 self.RemoveGlobalHypotheses()
1407 self.Segment().AutomaticLength(fineness)
1414 return self.Compute()
1416 ## Assigns a hypothesis
1417 # @param hyp a hypothesis to assign
1418 # @param geom a subhape of mesh geometry
1419 # @return SMESH.Hypothesis_Status
1420 # @ingroup l2_hypotheses
1421 def AddHypothesis(self, hyp, geom=0):
1422 if isinstance( hyp, Mesh_Algorithm ):
1423 hyp = hyp.GetAlgorithm()
1428 geom = self.mesh.GetShapeToMesh()
1430 status = self.mesh.AddHypothesis(geom, hyp)
1431 isAlgo = hyp._narrow( SMESH_Algo )
1432 hyp_name = GetName( hyp )
1435 geom_name = GetName( geom )
1436 TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1439 ## Unassigns a hypothesis
1440 # @param hyp a hypothesis to unassign
1441 # @param geom a subshape of mesh geometry
1442 # @return SMESH.Hypothesis_Status
1443 # @ingroup l2_hypotheses
1444 def RemoveHypothesis(self, hyp, geom=0):
1445 if isinstance( hyp, Mesh_Algorithm ):
1446 hyp = hyp.GetAlgorithm()
1451 status = self.mesh.RemoveHypothesis(geom, hyp)
1454 ## Gets the list of hypotheses added on a geometry
1455 # @param geom a subshape of mesh geometry
1456 # @return the sequence of SMESH_Hypothesis
1457 # @ingroup l2_hypotheses
1458 def GetHypothesisList(self, geom):
1459 return self.mesh.GetHypothesisList( geom )
1461 ## Removes all global hypotheses
1462 # @ingroup l2_hypotheses
1463 def RemoveGlobalHypotheses(self):
1464 current_hyps = self.mesh.GetHypothesisList( self.geom )
1465 for hyp in current_hyps:
1466 self.mesh.RemoveHypothesis( self.geom, hyp )
1470 ## Creates a mesh group based on the geometric object \a grp
1471 # and gives a \a name, \n if this parameter is not defined
1472 # the name is the same as the geometric group name \n
1473 # Note: Works like GroupOnGeom().
1474 # @param grp a geometric group, a vertex, an edge, a face or a solid
1475 # @param name the name of the mesh group
1476 # @return SMESH_GroupOnGeom
1477 # @ingroup l2_grps_create
1478 def Group(self, grp, name=""):
1479 return self.GroupOnGeom(grp, name)
1481 ## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead.
1482 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1483 ## allowing to overwrite the file if it exists or add the exported data to its contents
1484 # @param f the file name
1485 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1486 # @param opt boolean parameter for creating/not creating
1487 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1488 # @param overwrite boolean parameter for overwriting/not overwriting the file
1489 # @ingroup l2_impexp
1490 def ExportToMED(self, f, version, opt=0, overwrite=1):
1491 self.mesh.ExportToMEDX(f, opt, version, overwrite)
1493 ## Exports the mesh in a file in MED format and chooses the \a version of MED format
1494 ## allowing to overwrite the file if it exists or add the exported data to its contents
1495 # @param f is the file name
1496 # @param auto_groups boolean parameter for creating/not creating
1497 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1498 # the typical use is auto_groups=false.
1499 # @param version MED format version(MED_V2_1 or MED_V2_2)
1500 # @param overwrite boolean parameter for overwriting/not overwriting the file
1501 # @ingroup l2_impexp
1502 def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1):
1503 self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
1505 ## Exports the mesh in a file in DAT format
1506 # @param f the file name
1507 # @ingroup l2_impexp
1508 def ExportDAT(self, f):
1509 self.mesh.ExportDAT(f)
1511 ## Exports the mesh in a file in UNV format
1512 # @param f the file name
1513 # @ingroup l2_impexp
1514 def ExportUNV(self, f):
1515 self.mesh.ExportUNV(f)
1517 ## Export the mesh in a file in STL format
1518 # @param f the file name
1519 # @param ascii defines the file encoding
1520 # @ingroup l2_impexp
1521 def ExportSTL(self, f, ascii=1):
1522 self.mesh.ExportSTL(f, ascii)
1525 # Operations with groups:
1526 # ----------------------
1528 ## Creates an empty mesh group
1529 # @param elementType the type of elements in the group
1530 # @param name the name of the mesh group
1531 # @return SMESH_Group
1532 # @ingroup l2_grps_create
1533 def CreateEmptyGroup(self, elementType, name):
1534 return self.mesh.CreateGroup(elementType, name)
1536 ## Creates a mesh group based on the geometrical object \a grp
1537 # and gives a \a name, \n if this parameter is not defined
1538 # the name is the same as the geometrical group name
1539 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1540 # @param name the name of the mesh group
1541 # @param typ the type of elements in the group. If not set, it is
1542 # automatically detected by the type of the geometry
1543 # @return SMESH_GroupOnGeom
1544 # @ingroup l2_grps_create
1545 def GroupOnGeom(self, grp, name="", typ=None):
1547 name = grp.GetName()
1550 tgeo = str(grp.GetShapeType())
1551 if tgeo == "VERTEX":
1553 elif tgeo == "EDGE":
1555 elif tgeo == "FACE":
1557 elif tgeo == "SOLID":
1559 elif tgeo == "SHELL":
1561 elif tgeo == "COMPOUND":
1562 try: # it raises on a compound of compounds
1563 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1564 print "Mesh.Group: empty geometric group", GetName( grp )
1569 if grp.GetType() == 37: # GEOMImpl_Types.hxx: #define GEOM_GROUP 37
1571 tgeo = self.geompyD.GetType(grp)
1572 if tgeo == geompyDC.ShapeType["VERTEX"]:
1574 elif tgeo == geompyDC.ShapeType["EDGE"]:
1576 elif tgeo == geompyDC.ShapeType["FACE"]:
1578 elif tgeo == geompyDC.ShapeType["SOLID"]:
1584 for elemType, shapeType in [[VOLUME,"SOLID"],[FACE,"FACE"],
1585 [EDGE,"EDGE"],[NODE,"VERTEX"]]:
1586 if self.geompyD.SubShapeAll(grp,geompyDC.ShapeType[shapeType]):
1594 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1597 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1599 ## Creates a mesh group by the given ids of elements
1600 # @param groupName the name of the mesh group
1601 # @param elementType the type of elements in the group
1602 # @param elemIDs the list of ids
1603 # @return SMESH_Group
1604 # @ingroup l2_grps_create
1605 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1606 group = self.mesh.CreateGroup(elementType, groupName)
1610 ## Creates a mesh group by the given conditions
1611 # @param groupName the name of the mesh group
1612 # @param elementType the type of elements in the group
1613 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1614 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1615 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1616 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1617 # @return SMESH_Group
1618 # @ingroup l2_grps_create
1622 CritType=FT_Undefined,
1625 UnaryOp=FT_Undefined):
1626 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1627 group = self.MakeGroupByCriterion(groupName, aCriterion)
1630 ## Creates a mesh group by the given criterion
1631 # @param groupName the name of the mesh group
1632 # @param Criterion the instance of Criterion class
1633 # @return SMESH_Group
1634 # @ingroup l2_grps_create
1635 def MakeGroupByCriterion(self, groupName, Criterion):
1636 aFilterMgr = self.smeshpyD.CreateFilterManager()
1637 aFilter = aFilterMgr.CreateFilter()
1638 aFilter.SetMesh( self.mesh )
1640 aCriteria.append(Criterion)
1641 aFilter.SetCriteria(aCriteria)
1642 group = self.MakeGroupByFilter(groupName, aFilter)
1645 ## Creates a mesh group by the given criteria (list of criteria)
1646 # @param groupName the name of the mesh group
1647 # @param theCriteria the list of criteria
1648 # @return SMESH_Group
1649 # @ingroup l2_grps_create
1650 def MakeGroupByCriteria(self, groupName, theCriteria):
1651 aFilterMgr = self.smeshpyD.CreateFilterManager()
1652 aFilter = aFilterMgr.CreateFilter()
1653 aFilter.SetMesh( self.mesh )
1654 aFilter.SetCriteria(theCriteria)
1655 group = self.MakeGroupByFilter(groupName, aFilter)
1658 ## Creates a mesh group by the given filter
1659 # @param groupName the name of the mesh group
1660 # @param theFilter the instance of Filter class
1661 # @return SMESH_Group
1662 # @ingroup l2_grps_create
1663 def MakeGroupByFilter(self, groupName, theFilter):
1664 group = self.CreateEmptyGroup(theFilter.GetElementType(), groupName)
1665 group.AddFrom( theFilter )
1668 ## Passes mesh elements through the given filter and return IDs of fitting elements
1669 # @param theFilter SMESH_Filter
1670 # @return a list of ids
1671 # @ingroup l1_controls
1672 def GetIdsFromFilter(self, theFilter):
1673 return theFilter.GetIDs()
1675 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1676 # Returns a list of special structures (borders).
1677 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1678 # @ingroup l1_controls
1679 def GetFreeBorders(self):
1680 aFilterMgr = self.smeshpyD.CreateFilterManager()
1681 aPredicate = aFilterMgr.CreateFreeEdges()
1682 aPredicate.SetMesh(self.mesh)
1683 aBorders = aPredicate.GetBorders()
1687 # @ingroup l2_grps_delete
1688 def RemoveGroup(self, group):
1689 self.mesh.RemoveGroup(group)
1691 ## Removes a group with its contents
1692 # @ingroup l2_grps_delete
1693 def RemoveGroupWithContents(self, group):
1694 self.mesh.RemoveGroupWithContents(group)
1696 ## Gets the list of groups existing in the mesh
1697 # @return a sequence of SMESH_GroupBase
1698 # @ingroup l2_grps_create
1699 def GetGroups(self):
1700 return self.mesh.GetGroups()
1702 ## Gets the number of groups existing in the mesh
1703 # @return the quantity of groups as an integer value
1704 # @ingroup l2_grps_create
1706 return self.mesh.NbGroups()
1708 ## Gets the list of names of groups existing in the mesh
1709 # @return list of strings
1710 # @ingroup l2_grps_create
1711 def GetGroupNames(self):
1712 groups = self.GetGroups()
1714 for group in groups:
1715 names.append(group.GetName())
1718 ## Produces a union of two groups
1719 # A new group is created. All mesh elements that are
1720 # present in the initial groups are added to the new one
1721 # @return an instance of SMESH_Group
1722 # @ingroup l2_grps_operon
1723 def UnionGroups(self, group1, group2, name):
1724 return self.mesh.UnionGroups(group1, group2, name)
1726 ## Produces a union list of groups
1727 # New group is created. All mesh elements that are present in
1728 # initial groups are added to the new one
1729 # @return an instance of SMESH_Group
1730 # @ingroup l2_grps_operon
1731 def UnionListOfGroups(self, groups, name):
1732 return self.mesh.UnionListOfGroups(groups, name)
1734 ## Prodices an intersection of two groups
1735 # A new group is created. All mesh elements that are common
1736 # for the two initial groups are added to the new one.
1737 # @return an instance of SMESH_Group
1738 # @ingroup l2_grps_operon
1739 def IntersectGroups(self, group1, group2, name):
1740 return self.mesh.IntersectGroups(group1, group2, name)
1742 ## Produces an intersection of groups
1743 # New group is created. All mesh elements that are present in all
1744 # initial groups simultaneously are added to the new one
1745 # @return an instance of SMESH_Group
1746 # @ingroup l2_grps_operon
1747 def IntersectListOfGroups(self, groups, name):
1748 return self.mesh.IntersectListOfGroups(groups, name)
1750 ## Produces a cut of two groups
1751 # A new group is created. All mesh elements that are present in
1752 # the main group but are not present in the tool group are added to the new one
1753 # @return an instance of SMESH_Group
1754 # @ingroup l2_grps_operon
1755 def CutGroups(self, main_group, tool_group, name):
1756 return self.mesh.CutGroups(main_group, tool_group, name)
1758 ## Produces a cut of groups
1759 # A new group is created. All mesh elements that are present in main groups
1760 # but do not present in tool groups are added to the new one
1761 # @return an instance of SMESH_Group
1762 # @ingroup l2_grps_operon
1763 def CutListOfGroups(self, main_groups, tool_groups, name):
1764 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1766 ## Produces a group of elements with specified element type using list of existing groups
1767 # A new group is created. System
1768 # 1) extract all nodes on which groups elements are built
1769 # 2) combine all elements of specified dimension laying on these nodes
1770 # @return an instance of SMESH_Group
1771 # @ingroup l2_grps_operon
1772 def CreateDimGroup(self, groups, elem_type, name):
1773 return self.mesh.CreateDimGroup(groups, elem_type, name)
1776 ## Convert group on geom into standalone group
1777 # @ingroup l2_grps_delete
1778 def ConvertToStandalone(self, group):
1779 return self.mesh.ConvertToStandalone(group)
1781 # Get some info about mesh:
1782 # ------------------------
1784 ## Returns the log of nodes and elements added or removed
1785 # since the previous clear of the log.
1786 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1787 # @return list of log_block structures:
1792 # @ingroup l1_auxiliary
1793 def GetLog(self, clearAfterGet):
1794 return self.mesh.GetLog(clearAfterGet)
1796 ## Clears the log of nodes and elements added or removed since the previous
1797 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1798 # @ingroup l1_auxiliary
1800 self.mesh.ClearLog()
1802 ## Toggles auto color mode on the object.
1803 # @param theAutoColor the flag which toggles auto color mode.
1804 # @ingroup l1_auxiliary
1805 def SetAutoColor(self, theAutoColor):
1806 self.mesh.SetAutoColor(theAutoColor)
1808 ## Gets flag of object auto color mode.
1809 # @return True or False
1810 # @ingroup l1_auxiliary
1811 def GetAutoColor(self):
1812 return self.mesh.GetAutoColor()
1814 ## Gets the internal ID
1815 # @return integer value, which is the internal Id of the mesh
1816 # @ingroup l1_auxiliary
1818 return self.mesh.GetId()
1821 # @return integer value, which is the study Id of the mesh
1822 # @ingroup l1_auxiliary
1823 def GetStudyId(self):
1824 return self.mesh.GetStudyId()
1826 ## Checks the group names for duplications.
1827 # Consider the maximum group name length stored in MED file.
1828 # @return True or False
1829 # @ingroup l1_auxiliary
1830 def HasDuplicatedGroupNamesMED(self):
1831 return self.mesh.HasDuplicatedGroupNamesMED()
1833 ## Obtains the mesh editor tool
1834 # @return an instance of SMESH_MeshEditor
1835 # @ingroup l1_modifying
1836 def GetMeshEditor(self):
1837 return self.mesh.GetMeshEditor()
1840 # @return an instance of SALOME_MED::MESH
1841 # @ingroup l1_auxiliary
1842 def GetMEDMesh(self):
1843 return self.mesh.GetMEDMesh()
1846 # Get informations about mesh contents:
1847 # ------------------------------------
1849 ## Gets the mesh stattistic
1850 # @return dictionary type element - count of elements
1851 # @ingroup l1_meshinfo
1852 def GetMeshInfo(self, obj = None):
1853 if not obj: obj = self.mesh
1854 return self.smeshpyD.GetMeshInfo(obj)
1856 ## Returns the number of nodes in the mesh
1857 # @return an integer value
1858 # @ingroup l1_meshinfo
1860 return self.mesh.NbNodes()
1862 ## Returns the number of elements in the mesh
1863 # @return an integer value
1864 # @ingroup l1_meshinfo
1865 def NbElements(self):
1866 return self.mesh.NbElements()
1868 ## Returns the number of 0d elements in the mesh
1869 # @return an integer value
1870 # @ingroup l1_meshinfo
1871 def Nb0DElements(self):
1872 return self.mesh.Nb0DElements()
1874 ## Returns the number of edges in the mesh
1875 # @return an integer value
1876 # @ingroup l1_meshinfo
1878 return self.mesh.NbEdges()
1880 ## Returns the number of edges with the given order in the mesh
1881 # @param elementOrder the order of elements:
1882 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1883 # @return an integer value
1884 # @ingroup l1_meshinfo
1885 def NbEdgesOfOrder(self, elementOrder):
1886 return self.mesh.NbEdgesOfOrder(elementOrder)
1888 ## Returns the number of faces in the mesh
1889 # @return an integer value
1890 # @ingroup l1_meshinfo
1892 return self.mesh.NbFaces()
1894 ## Returns the number of faces with the given order in the mesh
1895 # @param elementOrder the order of elements:
1896 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1897 # @return an integer value
1898 # @ingroup l1_meshinfo
1899 def NbFacesOfOrder(self, elementOrder):
1900 return self.mesh.NbFacesOfOrder(elementOrder)
1902 ## Returns the number of triangles in the mesh
1903 # @return an integer value
1904 # @ingroup l1_meshinfo
1905 def NbTriangles(self):
1906 return self.mesh.NbTriangles()
1908 ## Returns the number of triangles with the given order in the mesh
1909 # @param elementOrder is the order of elements:
1910 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1911 # @return an integer value
1912 # @ingroup l1_meshinfo
1913 def NbTrianglesOfOrder(self, elementOrder):
1914 return self.mesh.NbTrianglesOfOrder(elementOrder)
1916 ## Returns the number of quadrangles in the mesh
1917 # @return an integer value
1918 # @ingroup l1_meshinfo
1919 def NbQuadrangles(self):
1920 return self.mesh.NbQuadrangles()
1922 ## Returns the number of quadrangles with the given order in the mesh
1923 # @param elementOrder the order of elements:
1924 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1925 # @return an integer value
1926 # @ingroup l1_meshinfo
1927 def NbQuadranglesOfOrder(self, elementOrder):
1928 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1930 ## Returns the number of polygons in the mesh
1931 # @return an integer value
1932 # @ingroup l1_meshinfo
1933 def NbPolygons(self):
1934 return self.mesh.NbPolygons()
1936 ## Returns the number of volumes in the mesh
1937 # @return an integer value
1938 # @ingroup l1_meshinfo
1939 def NbVolumes(self):
1940 return self.mesh.NbVolumes()
1942 ## Returns the number of volumes with the given order in the mesh
1943 # @param elementOrder the order of elements:
1944 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1945 # @return an integer value
1946 # @ingroup l1_meshinfo
1947 def NbVolumesOfOrder(self, elementOrder):
1948 return self.mesh.NbVolumesOfOrder(elementOrder)
1950 ## Returns the number of tetrahedrons in the mesh
1951 # @return an integer value
1952 # @ingroup l1_meshinfo
1954 return self.mesh.NbTetras()
1956 ## Returns the number of tetrahedrons with the given order in the mesh
1957 # @param elementOrder the order of elements:
1958 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1959 # @return an integer value
1960 # @ingroup l1_meshinfo
1961 def NbTetrasOfOrder(self, elementOrder):
1962 return self.mesh.NbTetrasOfOrder(elementOrder)
1964 ## Returns the number of hexahedrons in the mesh
1965 # @return an integer value
1966 # @ingroup l1_meshinfo
1968 return self.mesh.NbHexas()
1970 ## Returns the number of hexahedrons with the given order in the mesh
1971 # @param elementOrder the order of elements:
1972 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1973 # @return an integer value
1974 # @ingroup l1_meshinfo
1975 def NbHexasOfOrder(self, elementOrder):
1976 return self.mesh.NbHexasOfOrder(elementOrder)
1978 ## Returns the number of pyramids in the mesh
1979 # @return an integer value
1980 # @ingroup l1_meshinfo
1981 def NbPyramids(self):
1982 return self.mesh.NbPyramids()
1984 ## Returns the number of pyramids with the given order in the mesh
1985 # @param elementOrder the order of elements:
1986 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1987 # @return an integer value
1988 # @ingroup l1_meshinfo
1989 def NbPyramidsOfOrder(self, elementOrder):
1990 return self.mesh.NbPyramidsOfOrder(elementOrder)
1992 ## Returns the number of prisms in the mesh
1993 # @return an integer value
1994 # @ingroup l1_meshinfo
1996 return self.mesh.NbPrisms()
1998 ## Returns the number of prisms with the given order in the mesh
1999 # @param elementOrder the order of elements:
2000 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2001 # @return an integer value
2002 # @ingroup l1_meshinfo
2003 def NbPrismsOfOrder(self, elementOrder):
2004 return self.mesh.NbPrismsOfOrder(elementOrder)
2006 ## Returns the number of polyhedrons in the mesh
2007 # @return an integer value
2008 # @ingroup l1_meshinfo
2009 def NbPolyhedrons(self):
2010 return self.mesh.NbPolyhedrons()
2012 ## Returns the number of submeshes in the mesh
2013 # @return an integer value
2014 # @ingroup l1_meshinfo
2015 def NbSubMesh(self):
2016 return self.mesh.NbSubMesh()
2018 ## Returns the list of mesh elements IDs
2019 # @return the list of integer values
2020 # @ingroup l1_meshinfo
2021 def GetElementsId(self):
2022 return self.mesh.GetElementsId()
2024 ## Returns the list of IDs of mesh elements with the given type
2025 # @param elementType the required type of elements (SMESH.NODE, SMESH.EDGE, SMESH.FACE or SMESH.VOLUME)
2026 # @return list of integer values
2027 # @ingroup l1_meshinfo
2028 def GetElementsByType(self, elementType):
2029 return self.mesh.GetElementsByType(elementType)
2031 ## Returns the list of mesh nodes IDs
2032 # @return the list of integer values
2033 # @ingroup l1_meshinfo
2034 def GetNodesId(self):
2035 return self.mesh.GetNodesId()
2037 # Get the information about mesh elements:
2038 # ------------------------------------
2040 ## Returns the type of mesh element
2041 # @return the value from SMESH::ElementType enumeration
2042 # @ingroup l1_meshinfo
2043 def GetElementType(self, id, iselem):
2044 return self.mesh.GetElementType(id, iselem)
2046 ## Returns the geometric type of mesh element
2047 # @return the value from SMESH::EntityType enumeration
2048 # @ingroup l1_meshinfo
2049 def GetElementGeomType(self, id):
2050 return self.mesh.GetElementGeomType(id)
2052 ## Returns the list of submesh elements IDs
2053 # @param Shape a geom object(subshape) IOR
2054 # Shape must be the subshape of a ShapeToMesh()
2055 # @return the list of integer values
2056 # @ingroup l1_meshinfo
2057 def GetSubMeshElementsId(self, Shape):
2058 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2059 ShapeID = Shape.GetSubShapeIndices()[0]
2062 return self.mesh.GetSubMeshElementsId(ShapeID)
2064 ## Returns the list of submesh nodes IDs
2065 # @param Shape a geom object(subshape) IOR
2066 # Shape must be the subshape of a ShapeToMesh()
2067 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
2068 # @return the list of integer values
2069 # @ingroup l1_meshinfo
2070 def GetSubMeshNodesId(self, Shape, all):
2071 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2072 ShapeID = Shape.GetSubShapeIndices()[0]
2075 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2077 ## Returns type of elements on given shape
2078 # @param Shape a geom object(subshape) IOR
2079 # Shape must be a subshape of a ShapeToMesh()
2080 # @return element type
2081 # @ingroup l1_meshinfo
2082 def GetSubMeshElementType(self, Shape):
2083 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2084 ShapeID = Shape.GetSubShapeIndices()[0]
2087 return self.mesh.GetSubMeshElementType(ShapeID)
2089 ## Gets the mesh description
2090 # @return string value
2091 # @ingroup l1_meshinfo
2093 return self.mesh.Dump()
2096 # Get the information about nodes and elements of a mesh by its IDs:
2097 # -----------------------------------------------------------
2099 ## Gets XYZ coordinates of a node
2100 # \n If there is no nodes for the given ID - returns an empty list
2101 # @return a list of double precision values
2102 # @ingroup l1_meshinfo
2103 def GetNodeXYZ(self, id):
2104 return self.mesh.GetNodeXYZ(id)
2106 ## Returns list of IDs of inverse elements for the given node
2107 # \n If there is no node for the given ID - returns an empty list
2108 # @return a list of integer values
2109 # @ingroup l1_meshinfo
2110 def GetNodeInverseElements(self, id):
2111 return self.mesh.GetNodeInverseElements(id)
2113 ## @brief Returns the position of a node on the shape
2114 # @return SMESH::NodePosition
2115 # @ingroup l1_meshinfo
2116 def GetNodePosition(self,NodeID):
2117 return self.mesh.GetNodePosition(NodeID)
2119 ## If the given element is a node, returns the ID of shape
2120 # \n If there is no node for the given ID - returns -1
2121 # @return an integer value
2122 # @ingroup l1_meshinfo
2123 def GetShapeID(self, id):
2124 return self.mesh.GetShapeID(id)
2126 ## Returns the ID of the result shape after
2127 # FindShape() from SMESH_MeshEditor for the given element
2128 # \n If there is no element for the given ID - returns -1
2129 # @return an integer value
2130 # @ingroup l1_meshinfo
2131 def GetShapeIDForElem(self,id):
2132 return self.mesh.GetShapeIDForElem(id)
2134 ## Returns the number of nodes for the given element
2135 # \n If there is no element for the given ID - returns -1
2136 # @return an integer value
2137 # @ingroup l1_meshinfo
2138 def GetElemNbNodes(self, id):
2139 return self.mesh.GetElemNbNodes(id)
2141 ## Returns the node ID the given index for the given element
2142 # \n If there is no element for the given ID - returns -1
2143 # \n If there is no node for the given index - returns -2
2144 # @return an integer value
2145 # @ingroup l1_meshinfo
2146 def GetElemNode(self, id, index):
2147 return self.mesh.GetElemNode(id, index)
2149 ## Returns the IDs of nodes of the given element
2150 # @return a list of integer values
2151 # @ingroup l1_meshinfo
2152 def GetElemNodes(self, id):
2153 return self.mesh.GetElemNodes(id)
2155 ## Returns true if the given node is the medium node in the given quadratic element
2156 # @ingroup l1_meshinfo
2157 def IsMediumNode(self, elementID, nodeID):
2158 return self.mesh.IsMediumNode(elementID, nodeID)
2160 ## Returns true if the given node is the medium node in one of quadratic elements
2161 # @ingroup l1_meshinfo
2162 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2163 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2165 ## Returns the number of edges for the given element
2166 # @ingroup l1_meshinfo
2167 def ElemNbEdges(self, id):
2168 return self.mesh.ElemNbEdges(id)
2170 ## Returns the number of faces for the given element
2171 # @ingroup l1_meshinfo
2172 def ElemNbFaces(self, id):
2173 return self.mesh.ElemNbFaces(id)
2175 ## Returns nodes of given face (counted from zero) for given volumic element.
2176 # @ingroup l1_meshinfo
2177 def GetElemFaceNodes(self,elemId, faceIndex):
2178 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2180 ## Returns an element based on all given nodes.
2181 # @ingroup l1_meshinfo
2182 def FindElementByNodes(self,nodes):
2183 return self.mesh.FindElementByNodes(nodes)
2185 ## Returns true if the given element is a polygon
2186 # @ingroup l1_meshinfo
2187 def IsPoly(self, id):
2188 return self.mesh.IsPoly(id)
2190 ## Returns true if the given element is quadratic
2191 # @ingroup l1_meshinfo
2192 def IsQuadratic(self, id):
2193 return self.mesh.IsQuadratic(id)
2195 ## Returns XYZ coordinates of the barycenter of the given element
2196 # \n If there is no element for the given ID - returns an empty list
2197 # @return a list of three double values
2198 # @ingroup l1_meshinfo
2199 def BaryCenter(self, id):
2200 return self.mesh.BaryCenter(id)
2203 # Mesh edition (SMESH_MeshEditor functionality):
2204 # ---------------------------------------------
2206 ## Removes the elements from the mesh by ids
2207 # @param IDsOfElements is a list of ids of elements to remove
2208 # @return True or False
2209 # @ingroup l2_modif_del
2210 def RemoveElements(self, IDsOfElements):
2211 return self.editor.RemoveElements(IDsOfElements)
2213 ## Removes nodes from mesh by ids
2214 # @param IDsOfNodes is a list of ids of nodes to remove
2215 # @return True or False
2216 # @ingroup l2_modif_del
2217 def RemoveNodes(self, IDsOfNodes):
2218 return self.editor.RemoveNodes(IDsOfNodes)
2220 ## Removes all orphan (free) nodes from mesh
2221 # @return number of the removed nodes
2222 # @ingroup l2_modif_del
2223 def RemoveOrphanNodes(self):
2224 return self.editor.RemoveOrphanNodes()
2226 ## Add a node to the mesh by coordinates
2227 # @return Id of the new node
2228 # @ingroup l2_modif_add
2229 def AddNode(self, x, y, z):
2230 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2231 self.mesh.SetParameters(Parameters)
2232 return self.editor.AddNode( x, y, z)
2234 ## Creates a 0D element on a node with given number.
2235 # @param IDOfNode the ID of node for creation of the element.
2236 # @return the Id of the new 0D element
2237 # @ingroup l2_modif_add
2238 def Add0DElement(self, IDOfNode):
2239 return self.editor.Add0DElement(IDOfNode)
2241 ## Creates a linear or quadratic edge (this is determined
2242 # by the number of given nodes).
2243 # @param IDsOfNodes the list of node IDs for creation of the element.
2244 # The order of nodes in this list should correspond to the description
2245 # of MED. \n This description is located by the following link:
2246 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2247 # @return the Id of the new edge
2248 # @ingroup l2_modif_add
2249 def AddEdge(self, IDsOfNodes):
2250 return self.editor.AddEdge(IDsOfNodes)
2252 ## Creates a linear or quadratic face (this is determined
2253 # by the number of given nodes).
2254 # @param IDsOfNodes the list of node IDs for creation of the element.
2255 # The order of nodes in this list should correspond to the description
2256 # of MED. \n This description is located by the following link:
2257 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2258 # @return the Id of the new face
2259 # @ingroup l2_modif_add
2260 def AddFace(self, IDsOfNodes):
2261 return self.editor.AddFace(IDsOfNodes)
2263 ## Adds a polygonal face to the mesh by the list of node IDs
2264 # @param IdsOfNodes the list of node IDs for creation of the element.
2265 # @return the Id of the new face
2266 # @ingroup l2_modif_add
2267 def AddPolygonalFace(self, IdsOfNodes):
2268 return self.editor.AddPolygonalFace(IdsOfNodes)
2270 ## Creates both simple and quadratic volume (this is determined
2271 # by the number of given nodes).
2272 # @param IDsOfNodes the list of node IDs for creation of the element.
2273 # The order of nodes in this list should correspond to the description
2274 # of MED. \n This description is located by the following link:
2275 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2276 # @return the Id of the new volumic element
2277 # @ingroup l2_modif_add
2278 def AddVolume(self, IDsOfNodes):
2279 return self.editor.AddVolume(IDsOfNodes)
2281 ## Creates a volume of many faces, giving nodes for each face.
2282 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2283 # @param Quantities the list of integer values, Quantities[i]
2284 # gives the quantity of nodes in face number i.
2285 # @return the Id of the new volumic element
2286 # @ingroup l2_modif_add
2287 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2288 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2290 ## Creates a volume of many faces, giving the IDs of the existing faces.
2291 # @param IdsOfFaces the list of face IDs for volume creation.
2293 # Note: The created volume will refer only to the nodes
2294 # of the given faces, not to the faces themselves.
2295 # @return the Id of the new volumic element
2296 # @ingroup l2_modif_add
2297 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2298 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2301 ## @brief Binds a node to a vertex
2302 # @param NodeID a node ID
2303 # @param Vertex a vertex or vertex ID
2304 # @return True if succeed else raises an exception
2305 # @ingroup l2_modif_add
2306 def SetNodeOnVertex(self, NodeID, Vertex):
2307 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2308 VertexID = Vertex.GetSubShapeIndices()[0]
2312 self.editor.SetNodeOnVertex(NodeID, VertexID)
2313 except SALOME.SALOME_Exception, inst:
2314 raise ValueError, inst.details.text
2318 ## @brief Stores the node position on an edge
2319 # @param NodeID a node ID
2320 # @param Edge an edge or edge ID
2321 # @param paramOnEdge a parameter on the edge where the node is located
2322 # @return True if succeed else raises an exception
2323 # @ingroup l2_modif_add
2324 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2325 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2326 EdgeID = Edge.GetSubShapeIndices()[0]
2330 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2331 except SALOME.SALOME_Exception, inst:
2332 raise ValueError, inst.details.text
2335 ## @brief Stores node position on a face
2336 # @param NodeID a node ID
2337 # @param Face a face or face ID
2338 # @param u U parameter on the face where the node is located
2339 # @param v V parameter on the face where the node is located
2340 # @return True if succeed else raises an exception
2341 # @ingroup l2_modif_add
2342 def SetNodeOnFace(self, NodeID, Face, u, v):
2343 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2344 FaceID = Face.GetSubShapeIndices()[0]
2348 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2349 except SALOME.SALOME_Exception, inst:
2350 raise ValueError, inst.details.text
2353 ## @brief Binds a node to a solid
2354 # @param NodeID a node ID
2355 # @param Solid a solid or solid ID
2356 # @return True if succeed else raises an exception
2357 # @ingroup l2_modif_add
2358 def SetNodeInVolume(self, NodeID, Solid):
2359 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2360 SolidID = Solid.GetSubShapeIndices()[0]
2364 self.editor.SetNodeInVolume(NodeID, SolidID)
2365 except SALOME.SALOME_Exception, inst:
2366 raise ValueError, inst.details.text
2369 ## @brief Bind an element to a shape
2370 # @param ElementID an element ID
2371 # @param Shape a shape or shape ID
2372 # @return True if succeed else raises an exception
2373 # @ingroup l2_modif_add
2374 def SetMeshElementOnShape(self, ElementID, Shape):
2375 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2376 ShapeID = Shape.GetSubShapeIndices()[0]
2380 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2381 except SALOME.SALOME_Exception, inst:
2382 raise ValueError, inst.details.text
2386 ## Moves the node with the given id
2387 # @param NodeID the id of the node
2388 # @param x a new X coordinate
2389 # @param y a new Y coordinate
2390 # @param z a new Z coordinate
2391 # @return True if succeed else False
2392 # @ingroup l2_modif_movenode
2393 def MoveNode(self, NodeID, x, y, z):
2394 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2395 self.mesh.SetParameters(Parameters)
2396 return self.editor.MoveNode(NodeID, x, y, z)
2398 ## Finds the node closest to a point and moves it to a point location
2399 # @param x the X coordinate of a point
2400 # @param y the Y coordinate of a point
2401 # @param z the Z coordinate of a point
2402 # @param NodeID if specified (>0), the node with this ID is moved,
2403 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2404 # @return the ID of a node
2405 # @ingroup l2_modif_throughp
2406 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2407 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2408 self.mesh.SetParameters(Parameters)
2409 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2411 ## Finds the node closest to a point
2412 # @param x the X coordinate of a point
2413 # @param y the Y coordinate of a point
2414 # @param z the Z coordinate of a point
2415 # @return the ID of a node
2416 # @ingroup l2_modif_throughp
2417 def FindNodeClosestTo(self, x, y, z):
2418 #preview = self.mesh.GetMeshEditPreviewer()
2419 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2420 return self.editor.FindNodeClosestTo(x, y, z)
2422 ## Finds the elements where a point lays IN or ON
2423 # @param x the X coordinate of a point
2424 # @param y the Y coordinate of a point
2425 # @param z the Z coordinate of a point
2426 # @param elementType type of elements to find (SMESH.ALL type
2427 # means elements of any type excluding nodes and 0D elements)
2428 # @return list of IDs of found elements
2429 # @ingroup l2_modif_throughp
2430 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2431 return self.editor.FindElementsByPoint(x, y, z, elementType)
2433 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2434 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2436 def GetPointState(self, x, y, z):
2437 return self.editor.GetPointState(x, y, z)
2439 ## Finds the node closest to a point and moves it to a point location
2440 # @param x the X coordinate of a point
2441 # @param y the Y coordinate of a point
2442 # @param z the Z coordinate of a point
2443 # @return the ID of a moved node
2444 # @ingroup l2_modif_throughp
2445 def MeshToPassThroughAPoint(self, x, y, z):
2446 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2448 ## Replaces two neighbour triangles sharing Node1-Node2 link
2449 # with the triangles built on the same 4 nodes but having other common link.
2450 # @param NodeID1 the ID of the first node
2451 # @param NodeID2 the ID of the second node
2452 # @return false if proper faces were not found
2453 # @ingroup l2_modif_invdiag
2454 def InverseDiag(self, NodeID1, NodeID2):
2455 return self.editor.InverseDiag(NodeID1, NodeID2)
2457 ## Replaces two neighbour triangles sharing Node1-Node2 link
2458 # with a quadrangle built on the same 4 nodes.
2459 # @param NodeID1 the ID of the first node
2460 # @param NodeID2 the ID of the second node
2461 # @return false if proper faces were not found
2462 # @ingroup l2_modif_unitetri
2463 def DeleteDiag(self, NodeID1, NodeID2):
2464 return self.editor.DeleteDiag(NodeID1, NodeID2)
2466 ## Reorients elements by ids
2467 # @param IDsOfElements if undefined reorients all mesh elements
2468 # @return True if succeed else False
2469 # @ingroup l2_modif_changori
2470 def Reorient(self, IDsOfElements=None):
2471 if IDsOfElements == None:
2472 IDsOfElements = self.GetElementsId()
2473 return self.editor.Reorient(IDsOfElements)
2475 ## Reorients all elements of the object
2476 # @param theObject mesh, submesh or group
2477 # @return True if succeed else False
2478 # @ingroup l2_modif_changori
2479 def ReorientObject(self, theObject):
2480 if ( isinstance( theObject, Mesh )):
2481 theObject = theObject.GetMesh()
2482 return self.editor.ReorientObject(theObject)
2484 ## Fuses the neighbouring triangles into quadrangles.
2485 # @param IDsOfElements The triangles to be fused,
2486 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2487 # @param MaxAngle is the maximum angle between element normals at which the fusion
2488 # is still performed; theMaxAngle is mesured in radians.
2489 # Also it could be a name of variable which defines angle in degrees.
2490 # @return TRUE in case of success, FALSE otherwise.
2491 # @ingroup l2_modif_unitetri
2492 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2494 if isinstance(MaxAngle,str):
2496 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2498 MaxAngle = DegreesToRadians(MaxAngle)
2499 if IDsOfElements == []:
2500 IDsOfElements = self.GetElementsId()
2501 self.mesh.SetParameters(Parameters)
2503 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2504 Functor = theCriterion
2506 Functor = self.smeshpyD.GetFunctor(theCriterion)
2507 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2509 ## Fuses the neighbouring triangles of the object into quadrangles
2510 # @param theObject is mesh, submesh or group
2511 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2512 # @param MaxAngle a max angle between element normals at which the fusion
2513 # is still performed; theMaxAngle is mesured in radians.
2514 # @return TRUE in case of success, FALSE otherwise.
2515 # @ingroup l2_modif_unitetri
2516 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2517 if ( isinstance( theObject, Mesh )):
2518 theObject = theObject.GetMesh()
2519 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2521 ## Splits quadrangles into triangles.
2522 # @param IDsOfElements the faces to be splitted.
2523 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2524 # @return TRUE in case of success, FALSE otherwise.
2525 # @ingroup l2_modif_cutquadr
2526 def QuadToTri (self, IDsOfElements, theCriterion):
2527 if IDsOfElements == []:
2528 IDsOfElements = self.GetElementsId()
2529 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2531 ## Splits quadrangles into triangles.
2532 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2533 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2534 # @return TRUE in case of success, FALSE otherwise.
2535 # @ingroup l2_modif_cutquadr
2536 def QuadToTriObject (self, theObject, theCriterion):
2537 if ( isinstance( theObject, Mesh )):
2538 theObject = theObject.GetMesh()
2539 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2541 ## Splits quadrangles into triangles.
2542 # @param IDsOfElements the faces to be splitted
2543 # @param Diag13 is used to choose a diagonal for splitting.
2544 # @return TRUE in case of success, FALSE otherwise.
2545 # @ingroup l2_modif_cutquadr
2546 def SplitQuad (self, IDsOfElements, Diag13):
2547 if IDsOfElements == []:
2548 IDsOfElements = self.GetElementsId()
2549 return self.editor.SplitQuad(IDsOfElements, Diag13)
2551 ## Splits quadrangles into triangles.
2552 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2553 # @param Diag13 is used to choose a diagonal for splitting.
2554 # @return TRUE in case of success, FALSE otherwise.
2555 # @ingroup l2_modif_cutquadr
2556 def SplitQuadObject (self, theObject, Diag13):
2557 if ( isinstance( theObject, Mesh )):
2558 theObject = theObject.GetMesh()
2559 return self.editor.SplitQuadObject(theObject, Diag13)
2561 ## Finds a better splitting of the given quadrangle.
2562 # @param IDOfQuad the ID of the quadrangle to be splitted.
2563 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2564 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2565 # diagonal is better, 0 if error occurs.
2566 # @ingroup l2_modif_cutquadr
2567 def BestSplit (self, IDOfQuad, theCriterion):
2568 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2570 ## Splits volumic elements into tetrahedrons
2571 # @param elemIDs either list of elements or mesh or group or submesh
2572 # @param method flags passing splitting method: Hex_5Tet, Hex_6Tet, Hex_24Tet
2573 # Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc
2574 # @ingroup l2_modif_cutquadr
2575 def SplitVolumesIntoTetra(self, elemIDs, method=Hex_5Tet ):
2576 if isinstance( elemIDs, Mesh ):
2577 elemIDs = elemIDs.GetMesh()
2578 if ( isinstance( elemIDs, list )):
2579 elemIDs = self.editor.MakeIDSource(elemIDs, SMESH.VOLUME)
2580 self.editor.SplitVolumesIntoTetra(elemIDs, method)
2582 ## Splits quadrangle faces near triangular facets of volumes
2584 # @ingroup l1_auxiliary
2585 def SplitQuadsNearTriangularFacets(self):
2586 faces_array = self.GetElementsByType(SMESH.FACE)
2587 for face_id in faces_array:
2588 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2589 quad_nodes = self.mesh.GetElemNodes(face_id)
2590 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2591 isVolumeFound = False
2592 for node1_elem in node1_elems:
2593 if not isVolumeFound:
2594 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2595 nb_nodes = self.GetElemNbNodes(node1_elem)
2596 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2597 volume_elem = node1_elem
2598 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2599 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2600 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2601 isVolumeFound = True
2602 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2603 self.SplitQuad([face_id], False) # diagonal 2-4
2604 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2605 isVolumeFound = True
2606 self.SplitQuad([face_id], True) # diagonal 1-3
2607 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2608 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2609 isVolumeFound = True
2610 self.SplitQuad([face_id], True) # diagonal 1-3
2612 ## @brief Splits hexahedrons into tetrahedrons.
2614 # This operation uses pattern mapping functionality for splitting.
2615 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2616 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2617 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2618 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2619 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2620 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2621 # @return TRUE in case of success, FALSE otherwise.
2622 # @ingroup l1_auxiliary
2623 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2624 # Pattern: 5.---------.6
2629 # (0,0,1) 4.---------.7 * |
2636 # (0,0,0) 0.---------.3
2637 pattern_tetra = "!!! Nb of points: \n 8 \n\
2647 !!! Indices of points of 6 tetras: \n\
2655 pattern = self.smeshpyD.GetPattern()
2656 isDone = pattern.LoadFromFile(pattern_tetra)
2658 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2661 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2662 isDone = pattern.MakeMesh(self.mesh, False, False)
2663 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2665 # split quafrangle faces near triangular facets of volumes
2666 self.SplitQuadsNearTriangularFacets()
2670 ## @brief Split hexahedrons into prisms.
2672 # Uses the pattern mapping functionality for splitting.
2673 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2674 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2675 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2676 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2677 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2678 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2679 # @return TRUE in case of success, FALSE otherwise.
2680 # @ingroup l1_auxiliary
2681 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2682 # Pattern: 5.---------.6
2687 # (0,0,1) 4.---------.7 |
2694 # (0,0,0) 0.---------.3
2695 pattern_prism = "!!! Nb of points: \n 8 \n\
2705 !!! Indices of points of 2 prisms: \n\
2709 pattern = self.smeshpyD.GetPattern()
2710 isDone = pattern.LoadFromFile(pattern_prism)
2712 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2715 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2716 isDone = pattern.MakeMesh(self.mesh, False, False)
2717 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2719 # Splits quafrangle faces near triangular facets of volumes
2720 self.SplitQuadsNearTriangularFacets()
2724 ## Smoothes elements
2725 # @param IDsOfElements the list if ids of elements to smooth
2726 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2727 # Note that nodes built on edges and boundary nodes are always fixed.
2728 # @param MaxNbOfIterations the maximum number of iterations
2729 # @param MaxAspectRatio varies in range [1.0, inf]
2730 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2731 # @return TRUE in case of success, FALSE otherwise.
2732 # @ingroup l2_modif_smooth
2733 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2734 MaxNbOfIterations, MaxAspectRatio, Method):
2735 if IDsOfElements == []:
2736 IDsOfElements = self.GetElementsId()
2737 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2738 self.mesh.SetParameters(Parameters)
2739 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2740 MaxNbOfIterations, MaxAspectRatio, Method)
2742 ## Smoothes elements which belong to the given object
2743 # @param theObject the object to smooth
2744 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2745 # Note that nodes built on edges and boundary nodes are always fixed.
2746 # @param MaxNbOfIterations the maximum number of iterations
2747 # @param MaxAspectRatio varies in range [1.0, inf]
2748 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2749 # @return TRUE in case of success, FALSE otherwise.
2750 # @ingroup l2_modif_smooth
2751 def SmoothObject(self, theObject, IDsOfFixedNodes,
2752 MaxNbOfIterations, MaxAspectRatio, Method):
2753 if ( isinstance( theObject, Mesh )):
2754 theObject = theObject.GetMesh()
2755 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2756 MaxNbOfIterations, MaxAspectRatio, Method)
2758 ## Parametrically smoothes the given elements
2759 # @param IDsOfElements the list if ids of elements to smooth
2760 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2761 # Note that nodes built on edges and boundary nodes are always fixed.
2762 # @param MaxNbOfIterations the maximum number of iterations
2763 # @param MaxAspectRatio varies in range [1.0, inf]
2764 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2765 # @return TRUE in case of success, FALSE otherwise.
2766 # @ingroup l2_modif_smooth
2767 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2768 MaxNbOfIterations, MaxAspectRatio, Method):
2769 if IDsOfElements == []:
2770 IDsOfElements = self.GetElementsId()
2771 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2772 self.mesh.SetParameters(Parameters)
2773 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2774 MaxNbOfIterations, MaxAspectRatio, Method)
2776 ## Parametrically smoothes the elements which belong to the given object
2777 # @param theObject the object to smooth
2778 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2779 # Note that nodes built on edges and boundary nodes are always fixed.
2780 # @param MaxNbOfIterations the maximum number of iterations
2781 # @param MaxAspectRatio varies in range [1.0, inf]
2782 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2783 # @return TRUE in case of success, FALSE otherwise.
2784 # @ingroup l2_modif_smooth
2785 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2786 MaxNbOfIterations, MaxAspectRatio, Method):
2787 if ( isinstance( theObject, Mesh )):
2788 theObject = theObject.GetMesh()
2789 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2790 MaxNbOfIterations, MaxAspectRatio, Method)
2792 ## Converts the mesh to quadratic, deletes old elements, replacing
2793 # them with quadratic with the same id.
2794 # @param theForce3d new node creation method:
2795 # 0 - the medium node lies at the geometrical edge from which the mesh element is built
2796 # 1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element
2797 # @ingroup l2_modif_tofromqu
2798 def ConvertToQuadratic(self, theForce3d):
2799 self.editor.ConvertToQuadratic(theForce3d)
2801 ## Converts the mesh from quadratic to ordinary,
2802 # deletes old quadratic elements, \n replacing
2803 # them with ordinary mesh elements with the same id.
2804 # @return TRUE in case of success, FALSE otherwise.
2805 # @ingroup l2_modif_tofromqu
2806 def ConvertFromQuadratic(self):
2807 return self.editor.ConvertFromQuadratic()
2809 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
2810 # @return TRUE if operation has been completed successfully, FALSE otherwise
2811 # @ingroup l2_modif_edit
2812 def Make2DMeshFrom3D(self):
2813 return self.editor. Make2DMeshFrom3D()
2815 ## Creates missing boundary elements
2816 # @param elements - elements whose boundary is to be checked:
2817 # mesh, group, sub-mesh or list of elements
2818 # @param dimension - defines type of boundary elements to create:
2819 # SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D
2820 # @param groupName - a name of group to store created boundary elements in,
2821 # "" means not to create the group
2822 # @param meshName - a name of new mesh to store created boundary elements in,
2823 # "" means not to create the new mesh
2824 # @param toCopyElements - if true, the checked elements will be copied into the new mesh
2825 # @param toCopyExistingBondary - if true, not only new but also pre-existing
2826 # boundary elements will be copied into the new mesh
2827 # @return tuple (mesh, group) where bondary elements were added to
2828 # @ingroup l2_modif_edit
2829 def MakeBoundaryMesh(self, elements, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
2830 toCopyElements=False, toCopyExistingBondary=False):
2831 if isinstance( elements, Mesh ):
2832 elements = elements.GetMesh()
2833 if ( isinstance( elements, list )):
2834 elemType = SMESH.ALL
2835 if elements: elemType = self.GetElementType( elements[0], iselem=True)
2836 elements = self.editor.MakeIDSource(elements, elemType)
2837 mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName,
2838 toCopyElements,toCopyExistingBondary)
2839 if mesh: mesh = self.smeshpyD.Mesh(mesh)
2842 ## Renumber mesh nodes
2843 # @ingroup l2_modif_renumber
2844 def RenumberNodes(self):
2845 self.editor.RenumberNodes()
2847 ## Renumber mesh elements
2848 # @ingroup l2_modif_renumber
2849 def RenumberElements(self):
2850 self.editor.RenumberElements()
2852 ## Generates new elements by rotation of the elements around the axis
2853 # @param IDsOfElements the list of ids of elements to sweep
2854 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2855 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2856 # @param NbOfSteps the number of steps
2857 # @param Tolerance tolerance
2858 # @param MakeGroups forces the generation of new groups from existing ones
2859 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2860 # of all steps, else - size of each step
2861 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2862 # @ingroup l2_modif_extrurev
2863 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2864 MakeGroups=False, TotalAngle=False):
2866 if isinstance(AngleInRadians,str):
2868 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2870 AngleInRadians = DegreesToRadians(AngleInRadians)
2871 if IDsOfElements == []:
2872 IDsOfElements = self.GetElementsId()
2873 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2874 Axis = self.smeshpyD.GetAxisStruct(Axis)
2875 Axis,AxisParameters = ParseAxisStruct(Axis)
2876 if TotalAngle and NbOfSteps:
2877 AngleInRadians /= NbOfSteps
2878 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2879 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2880 self.mesh.SetParameters(Parameters)
2882 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2883 AngleInRadians, NbOfSteps, Tolerance)
2884 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2887 ## Generates new elements by rotation of the elements of object around the axis
2888 # @param theObject object which elements should be sweeped
2889 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2890 # @param AngleInRadians the angle of Rotation
2891 # @param NbOfSteps number of steps
2892 # @param Tolerance tolerance
2893 # @param MakeGroups forces the generation of new groups from existing ones
2894 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2895 # of all steps, else - size of each step
2896 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2897 # @ingroup l2_modif_extrurev
2898 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2899 MakeGroups=False, TotalAngle=False):
2901 if isinstance(AngleInRadians,str):
2903 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2905 AngleInRadians = DegreesToRadians(AngleInRadians)
2906 if ( isinstance( theObject, Mesh )):
2907 theObject = theObject.GetMesh()
2908 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2909 Axis = self.smeshpyD.GetAxisStruct(Axis)
2910 Axis,AxisParameters = ParseAxisStruct(Axis)
2911 if TotalAngle and NbOfSteps:
2912 AngleInRadians /= NbOfSteps
2913 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2914 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2915 self.mesh.SetParameters(Parameters)
2917 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2918 NbOfSteps, Tolerance)
2919 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2922 ## Generates new elements by rotation of the elements of object around the axis
2923 # @param theObject object which elements should be sweeped
2924 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2925 # @param AngleInRadians the angle of Rotation
2926 # @param NbOfSteps number of steps
2927 # @param Tolerance tolerance
2928 # @param MakeGroups forces the generation of new groups from existing ones
2929 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2930 # of all steps, else - size of each step
2931 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2932 # @ingroup l2_modif_extrurev
2933 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2934 MakeGroups=False, TotalAngle=False):
2936 if isinstance(AngleInRadians,str):
2938 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2940 AngleInRadians = DegreesToRadians(AngleInRadians)
2941 if ( isinstance( theObject, Mesh )):
2942 theObject = theObject.GetMesh()
2943 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2944 Axis = self.smeshpyD.GetAxisStruct(Axis)
2945 Axis,AxisParameters = ParseAxisStruct(Axis)
2946 if TotalAngle and NbOfSteps:
2947 AngleInRadians /= NbOfSteps
2948 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2949 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2950 self.mesh.SetParameters(Parameters)
2952 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2953 NbOfSteps, Tolerance)
2954 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2957 ## Generates new elements by rotation of the elements of object around the axis
2958 # @param theObject object which elements should be sweeped
2959 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2960 # @param AngleInRadians the angle of Rotation
2961 # @param NbOfSteps number of steps
2962 # @param Tolerance tolerance
2963 # @param MakeGroups forces the generation of new groups from existing ones
2964 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2965 # of all steps, else - size of each step
2966 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2967 # @ingroup l2_modif_extrurev
2968 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2969 MakeGroups=False, TotalAngle=False):
2971 if isinstance(AngleInRadians,str):
2973 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2975 AngleInRadians = DegreesToRadians(AngleInRadians)
2976 if ( isinstance( theObject, Mesh )):
2977 theObject = theObject.GetMesh()
2978 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2979 Axis = self.smeshpyD.GetAxisStruct(Axis)
2980 Axis,AxisParameters = ParseAxisStruct(Axis)
2981 if TotalAngle and NbOfSteps:
2982 AngleInRadians /= NbOfSteps
2983 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2984 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2985 self.mesh.SetParameters(Parameters)
2987 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2988 NbOfSteps, Tolerance)
2989 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2992 ## Generates new elements by extrusion of the elements with given ids
2993 # @param IDsOfElements the list of elements ids for extrusion
2994 # @param StepVector vector, defining the direction and value of extrusion
2995 # @param NbOfSteps the number of steps
2996 # @param MakeGroups forces the generation of new groups from existing ones
2997 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2998 # @ingroup l2_modif_extrurev
2999 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
3000 if IDsOfElements == []:
3001 IDsOfElements = self.GetElementsId()
3002 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3003 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3004 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3005 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3006 Parameters = StepVectorParameters + var_separator + Parameters
3007 self.mesh.SetParameters(Parameters)
3009 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
3010 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
3013 ## Generates new elements by extrusion of the elements with given ids
3014 # @param IDsOfElements is ids of elements
3015 # @param StepVector vector, defining the direction and value of extrusion
3016 # @param NbOfSteps the number of steps
3017 # @param ExtrFlags sets flags for extrusion
3018 # @param SewTolerance uses for comparing locations of nodes if flag
3019 # EXTRUSION_FLAG_SEW is set
3020 # @param MakeGroups forces the generation of new groups from existing ones
3021 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3022 # @ingroup l2_modif_extrurev
3023 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
3024 ExtrFlags, SewTolerance, MakeGroups=False):
3025 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3026 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3028 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
3029 ExtrFlags, SewTolerance)
3030 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
3031 ExtrFlags, SewTolerance)
3034 ## Generates new elements by extrusion of the elements which belong to the object
3035 # @param theObject the object which elements should be processed
3036 # @param StepVector vector, defining the direction and value of extrusion
3037 # @param NbOfSteps the number of steps
3038 # @param MakeGroups forces the generation of new groups from existing ones
3039 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3040 # @ingroup l2_modif_extrurev
3041 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3042 if ( isinstance( theObject, Mesh )):
3043 theObject = theObject.GetMesh()
3044 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3045 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3046 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3047 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3048 Parameters = StepVectorParameters + var_separator + Parameters
3049 self.mesh.SetParameters(Parameters)
3051 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3052 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
3055 ## Generates new elements by extrusion of the elements which belong to the object
3056 # @param theObject object which elements should be processed
3057 # @param StepVector vector, defining the direction and value of extrusion
3058 # @param NbOfSteps the number of steps
3059 # @param MakeGroups to generate new groups from existing ones
3060 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3061 # @ingroup l2_modif_extrurev
3062 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3063 if ( isinstance( theObject, Mesh )):
3064 theObject = theObject.GetMesh()
3065 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3066 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3067 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3068 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3069 Parameters = StepVectorParameters + var_separator + Parameters
3070 self.mesh.SetParameters(Parameters)
3072 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3073 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3076 ## Generates new elements by extrusion of the elements which belong to the object
3077 # @param theObject object which elements should be processed
3078 # @param StepVector vector, defining the direction and value of extrusion
3079 # @param NbOfSteps the number of steps
3080 # @param MakeGroups forces the generation of new groups from existing ones
3081 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3082 # @ingroup l2_modif_extrurev
3083 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3084 if ( isinstance( theObject, Mesh )):
3085 theObject = theObject.GetMesh()
3086 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3087 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3088 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3089 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3090 Parameters = StepVectorParameters + var_separator + Parameters
3091 self.mesh.SetParameters(Parameters)
3093 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3094 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3099 ## Generates new elements by extrusion of the given elements
3100 # The path of extrusion must be a meshed edge.
3101 # @param Base mesh or list of ids of elements for extrusion
3102 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3103 # @param NodeStart the start node from Path. Defines the direction of extrusion
3104 # @param HasAngles allows the shape to be rotated around the path
3105 # to get the resulting mesh in a helical fashion
3106 # @param Angles list of angles in radians
3107 # @param LinearVariation forces the computation of rotation angles as linear
3108 # variation of the given Angles along path steps
3109 # @param HasRefPoint allows using the reference point
3110 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3111 # The User can specify any point as the Reference Point.
3112 # @param MakeGroups forces the generation of new groups from existing ones
3113 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3114 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3115 # only SMESH::Extrusion_Error otherwise
3116 # @ingroup l2_modif_extrurev
3117 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3118 HasAngles, Angles, LinearVariation,
3119 HasRefPoint, RefPoint, MakeGroups, ElemType):
3120 Angles,AnglesParameters = ParseAngles(Angles)
3121 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3122 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3123 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3125 Parameters = AnglesParameters + var_separator + RefPointParameters
3126 self.mesh.SetParameters(Parameters)
3128 if isinstance(Base,list):
3130 if Base == []: IDsOfElements = self.GetElementsId()
3131 else: IDsOfElements = Base
3132 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3133 HasAngles, Angles, LinearVariation,
3134 HasRefPoint, RefPoint, MakeGroups, ElemType)
3136 if isinstance(Base,Mesh):
3137 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3138 HasAngles, Angles, LinearVariation,
3139 HasRefPoint, RefPoint, MakeGroups, ElemType)
3141 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3144 ## Generates new elements by extrusion of the given elements
3145 # The path of extrusion must be a meshed edge.
3146 # @param IDsOfElements ids of elements
3147 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3148 # @param PathShape shape(edge) defines the sub-mesh for the path
3149 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3150 # @param HasAngles allows the shape to be rotated around the path
3151 # to get the resulting mesh in a helical fashion
3152 # @param Angles list of angles in radians
3153 # @param HasRefPoint allows using the reference point
3154 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3155 # The User can specify any point as the Reference Point.
3156 # @param MakeGroups forces the generation of new groups from existing ones
3157 # @param LinearVariation forces the computation of rotation angles as linear
3158 # variation of the given Angles along path steps
3159 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3160 # only SMESH::Extrusion_Error otherwise
3161 # @ingroup l2_modif_extrurev
3162 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3163 HasAngles, Angles, HasRefPoint, RefPoint,
3164 MakeGroups=False, LinearVariation=False):
3165 Angles,AnglesParameters = ParseAngles(Angles)
3166 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3167 if IDsOfElements == []:
3168 IDsOfElements = self.GetElementsId()
3169 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3170 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3172 if ( isinstance( PathMesh, Mesh )):
3173 PathMesh = PathMesh.GetMesh()
3174 if HasAngles and Angles and LinearVariation:
3175 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3177 Parameters = AnglesParameters + var_separator + RefPointParameters
3178 self.mesh.SetParameters(Parameters)
3180 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3181 PathShape, NodeStart, HasAngles,
3182 Angles, HasRefPoint, RefPoint)
3183 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3184 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3186 ## Generates new elements by extrusion of the elements which belong to the object
3187 # The path of extrusion must be a meshed edge.
3188 # @param theObject the object which elements should be processed
3189 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3190 # @param PathShape shape(edge) defines the sub-mesh for the path
3191 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3192 # @param HasAngles allows the shape to be rotated around the path
3193 # to get the resulting mesh in a helical fashion
3194 # @param Angles list of angles
3195 # @param HasRefPoint allows using the reference point
3196 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3197 # The User can specify any point as the Reference Point.
3198 # @param MakeGroups forces the generation of new groups from existing ones
3199 # @param LinearVariation forces the computation of rotation angles as linear
3200 # variation of the given Angles along path steps
3201 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3202 # only SMESH::Extrusion_Error otherwise
3203 # @ingroup l2_modif_extrurev
3204 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3205 HasAngles, Angles, HasRefPoint, RefPoint,
3206 MakeGroups=False, LinearVariation=False):
3207 Angles,AnglesParameters = ParseAngles(Angles)
3208 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3209 if ( isinstance( theObject, Mesh )):
3210 theObject = theObject.GetMesh()
3211 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3212 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3213 if ( isinstance( PathMesh, Mesh )):
3214 PathMesh = PathMesh.GetMesh()
3215 if HasAngles and Angles and LinearVariation:
3216 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3218 Parameters = AnglesParameters + var_separator + RefPointParameters
3219 self.mesh.SetParameters(Parameters)
3221 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3222 PathShape, NodeStart, HasAngles,
3223 Angles, HasRefPoint, RefPoint)
3224 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3225 NodeStart, HasAngles, Angles, HasRefPoint,
3228 ## Generates new elements by extrusion of the elements which belong to the object
3229 # The path of extrusion must be a meshed edge.
3230 # @param theObject the object which elements should be processed
3231 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3232 # @param PathShape shape(edge) defines the sub-mesh for the path
3233 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3234 # @param HasAngles allows the shape to be rotated around the path
3235 # to get the resulting mesh in a helical fashion
3236 # @param Angles list of angles
3237 # @param HasRefPoint allows using the reference point
3238 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3239 # The User can specify any point as the Reference Point.
3240 # @param MakeGroups forces the generation of new groups from existing ones
3241 # @param LinearVariation forces the computation of rotation angles as linear
3242 # variation of the given Angles along path steps
3243 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3244 # only SMESH::Extrusion_Error otherwise
3245 # @ingroup l2_modif_extrurev
3246 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3247 HasAngles, Angles, HasRefPoint, RefPoint,
3248 MakeGroups=False, LinearVariation=False):
3249 Angles,AnglesParameters = ParseAngles(Angles)
3250 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3251 if ( isinstance( theObject, Mesh )):
3252 theObject = theObject.GetMesh()
3253 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3254 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3255 if ( isinstance( PathMesh, Mesh )):
3256 PathMesh = PathMesh.GetMesh()
3257 if HasAngles and Angles and LinearVariation:
3258 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3260 Parameters = AnglesParameters + var_separator + RefPointParameters
3261 self.mesh.SetParameters(Parameters)
3263 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3264 PathShape, NodeStart, HasAngles,
3265 Angles, HasRefPoint, RefPoint)
3266 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3267 NodeStart, HasAngles, Angles, HasRefPoint,
3270 ## Generates new elements by extrusion of the elements which belong to the object
3271 # The path of extrusion must be a meshed edge.
3272 # @param theObject the object which elements should be processed
3273 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3274 # @param PathShape shape(edge) defines the sub-mesh for the path
3275 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3276 # @param HasAngles allows the shape to be rotated around the path
3277 # to get the resulting mesh in a helical fashion
3278 # @param Angles list of angles
3279 # @param HasRefPoint allows using the reference point
3280 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3281 # The User can specify any point as the Reference Point.
3282 # @param MakeGroups forces the generation of new groups from existing ones
3283 # @param LinearVariation forces the computation of rotation angles as linear
3284 # variation of the given Angles along path steps
3285 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3286 # only SMESH::Extrusion_Error otherwise
3287 # @ingroup l2_modif_extrurev
3288 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3289 HasAngles, Angles, HasRefPoint, RefPoint,
3290 MakeGroups=False, LinearVariation=False):
3291 Angles,AnglesParameters = ParseAngles(Angles)
3292 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3293 if ( isinstance( theObject, Mesh )):
3294 theObject = theObject.GetMesh()
3295 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3296 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3297 if ( isinstance( PathMesh, Mesh )):
3298 PathMesh = PathMesh.GetMesh()
3299 if HasAngles and Angles and LinearVariation:
3300 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3302 Parameters = AnglesParameters + var_separator + RefPointParameters
3303 self.mesh.SetParameters(Parameters)
3305 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3306 PathShape, NodeStart, HasAngles,
3307 Angles, HasRefPoint, RefPoint)
3308 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3309 NodeStart, HasAngles, Angles, HasRefPoint,
3312 ## Creates a symmetrical copy of mesh elements
3313 # @param IDsOfElements list of elements ids
3314 # @param Mirror is AxisStruct or geom object(point, line, plane)
3315 # @param theMirrorType is POINT, AXIS or PLANE
3316 # If the Mirror is a geom object this parameter is unnecessary
3317 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3318 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3319 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3320 # @ingroup l2_modif_trsf
3321 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3322 if IDsOfElements == []:
3323 IDsOfElements = self.GetElementsId()
3324 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3325 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3326 Mirror,Parameters = ParseAxisStruct(Mirror)
3327 self.mesh.SetParameters(Parameters)
3328 if Copy and MakeGroups:
3329 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3330 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3333 ## Creates a new mesh by a symmetrical copy of mesh elements
3334 # @param IDsOfElements the list of elements ids
3335 # @param Mirror is AxisStruct or geom object (point, line, plane)
3336 # @param theMirrorType is POINT, AXIS or PLANE
3337 # If the Mirror is a geom object this parameter is unnecessary
3338 # @param MakeGroups to generate new groups from existing ones
3339 # @param NewMeshName a name of the new mesh to create
3340 # @return instance of Mesh class
3341 # @ingroup l2_modif_trsf
3342 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3343 if IDsOfElements == []:
3344 IDsOfElements = self.GetElementsId()
3345 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3346 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3347 Mirror,Parameters = ParseAxisStruct(Mirror)
3348 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3349 MakeGroups, NewMeshName)
3350 mesh.SetParameters(Parameters)
3351 return Mesh(self.smeshpyD,self.geompyD,mesh)
3353 ## Creates a symmetrical copy of the object
3354 # @param theObject mesh, submesh or group
3355 # @param Mirror AxisStruct or geom object (point, line, plane)
3356 # @param theMirrorType is POINT, AXIS or PLANE
3357 # If the Mirror is a geom object this parameter is unnecessary
3358 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3359 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3360 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3361 # @ingroup l2_modif_trsf
3362 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3363 if ( isinstance( theObject, Mesh )):
3364 theObject = theObject.GetMesh()
3365 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3366 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3367 Mirror,Parameters = ParseAxisStruct(Mirror)
3368 self.mesh.SetParameters(Parameters)
3369 if Copy and MakeGroups:
3370 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3371 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3374 ## Creates a new mesh by a symmetrical copy of the object
3375 # @param theObject mesh, submesh or group
3376 # @param Mirror AxisStruct or geom object (point, line, plane)
3377 # @param theMirrorType POINT, AXIS or PLANE
3378 # If the Mirror is a geom object this parameter is unnecessary
3379 # @param MakeGroups forces the generation of new groups from existing ones
3380 # @param NewMeshName the name of the new mesh to create
3381 # @return instance of Mesh class
3382 # @ingroup l2_modif_trsf
3383 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3384 if ( isinstance( theObject, Mesh )):
3385 theObject = theObject.GetMesh()
3386 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3387 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3388 Mirror,Parameters = ParseAxisStruct(Mirror)
3389 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3390 MakeGroups, NewMeshName)
3391 mesh.SetParameters(Parameters)
3392 return Mesh( self.smeshpyD,self.geompyD,mesh )
3394 ## Translates the elements
3395 # @param IDsOfElements list of elements ids
3396 # @param Vector the direction of translation (DirStruct or vector)
3397 # @param Copy allows copying the translated elements
3398 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3399 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3400 # @ingroup l2_modif_trsf
3401 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3402 if IDsOfElements == []:
3403 IDsOfElements = self.GetElementsId()
3404 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3405 Vector = self.smeshpyD.GetDirStruct(Vector)
3406 Vector,Parameters = ParseDirStruct(Vector)
3407 self.mesh.SetParameters(Parameters)
3408 if Copy and MakeGroups:
3409 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3410 self.editor.Translate(IDsOfElements, Vector, Copy)
3413 ## Creates a new mesh of translated elements
3414 # @param IDsOfElements list of elements ids
3415 # @param Vector the direction of translation (DirStruct or vector)
3416 # @param MakeGroups forces the generation of new groups from existing ones
3417 # @param NewMeshName the name of the newly created mesh
3418 # @return instance of Mesh class
3419 # @ingroup l2_modif_trsf
3420 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3421 if IDsOfElements == []:
3422 IDsOfElements = self.GetElementsId()
3423 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3424 Vector = self.smeshpyD.GetDirStruct(Vector)
3425 Vector,Parameters = ParseDirStruct(Vector)
3426 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3427 mesh.SetParameters(Parameters)
3428 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3430 ## Translates the object
3431 # @param theObject the object to translate (mesh, submesh, or group)
3432 # @param Vector direction of translation (DirStruct or geom vector)
3433 # @param Copy allows copying the translated elements
3434 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3435 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3436 # @ingroup l2_modif_trsf
3437 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3438 if ( isinstance( theObject, Mesh )):
3439 theObject = theObject.GetMesh()
3440 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3441 Vector = self.smeshpyD.GetDirStruct(Vector)
3442 Vector,Parameters = ParseDirStruct(Vector)
3443 self.mesh.SetParameters(Parameters)
3444 if Copy and MakeGroups:
3445 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3446 self.editor.TranslateObject(theObject, Vector, Copy)
3449 ## Creates a new mesh from the translated object
3450 # @param theObject the object to translate (mesh, submesh, or group)
3451 # @param Vector the direction of translation (DirStruct or geom vector)
3452 # @param MakeGroups forces the generation of new groups from existing ones
3453 # @param NewMeshName the name of the newly created mesh
3454 # @return instance of Mesh class
3455 # @ingroup l2_modif_trsf
3456 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3457 if (isinstance(theObject, Mesh)):
3458 theObject = theObject.GetMesh()
3459 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3460 Vector = self.smeshpyD.GetDirStruct(Vector)
3461 Vector,Parameters = ParseDirStruct(Vector)
3462 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3463 mesh.SetParameters(Parameters)
3464 return Mesh( self.smeshpyD, self.geompyD, mesh )
3468 ## Scales the object
3469 # @param theObject - the object to translate (mesh, submesh, or group)
3470 # @param thePoint - base point for scale
3471 # @param theScaleFact - list of 1-3 scale factors for axises
3472 # @param Copy - allows copying the translated elements
3473 # @param MakeGroups - forces the generation of new groups from existing
3475 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3476 # empty list otherwise
3477 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3478 if ( isinstance( theObject, Mesh )):
3479 theObject = theObject.GetMesh()
3480 if ( isinstance( theObject, list )):
3481 theObject = self.editor.MakeIDSource(theObject, SMESH.ALL)
3483 thePoint, Parameters = ParsePointStruct(thePoint)
3484 self.mesh.SetParameters(Parameters)
3486 if Copy and MakeGroups:
3487 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3488 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3491 ## Creates a new mesh from the translated object
3492 # @param theObject - the object to translate (mesh, submesh, or group)
3493 # @param thePoint - base point for scale
3494 # @param theScaleFact - list of 1-3 scale factors for axises
3495 # @param MakeGroups - forces the generation of new groups from existing ones
3496 # @param NewMeshName - the name of the newly created mesh
3497 # @return instance of Mesh class
3498 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3499 if (isinstance(theObject, Mesh)):
3500 theObject = theObject.GetMesh()
3501 if ( isinstance( theObject, list )):
3502 theObject = self.editor.MakeIDSource(theObject,SMESH.ALL)
3504 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3505 MakeGroups, NewMeshName)
3506 #mesh.SetParameters(Parameters)
3507 return Mesh( self.smeshpyD, self.geompyD, mesh )
3511 ## Rotates the elements
3512 # @param IDsOfElements list of elements ids
3513 # @param Axis the axis of rotation (AxisStruct or geom line)
3514 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3515 # @param Copy allows copying the rotated elements
3516 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3517 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3518 # @ingroup l2_modif_trsf
3519 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3521 if isinstance(AngleInRadians,str):
3523 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3525 AngleInRadians = DegreesToRadians(AngleInRadians)
3526 if IDsOfElements == []:
3527 IDsOfElements = self.GetElementsId()
3528 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3529 Axis = self.smeshpyD.GetAxisStruct(Axis)
3530 Axis,AxisParameters = ParseAxisStruct(Axis)
3531 Parameters = AxisParameters + var_separator + Parameters
3532 self.mesh.SetParameters(Parameters)
3533 if Copy and MakeGroups:
3534 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3535 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3538 ## Creates a new mesh of rotated elements
3539 # @param IDsOfElements list of element ids
3540 # @param Axis the axis of rotation (AxisStruct or geom line)
3541 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3542 # @param MakeGroups forces the generation of new groups from existing ones
3543 # @param NewMeshName the name of the newly created mesh
3544 # @return instance of Mesh class
3545 # @ingroup l2_modif_trsf
3546 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3548 if isinstance(AngleInRadians,str):
3550 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3552 AngleInRadians = DegreesToRadians(AngleInRadians)
3553 if IDsOfElements == []:
3554 IDsOfElements = self.GetElementsId()
3555 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3556 Axis = self.smeshpyD.GetAxisStruct(Axis)
3557 Axis,AxisParameters = ParseAxisStruct(Axis)
3558 Parameters = AxisParameters + var_separator + Parameters
3559 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3560 MakeGroups, NewMeshName)
3561 mesh.SetParameters(Parameters)
3562 return Mesh( self.smeshpyD, self.geompyD, mesh )
3564 ## Rotates the object
3565 # @param theObject the object to rotate( mesh, submesh, or group)
3566 # @param Axis the axis of rotation (AxisStruct or geom line)
3567 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3568 # @param Copy allows copying the rotated elements
3569 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3570 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3571 # @ingroup l2_modif_trsf
3572 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3574 if isinstance(AngleInRadians,str):
3576 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3578 AngleInRadians = DegreesToRadians(AngleInRadians)
3579 if (isinstance(theObject, Mesh)):
3580 theObject = theObject.GetMesh()
3581 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3582 Axis = self.smeshpyD.GetAxisStruct(Axis)
3583 Axis,AxisParameters = ParseAxisStruct(Axis)
3584 Parameters = AxisParameters + ":" + Parameters
3585 self.mesh.SetParameters(Parameters)
3586 if Copy and MakeGroups:
3587 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3588 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3591 ## Creates a new mesh from the rotated object
3592 # @param theObject the object to rotate (mesh, submesh, or group)
3593 # @param Axis the axis of rotation (AxisStruct or geom line)
3594 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3595 # @param MakeGroups forces the generation of new groups from existing ones
3596 # @param NewMeshName the name of the newly created mesh
3597 # @return instance of Mesh class
3598 # @ingroup l2_modif_trsf
3599 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3601 if isinstance(AngleInRadians,str):
3603 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3605 AngleInRadians = DegreesToRadians(AngleInRadians)
3606 if (isinstance( theObject, Mesh )):
3607 theObject = theObject.GetMesh()
3608 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3609 Axis = self.smeshpyD.GetAxisStruct(Axis)
3610 Axis,AxisParameters = ParseAxisStruct(Axis)
3611 Parameters = AxisParameters + ":" + Parameters
3612 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3613 MakeGroups, NewMeshName)
3614 mesh.SetParameters(Parameters)
3615 return Mesh( self.smeshpyD, self.geompyD, mesh )
3617 ## Finds groups of ajacent nodes within Tolerance.
3618 # @param Tolerance the value of tolerance
3619 # @return the list of groups of nodes
3620 # @ingroup l2_modif_trsf
3621 def FindCoincidentNodes (self, Tolerance):
3622 return self.editor.FindCoincidentNodes(Tolerance)
3624 ## Finds groups of ajacent nodes within Tolerance.
3625 # @param Tolerance the value of tolerance
3626 # @param SubMeshOrGroup SubMesh or Group
3627 # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
3628 # @return the list of groups of nodes
3629 # @ingroup l2_modif_trsf
3630 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
3631 if (isinstance( SubMeshOrGroup, Mesh )):
3632 SubMeshOrGroup = SubMeshOrGroup.GetMesh()
3633 if not isinstance( exceptNodes, list):
3634 exceptNodes = [ exceptNodes ]
3635 if exceptNodes and isinstance( exceptNodes[0], int):
3636 exceptNodes = [ self.editor.MakeIDSource( exceptNodes, SMESH.NODE)]
3637 return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes)
3640 # @param GroupsOfNodes the list of groups of nodes
3641 # @ingroup l2_modif_trsf
3642 def MergeNodes (self, GroupsOfNodes):
3643 self.editor.MergeNodes(GroupsOfNodes)
3645 ## Finds the elements built on the same nodes.
3646 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3647 # @return a list of groups of equal elements
3648 # @ingroup l2_modif_trsf
3649 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3650 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3651 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3652 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3654 ## Merges elements in each given group.
3655 # @param GroupsOfElementsID groups of elements for merging
3656 # @ingroup l2_modif_trsf
3657 def MergeElements(self, GroupsOfElementsID):
3658 self.editor.MergeElements(GroupsOfElementsID)
3660 ## Leaves one element and removes all other elements built on the same nodes.
3661 # @ingroup l2_modif_trsf
3662 def MergeEqualElements(self):
3663 self.editor.MergeEqualElements()
3665 ## Sews free borders
3666 # @return SMESH::Sew_Error
3667 # @ingroup l2_modif_trsf
3668 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3669 FirstNodeID2, SecondNodeID2, LastNodeID2,
3670 CreatePolygons, CreatePolyedrs):
3671 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3672 FirstNodeID2, SecondNodeID2, LastNodeID2,
3673 CreatePolygons, CreatePolyedrs)
3675 ## Sews conform free borders
3676 # @return SMESH::Sew_Error
3677 # @ingroup l2_modif_trsf
3678 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3679 FirstNodeID2, SecondNodeID2):
3680 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3681 FirstNodeID2, SecondNodeID2)
3683 ## Sews border to side
3684 # @return SMESH::Sew_Error
3685 # @ingroup l2_modif_trsf
3686 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3687 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3688 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3689 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3691 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3692 # merged with the nodes of elements of Side2.
3693 # The number of elements in theSide1 and in theSide2 must be
3694 # equal and they should have similar nodal connectivity.
3695 # The nodes to merge should belong to side borders and
3696 # the first node should be linked to the second.
3697 # @return SMESH::Sew_Error
3698 # @ingroup l2_modif_trsf
3699 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3700 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3701 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3702 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3703 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3704 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3706 ## Sets new nodes for the given element.
3707 # @param ide the element id
3708 # @param newIDs nodes ids
3709 # @return If the number of nodes does not correspond to the type of element - returns false
3710 # @ingroup l2_modif_edit
3711 def ChangeElemNodes(self, ide, newIDs):
3712 return self.editor.ChangeElemNodes(ide, newIDs)
3714 ## If during the last operation of MeshEditor some nodes were
3715 # created, this method returns the list of their IDs, \n
3716 # if new nodes were not created - returns empty list
3717 # @return the list of integer values (can be empty)
3718 # @ingroup l1_auxiliary
3719 def GetLastCreatedNodes(self):
3720 return self.editor.GetLastCreatedNodes()
3722 ## If during the last operation of MeshEditor some elements were
3723 # created this method returns the list of their IDs, \n
3724 # if new elements were not created - returns empty list
3725 # @return the list of integer values (can be empty)
3726 # @ingroup l1_auxiliary
3727 def GetLastCreatedElems(self):
3728 return self.editor.GetLastCreatedElems()
3730 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3731 # @param theNodes identifiers of nodes to be doubled
3732 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
3733 # nodes. If list of element identifiers is empty then nodes are doubled but
3734 # they not assigned to elements
3735 # @return TRUE if operation has been completed successfully, FALSE otherwise
3736 # @ingroup l2_modif_edit
3737 def DoubleNodes(self, theNodes, theModifiedElems):
3738 return self.editor.DoubleNodes(theNodes, theModifiedElems)
3740 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3741 # This method provided for convenience works as DoubleNodes() described above.
3742 # @param theNodeId identifiers of node to be doubled
3743 # @param theModifiedElems identifiers of elements to be updated
3744 # @return TRUE if operation has been completed successfully, FALSE otherwise
3745 # @ingroup l2_modif_edit
3746 def DoubleNode(self, theNodeId, theModifiedElems):
3747 return self.editor.DoubleNode(theNodeId, theModifiedElems)
3749 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3750 # This method provided for convenience works as DoubleNodes() described above.
3751 # @param theNodes group of nodes to be doubled
3752 # @param theModifiedElems group of elements to be updated.
3753 # @param theMakeGroup forces the generation of a group containing new nodes.
3754 # @return TRUE or a created group if operation has been completed successfully,
3755 # FALSE or None otherwise
3756 # @ingroup l2_modif_edit
3757 def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
3759 return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
3760 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3762 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3763 # This method provided for convenience works as DoubleNodes() described above.
3764 # @param theNodes list of groups of nodes to be doubled
3765 # @param theModifiedElems list of groups of elements to be updated.
3766 # @return TRUE if operation has been completed successfully, FALSE otherwise
3767 # @ingroup l2_modif_edit
3768 def DoubleNodeGroups(self, theNodes, theModifiedElems):
3769 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3771 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3772 # @param theElems - the list of elements (edges or faces) to be replicated
3773 # The nodes for duplication could be found from these elements
3774 # @param theNodesNot - list of nodes to NOT replicate
3775 # @param theAffectedElems - the list of elements (cells and edges) to which the
3776 # replicated nodes should be associated to.
3777 # @return TRUE if operation has been completed successfully, FALSE otherwise
3778 # @ingroup l2_modif_edit
3779 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
3780 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
3782 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3783 # @param theElems - the list of elements (edges or faces) to be replicated
3784 # The nodes for duplication could be found from these elements
3785 # @param theNodesNot - list of nodes to NOT replicate
3786 # @param theShape - shape to detect affected elements (element which geometric center
3787 # located on or inside shape).
3788 # The replicated nodes should be associated to affected elements.
3789 # @return TRUE if operation has been completed successfully, FALSE otherwise
3790 # @ingroup l2_modif_edit
3791 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
3792 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
3794 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3795 # This method provided for convenience works as DoubleNodes() described above.
3796 # @param theElems - group of of elements (edges or faces) to be replicated
3797 # @param theNodesNot - group of nodes not to replicated
3798 # @param theAffectedElems - group of elements to which the replicated nodes
3799 # should be associated to.
3800 # @param theMakeGroup forces the generation of a group containing new elements.
3801 # @ingroup l2_modif_edit
3802 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
3804 return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
3805 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
3807 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3808 # This method provided for convenience works as DoubleNodes() described above.
3809 # @param theElems - group of of elements (edges or faces) to be replicated
3810 # @param theNodesNot - group of nodes not to replicated
3811 # @param theShape - shape to detect affected elements (element which geometric center
3812 # located on or inside shape).
3813 # The replicated nodes should be associated to affected elements.
3814 # @ingroup l2_modif_edit
3815 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
3816 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
3818 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3819 # This method provided for convenience works as DoubleNodes() described above.
3820 # @param theElems - list of groups of elements (edges or faces) to be replicated
3821 # @param theNodesNot - list of groups of nodes not to replicated
3822 # @param theAffectedElems - group of elements to which the replicated nodes
3823 # should be associated to.
3824 # @return TRUE if operation has been completed successfully, FALSE otherwise
3825 # @ingroup l2_modif_edit
3826 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems):
3827 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
3829 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3830 # This method provided for convenience works as DoubleNodes() described above.
3831 # @param theElems - list of groups of elements (edges or faces) to be replicated
3832 # @param theNodesNot - list of groups of nodes not to replicated
3833 # @param theShape - shape to detect affected elements (element which geometric center
3834 # located on or inside shape).
3835 # The replicated nodes should be associated to affected elements.
3836 # @return TRUE if operation has been completed successfully, FALSE otherwise
3837 # @ingroup l2_modif_edit
3838 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
3839 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
3841 ## The mother class to define algorithm, it is not recommended to use it directly.
3844 # @ingroup l2_algorithms
3845 class Mesh_Algorithm:
3846 # @class Mesh_Algorithm
3847 # @brief Class Mesh_Algorithm
3849 #def __init__(self,smesh):
3857 ## Finds a hypothesis in the study by its type name and parameters.
3858 # Finds only the hypotheses created in smeshpyD engine.
3859 # @return SMESH.SMESH_Hypothesis
3860 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3861 study = smeshpyD.GetCurrentStudy()
3862 #to do: find component by smeshpyD object, not by its data type
3863 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3864 if scomp is not None:
3865 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3866 # Check if the root label of the hypotheses exists
3867 if res and hypRoot is not None:
3868 iter = study.NewChildIterator(hypRoot)
3869 # Check all published hypotheses
3871 hypo_so_i = iter.Value()
3872 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3873 if attr is not None:
3874 anIOR = attr.Value()
3875 hypo_o_i = salome.orb.string_to_object(anIOR)
3876 if hypo_o_i is not None:
3877 # Check if this is a hypothesis
3878 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3879 if hypo_i is not None:
3880 # Check if the hypothesis belongs to current engine
3881 if smeshpyD.GetObjectId(hypo_i) > 0:
3882 # Check if this is the required hypothesis
3883 if hypo_i.GetName() == hypname:
3885 if CompareMethod(hypo_i, args):
3899 ## Finds the algorithm in the study by its type name.
3900 # Finds only the algorithms, which have been created in smeshpyD engine.
3901 # @return SMESH.SMESH_Algo
3902 def FindAlgorithm (self, algoname, smeshpyD):
3903 study = smeshpyD.GetCurrentStudy()
3904 #to do: find component by smeshpyD object, not by its data type
3905 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3906 if scomp is not None:
3907 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3908 # Check if the root label of the algorithms exists
3909 if res and hypRoot is not None:
3910 iter = study.NewChildIterator(hypRoot)
3911 # Check all published algorithms
3913 algo_so_i = iter.Value()
3914 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3915 if attr is not None:
3916 anIOR = attr.Value()
3917 algo_o_i = salome.orb.string_to_object(anIOR)
3918 if algo_o_i is not None:
3919 # Check if this is an algorithm
3920 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3921 if algo_i is not None:
3922 # Checks if the algorithm belongs to the current engine
3923 if smeshpyD.GetObjectId(algo_i) > 0:
3924 # Check if this is the required algorithm
3925 if algo_i.GetName() == algoname:
3938 ## If the algorithm is global, returns 0; \n
3939 # else returns the submesh associated to this algorithm.
3940 def GetSubMesh(self):
3943 ## Returns the wrapped mesher.
3944 def GetAlgorithm(self):
3947 ## Gets the list of hypothesis that can be used with this algorithm
3948 def GetCompatibleHypothesis(self):
3951 mylist = self.algo.GetCompatibleHypothesis()
3954 ## Gets the name of the algorithm
3958 ## Sets the name to the algorithm
3959 def SetName(self, name):
3960 self.mesh.smeshpyD.SetName(self.algo, name)
3962 ## Gets the id of the algorithm
3964 return self.algo.GetId()
3967 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3969 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3970 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3972 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3974 self.Assign(algo, mesh, geom)
3978 def Assign(self, algo, mesh, geom):
3980 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3989 name = GetName(geom)
3992 name = mesh.geompyD.SubShapeName(geom, piece)
3993 mesh.geompyD.addToStudyInFather(piece, geom, name)
3995 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3998 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3999 TreatHypoStatus( status, algo.GetName(), name, True )
4001 def CompareHyp (self, hyp, args):
4002 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
4005 def CompareEqualHyp (self, hyp, args):
4009 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
4010 UseExisting=0, CompareMethod=""):
4013 if CompareMethod == "": CompareMethod = self.CompareHyp
4014 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
4017 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
4023 a = a + s + str(args[i])
4027 self.mesh.smeshpyD.SetName(hypo, hyp + a)
4029 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
4030 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
4033 ## Returns entry of the shape to mesh in the study
4034 def MainShapeEntry(self):
4036 if not self.mesh or not self.mesh.GetMesh(): return entry
4037 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
4038 study = self.mesh.smeshpyD.GetCurrentStudy()
4039 ior = salome.orb.object_to_string( self.mesh.GetShape() )
4040 sobj = study.FindObjectIOR(ior)
4041 if sobj: entry = sobj.GetID()
4042 if not entry: return ""
4045 # Public class: Mesh_Segment
4046 # --------------------------
4048 ## Class to define a segment 1D algorithm for discretization
4051 # @ingroup l3_algos_basic
4052 class Mesh_Segment(Mesh_Algorithm):
4054 ## Private constructor.
4055 def __init__(self, mesh, geom=0):
4056 Mesh_Algorithm.__init__(self)
4057 self.Create(mesh, geom, "Regular_1D")
4059 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
4060 # @param l for the length of segments that cut an edge
4061 # @param UseExisting if ==true - searches for an existing hypothesis created with
4062 # the same parameters, else (default) - creates a new one
4063 # @param p precision, used for calculation of the number of segments.
4064 # The precision should be a positive, meaningful value within the range [0,1].
4065 # In general, the number of segments is calculated with the formula:
4066 # nb = ceil((edge_length / l) - p)
4067 # Function ceil rounds its argument to the higher integer.
4068 # So, p=0 means rounding of (edge_length / l) to the higher integer,
4069 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
4070 # p=1 means rounding of (edge_length / l) to the lower integer.
4071 # Default value is 1e-07.
4072 # @return an instance of StdMeshers_LocalLength hypothesis
4073 # @ingroup l3_hypos_1dhyps
4074 def LocalLength(self, l, UseExisting=0, p=1e-07):
4075 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
4076 CompareMethod=self.CompareLocalLength)
4082 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
4083 def CompareLocalLength(self, hyp, args):
4084 if IsEqual(hyp.GetLength(), args[0]):
4085 return IsEqual(hyp.GetPrecision(), args[1])
4088 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
4089 # @param length is optional maximal allowed length of segment, if it is omitted
4090 # the preestimated length is used that depends on geometry size
4091 # @param UseExisting if ==true - searches for an existing hypothesis created with
4092 # the same parameters, else (default) - create a new one
4093 # @return an instance of StdMeshers_MaxLength hypothesis
4094 # @ingroup l3_hypos_1dhyps
4095 def MaxSize(self, length=0.0, UseExisting=0):
4096 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
4099 hyp.SetLength(length)
4101 # set preestimated length
4102 gen = self.mesh.smeshpyD
4103 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
4104 self.mesh.GetMesh(), self.mesh.GetShape(),
4106 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
4108 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
4111 hyp.SetUsePreestimatedLength( length == 0.0 )
4114 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
4115 # @param n for the number of segments that cut an edge
4116 # @param s for the scale factor (optional)
4117 # @param reversedEdges is a list of edges to mesh using reversed orientation
4118 # @param UseExisting if ==true - searches for an existing hypothesis created with
4119 # the same parameters, else (default) - create a new one
4120 # @return an instance of StdMeshers_NumberOfSegments hypothesis
4121 # @ingroup l3_hypos_1dhyps
4122 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4123 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4124 reversedEdges, UseExisting = [], reversedEdges
4125 entry = self.MainShapeEntry()
4127 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
4128 UseExisting=UseExisting,
4129 CompareMethod=self.CompareNumberOfSegments)
4131 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
4132 UseExisting=UseExisting,
4133 CompareMethod=self.CompareNumberOfSegments)
4134 hyp.SetDistrType( 1 )
4135 hyp.SetScaleFactor(s)
4136 hyp.SetNumberOfSegments(n)
4137 hyp.SetReversedEdges( reversedEdges )
4138 hyp.SetObjectEntry( entry )
4142 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4143 def CompareNumberOfSegments(self, hyp, args):
4144 if hyp.GetNumberOfSegments() == args[0]:
4146 if hyp.GetReversedEdges() == args[1]:
4147 if not args[1] or hyp.GetObjectEntry() == args[2]:
4150 if hyp.GetReversedEdges() == args[2]:
4151 if not args[2] or hyp.GetObjectEntry() == args[3]:
4152 if hyp.GetDistrType() == 1:
4153 if IsEqual(hyp.GetScaleFactor(), args[1]):
4157 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4158 # @param start defines the length of the first segment
4159 # @param end defines the length of the last segment
4160 # @param reversedEdges is a list of edges to mesh using reversed orientation
4161 # @param UseExisting if ==true - searches for an existing hypothesis created with
4162 # the same parameters, else (default) - creates a new one
4163 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4164 # @ingroup l3_hypos_1dhyps
4165 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4166 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4167 reversedEdges, UseExisting = [], reversedEdges
4168 entry = self.MainShapeEntry()
4169 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
4170 UseExisting=UseExisting,
4171 CompareMethod=self.CompareArithmetic1D)
4172 hyp.SetStartLength(start)
4173 hyp.SetEndLength(end)
4174 hyp.SetReversedEdges( reversedEdges )
4175 hyp.SetObjectEntry( entry )
4179 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4180 def CompareArithmetic1D(self, hyp, args):
4181 if IsEqual(hyp.GetLength(1), args[0]):
4182 if IsEqual(hyp.GetLength(0), args[1]):
4183 if hyp.GetReversedEdges() == args[2]:
4184 if not args[2] or hyp.GetObjectEntry() == args[3]:
4189 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4190 # on curve from 0 to 1 (additionally it is neecessary to check
4191 # orientation of edges and create list of reversed edges if it is
4192 # needed) and sets numbers of segments between given points (default
4193 # values are equals 1
4194 # @param points defines the list of parameters on curve
4195 # @param nbSegs defines the list of numbers of segments
4196 # @param reversedEdges is a list of edges to mesh using reversed orientation
4197 # @param UseExisting if ==true - searches for an existing hypothesis created with
4198 # the same parameters, else (default) - creates a new one
4199 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4200 # @ingroup l3_hypos_1dhyps
4201 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4202 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4203 reversedEdges, UseExisting = [], reversedEdges
4204 if reversedEdges and isinstance( reversedEdges[0], geompyDC.GEOM._objref_GEOM_Object ):
4205 for i in range( len( reversedEdges )):
4206 reversedEdges[i] = self.mesh.geompyD.GetSubShapeID(self.mesh.geom, reversedEdges[i] )
4207 entry = self.MainShapeEntry()
4208 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
4209 UseExisting=UseExisting,
4210 CompareMethod=self.CompareFixedPoints1D)
4211 hyp.SetPoints(points)
4212 hyp.SetNbSegments(nbSegs)
4213 hyp.SetReversedEdges(reversedEdges)
4214 hyp.SetObjectEntry(entry)
4218 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4219 ## as the given arguments
4220 def CompareFixedPoints1D(self, hyp, args):
4221 if hyp.GetPoints() == args[0]:
4222 if hyp.GetNbSegments() == args[1]:
4223 if hyp.GetReversedEdges() == args[2]:
4224 if not args[2] or hyp.GetObjectEntry() == args[3]:
4230 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4231 # @param start defines the length of the first segment
4232 # @param end defines the length of the last segment
4233 # @param reversedEdges is a list of edges to mesh using reversed orientation
4234 # @param UseExisting if ==true - searches for an existing hypothesis created with
4235 # the same parameters, else (default) - creates a new one
4236 # @return an instance of StdMeshers_StartEndLength hypothesis
4237 # @ingroup l3_hypos_1dhyps
4238 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4239 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4240 reversedEdges, UseExisting = [], reversedEdges
4241 entry = self.MainShapeEntry()
4242 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
4243 UseExisting=UseExisting,
4244 CompareMethod=self.CompareStartEndLength)
4245 hyp.SetStartLength(start)
4246 hyp.SetEndLength(end)
4247 hyp.SetReversedEdges( reversedEdges )
4248 hyp.SetObjectEntry( entry )
4251 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4252 def CompareStartEndLength(self, hyp, args):
4253 if IsEqual(hyp.GetLength(1), args[0]):
4254 if IsEqual(hyp.GetLength(0), args[1]):
4255 if hyp.GetReversedEdges() == args[2]:
4256 if not args[2] or hyp.GetObjectEntry() == args[3]:
4260 ## Defines "Deflection1D" hypothesis
4261 # @param d for the deflection
4262 # @param UseExisting if ==true - searches for an existing hypothesis created with
4263 # the same parameters, else (default) - create a new one
4264 # @ingroup l3_hypos_1dhyps
4265 def Deflection1D(self, d, UseExisting=0):
4266 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4267 CompareMethod=self.CompareDeflection1D)
4268 hyp.SetDeflection(d)
4271 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4272 def CompareDeflection1D(self, hyp, args):
4273 return IsEqual(hyp.GetDeflection(), args[0])
4275 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4276 # the opposite side in case of quadrangular faces
4277 # @ingroup l3_hypos_additi
4278 def Propagation(self):
4279 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4281 ## Defines "AutomaticLength" hypothesis
4282 # @param fineness for the fineness [0-1]
4283 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4284 # same parameters, else (default) - create a new one
4285 # @ingroup l3_hypos_1dhyps
4286 def AutomaticLength(self, fineness=0, UseExisting=0):
4287 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4288 CompareMethod=self.CompareAutomaticLength)
4289 hyp.SetFineness( fineness )
4292 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4293 def CompareAutomaticLength(self, hyp, args):
4294 return IsEqual(hyp.GetFineness(), args[0])
4296 ## Defines "SegmentLengthAroundVertex" hypothesis
4297 # @param length for the segment length
4298 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4299 # Any other integer value means that the hypothesis will be set on the
4300 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4301 # @param UseExisting if ==true - searches for an existing hypothesis created with
4302 # the same parameters, else (default) - creates a new one
4303 # @ingroup l3_algos_segmarv
4304 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4306 store_geom = self.geom
4307 if type(vertex) is types.IntType:
4308 if vertex == 0 or vertex == 1:
4309 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
4317 if self.geom is None:
4318 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4320 name = GetName(self.geom)
4323 piece = self.mesh.geom
4324 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
4325 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
4327 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4329 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4331 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4332 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4334 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4335 CompareMethod=self.CompareLengthNearVertex)
4336 self.geom = store_geom
4337 hyp.SetLength( length )
4340 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4341 # @ingroup l3_algos_segmarv
4342 def CompareLengthNearVertex(self, hyp, args):
4343 return IsEqual(hyp.GetLength(), args[0])
4345 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4346 # If the 2D mesher sees that all boundary edges are quadratic,
4347 # it generates quadratic faces, else it generates linear faces using
4348 # medium nodes as if they are vertices.
4349 # The 3D mesher generates quadratic volumes only if all boundary faces
4350 # are quadratic, else it fails.
4352 # @ingroup l3_hypos_additi
4353 def QuadraticMesh(self):
4354 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4357 # Public class: Mesh_CompositeSegment
4358 # --------------------------
4360 ## Defines a segment 1D algorithm for discretization
4362 # @ingroup l3_algos_basic
4363 class Mesh_CompositeSegment(Mesh_Segment):
4365 ## Private constructor.
4366 def __init__(self, mesh, geom=0):
4367 self.Create(mesh, geom, "CompositeSegment_1D")
4370 # Public class: Mesh_Segment_Python
4371 # ---------------------------------
4373 ## Defines a segment 1D algorithm for discretization with python function
4375 # @ingroup l3_algos_basic
4376 class Mesh_Segment_Python(Mesh_Segment):
4378 ## Private constructor.
4379 def __init__(self, mesh, geom=0):
4380 import Python1dPlugin
4381 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4383 ## Defines "PythonSplit1D" hypothesis
4384 # @param n for the number of segments that cut an edge
4385 # @param func for the python function that calculates the length of all segments
4386 # @param UseExisting if ==true - searches for the existing hypothesis created with
4387 # the same parameters, else (default) - creates a new one
4388 # @ingroup l3_hypos_1dhyps
4389 def PythonSplit1D(self, n, func, UseExisting=0):
4390 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4391 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4392 hyp.SetNumberOfSegments(n)
4393 hyp.SetPythonLog10RatioFunction(func)
4396 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4397 def ComparePythonSplit1D(self, hyp, args):
4398 #if hyp.GetNumberOfSegments() == args[0]:
4399 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4403 # Public class: Mesh_Triangle
4404 # ---------------------------
4406 ## Defines a triangle 2D algorithm
4408 # @ingroup l3_algos_basic
4409 class Mesh_Triangle(Mesh_Algorithm):
4418 ## Private constructor.
4419 def __init__(self, mesh, algoType, geom=0):
4420 Mesh_Algorithm.__init__(self)
4422 self.algoType = algoType
4423 if algoType == MEFISTO:
4424 self.Create(mesh, geom, "MEFISTO_2D")
4426 elif algoType == BLSURF:
4428 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4429 #self.SetPhysicalMesh() - PAL19680
4430 elif algoType == NETGEN:
4432 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4434 elif algoType == NETGEN_2D:
4436 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4439 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4440 # @param area for the maximum area of each triangle
4441 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4442 # same parameters, else (default) - creates a new one
4444 # Only for algoType == MEFISTO || NETGEN_2D
4445 # @ingroup l3_hypos_2dhyps
4446 def MaxElementArea(self, area, UseExisting=0):
4447 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4448 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4449 CompareMethod=self.CompareMaxElementArea)
4450 elif self.algoType == NETGEN:
4451 hyp = self.Parameters(SIMPLE)
4452 hyp.SetMaxElementArea(area)
4455 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4456 def CompareMaxElementArea(self, hyp, args):
4457 return IsEqual(hyp.GetMaxElementArea(), args[0])
4459 ## Defines "LengthFromEdges" hypothesis to build triangles
4460 # based on the length of the edges taken from the wire
4462 # Only for algoType == MEFISTO || NETGEN_2D
4463 # @ingroup l3_hypos_2dhyps
4464 def LengthFromEdges(self):
4465 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4466 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4468 elif self.algoType == NETGEN:
4469 hyp = self.Parameters(SIMPLE)
4470 hyp.LengthFromEdges()
4473 ## Sets a way to define size of mesh elements to generate.
4474 # @param thePhysicalMesh is: DefaultSize or Custom.
4475 # @ingroup l3_hypos_blsurf
4476 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4477 # Parameter of BLSURF algo
4478 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4480 ## Sets size of mesh elements to generate.
4481 # @ingroup l3_hypos_blsurf
4482 def SetPhySize(self, theVal):
4483 # Parameter of BLSURF algo
4484 self.SetPhysicalMesh(1) #Custom - else why to set the size?
4485 self.Parameters().SetPhySize(theVal)
4487 ## Sets lower boundary of mesh element size (PhySize).
4488 # @ingroup l3_hypos_blsurf
4489 def SetPhyMin(self, theVal=-1):
4490 # Parameter of BLSURF algo
4491 self.Parameters().SetPhyMin(theVal)
4493 ## Sets upper boundary of mesh element size (PhySize).
4494 # @ingroup l3_hypos_blsurf
4495 def SetPhyMax(self, theVal=-1):
4496 # Parameter of BLSURF algo
4497 self.Parameters().SetPhyMax(theVal)
4499 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4500 # @param theGeometricMesh is: 0 (None) or 1 (Custom)
4501 # @ingroup l3_hypos_blsurf
4502 def SetGeometricMesh(self, theGeometricMesh=0):
4503 # Parameter of BLSURF algo
4504 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4505 self.params.SetGeometricMesh(theGeometricMesh)
4507 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4508 # @ingroup l3_hypos_blsurf
4509 def SetAngleMeshS(self, theVal=_angleMeshS):
4510 # Parameter of BLSURF algo
4511 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4512 self.params.SetAngleMeshS(theVal)
4514 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4515 # @ingroup l3_hypos_blsurf
4516 def SetAngleMeshC(self, theVal=_angleMeshS):
4517 # Parameter of BLSURF algo
4518 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4519 self.params.SetAngleMeshC(theVal)
4521 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4522 # @ingroup l3_hypos_blsurf
4523 def SetGeoMin(self, theVal=-1):
4524 # Parameter of BLSURF algo
4525 self.Parameters().SetGeoMin(theVal)
4527 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4528 # @ingroup l3_hypos_blsurf
4529 def SetGeoMax(self, theVal=-1):
4530 # Parameter of BLSURF algo
4531 self.Parameters().SetGeoMax(theVal)
4533 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4534 # @ingroup l3_hypos_blsurf
4535 def SetGradation(self, theVal=_gradation):
4536 # Parameter of BLSURF algo
4537 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4538 self.params.SetGradation(theVal)
4540 ## Sets topology usage way.
4541 # @param way defines how mesh conformity is assured <ul>
4542 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4543 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4544 # @ingroup l3_hypos_blsurf
4545 def SetTopology(self, way):
4546 # Parameter of BLSURF algo
4547 self.Parameters().SetTopology(way)
4549 ## To respect geometrical edges or not.
4550 # @ingroup l3_hypos_blsurf
4551 def SetDecimesh(self, toIgnoreEdges=False):
4552 # Parameter of BLSURF algo
4553 self.Parameters().SetDecimesh(toIgnoreEdges)
4555 ## Sets verbosity level in the range 0 to 100.
4556 # @ingroup l3_hypos_blsurf
4557 def SetVerbosity(self, level):
4558 # Parameter of BLSURF algo
4559 self.Parameters().SetVerbosity(level)
4561 ## Sets advanced option value.
4562 # @ingroup l3_hypos_blsurf
4563 def SetOptionValue(self, optionName, level):
4564 # Parameter of BLSURF algo
4565 self.Parameters().SetOptionValue(optionName,level)
4567 ## Sets QuadAllowed flag.
4568 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
4569 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4570 def SetQuadAllowed(self, toAllow=True):
4571 if self.algoType == NETGEN_2D:
4572 if toAllow: # add QuadranglePreference
4573 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4574 else: # remove QuadranglePreference
4575 for hyp in self.mesh.GetHypothesisList( self.geom ):
4576 if hyp.GetName() == "QuadranglePreference":
4577 self.mesh.RemoveHypothesis( self.geom, hyp )
4582 if self.Parameters():
4583 self.params.SetQuadAllowed(toAllow)
4586 ## Defines hypothesis having several parameters
4588 # @ingroup l3_hypos_netgen
4589 def Parameters(self, which=SOLE):
4592 if self.algoType == NETGEN:
4594 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4595 "libNETGENEngine.so", UseExisting=0)
4597 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4598 "libNETGENEngine.so", UseExisting=0)
4600 elif self.algoType == MEFISTO:
4601 print "Mefisto algo support no multi-parameter hypothesis"
4603 elif self.algoType == NETGEN_2D:
4604 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4605 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4607 elif self.algoType == BLSURF:
4608 self.params = self.Hypothesis("BLSURF_Parameters", [],
4609 "libBLSURFEngine.so", UseExisting=0)
4612 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4617 # Only for algoType == NETGEN
4618 # @ingroup l3_hypos_netgen
4619 def SetMaxSize(self, theSize):
4620 if self.Parameters():
4621 self.params.SetMaxSize(theSize)
4623 ## Sets SecondOrder flag
4625 # Only for algoType == NETGEN
4626 # @ingroup l3_hypos_netgen
4627 def SetSecondOrder(self, theVal):
4628 if self.Parameters():
4629 self.params.SetSecondOrder(theVal)
4631 ## Sets Optimize flag
4633 # Only for algoType == NETGEN
4634 # @ingroup l3_hypos_netgen
4635 def SetOptimize(self, theVal):
4636 if self.Parameters():
4637 self.params.SetOptimize(theVal)
4640 # @param theFineness is:
4641 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4643 # Only for algoType == NETGEN
4644 # @ingroup l3_hypos_netgen
4645 def SetFineness(self, theFineness):
4646 if self.Parameters():
4647 self.params.SetFineness(theFineness)
4651 # Only for algoType == NETGEN
4652 # @ingroup l3_hypos_netgen
4653 def SetGrowthRate(self, theRate):
4654 if self.Parameters():
4655 self.params.SetGrowthRate(theRate)
4657 ## Sets NbSegPerEdge
4659 # Only for algoType == NETGEN
4660 # @ingroup l3_hypos_netgen
4661 def SetNbSegPerEdge(self, theVal):
4662 if self.Parameters():
4663 self.params.SetNbSegPerEdge(theVal)
4665 ## Sets NbSegPerRadius
4667 # Only for algoType == NETGEN
4668 # @ingroup l3_hypos_netgen
4669 def SetNbSegPerRadius(self, theVal):
4670 if self.Parameters():
4671 self.params.SetNbSegPerRadius(theVal)
4673 ## Sets number of segments overriding value set by SetLocalLength()
4675 # Only for algoType == NETGEN
4676 # @ingroup l3_hypos_netgen
4677 def SetNumberOfSegments(self, theVal):
4678 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4680 ## Sets number of segments overriding value set by SetNumberOfSegments()
4682 # Only for algoType == NETGEN
4683 # @ingroup l3_hypos_netgen
4684 def SetLocalLength(self, theVal):
4685 self.Parameters(SIMPLE).SetLocalLength(theVal)
4690 # Public class: Mesh_Quadrangle
4691 # -----------------------------
4693 ## Defines a quadrangle 2D algorithm
4695 # @ingroup l3_algos_basic
4696 class Mesh_Quadrangle(Mesh_Algorithm):
4700 ## Private constructor.
4701 def __init__(self, mesh, geom=0):
4702 Mesh_Algorithm.__init__(self)
4703 self.Create(mesh, geom, "Quadrangle_2D")
4706 ## Defines "QuadrangleParameters" hypothesis
4707 # @param quadType defines the algorithm of transition between differently descretized
4708 # sides of a geometrical face:
4709 # - QUAD_STANDARD - both triangles and quadrangles are possible in the transition
4710 # area along the finer meshed sides.
4711 # - QUAD_TRIANGLE_PREF - only triangles are built in the transition area along the
4712 # finer meshed sides.
4713 # - QUAD_QUADRANGLE_PREF - only quadrangles are built in the transition area along
4714 # the finer meshed sides, iff the total quantity of segments on
4715 # all four sides of the face is even (divisible by 2).
4716 # - QUAD_QUADRANGLE_PREF_REVERSED - same as QUAD_QUADRANGLE_PREF but the transition
4717 # area is located along the coarser meshed sides.
4718 # - QUAD_REDUCED - only quadrangles are built and the transition between the sides
4719 # is made gradually, layer by layer. This type has a limitation on
4720 # the number of segments: one pair of opposite sides must have the
4721 # same number of segments, the other pair must have an even difference
4722 # between the numbers of segments on the sides.
4723 # @param triangleVertex: vertex of a trilateral geometrical face, around which triangles
4724 # will be created while other elements will be quadrangles.
4725 # Vertex can be either a GEOM_Object or a vertex ID within the
4727 # @param UseExisting: if ==true - searches for the existing hypothesis created with
4728 # the same parameters, else (default) - creates a new one
4729 # @ingroup l3_hypos_quad
4730 def QuadrangleParameters(self, quadType=StdMeshers.QUAD_STANDARD, triangleVertex=0, UseExisting=0):
4731 vertexID = triangleVertex
4732 if isinstance( triangleVertex, geompyDC.GEOM._objref_GEOM_Object ):
4733 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, triangleVertex )
4735 compFun = lambda hyp,args: \
4736 hyp.GetQuadType() == args[0] and \
4737 ( hyp.GetTriaVertex()==args[1] or ( hyp.GetTriaVertex()<1 and args[1]<1))
4738 self.params = self.Hypothesis("QuadrangleParams", [quadType,vertexID],
4739 UseExisting = UseExisting, CompareMethod=compFun)
4741 if self.params.GetQuadType() != quadType:
4742 self.params.SetQuadType(quadType)
4744 self.params.SetTriaVertex( vertexID )
4747 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
4748 # quadrangles are built in the transition area along the finer meshed sides,
4749 # iff the total quantity of segments on all four sides of the face is even.
4750 # @param reversed if True, transition area is located along the coarser meshed sides.
4751 # @param UseExisting: if ==true - searches for the existing hypothesis created with
4752 # the same parameters, else (default) - creates a new one
4753 # @ingroup l3_hypos_quad
4754 def QuadranglePreference(self, reversed=False, UseExisting=0):
4756 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF_REVERSED,UseExisting=UseExisting)
4757 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF,UseExisting=UseExisting)
4759 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
4760 # triangles are built in the transition area along the finer meshed sides.
4761 # @param UseExisting: if ==true - searches for the existing hypothesis created with
4762 # the same parameters, else (default) - creates a new one
4763 # @ingroup l3_hypos_quad
4764 def TrianglePreference(self, UseExisting=0):
4765 return self.QuadrangleParameters(QUAD_TRIANGLE_PREF,UseExisting=UseExisting)
4767 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
4768 # quadrangles are built and the transition between the sides is made gradually,
4769 # layer by layer. This type has a limitation on the number of segments: one pair
4770 # of opposite sides must have the same number of segments, the other pair must
4771 # have an even difference between the numbers of segments on the sides.
4772 # @param UseExisting: if ==true - searches for the existing hypothesis created with
4773 # the same parameters, else (default) - creates a new one
4774 # @ingroup l3_hypos_quad
4775 def Reduced(self, UseExisting=0):
4776 return self.QuadrangleParameters(QUAD_REDUCED,UseExisting=UseExisting)
4778 ## Defines "QuadrangleParams" hypothesis with QUAD_STANDARD type of quadrangulation
4779 # @param vertex: vertex of a trilateral geometrical face, around which triangles
4780 # will be created while other elements will be quadrangles.
4781 # Vertex can be either a GEOM_Object or a vertex ID within the
4783 # @param UseExisting: if ==true - searches for the existing hypothesis created with
4784 # the same parameters, else (default) - creates a new one
4785 # @ingroup l3_hypos_quad
4786 def TriangleVertex(self, vertex, UseExisting=0):
4787 return self.QuadrangleParameters(QUAD_STANDARD,vertex,UseExisting)
4790 # Public class: Mesh_Tetrahedron
4791 # ------------------------------
4793 ## Defines a tetrahedron 3D algorithm
4795 # @ingroup l3_algos_basic
4796 class Mesh_Tetrahedron(Mesh_Algorithm):
4801 ## Private constructor.
4802 def __init__(self, mesh, algoType, geom=0):
4803 Mesh_Algorithm.__init__(self)
4805 if algoType == NETGEN:
4807 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4810 elif algoType == FULL_NETGEN:
4812 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4815 elif algoType == GHS3D:
4817 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4820 elif algoType == GHS3DPRL:
4821 CheckPlugin(GHS3DPRL)
4822 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4825 self.algoType = algoType
4827 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4828 # @param vol for the maximum volume of each tetrahedron
4829 # @param UseExisting if ==true - searches for the existing hypothesis created with
4830 # the same parameters, else (default) - creates a new one
4831 # @ingroup l3_hypos_maxvol
4832 def MaxElementVolume(self, vol, UseExisting=0):
4833 if self.algoType == NETGEN:
4834 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4835 CompareMethod=self.CompareMaxElementVolume)
4836 hyp.SetMaxElementVolume(vol)
4838 elif self.algoType == FULL_NETGEN:
4839 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4842 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4843 def CompareMaxElementVolume(self, hyp, args):
4844 return IsEqual(hyp.GetMaxElementVolume(), args[0])
4846 ## Defines hypothesis having several parameters
4848 # @ingroup l3_hypos_netgen
4849 def Parameters(self, which=SOLE):
4853 if self.algoType == FULL_NETGEN:
4855 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4856 "libNETGENEngine.so", UseExisting=0)
4858 self.params = self.Hypothesis("NETGEN_Parameters", [],
4859 "libNETGENEngine.so", UseExisting=0)
4862 if self.algoType == GHS3D:
4863 self.params = self.Hypothesis("GHS3D_Parameters", [],
4864 "libGHS3DEngine.so", UseExisting=0)
4867 if self.algoType == GHS3DPRL:
4868 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4869 "libGHS3DPRLEngine.so", UseExisting=0)
4872 print "Algo supports no multi-parameter hypothesis"
4876 # Parameter of FULL_NETGEN
4877 # @ingroup l3_hypos_netgen
4878 def SetMaxSize(self, theSize):
4879 self.Parameters().SetMaxSize(theSize)
4881 ## Sets SecondOrder flag
4882 # Parameter of FULL_NETGEN
4883 # @ingroup l3_hypos_netgen
4884 def SetSecondOrder(self, theVal):
4885 self.Parameters().SetSecondOrder(theVal)
4887 ## Sets Optimize flag
4888 # Parameter of FULL_NETGEN
4889 # @ingroup l3_hypos_netgen
4890 def SetOptimize(self, theVal):
4891 self.Parameters().SetOptimize(theVal)
4894 # @param theFineness is:
4895 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4896 # Parameter of FULL_NETGEN
4897 # @ingroup l3_hypos_netgen
4898 def SetFineness(self, theFineness):
4899 self.Parameters().SetFineness(theFineness)
4902 # Parameter of FULL_NETGEN
4903 # @ingroup l3_hypos_netgen
4904 def SetGrowthRate(self, theRate):
4905 self.Parameters().SetGrowthRate(theRate)
4907 ## Sets NbSegPerEdge
4908 # Parameter of FULL_NETGEN
4909 # @ingroup l3_hypos_netgen
4910 def SetNbSegPerEdge(self, theVal):
4911 self.Parameters().SetNbSegPerEdge(theVal)
4913 ## Sets NbSegPerRadius
4914 # Parameter of FULL_NETGEN
4915 # @ingroup l3_hypos_netgen
4916 def SetNbSegPerRadius(self, theVal):
4917 self.Parameters().SetNbSegPerRadius(theVal)
4919 ## Sets number of segments overriding value set by SetLocalLength()
4920 # Only for algoType == NETGEN_FULL
4921 # @ingroup l3_hypos_netgen
4922 def SetNumberOfSegments(self, theVal):
4923 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4925 ## Sets number of segments overriding value set by SetNumberOfSegments()
4926 # Only for algoType == NETGEN_FULL
4927 # @ingroup l3_hypos_netgen
4928 def SetLocalLength(self, theVal):
4929 self.Parameters(SIMPLE).SetLocalLength(theVal)
4931 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4932 # Overrides value set by LengthFromEdges()
4933 # Only for algoType == NETGEN_FULL
4934 # @ingroup l3_hypos_netgen
4935 def MaxElementArea(self, area):
4936 self.Parameters(SIMPLE).SetMaxElementArea(area)
4938 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4939 # Overrides value set by MaxElementArea()
4940 # Only for algoType == NETGEN_FULL
4941 # @ingroup l3_hypos_netgen
4942 def LengthFromEdges(self):
4943 self.Parameters(SIMPLE).LengthFromEdges()
4945 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4946 # Overrides value set by MaxElementVolume()
4947 # Only for algoType == NETGEN_FULL
4948 # @ingroup l3_hypos_netgen
4949 def LengthFromFaces(self):
4950 self.Parameters(SIMPLE).LengthFromFaces()
4952 ## To mesh "holes" in a solid or not. Default is to mesh.
4953 # @ingroup l3_hypos_ghs3dh
4954 def SetToMeshHoles(self, toMesh):
4955 # Parameter of GHS3D
4956 self.Parameters().SetToMeshHoles(toMesh)
4958 ## Set Optimization level:
4959 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
4960 # Strong_Optimization.
4961 # Default is Standard_Optimization
4962 # @ingroup l3_hypos_ghs3dh
4963 def SetOptimizationLevel(self, level):
4964 # Parameter of GHS3D
4965 self.Parameters().SetOptimizationLevel(level)
4967 ## Maximal size of memory to be used by the algorithm (in Megabytes).
4968 # @ingroup l3_hypos_ghs3dh
4969 def SetMaximumMemory(self, MB):
4970 # Advanced parameter of GHS3D
4971 self.Parameters().SetMaximumMemory(MB)
4973 ## Initial size of memory to be used by the algorithm (in Megabytes) in
4974 # automatic memory adjustment mode.
4975 # @ingroup l3_hypos_ghs3dh
4976 def SetInitialMemory(self, MB):
4977 # Advanced parameter of GHS3D
4978 self.Parameters().SetInitialMemory(MB)
4980 ## Path to working directory.
4981 # @ingroup l3_hypos_ghs3dh
4982 def SetWorkingDirectory(self, path):
4983 # Advanced parameter of GHS3D
4984 self.Parameters().SetWorkingDirectory(path)
4986 ## To keep working files or remove them. Log file remains in case of errors anyway.
4987 # @ingroup l3_hypos_ghs3dh
4988 def SetKeepFiles(self, toKeep):
4989 # Advanced parameter of GHS3D and GHS3DPRL
4990 self.Parameters().SetKeepFiles(toKeep)
4992 ## To set verbose level [0-10]. <ul>
4993 #<li> 0 - no standard output,
4994 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4995 # indicates when the final mesh is being saved. In addition the software
4996 # gives indication regarding the CPU time.
4997 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4998 # histogram of the skin mesh, quality statistics histogram together with
4999 # the characteristics of the final mesh.</ul>
5000 # @ingroup l3_hypos_ghs3dh
5001 def SetVerboseLevel(self, level):
5002 # Advanced parameter of GHS3D
5003 self.Parameters().SetVerboseLevel(level)
5005 ## To create new nodes.
5006 # @ingroup l3_hypos_ghs3dh
5007 def SetToCreateNewNodes(self, toCreate):
5008 # Advanced parameter of GHS3D
5009 self.Parameters().SetToCreateNewNodes(toCreate)
5011 ## To use boundary recovery version which tries to create mesh on a very poor
5012 # quality surface mesh.
5013 # @ingroup l3_hypos_ghs3dh
5014 def SetToUseBoundaryRecoveryVersion(self, toUse):
5015 # Advanced parameter of GHS3D
5016 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
5018 ## Sets command line option as text.
5019 # @ingroup l3_hypos_ghs3dh
5020 def SetTextOption(self, option):
5021 # Advanced parameter of GHS3D
5022 self.Parameters().SetTextOption(option)
5024 ## Sets MED files name and path.
5025 def SetMEDName(self, value):
5026 self.Parameters().SetMEDName(value)
5028 ## Sets the number of partition of the initial mesh
5029 def SetNbPart(self, value):
5030 self.Parameters().SetNbPart(value)
5032 ## When big mesh, start tepal in background
5033 def SetBackground(self, value):
5034 self.Parameters().SetBackground(value)
5036 # Public class: Mesh_Hexahedron
5037 # ------------------------------
5039 ## Defines a hexahedron 3D algorithm
5041 # @ingroup l3_algos_basic
5042 class Mesh_Hexahedron(Mesh_Algorithm):
5047 ## Private constructor.
5048 def __init__(self, mesh, algoType=Hexa, geom=0):
5049 Mesh_Algorithm.__init__(self)
5051 self.algoType = algoType
5053 if algoType == Hexa:
5054 self.Create(mesh, geom, "Hexa_3D")
5057 elif algoType == Hexotic:
5058 CheckPlugin(Hexotic)
5059 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
5062 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
5063 # @ingroup l3_hypos_hexotic
5064 def MinMaxQuad(self, min=3, max=8, quad=True):
5065 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
5067 self.params.SetHexesMinLevel(min)
5068 self.params.SetHexesMaxLevel(max)
5069 self.params.SetHexoticQuadrangles(quad)
5072 # Deprecated, only for compatibility!
5073 # Public class: Mesh_Netgen
5074 # ------------------------------
5076 ## Defines a NETGEN-based 2D or 3D algorithm
5077 # that needs no discrete boundary (i.e. independent)
5079 # This class is deprecated, only for compatibility!
5082 # @ingroup l3_algos_basic
5083 class Mesh_Netgen(Mesh_Algorithm):
5087 ## Private constructor.
5088 def __init__(self, mesh, is3D, geom=0):
5089 Mesh_Algorithm.__init__(self)
5095 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5099 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
5102 ## Defines the hypothesis containing parameters of the algorithm
5103 def Parameters(self):
5105 hyp = self.Hypothesis("NETGEN_Parameters", [],
5106 "libNETGENEngine.so", UseExisting=0)
5108 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
5109 "libNETGENEngine.so", UseExisting=0)
5112 # Public class: Mesh_Projection1D
5113 # ------------------------------
5115 ## Defines a projection 1D algorithm
5116 # @ingroup l3_algos_proj
5118 class Mesh_Projection1D(Mesh_Algorithm):
5120 ## Private constructor.
5121 def __init__(self, mesh, geom=0):
5122 Mesh_Algorithm.__init__(self)
5123 self.Create(mesh, geom, "Projection_1D")
5125 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
5126 # a mesh pattern is taken, and, optionally, the association of vertices
5127 # between the source edge and a target edge (to which a hypothesis is assigned)
5128 # @param edge from which nodes distribution is taken
5129 # @param mesh from which nodes distribution is taken (optional)
5130 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
5131 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
5132 # to associate with \a srcV (optional)
5133 # @param UseExisting if ==true - searches for the existing hypothesis created with
5134 # the same parameters, else (default) - creates a new one
5135 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
5136 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
5138 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
5139 hyp.SetSourceEdge( edge )
5140 if not mesh is None and isinstance(mesh, Mesh):
5141 mesh = mesh.GetMesh()
5142 hyp.SetSourceMesh( mesh )
5143 hyp.SetVertexAssociation( srcV, tgtV )
5146 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
5147 #def CompareSourceEdge(self, hyp, args):
5148 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
5152 # Public class: Mesh_Projection2D
5153 # ------------------------------
5155 ## Defines a projection 2D algorithm
5156 # @ingroup l3_algos_proj
5158 class Mesh_Projection2D(Mesh_Algorithm):
5160 ## Private constructor.
5161 def __init__(self, mesh, geom=0):
5162 Mesh_Algorithm.__init__(self)
5163 self.Create(mesh, geom, "Projection_2D")
5165 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
5166 # a mesh pattern is taken, and, optionally, the association of vertices
5167 # between the source face and the target face (to which a hypothesis is assigned)
5168 # @param face from which the mesh pattern is taken
5169 # @param mesh from which the mesh pattern is taken (optional)
5170 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
5171 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
5172 # to associate with \a srcV1 (optional)
5173 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
5174 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
5175 # to associate with \a srcV2 (optional)
5176 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
5177 # the same parameters, else (default) - forces the creation a new one
5179 # Note: all association vertices must belong to one edge of a face
5180 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
5181 srcV2=None, tgtV2=None, UseExisting=0):
5182 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
5184 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
5185 hyp.SetSourceFace( face )
5186 if not mesh is None and isinstance(mesh, Mesh):
5187 mesh = mesh.GetMesh()
5188 hyp.SetSourceMesh( mesh )
5189 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5192 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
5193 #def CompareSourceFace(self, hyp, args):
5194 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
5197 # Public class: Mesh_Projection3D
5198 # ------------------------------
5200 ## Defines a projection 3D algorithm
5201 # @ingroup l3_algos_proj
5203 class Mesh_Projection3D(Mesh_Algorithm):
5205 ## Private constructor.
5206 def __init__(self, mesh, geom=0):
5207 Mesh_Algorithm.__init__(self)
5208 self.Create(mesh, geom, "Projection_3D")
5210 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
5211 # the mesh pattern is taken, and, optionally, the association of vertices
5212 # between the source and the target solid (to which a hipothesis is assigned)
5213 # @param solid from where the mesh pattern is taken
5214 # @param mesh from where the mesh pattern is taken (optional)
5215 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
5216 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
5217 # to associate with \a srcV1 (optional)
5218 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
5219 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
5220 # to associate with \a srcV2 (optional)
5221 # @param UseExisting - if ==true - searches for the existing hypothesis created with
5222 # the same parameters, else (default) - creates a new one
5224 # Note: association vertices must belong to one edge of a solid
5225 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
5226 srcV2=0, tgtV2=0, UseExisting=0):
5227 hyp = self.Hypothesis("ProjectionSource3D",
5228 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
5230 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
5231 hyp.SetSource3DShape( solid )
5232 if not mesh is None and isinstance(mesh, Mesh):
5233 mesh = mesh.GetMesh()
5234 hyp.SetSourceMesh( mesh )
5235 if srcV1 and srcV2 and tgtV1 and tgtV2:
5236 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5237 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
5240 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
5241 #def CompareSourceShape3D(self, hyp, args):
5242 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
5246 # Public class: Mesh_Prism
5247 # ------------------------
5249 ## Defines a 3D extrusion algorithm
5250 # @ingroup l3_algos_3dextr
5252 class Mesh_Prism3D(Mesh_Algorithm):
5254 ## Private constructor.
5255 def __init__(self, mesh, geom=0):
5256 Mesh_Algorithm.__init__(self)
5257 self.Create(mesh, geom, "Prism_3D")
5259 # Public class: Mesh_RadialPrism
5260 # -------------------------------
5262 ## Defines a Radial Prism 3D algorithm
5263 # @ingroup l3_algos_radialp
5265 class Mesh_RadialPrism3D(Mesh_Algorithm):
5267 ## Private constructor.
5268 def __init__(self, mesh, geom=0):
5269 Mesh_Algorithm.__init__(self)
5270 self.Create(mesh, geom, "RadialPrism_3D")
5272 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
5273 self.nbLayers = None
5275 ## Return 3D hypothesis holding the 1D one
5276 def Get3DHypothesis(self):
5277 return self.distribHyp
5279 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5280 # hypothesis. Returns the created hypothesis
5281 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5282 #print "OwnHypothesis",hypType
5283 if not self.nbLayers is None:
5284 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5285 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5286 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5287 self.mesh.smeshpyD.SetCurrentStudy( None )
5288 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5289 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5290 self.distribHyp.SetLayerDistribution( hyp )
5293 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
5294 # prisms to build between the inner and outer shells
5295 # @param n number of layers
5296 # @param UseExisting if ==true - searches for the existing hypothesis created with
5297 # the same parameters, else (default) - creates a new one
5298 def NumberOfLayers(self, n, UseExisting=0):
5299 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5300 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
5301 CompareMethod=self.CompareNumberOfLayers)
5302 self.nbLayers.SetNumberOfLayers( n )
5303 return self.nbLayers
5305 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5306 def CompareNumberOfLayers(self, hyp, args):
5307 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5309 ## Defines "LocalLength" hypothesis, specifying the segment length
5310 # to build between the inner and the outer shells
5311 # @param l the length of segments
5312 # @param p the precision of rounding
5313 def LocalLength(self, l, p=1e-07):
5314 hyp = self.OwnHypothesis("LocalLength", [l,p])
5319 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
5320 # prisms to build between the inner and the outer shells.
5321 # @param n the number of layers
5322 # @param s the scale factor (optional)
5323 def NumberOfSegments(self, n, s=[]):
5325 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5327 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5328 hyp.SetDistrType( 1 )
5329 hyp.SetScaleFactor(s)
5330 hyp.SetNumberOfSegments(n)
5333 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5334 # to build between the inner and the outer shells with a length that changes in arithmetic progression
5335 # @param start the length of the first segment
5336 # @param end the length of the last segment
5337 def Arithmetic1D(self, start, end ):
5338 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5339 hyp.SetLength(start, 1)
5340 hyp.SetLength(end , 0)
5343 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5344 # to build between the inner and the outer shells as geometric length increasing
5345 # @param start for the length of the first segment
5346 # @param end for the length of the last segment
5347 def StartEndLength(self, start, end):
5348 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5349 hyp.SetLength(start, 1)
5350 hyp.SetLength(end , 0)
5353 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5354 # to build between the inner and outer shells
5355 # @param fineness defines the quality of the mesh within the range [0-1]
5356 def AutomaticLength(self, fineness=0):
5357 hyp = self.OwnHypothesis("AutomaticLength")
5358 hyp.SetFineness( fineness )
5361 # Public class: Mesh_RadialQuadrangle1D2D
5362 # -------------------------------
5364 ## Defines a Radial Quadrangle 1D2D algorithm
5365 # @ingroup l2_algos_radialq
5367 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
5369 ## Private constructor.
5370 def __init__(self, mesh, geom=0):
5371 Mesh_Algorithm.__init__(self)
5372 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5374 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
5375 self.nbLayers = None
5377 ## Return 2D hypothesis holding the 1D one
5378 def Get2DHypothesis(self):
5379 return self.distribHyp
5381 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5382 # hypothesis. Returns the created hypothesis
5383 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5384 #print "OwnHypothesis",hypType
5386 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5387 if self.distribHyp is None:
5388 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5390 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5391 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5392 self.mesh.smeshpyD.SetCurrentStudy( None )
5393 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5394 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5395 self.distribHyp.SetLayerDistribution( hyp )
5398 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
5399 # @param n number of layers
5400 # @param UseExisting if ==true - searches for the existing hypothesis created with
5401 # the same parameters, else (default) - creates a new one
5402 def NumberOfLayers(self, n, UseExisting=0):
5404 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5405 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5406 CompareMethod=self.CompareNumberOfLayers)
5407 self.nbLayers.SetNumberOfLayers( n )
5408 return self.nbLayers
5410 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5411 def CompareNumberOfLayers(self, hyp, args):
5412 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5414 ## Defines "LocalLength" hypothesis, specifying the segment length
5415 # @param l the length of segments
5416 # @param p the precision of rounding
5417 def LocalLength(self, l, p=1e-07):
5418 hyp = self.OwnHypothesis("LocalLength", [l,p])
5423 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5424 # @param n the number of layers
5425 # @param s the scale factor (optional)
5426 def NumberOfSegments(self, n, s=[]):
5428 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5430 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5431 hyp.SetDistrType( 1 )
5432 hyp.SetScaleFactor(s)
5433 hyp.SetNumberOfSegments(n)
5436 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5437 # with a length that changes in arithmetic progression
5438 # @param start the length of the first segment
5439 # @param end the length of the last segment
5440 def Arithmetic1D(self, start, end ):
5441 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5442 hyp.SetLength(start, 1)
5443 hyp.SetLength(end , 0)
5446 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5447 # as geometric length increasing
5448 # @param start for the length of the first segment
5449 # @param end for the length of the last segment
5450 def StartEndLength(self, start, end):
5451 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5452 hyp.SetLength(start, 1)
5453 hyp.SetLength(end , 0)
5456 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5457 # @param fineness defines the quality of the mesh within the range [0-1]
5458 def AutomaticLength(self, fineness=0):
5459 hyp = self.OwnHypothesis("AutomaticLength")
5460 hyp.SetFineness( fineness )
5464 # Private class: Mesh_UseExisting
5465 # -------------------------------
5466 class Mesh_UseExisting(Mesh_Algorithm):
5468 def __init__(self, dim, mesh, geom=0):
5470 self.Create(mesh, geom, "UseExisting_1D")
5472 self.Create(mesh, geom, "UseExisting_2D")
5475 import salome_notebook
5476 notebook = salome_notebook.notebook
5478 ##Return values of the notebook variables
5479 def ParseParameters(last, nbParams,nbParam, value):
5483 listSize = len(last)
5484 for n in range(0,nbParams):
5486 if counter < listSize:
5487 strResult = strResult + last[counter]
5489 strResult = strResult + ""
5491 if isinstance(value, str):
5492 if notebook.isVariable(value):
5493 result = notebook.get(value)
5494 strResult=strResult+value
5496 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
5498 strResult=strResult+str(value)
5500 if nbParams - 1 != counter:
5501 strResult=strResult+var_separator #":"
5503 return result, strResult
5505 #Wrapper class for StdMeshers_LocalLength hypothesis
5506 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5508 ## Set Length parameter value
5509 # @param length numerical value or name of variable from notebook
5510 def SetLength(self, length):
5511 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
5512 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5513 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
5515 ## Set Precision parameter value
5516 # @param precision numerical value or name of variable from notebook
5517 def SetPrecision(self, precision):
5518 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
5519 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5520 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5522 #Registering the new proxy for LocalLength
5523 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5526 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5527 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5529 def SetLayerDistribution(self, hypo):
5530 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
5531 hypo.ClearParameters();
5532 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5534 #Registering the new proxy for LayerDistribution
5535 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5537 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5538 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5540 ## Set Length parameter value
5541 # @param length numerical value or name of variable from notebook
5542 def SetLength(self, length):
5543 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
5544 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
5545 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5547 #Registering the new proxy for SegmentLengthAroundVertex
5548 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5551 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5552 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5554 ## Set Length parameter value
5555 # @param length numerical value or name of variable from notebook
5556 # @param isStart true is length is Start Length, otherwise false
5557 def SetLength(self, length, isStart):
5561 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
5562 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
5563 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
5565 #Registering the new proxy for Arithmetic1D
5566 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
5568 #Wrapper class for StdMeshers_Deflection1D hypothesis
5569 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
5571 ## Set Deflection parameter value
5572 # @param deflection numerical value or name of variable from notebook
5573 def SetDeflection(self, deflection):
5574 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
5575 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
5576 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
5578 #Registering the new proxy for Deflection1D
5579 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
5581 #Wrapper class for StdMeshers_StartEndLength hypothesis
5582 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
5584 ## Set Length parameter value
5585 # @param length numerical value or name of variable from notebook
5586 # @param isStart true is length is Start Length, otherwise false
5587 def SetLength(self, length, isStart):
5591 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
5592 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
5593 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
5595 #Registering the new proxy for StartEndLength
5596 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
5598 #Wrapper class for StdMeshers_MaxElementArea hypothesis
5599 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
5601 ## Set Max Element Area parameter value
5602 # @param area numerical value or name of variable from notebook
5603 def SetMaxElementArea(self, area):
5604 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
5605 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
5606 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
5608 #Registering the new proxy for MaxElementArea
5609 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
5612 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
5613 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
5615 ## Set Max Element Volume parameter value
5616 # @param volume numerical value or name of variable from notebook
5617 def SetMaxElementVolume(self, volume):
5618 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
5619 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
5620 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
5622 #Registering the new proxy for MaxElementVolume
5623 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
5626 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
5627 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
5629 ## Set Number Of Layers parameter value
5630 # @param nbLayers numerical value or name of variable from notebook
5631 def SetNumberOfLayers(self, nbLayers):
5632 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
5633 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
5634 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
5636 #Registering the new proxy for NumberOfLayers
5637 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
5639 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
5640 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
5642 ## Set Number Of Segments parameter value
5643 # @param nbSeg numerical value or name of variable from notebook
5644 def SetNumberOfSegments(self, nbSeg):
5645 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
5646 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
5647 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5648 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
5650 ## Set Scale Factor parameter value
5651 # @param factor numerical value or name of variable from notebook
5652 def SetScaleFactor(self, factor):
5653 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
5654 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5655 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
5657 #Registering the new proxy for NumberOfSegments
5658 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
5660 if not noNETGENPlugin:
5661 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
5662 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
5664 ## Set Max Size parameter value
5665 # @param maxsize numerical value or name of variable from notebook
5666 def SetMaxSize(self, maxsize):
5667 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5668 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
5669 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5670 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
5672 ## Set Growth Rate parameter value
5673 # @param value numerical value or name of variable from notebook
5674 def SetGrowthRate(self, value):
5675 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5676 value, parameters = ParseParameters(lastParameters,4,2,value)
5677 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5678 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
5680 ## Set Number of Segments per Edge parameter value
5681 # @param value numerical value or name of variable from notebook
5682 def SetNbSegPerEdge(self, value):
5683 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5684 value, parameters = ParseParameters(lastParameters,4,3,value)
5685 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5686 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
5688 ## Set Number of Segments per Radius parameter value
5689 # @param value numerical value or name of variable from notebook
5690 def SetNbSegPerRadius(self, value):
5691 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5692 value, parameters = ParseParameters(lastParameters,4,4,value)
5693 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5694 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
5696 #Registering the new proxy for NETGENPlugin_Hypothesis
5697 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5700 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5701 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5704 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5705 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5707 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5708 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5710 ## Set Number of Segments parameter value
5711 # @param nbSeg numerical value or name of variable from notebook
5712 def SetNumberOfSegments(self, nbSeg):
5713 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5714 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5715 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5716 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5718 ## Set Local Length parameter value
5719 # @param length numerical value or name of variable from notebook
5720 def SetLocalLength(self, length):
5721 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5722 length, parameters = ParseParameters(lastParameters,2,1,length)
5723 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5724 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
5726 ## Set Max Element Area parameter value
5727 # @param area numerical value or name of variable from notebook
5728 def SetMaxElementArea(self, area):
5729 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5730 area, parameters = ParseParameters(lastParameters,2,2,area)
5731 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5732 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
5734 def LengthFromEdges(self):
5735 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5737 value, parameters = ParseParameters(lastParameters,2,2,value)
5738 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5739 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
5741 #Registering the new proxy for NETGEN_SimpleParameters_2D
5742 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
5745 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
5746 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
5747 ## Set Max Element Volume parameter value
5748 # @param volume numerical value or name of variable from notebook
5749 def SetMaxElementVolume(self, volume):
5750 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5751 volume, parameters = ParseParameters(lastParameters,3,3,volume)
5752 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5753 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5755 def LengthFromFaces(self):
5756 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5758 value, parameters = ParseParameters(lastParameters,3,3,value)
5759 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5760 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5762 #Registering the new proxy for NETGEN_SimpleParameters_3D
5763 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5765 pass # if not noNETGENPlugin:
5767 class Pattern(SMESH._objref_SMESH_Pattern):
5769 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5771 if isinstance(theNodeIndexOnKeyPoint1,str):
5773 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5775 theNodeIndexOnKeyPoint1 -= 1
5776 theMesh.SetParameters(Parameters)
5777 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5779 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5782 if isinstance(theNode000Index,str):
5784 if isinstance(theNode001Index,str):
5786 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5788 theNode000Index -= 1
5790 theNode001Index -= 1
5791 theMesh.SetParameters(Parameters)
5792 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5794 #Registering the new proxy for Pattern
5795 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)