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_additi Additional Hypotheses
56 ## @defgroup l2_submeshes Constructing submeshes
57 ## @defgroup l2_compounds Building Compounds
58 ## @defgroup l2_editing Editing Meshes
61 ## @defgroup l1_meshinfo Mesh Information
62 ## @defgroup l1_controls Quality controls and Filtering
63 ## @defgroup l1_grouping Grouping elements
65 ## @defgroup l2_grps_create Creating groups
66 ## @defgroup l2_grps_edit Editing groups
67 ## @defgroup l2_grps_operon Using operations on groups
68 ## @defgroup l2_grps_delete Deleting Groups
71 ## @defgroup l1_modifying Modifying meshes
73 ## @defgroup l2_modif_add Adding nodes and elements
74 ## @defgroup l2_modif_del Removing nodes and elements
75 ## @defgroup l2_modif_edit Modifying nodes and elements
76 ## @defgroup l2_modif_renumber Renumbering nodes and elements
77 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
78 ## @defgroup l2_modif_movenode Moving nodes
79 ## @defgroup l2_modif_throughp Mesh through point
80 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
81 ## @defgroup l2_modif_unitetri Uniting triangles
82 ## @defgroup l2_modif_changori Changing orientation of elements
83 ## @defgroup l2_modif_cutquadr Cutting quadrangles
84 ## @defgroup l2_modif_smooth Smoothing
85 ## @defgroup l2_modif_extrurev Extrusion and Revolution
86 ## @defgroup l2_modif_patterns Pattern mapping
87 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
94 import SMESH # This is necessary for back compatibility
102 # import NETGENPlugin module if possible
110 # import GHS3DPlugin module if possible
118 # import GHS3DPRLPlugin module if possible
121 import GHS3DPRLPlugin
126 # import HexoticPlugin module if possible
134 # import BLSURFPlugin module if possible
142 ## @addtogroup l1_auxiliary
145 # Types of algorithms
158 NETGEN_1D2D3D = FULL_NETGEN
159 NETGEN_FULL = FULL_NETGEN
167 # MirrorType enumeration
168 POINT = SMESH_MeshEditor.POINT
169 AXIS = SMESH_MeshEditor.AXIS
170 PLANE = SMESH_MeshEditor.PLANE
172 # Smooth_Method enumeration
173 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
174 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
176 # Fineness enumeration (for NETGEN)
184 # Optimization level of GHS3D
186 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
187 # V4.1 (partialy redefines V3.1). Issue 0020574
188 None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization, Strong_Optimization = 0,1,2,3,4
190 # Topology treatment way of BLSURF
191 FromCAD, PreProcess, PreProcessPlus = 0,1,2
193 # Element size flag of BLSURF
194 DefaultSize, DefaultGeom, Custom = 0,0,1
196 PrecisionConfusion = 1e-07
198 # TopAbs_State enumeration
199 [TopAbs_IN, TopAbs_OUT, TopAbs_ON, TopAbs_UNKNOWN] = range(4)
201 # Methods of splitting a hexahedron into tetrahedra
202 Hex_5Tet, Hex_6Tet, Hex_24Tet = 1, 2, 3
205 ## Converts an angle from degrees to radians
206 def DegreesToRadians(AngleInDegrees):
208 return AngleInDegrees * pi / 180.0
210 # Salome notebook variable separator
213 # Parametrized substitute for PointStruct
214 class PointStructStr:
223 def __init__(self, xStr, yStr, zStr):
227 if isinstance(xStr, str) and notebook.isVariable(xStr):
228 self.x = notebook.get(xStr)
231 if isinstance(yStr, str) and notebook.isVariable(yStr):
232 self.y = notebook.get(yStr)
235 if isinstance(zStr, str) and notebook.isVariable(zStr):
236 self.z = notebook.get(zStr)
240 # Parametrized substitute for PointStruct (with 6 parameters)
241 class PointStructStr6:
256 def __init__(self, x1Str, x2Str, y1Str, y2Str, z1Str, z2Str):
263 if isinstance(x1Str, str) and notebook.isVariable(x1Str):
264 self.x1 = notebook.get(x1Str)
267 if isinstance(x2Str, str) and notebook.isVariable(x2Str):
268 self.x2 = notebook.get(x2Str)
271 if isinstance(y1Str, str) and notebook.isVariable(y1Str):
272 self.y1 = notebook.get(y1Str)
275 if isinstance(y2Str, str) and notebook.isVariable(y2Str):
276 self.y2 = notebook.get(y2Str)
279 if isinstance(z1Str, str) and notebook.isVariable(z1Str):
280 self.z1 = notebook.get(z1Str)
283 if isinstance(z2Str, str) and notebook.isVariable(z2Str):
284 self.z2 = notebook.get(z2Str)
288 # Parametrized substitute for AxisStruct
304 def __init__(self, xStr, yStr, zStr, dxStr, dyStr, dzStr):
311 if isinstance(xStr, str) and notebook.isVariable(xStr):
312 self.x = notebook.get(xStr)
315 if isinstance(yStr, str) and notebook.isVariable(yStr):
316 self.y = notebook.get(yStr)
319 if isinstance(zStr, str) and notebook.isVariable(zStr):
320 self.z = notebook.get(zStr)
323 if isinstance(dxStr, str) and notebook.isVariable(dxStr):
324 self.dx = notebook.get(dxStr)
327 if isinstance(dyStr, str) and notebook.isVariable(dyStr):
328 self.dy = notebook.get(dyStr)
331 if isinstance(dzStr, str) and notebook.isVariable(dzStr):
332 self.dz = notebook.get(dzStr)
336 # Parametrized substitute for DirStruct
339 def __init__(self, pointStruct):
340 self.pointStruct = pointStruct
342 # Returns list of variable values from salome notebook
343 def ParsePointStruct(Point):
344 Parameters = 2*var_separator
345 if isinstance(Point, PointStructStr):
346 Parameters = str(Point.xStr) + var_separator + str(Point.yStr) + var_separator + str(Point.zStr)
347 Point = PointStruct(Point.x, Point.y, Point.z)
348 return Point, Parameters
350 # Returns list of variable values from salome notebook
351 def ParseDirStruct(Dir):
352 Parameters = 2*var_separator
353 if isinstance(Dir, DirStructStr):
354 pntStr = Dir.pointStruct
355 if isinstance(pntStr, PointStructStr6):
356 Parameters = str(pntStr.x1Str) + var_separator + str(pntStr.x2Str) + var_separator
357 Parameters += str(pntStr.y1Str) + var_separator + str(pntStr.y2Str) + var_separator
358 Parameters += str(pntStr.z1Str) + var_separator + str(pntStr.z2Str)
359 Point = PointStruct(pntStr.x2 - pntStr.x1, pntStr.y2 - pntStr.y1, pntStr.z2 - pntStr.z1)
361 Parameters = str(pntStr.xStr) + var_separator + str(pntStr.yStr) + var_separator + str(pntStr.zStr)
362 Point = PointStruct(pntStr.x, pntStr.y, pntStr.z)
363 Dir = DirStruct(Point)
364 return Dir, Parameters
366 # Returns list of variable values from salome notebook
367 def ParseAxisStruct(Axis):
368 Parameters = 5*var_separator
369 if isinstance(Axis, AxisStructStr):
370 Parameters = str(Axis.xStr) + var_separator + str(Axis.yStr) + var_separator + str(Axis.zStr) + var_separator
371 Parameters += str(Axis.dxStr) + var_separator + str(Axis.dyStr) + var_separator + str(Axis.dzStr)
372 Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz)
373 return Axis, Parameters
375 ## Return list of variable values from salome notebook
376 def ParseAngles(list):
379 for parameter in list:
380 if isinstance(parameter,str) and notebook.isVariable(parameter):
381 Result.append(DegreesToRadians(notebook.get(parameter)))
384 Result.append(parameter)
387 Parameters = Parameters + str(parameter)
388 Parameters = Parameters + var_separator
390 Parameters = Parameters[:len(Parameters)-1]
391 return Result, Parameters
393 def IsEqual(val1, val2, tol=PrecisionConfusion):
394 if abs(val1 - val2) < tol:
404 if isinstance(obj, SALOMEDS._objref_SObject):
407 ior = salome.orb.object_to_string(obj)
410 studies = salome.myStudyManager.GetOpenStudies()
411 for sname in studies:
412 s = salome.myStudyManager.GetStudyByName(sname)
414 sobj = s.FindObjectIOR(ior)
415 if not sobj: continue
416 return sobj.GetName()
417 if hasattr(obj, "GetName"):
418 # unknown CORBA object, having GetName() method
421 # unknown CORBA object, no GetName() method
424 if hasattr(obj, "GetName"):
425 # unknown non-CORBA object, having GetName() method
428 raise RuntimeError, "Null or invalid object"
430 ## Prints error message if a hypothesis was not assigned.
431 def TreatHypoStatus(status, hypName, geomName, isAlgo):
433 hypType = "algorithm"
435 hypType = "hypothesis"
437 if status == HYP_UNKNOWN_FATAL :
438 reason = "for unknown reason"
439 elif status == HYP_INCOMPATIBLE :
440 reason = "this hypothesis mismatches the algorithm"
441 elif status == HYP_NOTCONFORM :
442 reason = "a non-conform mesh would be built"
443 elif status == HYP_ALREADY_EXIST :
444 if isAlgo: return # it does not influence anything
445 reason = hypType + " of the same dimension is already assigned to this shape"
446 elif status == HYP_BAD_DIM :
447 reason = hypType + " mismatches the shape"
448 elif status == HYP_CONCURENT :
449 reason = "there are concurrent hypotheses on sub-shapes"
450 elif status == HYP_BAD_SUBSHAPE :
451 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
452 elif status == HYP_BAD_GEOMETRY:
453 reason = "geometry mismatches the expectation of the algorithm"
454 elif status == HYP_HIDDEN_ALGO:
455 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
456 elif status == HYP_HIDING_ALGO:
457 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
458 elif status == HYP_NEED_SHAPE:
459 reason = "Algorithm can't work without shape"
462 hypName = '"' + hypName + '"'
463 geomName= '"' + geomName+ '"'
464 if status < HYP_UNKNOWN_FATAL and not geomName =='""':
465 print hypName, "was assigned to", geomName,"but", reason
466 elif not geomName == '""':
467 print hypName, "was not assigned to",geomName,":", reason
469 print hypName, "was not assigned:", reason
472 ## Check meshing plugin availability
473 def CheckPlugin(plugin):
474 if plugin == NETGEN and noNETGENPlugin:
475 print "Warning: NETGENPlugin module unavailable"
477 elif plugin == GHS3D and noGHS3DPlugin:
478 print "Warning: GHS3DPlugin module unavailable"
480 elif plugin == GHS3DPRL and noGHS3DPRLPlugin:
481 print "Warning: GHS3DPRLPlugin module unavailable"
483 elif plugin == Hexotic and noHexoticPlugin:
484 print "Warning: HexoticPlugin module unavailable"
486 elif plugin == BLSURF and noBLSURFPlugin:
487 print "Warning: BLSURFPlugin module unavailable"
491 # end of l1_auxiliary
494 # All methods of this class are accessible directly from the smesh.py package.
495 class smeshDC(SMESH._objref_SMESH_Gen):
497 ## Sets the current study and Geometry component
498 # @ingroup l1_auxiliary
499 def init_smesh(self,theStudy,geompyD):
500 self.SetCurrentStudy(theStudy,geompyD)
502 ## Creates an empty Mesh. This mesh can have an underlying geometry.
503 # @param obj the Geometrical object on which the mesh is built. If not defined,
504 # the mesh will have no underlying geometry.
505 # @param name the name for the new mesh.
506 # @return an instance of Mesh class.
507 # @ingroup l2_construct
508 def Mesh(self, obj=0, name=0):
509 if isinstance(obj,str):
511 return Mesh(self,self.geompyD,obj,name)
513 ## Returns a long value from enumeration
514 # Should be used for SMESH.FunctorType enumeration
515 # @ingroup l1_controls
516 def EnumToLong(self,theItem):
519 ## Returns a string representation of the color.
520 # To be used with filters.
521 # @param c color value (SALOMEDS.Color)
522 # @ingroup l1_controls
523 def ColorToString(self,c):
525 if isinstance(c, SALOMEDS.Color):
526 val = "%s;%s;%s" % (c.R, c.G, c.B)
527 elif isinstance(c, str):
530 raise ValueError, "Color value should be of string or SALOMEDS.Color type"
533 ## Gets PointStruct from vertex
534 # @param theVertex a GEOM object(vertex)
535 # @return SMESH.PointStruct
536 # @ingroup l1_auxiliary
537 def GetPointStruct(self,theVertex):
538 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
539 return PointStruct(x,y,z)
541 ## Gets DirStruct from vector
542 # @param theVector a GEOM object(vector)
543 # @return SMESH.DirStruct
544 # @ingroup l1_auxiliary
545 def GetDirStruct(self,theVector):
546 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
547 if(len(vertices) != 2):
548 print "Error: vector object is incorrect."
550 p1 = self.geompyD.PointCoordinates(vertices[0])
551 p2 = self.geompyD.PointCoordinates(vertices[1])
552 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
553 dirst = DirStruct(pnt)
556 ## Makes DirStruct from a triplet
557 # @param x,y,z vector components
558 # @return SMESH.DirStruct
559 # @ingroup l1_auxiliary
560 def MakeDirStruct(self,x,y,z):
561 pnt = PointStruct(x,y,z)
562 return DirStruct(pnt)
564 ## Get AxisStruct from object
565 # @param theObj a GEOM object (line or plane)
566 # @return SMESH.AxisStruct
567 # @ingroup l1_auxiliary
568 def GetAxisStruct(self,theObj):
569 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
571 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
572 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
573 vertex1 = self.geompyD.PointCoordinates(vertex1)
574 vertex2 = self.geompyD.PointCoordinates(vertex2)
575 vertex3 = self.geompyD.PointCoordinates(vertex3)
576 vertex4 = self.geompyD.PointCoordinates(vertex4)
577 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
578 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
579 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] ]
580 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
582 elif len(edges) == 1:
583 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
584 p1 = self.geompyD.PointCoordinates( vertex1 )
585 p2 = self.geompyD.PointCoordinates( vertex2 )
586 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
590 # From SMESH_Gen interface:
591 # ------------------------
593 ## Sets the given name to the object
594 # @param obj the object to rename
595 # @param name a new object name
596 # @ingroup l1_auxiliary
597 def SetName(self, obj, name):
598 if isinstance( obj, Mesh ):
600 elif isinstance( obj, Mesh_Algorithm ):
601 obj = obj.GetAlgorithm()
602 ior = salome.orb.object_to_string(obj)
603 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
605 ## Sets the current mode
606 # @ingroup l1_auxiliary
607 def SetEmbeddedMode( self,theMode ):
608 #self.SetEmbeddedMode(theMode)
609 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
611 ## Gets the current mode
612 # @ingroup l1_auxiliary
613 def IsEmbeddedMode(self):
614 #return self.IsEmbeddedMode()
615 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
617 ## Sets the current study
618 # @ingroup l1_auxiliary
619 def SetCurrentStudy( self, theStudy, geompyD = None ):
620 #self.SetCurrentStudy(theStudy)
623 geompyD = geompy.geom
626 self.SetGeomEngine(geompyD)
627 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
629 ## Gets the current study
630 # @ingroup l1_auxiliary
631 def GetCurrentStudy(self):
632 #return self.GetCurrentStudy()
633 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
635 ## Creates a Mesh object importing data from the given UNV file
636 # @return an instance of Mesh class
638 def CreateMeshesFromUNV( self,theFileName ):
639 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
640 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
643 ## Creates a Mesh object(s) importing data from the given MED file
644 # @return a list of Mesh class instances
646 def CreateMeshesFromMED( self,theFileName ):
647 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
649 for iMesh in range(len(aSmeshMeshes)) :
650 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
651 aMeshes.append(aMesh)
652 return aMeshes, aStatus
654 ## Creates a Mesh object importing data from the given STL file
655 # @return an instance of Mesh class
657 def CreateMeshesFromSTL( self, theFileName ):
658 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
659 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
662 ## From SMESH_Gen interface
663 # @return the list of integer values
664 # @ingroup l1_auxiliary
665 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
666 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
668 ## From SMESH_Gen interface. Creates a pattern
669 # @return an instance of SMESH_Pattern
671 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
672 # @ingroup l2_modif_patterns
673 def GetPattern(self):
674 return SMESH._objref_SMESH_Gen.GetPattern(self)
676 ## Sets number of segments per diagonal of boundary box of geometry by which
677 # default segment length of appropriate 1D hypotheses is defined.
678 # Default value is 10
679 # @ingroup l1_auxiliary
680 def SetBoundaryBoxSegmentation(self, nbSegments):
681 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
683 ## Concatenate the given meshes into one mesh.
684 # @return an instance of Mesh class
685 # @param meshes the meshes to combine into one mesh
686 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
687 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
688 # @param mergeTolerance tolerance for merging nodes
689 # @param allGroups forces creation of groups of all elements
690 def Concatenate( self, meshes, uniteIdenticalGroups,
691 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
692 mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
693 for i,m in enumerate(meshes):
694 if isinstance(m, Mesh):
695 meshes[i] = m.GetMesh()
697 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
698 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
700 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
701 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
702 aSmeshMesh.SetParameters(Parameters)
703 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
706 # Filtering. Auxiliary functions:
707 # ------------------------------
709 ## Creates an empty criterion
710 # @return SMESH.Filter.Criterion
711 # @ingroup l1_controls
712 def GetEmptyCriterion(self):
713 Type = self.EnumToLong(FT_Undefined)
714 Compare = self.EnumToLong(FT_Undefined)
718 UnaryOp = self.EnumToLong(FT_Undefined)
719 BinaryOp = self.EnumToLong(FT_Undefined)
722 Precision = -1 ##@1e-07
723 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
724 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
726 ## Creates a criterion by the given parameters
727 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
728 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
729 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
730 # @param Treshold the threshold value (range of ids as string, shape, numeric)
731 # @param UnaryOp FT_LogicalNOT or FT_Undefined
732 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
733 # FT_Undefined (must be for the last criterion of all criteria)
734 # @return SMESH.Filter.Criterion
735 # @ingroup l1_controls
736 def GetCriterion(self,elementType,
738 Compare = FT_EqualTo,
740 UnaryOp=FT_Undefined,
741 BinaryOp=FT_Undefined):
742 aCriterion = self.GetEmptyCriterion()
743 aCriterion.TypeOfElement = elementType
744 aCriterion.Type = self.EnumToLong(CritType)
748 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
749 aCriterion.Compare = self.EnumToLong(Compare)
750 elif Compare == "=" or Compare == "==":
751 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
753 aCriterion.Compare = self.EnumToLong(FT_LessThan)
755 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
757 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
760 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
761 FT_BelongToCylinder, FT_LyingOnGeom]:
762 # Checks the treshold
763 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
764 aCriterion.ThresholdStr = GetName(aTreshold)
765 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
767 print "Error: The treshold should be a shape."
769 elif CritType == FT_RangeOfIds:
770 # Checks the treshold
771 if isinstance(aTreshold, str):
772 aCriterion.ThresholdStr = aTreshold
774 print "Error: The treshold should be a string."
776 elif CritType == FT_CoplanarFaces:
777 # Checks the treshold
778 if isinstance(aTreshold, int):
779 aCriterion.ThresholdID = "%s"%aTreshold
780 elif isinstance(aTreshold, str):
783 raise ValueError, "Invalid ID of mesh face: '%s'"%aTreshold
784 aCriterion.ThresholdID = aTreshold
787 "The treshold should be an ID of mesh face and not '%s'"%aTreshold
788 elif CritType == FT_ElemGeomType:
789 # Checks the treshold
791 aCriterion.Threshold = self.EnumToLong(aTreshold)
793 if isinstance(aTreshold, int):
794 aCriterion.Threshold = aTreshold
796 print "Error: The treshold should be an integer or SMESH.GeometryType."
800 elif CritType == FT_GroupColor:
801 # Checks the treshold
803 aCriterion.ThresholdStr = self.ColorToString(aTreshold)
805 print "Error: The threshold value should be of SALOMEDS.Color type"
808 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
809 FT_FreeFaces, FT_LinearOrQuadratic]:
810 # At this point the treshold is unnecessary
811 if aTreshold == FT_LogicalNOT:
812 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
813 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
814 aCriterion.BinaryOp = aTreshold
818 aTreshold = float(aTreshold)
819 aCriterion.Threshold = aTreshold
821 print "Error: The treshold should be a number."
824 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
825 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
827 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
828 aCriterion.BinaryOp = self.EnumToLong(Treshold)
830 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
831 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
833 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
834 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
838 ## Creates a filter with the given parameters
839 # @param elementType the type of elements in the group
840 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
841 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
842 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
843 # @param UnaryOp FT_LogicalNOT or FT_Undefined
844 # @return SMESH_Filter
845 # @ingroup l1_controls
846 def GetFilter(self,elementType,
847 CritType=FT_Undefined,
850 UnaryOp=FT_Undefined):
851 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
852 aFilterMgr = self.CreateFilterManager()
853 aFilter = aFilterMgr.CreateFilter()
855 aCriteria.append(aCriterion)
856 aFilter.SetCriteria(aCriteria)
859 ## Creates a numerical functor by its type
860 # @param theCriterion FT_...; functor type
861 # @return SMESH_NumericalFunctor
862 # @ingroup l1_controls
863 def GetFunctor(self,theCriterion):
864 aFilterMgr = self.CreateFilterManager()
865 if theCriterion == FT_AspectRatio:
866 return aFilterMgr.CreateAspectRatio()
867 elif theCriterion == FT_AspectRatio3D:
868 return aFilterMgr.CreateAspectRatio3D()
869 elif theCriterion == FT_Warping:
870 return aFilterMgr.CreateWarping()
871 elif theCriterion == FT_MinimumAngle:
872 return aFilterMgr.CreateMinimumAngle()
873 elif theCriterion == FT_Taper:
874 return aFilterMgr.CreateTaper()
875 elif theCriterion == FT_Skew:
876 return aFilterMgr.CreateSkew()
877 elif theCriterion == FT_Area:
878 return aFilterMgr.CreateArea()
879 elif theCriterion == FT_Volume3D:
880 return aFilterMgr.CreateVolume3D()
881 elif theCriterion == FT_MultiConnection:
882 return aFilterMgr.CreateMultiConnection()
883 elif theCriterion == FT_MultiConnection2D:
884 return aFilterMgr.CreateMultiConnection2D()
885 elif theCriterion == FT_Length:
886 return aFilterMgr.CreateLength()
887 elif theCriterion == FT_Length2D:
888 return aFilterMgr.CreateLength2D()
890 print "Error: given parameter is not numerucal functor type."
892 ## Creates hypothesis
893 # @param theHType mesh hypothesis type (string)
894 # @param theLibName mesh plug-in library name
895 # @return created hypothesis instance
896 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
897 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
899 ## Gets the mesh stattistic
900 # @return dictionary type element - count of elements
901 # @ingroup l1_meshinfo
902 def GetMeshInfo(self, obj):
903 if isinstance( obj, Mesh ):
906 if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource):
907 values = obj.GetMeshInfo()
908 for i in range(SMESH.Entity_Last._v):
909 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
914 #Registering the new proxy for SMESH_Gen
915 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
921 ## This class allows defining and managing a mesh.
922 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
923 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
924 # new nodes and elements and by changing the existing entities), to get information
925 # about a mesh and to export a mesh into different formats.
934 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
935 # sets the GUI name of this mesh to \a name.
936 # @param smeshpyD an instance of smeshDC class
937 # @param geompyD an instance of geompyDC class
938 # @param obj Shape to be meshed or SMESH_Mesh object
939 # @param name Study name of the mesh
940 # @ingroup l2_construct
941 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
942 self.smeshpyD=smeshpyD
947 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
949 self.mesh = self.smeshpyD.CreateMesh(self.geom)
950 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
953 self.mesh = self.smeshpyD.CreateEmptyMesh()
955 self.smeshpyD.SetName(self.mesh, name)
957 self.smeshpyD.SetName(self.mesh, GetName(obj))
960 self.geom = self.mesh.GetShapeToMesh()
962 self.editor = self.mesh.GetMeshEditor()
964 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
965 # @param theMesh a SMESH_Mesh object
966 # @ingroup l2_construct
967 def SetMesh(self, theMesh):
969 self.geom = self.mesh.GetShapeToMesh()
971 ## Returns the mesh, that is an instance of SMESH_Mesh interface
972 # @return a SMESH_Mesh object
973 # @ingroup l2_construct
977 ## Gets the name of the mesh
978 # @return the name of the mesh as a string
979 # @ingroup l2_construct
981 name = GetName(self.GetMesh())
984 ## Sets a name to the mesh
985 # @param name a new name of the mesh
986 # @ingroup l2_construct
987 def SetName(self, name):
988 self.smeshpyD.SetName(self.GetMesh(), name)
990 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
991 # The subMesh object gives access to the IDs of nodes and elements.
992 # @param theSubObject a geometrical object (shape)
993 # @param theName a name for the submesh
994 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
995 # @ingroup l2_submeshes
996 def GetSubMesh(self, theSubObject, theName):
997 submesh = self.mesh.GetSubMesh(theSubObject, theName)
1000 ## Returns the shape associated to the mesh
1001 # @return a GEOM_Object
1002 # @ingroup l2_construct
1006 ## Associates the given shape to the mesh (entails the recreation of the mesh)
1007 # @param geom the shape to be meshed (GEOM_Object)
1008 # @ingroup l2_construct
1009 def SetShape(self, geom):
1010 self.mesh = self.smeshpyD.CreateMesh(geom)
1012 ## Returns true if the hypotheses are defined well
1013 # @param theSubObject a subshape of a mesh shape
1014 # @return True or False
1015 # @ingroup l2_construct
1016 def IsReadyToCompute(self, theSubObject):
1017 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
1019 ## Returns errors of hypotheses definition.
1020 # The list of errors is empty if everything is OK.
1021 # @param theSubObject a subshape of a mesh shape
1022 # @return a list of errors
1023 # @ingroup l2_construct
1024 def GetAlgoState(self, theSubObject):
1025 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
1027 ## Returns a geometrical object on which the given element was built.
1028 # The returned geometrical object, if not nil, is either found in the
1029 # study or published by this method with the given name
1030 # @param theElementID the id of the mesh element
1031 # @param theGeomName the user-defined name of the geometrical object
1032 # @return GEOM::GEOM_Object instance
1033 # @ingroup l2_construct
1034 def GetGeometryByMeshElement(self, theElementID, theGeomName):
1035 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
1037 ## Returns the mesh dimension depending on the dimension of the underlying shape
1038 # @return mesh dimension as an integer value [0,3]
1039 # @ingroup l1_auxiliary
1040 def MeshDimension(self):
1041 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
1042 if len( shells ) > 0 :
1044 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
1046 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
1052 ## Creates a segment discretization 1D algorithm.
1053 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
1054 # \n If the optional \a geom parameter is not set, this algorithm is global.
1055 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1056 # @param algo the type of the required algorithm. Possible values are:
1058 # - smesh.PYTHON for discretization via a python function,
1059 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
1060 # @param geom If defined is the subshape to be meshed
1061 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
1062 # @ingroup l3_algos_basic
1063 def Segment(self, algo=REGULAR, geom=0):
1064 ## if Segment(geom) is called by mistake
1065 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
1066 algo, geom = geom, algo
1067 if not algo: algo = REGULAR
1070 return Mesh_Segment(self, geom)
1071 elif algo == PYTHON:
1072 return Mesh_Segment_Python(self, geom)
1073 elif algo == COMPOSITE:
1074 return Mesh_CompositeSegment(self, geom)
1076 return Mesh_Segment(self, geom)
1078 ## Enables creation of nodes and segments usable by 2D algoritms.
1079 # The added nodes and segments must be bound to edges and vertices by
1080 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
1081 # If the optional \a geom parameter is not set, this algorithm is global.
1082 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1083 # @param geom the subshape to be manually meshed
1084 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
1085 # @ingroup l3_algos_basic
1086 def UseExistingSegments(self, geom=0):
1087 algo = Mesh_UseExisting(1,self,geom)
1088 return algo.GetAlgorithm()
1090 ## Enables creation of nodes and faces usable by 3D algoritms.
1091 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
1092 # and SetMeshElementOnShape()
1093 # If the optional \a geom parameter is not set, this algorithm is global.
1094 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1095 # @param geom the subshape to be manually meshed
1096 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1097 # @ingroup l3_algos_basic
1098 def UseExistingFaces(self, geom=0):
1099 algo = Mesh_UseExisting(2,self,geom)
1100 return algo.GetAlgorithm()
1102 ## Creates a triangle 2D algorithm for faces.
1103 # If the optional \a geom parameter is not set, this algorithm is global.
1104 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1105 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1106 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1107 # @return an instance of Mesh_Triangle algorithm
1108 # @ingroup l3_algos_basic
1109 def Triangle(self, algo=MEFISTO, geom=0):
1110 ## if Triangle(geom) is called by mistake
1111 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1114 return Mesh_Triangle(self, algo, geom)
1116 ## Creates a quadrangle 2D algorithm for faces.
1117 # If the optional \a geom parameter is not set, this algorithm is global.
1118 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1119 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1120 # @param algo values are: smesh.QUADRANGLE || smesh.RADIAL_QUAD
1121 # @return an instance of Mesh_Quadrangle algorithm
1122 # @ingroup l3_algos_basic
1123 def Quadrangle(self, geom=0, algo=QUADRANGLE):
1124 if algo==RADIAL_QUAD:
1125 return Mesh_RadialQuadrangle1D2D(self,geom)
1127 return Mesh_Quadrangle(self, geom)
1129 ## Creates a tetrahedron 3D algorithm for solids.
1130 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1131 # If the optional \a geom parameter is not set, this algorithm is global.
1132 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1133 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1134 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1135 # @return an instance of Mesh_Tetrahedron algorithm
1136 # @ingroup l3_algos_basic
1137 def Tetrahedron(self, algo=NETGEN, geom=0):
1138 ## if Tetrahedron(geom) is called by mistake
1139 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1140 algo, geom = geom, algo
1141 if not algo: algo = NETGEN
1143 return Mesh_Tetrahedron(self, algo, geom)
1145 ## Creates a hexahedron 3D algorithm for solids.
1146 # If the optional \a geom parameter is not set, this algorithm is global.
1147 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1148 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1149 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1150 # @return an instance of Mesh_Hexahedron algorithm
1151 # @ingroup l3_algos_basic
1152 def Hexahedron(self, algo=Hexa, geom=0):
1153 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1154 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1155 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1156 elif geom == 0: algo, geom = Hexa, algo
1157 return Mesh_Hexahedron(self, algo, geom)
1159 ## Deprecated, used only for compatibility!
1160 # @return an instance of Mesh_Netgen algorithm
1161 # @ingroup l3_algos_basic
1162 def Netgen(self, is3D, geom=0):
1163 return Mesh_Netgen(self, is3D, geom)
1165 ## Creates a projection 1D algorithm for edges.
1166 # If the optional \a geom parameter is not set, this algorithm is global.
1167 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1168 # @param geom If defined, the subshape to be meshed
1169 # @return an instance of Mesh_Projection1D algorithm
1170 # @ingroup l3_algos_proj
1171 def Projection1D(self, geom=0):
1172 return Mesh_Projection1D(self, geom)
1174 ## Creates a projection 2D algorithm for faces.
1175 # If the optional \a geom parameter is not set, this algorithm is global.
1176 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1177 # @param geom If defined, the subshape to be meshed
1178 # @return an instance of Mesh_Projection2D algorithm
1179 # @ingroup l3_algos_proj
1180 def Projection2D(self, geom=0):
1181 return Mesh_Projection2D(self, geom)
1183 ## Creates a projection 3D algorithm for solids.
1184 # If the optional \a geom parameter is not set, this algorithm is global.
1185 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1186 # @param geom If defined, the subshape to be meshed
1187 # @return an instance of Mesh_Projection3D algorithm
1188 # @ingroup l3_algos_proj
1189 def Projection3D(self, geom=0):
1190 return Mesh_Projection3D(self, geom)
1192 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1193 # If the optional \a geom parameter is not set, this algorithm is global.
1194 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1195 # @param geom If defined, the subshape to be meshed
1196 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1197 # @ingroup l3_algos_radialp l3_algos_3dextr
1198 def Prism(self, geom=0):
1202 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1203 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1204 if nbSolids == 0 or nbSolids == nbShells:
1205 return Mesh_Prism3D(self, geom)
1206 return Mesh_RadialPrism3D(self, geom)
1208 ## Evaluates size of prospective mesh on a shape
1209 # @return True or False
1210 def Evaluate(self, geom=0):
1211 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1213 geom = self.mesh.GetShapeToMesh()
1216 return self.smeshpyD.Evaluate(self.mesh, geom)
1219 ## Computes the mesh and returns the status of the computation
1220 # @param geom geomtrical shape on which mesh data should be computed
1221 # @param discardModifs if True and the mesh has been edited since
1222 # a last total re-compute and that may prevent successful partial re-compute,
1223 # then the mesh is cleaned before Compute()
1224 # @return True or False
1225 # @ingroup l2_construct
1226 def Compute(self, geom=0, discardModifs=False):
1227 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1229 geom = self.mesh.GetShapeToMesh()
1234 if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693
1236 ok = self.smeshpyD.Compute(self.mesh, geom)
1237 except SALOME.SALOME_Exception, ex:
1238 print "Mesh computation failed, exception caught:"
1239 print " ", ex.details.text
1242 print "Mesh computation failed, exception caught:"
1243 traceback.print_exc()
1247 # Treat compute errors
1248 computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
1249 for err in computeErrors:
1251 if self.mesh.HasShapeToMesh():
1253 mainIOR = salome.orb.object_to_string(geom)
1254 for sname in salome.myStudyManager.GetOpenStudies():
1255 s = salome.myStudyManager.GetStudyByName(sname)
1257 mainSO = s.FindObjectIOR(mainIOR)
1258 if not mainSO: continue
1259 if err.subShapeID == 1:
1260 shapeText = ' on "%s"' % mainSO.GetName()
1261 subIt = s.NewChildIterator(mainSO)
1263 subSO = subIt.Value()
1265 obj = subSO.GetObject()
1266 if not obj: continue
1267 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
1269 ids = go.GetSubShapeIndices()
1270 if len(ids) == 1 and ids[0] == err.subShapeID:
1271 shapeText = ' on "%s"' % subSO.GetName()
1274 shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
1276 shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID)
1278 shapeText = " on subshape #%s" % (err.subShapeID)
1280 shapeText = " on subshape #%s" % (err.subShapeID)
1282 stdErrors = ["OK", #COMPERR_OK
1283 "Invalid input mesh", #COMPERR_BAD_INPUT_MESH
1284 "std::exception", #COMPERR_STD_EXCEPTION
1285 "OCC exception", #COMPERR_OCC_EXCEPTION
1286 "SALOME exception", #COMPERR_SLM_EXCEPTION
1287 "Unknown exception", #COMPERR_EXCEPTION
1288 "Memory allocation problem", #COMPERR_MEMORY_PB
1289 "Algorithm failed", #COMPERR_ALGO_FAILED
1290 "Unexpected geometry"]#COMPERR_BAD_SHAPE
1292 if err.code < len(stdErrors): errText = stdErrors[err.code]
1294 errText = "code %s" % -err.code
1295 if errText: errText += ". "
1296 errText += err.comment
1297 if allReasons != "":allReasons += "\n"
1298 allReasons += '"%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
1302 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1304 if err.isGlobalAlgo:
1312 reason = '%s %sD algorithm is missing' % (glob, dim)
1313 elif err.state == HYP_MISSING:
1314 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1315 % (glob, dim, name, dim))
1316 elif err.state == HYP_NOTCONFORM:
1317 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1318 elif err.state == HYP_BAD_PARAMETER:
1319 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1320 % ( glob, dim, name ))
1321 elif err.state == HYP_BAD_GEOMETRY:
1322 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1323 'geometry' % ( glob, dim, name ))
1325 reason = "For unknown reason."+\
1326 " Revise Mesh.Compute() implementation in smeshDC.py!"
1328 if allReasons != "":allReasons += "\n"
1329 allReasons += reason
1331 if allReasons != "":
1332 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1336 print '"' + GetName(self.mesh) + '"',"has not been computed."
1339 if salome.sg.hasDesktop():
1340 smeshgui = salome.ImportComponentGUI("SMESH")
1341 smeshgui.Init(self.mesh.GetStudyId())
1342 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1343 salome.sg.updateObjBrowser(1)
1347 ## Return submesh objects list in meshing order
1348 # @return list of list of submesh objects
1349 # @ingroup l2_construct
1350 def GetMeshOrder(self):
1351 return self.mesh.GetMeshOrder()
1353 ## Return submesh objects list in meshing order
1354 # @return list of list of submesh objects
1355 # @ingroup l2_construct
1356 def SetMeshOrder(self, submeshes):
1357 return self.mesh.SetMeshOrder(submeshes)
1359 ## Removes all nodes and elements
1360 # @ingroup l2_construct
1363 if salome.sg.hasDesktop():
1364 smeshgui = salome.ImportComponentGUI("SMESH")
1365 smeshgui.Init(self.mesh.GetStudyId())
1366 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1367 salome.sg.updateObjBrowser(1)
1369 ## Removes all nodes and elements of indicated shape
1370 # @ingroup l2_construct
1371 def ClearSubMesh(self, geomId):
1372 self.mesh.ClearSubMesh(geomId)
1373 if salome.sg.hasDesktop():
1374 smeshgui = salome.ImportComponentGUI("SMESH")
1375 smeshgui.Init(self.mesh.GetStudyId())
1376 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1377 salome.sg.updateObjBrowser(1)
1379 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1380 # @param fineness [0,-1] defines mesh fineness
1381 # @return True or False
1382 # @ingroup l3_algos_basic
1383 def AutomaticTetrahedralization(self, fineness=0):
1384 dim = self.MeshDimension()
1386 self.RemoveGlobalHypotheses()
1387 self.Segment().AutomaticLength(fineness)
1389 self.Triangle().LengthFromEdges()
1392 self.Tetrahedron(NETGEN)
1394 return self.Compute()
1396 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1397 # @param fineness [0,-1] defines mesh fineness
1398 # @return True or False
1399 # @ingroup l3_algos_basic
1400 def AutomaticHexahedralization(self, fineness=0):
1401 dim = self.MeshDimension()
1402 # assign the hypotheses
1403 self.RemoveGlobalHypotheses()
1404 self.Segment().AutomaticLength(fineness)
1411 return self.Compute()
1413 ## Assigns a hypothesis
1414 # @param hyp a hypothesis to assign
1415 # @param geom a subhape of mesh geometry
1416 # @return SMESH.Hypothesis_Status
1417 # @ingroup l2_hypotheses
1418 def AddHypothesis(self, hyp, geom=0):
1419 if isinstance( hyp, Mesh_Algorithm ):
1420 hyp = hyp.GetAlgorithm()
1425 geom = self.mesh.GetShapeToMesh()
1427 status = self.mesh.AddHypothesis(geom, hyp)
1428 isAlgo = hyp._narrow( SMESH_Algo )
1429 hyp_name = GetName( hyp )
1432 geom_name = GetName( geom )
1433 TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1436 ## Unassigns a hypothesis
1437 # @param hyp a hypothesis to unassign
1438 # @param geom a subshape of mesh geometry
1439 # @return SMESH.Hypothesis_Status
1440 # @ingroup l2_hypotheses
1441 def RemoveHypothesis(self, hyp, geom=0):
1442 if isinstance( hyp, Mesh_Algorithm ):
1443 hyp = hyp.GetAlgorithm()
1448 status = self.mesh.RemoveHypothesis(geom, hyp)
1451 ## Gets the list of hypotheses added on a geometry
1452 # @param geom a subshape of mesh geometry
1453 # @return the sequence of SMESH_Hypothesis
1454 # @ingroup l2_hypotheses
1455 def GetHypothesisList(self, geom):
1456 return self.mesh.GetHypothesisList( geom )
1458 ## Removes all global hypotheses
1459 # @ingroup l2_hypotheses
1460 def RemoveGlobalHypotheses(self):
1461 current_hyps = self.mesh.GetHypothesisList( self.geom )
1462 for hyp in current_hyps:
1463 self.mesh.RemoveHypothesis( self.geom, hyp )
1467 ## Creates a mesh group based on the geometric object \a grp
1468 # and gives a \a name, \n if this parameter is not defined
1469 # the name is the same as the geometric group name \n
1470 # Note: Works like GroupOnGeom().
1471 # @param grp a geometric group, a vertex, an edge, a face or a solid
1472 # @param name the name of the mesh group
1473 # @return SMESH_GroupOnGeom
1474 # @ingroup l2_grps_create
1475 def Group(self, grp, name=""):
1476 return self.GroupOnGeom(grp, name)
1478 ## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead.
1479 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1480 ## allowing to overwrite the file if it exists or add the exported data to its contents
1481 # @param f the file name
1482 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1483 # @param opt boolean parameter for creating/not creating
1484 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1485 # @param overwrite boolean parameter for overwriting/not overwriting the file
1486 # @ingroup l2_impexp
1487 def ExportToMED(self, f, version, opt=0, overwrite=1):
1488 self.mesh.ExportToMEDX(f, opt, version, overwrite)
1490 ## Exports the mesh in a file in MED format and chooses the \a version of MED format
1491 ## allowing to overwrite the file if it exists or add the exported data to its contents
1492 # @param f is the file name
1493 # @param auto_groups boolean parameter for creating/not creating
1494 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1495 # the typical use is auto_groups=false.
1496 # @param version MED format version(MED_V2_1 or MED_V2_2)
1497 # @param overwrite boolean parameter for overwriting/not overwriting the file
1498 # @ingroup l2_impexp
1499 def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1):
1500 self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
1502 ## Exports the mesh in a file in DAT format
1503 # @param f the file name
1504 # @ingroup l2_impexp
1505 def ExportDAT(self, f):
1506 self.mesh.ExportDAT(f)
1508 ## Exports the mesh in a file in UNV format
1509 # @param f the file name
1510 # @ingroup l2_impexp
1511 def ExportUNV(self, f):
1512 self.mesh.ExportUNV(f)
1514 ## Export the mesh in a file in STL format
1515 # @param f the file name
1516 # @param ascii defines the file encoding
1517 # @ingroup l2_impexp
1518 def ExportSTL(self, f, ascii=1):
1519 self.mesh.ExportSTL(f, ascii)
1522 # Operations with groups:
1523 # ----------------------
1525 ## Creates an empty mesh group
1526 # @param elementType the type of elements in the group
1527 # @param name the name of the mesh group
1528 # @return SMESH_Group
1529 # @ingroup l2_grps_create
1530 def CreateEmptyGroup(self, elementType, name):
1531 return self.mesh.CreateGroup(elementType, name)
1533 ## Creates a mesh group based on the geometrical object \a grp
1534 # and gives a \a name, \n if this parameter is not defined
1535 # the name is the same as the geometrical group name
1536 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1537 # @param name the name of the mesh group
1538 # @param typ the type of elements in the group. If not set, it is
1539 # automatically detected by the type of the geometry
1540 # @return SMESH_GroupOnGeom
1541 # @ingroup l2_grps_create
1542 def GroupOnGeom(self, grp, name="", typ=None):
1544 name = grp.GetName()
1547 tgeo = str(grp.GetShapeType())
1548 if tgeo == "VERTEX":
1550 elif tgeo == "EDGE":
1552 elif tgeo == "FACE":
1554 elif tgeo == "SOLID":
1556 elif tgeo == "SHELL":
1558 elif tgeo == "COMPOUND":
1559 try: # it raises on a compound of compounds
1560 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1561 print "Mesh.Group: empty geometric group", GetName( grp )
1566 if grp.GetType() == 37: # GEOMImpl_Types.hxx: #define GEOM_GROUP 37
1568 tgeo = self.geompyD.GetType(grp)
1569 if tgeo == geompyDC.ShapeType["VERTEX"]:
1571 elif tgeo == geompyDC.ShapeType["EDGE"]:
1573 elif tgeo == geompyDC.ShapeType["FACE"]:
1575 elif tgeo == geompyDC.ShapeType["SOLID"]:
1581 for elemType, shapeType in [[VOLUME,"SOLID"],[FACE,"FACE"],
1582 [EDGE,"EDGE"],[NODE,"VERTEX"]]:
1583 if self.geompyD.SubShapeAll(grp,geompyDC.ShapeType[shapeType]):
1591 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1594 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1596 ## Creates a mesh group by the given ids of elements
1597 # @param groupName the name of the mesh group
1598 # @param elementType the type of elements in the group
1599 # @param elemIDs the list of ids
1600 # @return SMESH_Group
1601 # @ingroup l2_grps_create
1602 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1603 group = self.mesh.CreateGroup(elementType, groupName)
1607 ## Creates a mesh group by the given conditions
1608 # @param groupName the name of the mesh group
1609 # @param elementType the type of elements in the group
1610 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1611 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1612 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1613 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1614 # @return SMESH_Group
1615 # @ingroup l2_grps_create
1619 CritType=FT_Undefined,
1622 UnaryOp=FT_Undefined):
1623 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1624 group = self.MakeGroupByCriterion(groupName, aCriterion)
1627 ## Creates a mesh group by the given criterion
1628 # @param groupName the name of the mesh group
1629 # @param Criterion the instance of Criterion class
1630 # @return SMESH_Group
1631 # @ingroup l2_grps_create
1632 def MakeGroupByCriterion(self, groupName, Criterion):
1633 aFilterMgr = self.smeshpyD.CreateFilterManager()
1634 aFilter = aFilterMgr.CreateFilter()
1636 aCriteria.append(Criterion)
1637 aFilter.SetCriteria(aCriteria)
1638 group = self.MakeGroupByFilter(groupName, aFilter)
1641 ## Creates a mesh group by the given criteria (list of criteria)
1642 # @param groupName the name of the mesh group
1643 # @param theCriteria the list of criteria
1644 # @return SMESH_Group
1645 # @ingroup l2_grps_create
1646 def MakeGroupByCriteria(self, groupName, theCriteria):
1647 aFilterMgr = self.smeshpyD.CreateFilterManager()
1648 aFilter = aFilterMgr.CreateFilter()
1649 aFilter.SetCriteria(theCriteria)
1650 group = self.MakeGroupByFilter(groupName, aFilter)
1653 ## Creates a mesh group by the given filter
1654 # @param groupName the name of the mesh group
1655 # @param theFilter the instance of Filter class
1656 # @return SMESH_Group
1657 # @ingroup l2_grps_create
1658 def MakeGroupByFilter(self, groupName, theFilter):
1659 anIds = theFilter.GetElementsId(self.mesh)
1660 anElemType = theFilter.GetElementType()
1661 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1664 ## Passes mesh elements through the given filter and return IDs of fitting elements
1665 # @param theFilter SMESH_Filter
1666 # @return a list of ids
1667 # @ingroup l1_controls
1668 def GetIdsFromFilter(self, theFilter):
1669 return theFilter.GetElementsId(self.mesh)
1671 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1672 # Returns a list of special structures (borders).
1673 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1674 # @ingroup l1_controls
1675 def GetFreeBorders(self):
1676 aFilterMgr = self.smeshpyD.CreateFilterManager()
1677 aPredicate = aFilterMgr.CreateFreeEdges()
1678 aPredicate.SetMesh(self.mesh)
1679 aBorders = aPredicate.GetBorders()
1683 # @ingroup l2_grps_delete
1684 def RemoveGroup(self, group):
1685 self.mesh.RemoveGroup(group)
1687 ## Removes a group with its contents
1688 # @ingroup l2_grps_delete
1689 def RemoveGroupWithContents(self, group):
1690 self.mesh.RemoveGroupWithContents(group)
1692 ## Gets the list of groups existing in the mesh
1693 # @return a sequence of SMESH_GroupBase
1694 # @ingroup l2_grps_create
1695 def GetGroups(self):
1696 return self.mesh.GetGroups()
1698 ## Gets the number of groups existing in the mesh
1699 # @return the quantity of groups as an integer value
1700 # @ingroup l2_grps_create
1702 return self.mesh.NbGroups()
1704 ## Gets the list of names of groups existing in the mesh
1705 # @return list of strings
1706 # @ingroup l2_grps_create
1707 def GetGroupNames(self):
1708 groups = self.GetGroups()
1710 for group in groups:
1711 names.append(group.GetName())
1714 ## Produces a union of two groups
1715 # A new group is created. All mesh elements that are
1716 # present in the initial groups are added to the new one
1717 # @return an instance of SMESH_Group
1718 # @ingroup l2_grps_operon
1719 def UnionGroups(self, group1, group2, name):
1720 return self.mesh.UnionGroups(group1, group2, name)
1722 ## Produces a union list of groups
1723 # New group is created. All mesh elements that are present in
1724 # initial groups are added to the new one
1725 # @return an instance of SMESH_Group
1726 # @ingroup l2_grps_operon
1727 def UnionListOfGroups(self, groups, name):
1728 return self.mesh.UnionListOfGroups(groups, name)
1730 ## Prodices an intersection of two groups
1731 # A new group is created. All mesh elements that are common
1732 # for the two initial groups are added to the new one.
1733 # @return an instance of SMESH_Group
1734 # @ingroup l2_grps_operon
1735 def IntersectGroups(self, group1, group2, name):
1736 return self.mesh.IntersectGroups(group1, group2, name)
1738 ## Produces an intersection of groups
1739 # New group is created. All mesh elements that are present in all
1740 # initial groups simultaneously are added to the new one
1741 # @return an instance of SMESH_Group
1742 # @ingroup l2_grps_operon
1743 def IntersectListOfGroups(self, groups, name):
1744 return self.mesh.IntersectListOfGroups(groups, name)
1746 ## Produces a cut of two groups
1747 # A new group is created. All mesh elements that are present in
1748 # the main group but are not present in the tool group are added to the new one
1749 # @return an instance of SMESH_Group
1750 # @ingroup l2_grps_operon
1751 def CutGroups(self, main_group, tool_group, name):
1752 return self.mesh.CutGroups(main_group, tool_group, name)
1754 ## Produces a cut of groups
1755 # A new group is created. All mesh elements that are present in main groups
1756 # but do not present in tool groups are added to the new one
1757 # @return an instance of SMESH_Group
1758 # @ingroup l2_grps_operon
1759 def CutListOfGroups(self, main_groups, tool_groups, name):
1760 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1762 ## Produces a group of elements with specified element type using list of existing groups
1763 # A new group is created. System
1764 # 1) extract all nodes on which groups elements are built
1765 # 2) combine all elements of specified dimension laying on these nodes
1766 # @return an instance of SMESH_Group
1767 # @ingroup l2_grps_operon
1768 def CreateDimGroup(self, groups, elem_type, name):
1769 return self.mesh.CreateDimGroup(groups, elem_type, name)
1772 ## Convert group on geom into standalone group
1773 # @ingroup l2_grps_delete
1774 def ConvertToStandalone(self, group):
1775 return self.mesh.ConvertToStandalone(group)
1777 # Get some info about mesh:
1778 # ------------------------
1780 ## Returns the log of nodes and elements added or removed
1781 # since the previous clear of the log.
1782 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1783 # @return list of log_block structures:
1788 # @ingroup l1_auxiliary
1789 def GetLog(self, clearAfterGet):
1790 return self.mesh.GetLog(clearAfterGet)
1792 ## Clears the log of nodes and elements added or removed since the previous
1793 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1794 # @ingroup l1_auxiliary
1796 self.mesh.ClearLog()
1798 ## Toggles auto color mode on the object.
1799 # @param theAutoColor the flag which toggles auto color mode.
1800 # @ingroup l1_auxiliary
1801 def SetAutoColor(self, theAutoColor):
1802 self.mesh.SetAutoColor(theAutoColor)
1804 ## Gets flag of object auto color mode.
1805 # @return True or False
1806 # @ingroup l1_auxiliary
1807 def GetAutoColor(self):
1808 return self.mesh.GetAutoColor()
1810 ## Gets the internal ID
1811 # @return integer value, which is the internal Id of the mesh
1812 # @ingroup l1_auxiliary
1814 return self.mesh.GetId()
1817 # @return integer value, which is the study Id of the mesh
1818 # @ingroup l1_auxiliary
1819 def GetStudyId(self):
1820 return self.mesh.GetStudyId()
1822 ## Checks the group names for duplications.
1823 # Consider the maximum group name length stored in MED file.
1824 # @return True or False
1825 # @ingroup l1_auxiliary
1826 def HasDuplicatedGroupNamesMED(self):
1827 return self.mesh.HasDuplicatedGroupNamesMED()
1829 ## Obtains the mesh editor tool
1830 # @return an instance of SMESH_MeshEditor
1831 # @ingroup l1_modifying
1832 def GetMeshEditor(self):
1833 return self.mesh.GetMeshEditor()
1836 # @return an instance of SALOME_MED::MESH
1837 # @ingroup l1_auxiliary
1838 def GetMEDMesh(self):
1839 return self.mesh.GetMEDMesh()
1842 # Get informations about mesh contents:
1843 # ------------------------------------
1845 ## Gets the mesh stattistic
1846 # @return dictionary type element - count of elements
1847 # @ingroup l1_meshinfo
1848 def GetMeshInfo(self, obj = None):
1849 if not obj: obj = self.mesh
1850 return self.smeshpyD.GetMeshInfo(obj)
1852 ## Returns the number of nodes in the mesh
1853 # @return an integer value
1854 # @ingroup l1_meshinfo
1856 return self.mesh.NbNodes()
1858 ## Returns the number of elements in the mesh
1859 # @return an integer value
1860 # @ingroup l1_meshinfo
1861 def NbElements(self):
1862 return self.mesh.NbElements()
1864 ## Returns the number of 0d elements in the mesh
1865 # @return an integer value
1866 # @ingroup l1_meshinfo
1867 def Nb0DElements(self):
1868 return self.mesh.Nb0DElements()
1870 ## Returns the number of edges in the mesh
1871 # @return an integer value
1872 # @ingroup l1_meshinfo
1874 return self.mesh.NbEdges()
1876 ## Returns the number of edges with the given order in the mesh
1877 # @param elementOrder the order of elements:
1878 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1879 # @return an integer value
1880 # @ingroup l1_meshinfo
1881 def NbEdgesOfOrder(self, elementOrder):
1882 return self.mesh.NbEdgesOfOrder(elementOrder)
1884 ## Returns the number of faces in the mesh
1885 # @return an integer value
1886 # @ingroup l1_meshinfo
1888 return self.mesh.NbFaces()
1890 ## Returns the number of faces with the given order in the mesh
1891 # @param elementOrder the order of elements:
1892 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1893 # @return an integer value
1894 # @ingroup l1_meshinfo
1895 def NbFacesOfOrder(self, elementOrder):
1896 return self.mesh.NbFacesOfOrder(elementOrder)
1898 ## Returns the number of triangles in the mesh
1899 # @return an integer value
1900 # @ingroup l1_meshinfo
1901 def NbTriangles(self):
1902 return self.mesh.NbTriangles()
1904 ## Returns the number of triangles with the given order in the mesh
1905 # @param elementOrder is the order of elements:
1906 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1907 # @return an integer value
1908 # @ingroup l1_meshinfo
1909 def NbTrianglesOfOrder(self, elementOrder):
1910 return self.mesh.NbTrianglesOfOrder(elementOrder)
1912 ## Returns the number of quadrangles in the mesh
1913 # @return an integer value
1914 # @ingroup l1_meshinfo
1915 def NbQuadrangles(self):
1916 return self.mesh.NbQuadrangles()
1918 ## Returns the number of quadrangles with the given order in the mesh
1919 # @param elementOrder the order of elements:
1920 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1921 # @return an integer value
1922 # @ingroup l1_meshinfo
1923 def NbQuadranglesOfOrder(self, elementOrder):
1924 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1926 ## Returns the number of polygons in the mesh
1927 # @return an integer value
1928 # @ingroup l1_meshinfo
1929 def NbPolygons(self):
1930 return self.mesh.NbPolygons()
1932 ## Returns the number of volumes in the mesh
1933 # @return an integer value
1934 # @ingroup l1_meshinfo
1935 def NbVolumes(self):
1936 return self.mesh.NbVolumes()
1938 ## Returns the number of volumes with the given order in the mesh
1939 # @param elementOrder the order of elements:
1940 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1941 # @return an integer value
1942 # @ingroup l1_meshinfo
1943 def NbVolumesOfOrder(self, elementOrder):
1944 return self.mesh.NbVolumesOfOrder(elementOrder)
1946 ## Returns the number of tetrahedrons in the mesh
1947 # @return an integer value
1948 # @ingroup l1_meshinfo
1950 return self.mesh.NbTetras()
1952 ## Returns the number of tetrahedrons with the given order in the mesh
1953 # @param elementOrder the order of elements:
1954 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1955 # @return an integer value
1956 # @ingroup l1_meshinfo
1957 def NbTetrasOfOrder(self, elementOrder):
1958 return self.mesh.NbTetrasOfOrder(elementOrder)
1960 ## Returns the number of hexahedrons in the mesh
1961 # @return an integer value
1962 # @ingroup l1_meshinfo
1964 return self.mesh.NbHexas()
1966 ## Returns the number of hexahedrons with the given order in the mesh
1967 # @param elementOrder the order of elements:
1968 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1969 # @return an integer value
1970 # @ingroup l1_meshinfo
1971 def NbHexasOfOrder(self, elementOrder):
1972 return self.mesh.NbHexasOfOrder(elementOrder)
1974 ## Returns the number of pyramids in the mesh
1975 # @return an integer value
1976 # @ingroup l1_meshinfo
1977 def NbPyramids(self):
1978 return self.mesh.NbPyramids()
1980 ## Returns the number of pyramids with the given order in the mesh
1981 # @param elementOrder the order of elements:
1982 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1983 # @return an integer value
1984 # @ingroup l1_meshinfo
1985 def NbPyramidsOfOrder(self, elementOrder):
1986 return self.mesh.NbPyramidsOfOrder(elementOrder)
1988 ## Returns the number of prisms in the mesh
1989 # @return an integer value
1990 # @ingroup l1_meshinfo
1992 return self.mesh.NbPrisms()
1994 ## Returns the number of prisms with the given order in the mesh
1995 # @param elementOrder the order of elements:
1996 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1997 # @return an integer value
1998 # @ingroup l1_meshinfo
1999 def NbPrismsOfOrder(self, elementOrder):
2000 return self.mesh.NbPrismsOfOrder(elementOrder)
2002 ## Returns the number of polyhedrons in the mesh
2003 # @return an integer value
2004 # @ingroup l1_meshinfo
2005 def NbPolyhedrons(self):
2006 return self.mesh.NbPolyhedrons()
2008 ## Returns the number of submeshes in the mesh
2009 # @return an integer value
2010 # @ingroup l1_meshinfo
2011 def NbSubMesh(self):
2012 return self.mesh.NbSubMesh()
2014 ## Returns the list of mesh elements IDs
2015 # @return the list of integer values
2016 # @ingroup l1_meshinfo
2017 def GetElementsId(self):
2018 return self.mesh.GetElementsId()
2020 ## Returns the list of IDs of mesh elements with the given type
2021 # @param elementType the required type of elements (SMESH.NODE, SMESH.EDGE, SMESH.FACE or SMESH.VOLUME)
2022 # @return list of integer values
2023 # @ingroup l1_meshinfo
2024 def GetElementsByType(self, elementType):
2025 return self.mesh.GetElementsByType(elementType)
2027 ## Returns the list of mesh nodes IDs
2028 # @return the list of integer values
2029 # @ingroup l1_meshinfo
2030 def GetNodesId(self):
2031 return self.mesh.GetNodesId()
2033 # Get the information about mesh elements:
2034 # ------------------------------------
2036 ## Returns the type of mesh element
2037 # @return the value from SMESH::ElementType enumeration
2038 # @ingroup l1_meshinfo
2039 def GetElementType(self, id, iselem):
2040 return self.mesh.GetElementType(id, iselem)
2042 ## Returns the geometric type of mesh element
2043 # @return the value from SMESH::EntityType enumeration
2044 # @ingroup l1_meshinfo
2045 def GetElementGeomType(self, id):
2046 return self.mesh.GetElementGeomType(id)
2048 ## Returns the list of submesh elements IDs
2049 # @param Shape a geom object(subshape) IOR
2050 # Shape must be the subshape of a ShapeToMesh()
2051 # @return the list of integer values
2052 # @ingroup l1_meshinfo
2053 def GetSubMeshElementsId(self, Shape):
2054 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2055 ShapeID = Shape.GetSubShapeIndices()[0]
2058 return self.mesh.GetSubMeshElementsId(ShapeID)
2060 ## Returns the list of submesh nodes IDs
2061 # @param Shape a geom object(subshape) IOR
2062 # Shape must be the subshape of a ShapeToMesh()
2063 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
2064 # @return the list of integer values
2065 # @ingroup l1_meshinfo
2066 def GetSubMeshNodesId(self, Shape, all):
2067 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2068 ShapeID = Shape.GetSubShapeIndices()[0]
2071 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2073 ## Returns type of elements on given shape
2074 # @param Shape a geom object(subshape) IOR
2075 # Shape must be a subshape of a ShapeToMesh()
2076 # @return element type
2077 # @ingroup l1_meshinfo
2078 def GetSubMeshElementType(self, Shape):
2079 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2080 ShapeID = Shape.GetSubShapeIndices()[0]
2083 return self.mesh.GetSubMeshElementType(ShapeID)
2085 ## Gets the mesh description
2086 # @return string value
2087 # @ingroup l1_meshinfo
2089 return self.mesh.Dump()
2092 # Get the information about nodes and elements of a mesh by its IDs:
2093 # -----------------------------------------------------------
2095 ## Gets XYZ coordinates of a node
2096 # \n If there is no nodes for the given ID - returns an empty list
2097 # @return a list of double precision values
2098 # @ingroup l1_meshinfo
2099 def GetNodeXYZ(self, id):
2100 return self.mesh.GetNodeXYZ(id)
2102 ## Returns list of IDs of inverse elements for the given node
2103 # \n If there is no node for the given ID - returns an empty list
2104 # @return a list of integer values
2105 # @ingroup l1_meshinfo
2106 def GetNodeInverseElements(self, id):
2107 return self.mesh.GetNodeInverseElements(id)
2109 ## @brief Returns the position of a node on the shape
2110 # @return SMESH::NodePosition
2111 # @ingroup l1_meshinfo
2112 def GetNodePosition(self,NodeID):
2113 return self.mesh.GetNodePosition(NodeID)
2115 ## If the given element is a node, returns the ID of shape
2116 # \n If there is no node for the given ID - returns -1
2117 # @return an integer value
2118 # @ingroup l1_meshinfo
2119 def GetShapeID(self, id):
2120 return self.mesh.GetShapeID(id)
2122 ## Returns the ID of the result shape after
2123 # FindShape() from SMESH_MeshEditor for the given element
2124 # \n If there is no element for the given ID - returns -1
2125 # @return an integer value
2126 # @ingroup l1_meshinfo
2127 def GetShapeIDForElem(self,id):
2128 return self.mesh.GetShapeIDForElem(id)
2130 ## Returns the number of nodes for the given element
2131 # \n If there is no element for the given ID - returns -1
2132 # @return an integer value
2133 # @ingroup l1_meshinfo
2134 def GetElemNbNodes(self, id):
2135 return self.mesh.GetElemNbNodes(id)
2137 ## Returns the node ID the given index for the given element
2138 # \n If there is no element for the given ID - returns -1
2139 # \n If there is no node for the given index - returns -2
2140 # @return an integer value
2141 # @ingroup l1_meshinfo
2142 def GetElemNode(self, id, index):
2143 return self.mesh.GetElemNode(id, index)
2145 ## Returns the IDs of nodes of the given element
2146 # @return a list of integer values
2147 # @ingroup l1_meshinfo
2148 def GetElemNodes(self, id):
2149 return self.mesh.GetElemNodes(id)
2151 ## Returns true if the given node is the medium node in the given quadratic element
2152 # @ingroup l1_meshinfo
2153 def IsMediumNode(self, elementID, nodeID):
2154 return self.mesh.IsMediumNode(elementID, nodeID)
2156 ## Returns true if the given node is the medium node in one of quadratic elements
2157 # @ingroup l1_meshinfo
2158 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2159 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2161 ## Returns the number of edges for the given element
2162 # @ingroup l1_meshinfo
2163 def ElemNbEdges(self, id):
2164 return self.mesh.ElemNbEdges(id)
2166 ## Returns the number of faces for the given element
2167 # @ingroup l1_meshinfo
2168 def ElemNbFaces(self, id):
2169 return self.mesh.ElemNbFaces(id)
2171 ## Returns nodes of given face (counted from zero) for given volumic element.
2172 # @ingroup l1_meshinfo
2173 def GetElemFaceNodes(self,elemId, faceIndex):
2174 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2176 ## Returns an element based on all given nodes.
2177 # @ingroup l1_meshinfo
2178 def FindElementByNodes(self,nodes):
2179 return self.mesh.FindElementByNodes(nodes)
2181 ## Returns true if the given element is a polygon
2182 # @ingroup l1_meshinfo
2183 def IsPoly(self, id):
2184 return self.mesh.IsPoly(id)
2186 ## Returns true if the given element is quadratic
2187 # @ingroup l1_meshinfo
2188 def IsQuadratic(self, id):
2189 return self.mesh.IsQuadratic(id)
2191 ## Returns XYZ coordinates of the barycenter of the given element
2192 # \n If there is no element for the given ID - returns an empty list
2193 # @return a list of three double values
2194 # @ingroup l1_meshinfo
2195 def BaryCenter(self, id):
2196 return self.mesh.BaryCenter(id)
2199 # Mesh edition (SMESH_MeshEditor functionality):
2200 # ---------------------------------------------
2202 ## Removes the elements from the mesh by ids
2203 # @param IDsOfElements is a list of ids of elements to remove
2204 # @return True or False
2205 # @ingroup l2_modif_del
2206 def RemoveElements(self, IDsOfElements):
2207 return self.editor.RemoveElements(IDsOfElements)
2209 ## Removes nodes from mesh by ids
2210 # @param IDsOfNodes is a list of ids of nodes to remove
2211 # @return True or False
2212 # @ingroup l2_modif_del
2213 def RemoveNodes(self, IDsOfNodes):
2214 return self.editor.RemoveNodes(IDsOfNodes)
2216 ## Removes all orphan (free) nodes from mesh
2217 # @return number of the removed nodes
2218 # @ingroup l2_modif_del
2219 def RemoveOrphanNodes(self):
2220 return self.editor.RemoveOrphanNodes()
2222 ## Add a node to the mesh by coordinates
2223 # @return Id of the new node
2224 # @ingroup l2_modif_add
2225 def AddNode(self, x, y, z):
2226 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2227 self.mesh.SetParameters(Parameters)
2228 return self.editor.AddNode( x, y, z)
2230 ## Creates a 0D element on a node with given number.
2231 # @param IDOfNode the ID of node for creation of the element.
2232 # @return the Id of the new 0D element
2233 # @ingroup l2_modif_add
2234 def Add0DElement(self, IDOfNode):
2235 return self.editor.Add0DElement(IDOfNode)
2237 ## Creates a linear or quadratic edge (this is determined
2238 # by the number of given nodes).
2239 # @param IDsOfNodes the list of node IDs for creation of the element.
2240 # The order of nodes in this list should correspond to the description
2241 # of MED. \n This description is located by the following link:
2242 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2243 # @return the Id of the new edge
2244 # @ingroup l2_modif_add
2245 def AddEdge(self, IDsOfNodes):
2246 return self.editor.AddEdge(IDsOfNodes)
2248 ## Creates a linear or quadratic face (this is determined
2249 # by the number of given nodes).
2250 # @param IDsOfNodes the list of node IDs for creation of the element.
2251 # The order of nodes in this list should correspond to the description
2252 # of MED. \n This description is located by the following link:
2253 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2254 # @return the Id of the new face
2255 # @ingroup l2_modif_add
2256 def AddFace(self, IDsOfNodes):
2257 return self.editor.AddFace(IDsOfNodes)
2259 ## Adds a polygonal face to the mesh by the list of node IDs
2260 # @param IdsOfNodes the list of node IDs for creation of the element.
2261 # @return the Id of the new face
2262 # @ingroup l2_modif_add
2263 def AddPolygonalFace(self, IdsOfNodes):
2264 return self.editor.AddPolygonalFace(IdsOfNodes)
2266 ## Creates both simple and quadratic volume (this is determined
2267 # by the number of given nodes).
2268 # @param IDsOfNodes the list of node IDs for creation of the element.
2269 # The order of nodes in this list should correspond to the description
2270 # of MED. \n This description is located by the following link:
2271 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2272 # @return the Id of the new volumic element
2273 # @ingroup l2_modif_add
2274 def AddVolume(self, IDsOfNodes):
2275 return self.editor.AddVolume(IDsOfNodes)
2277 ## Creates a volume of many faces, giving nodes for each face.
2278 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2279 # @param Quantities the list of integer values, Quantities[i]
2280 # gives the quantity of nodes in face number i.
2281 # @return the Id of the new volumic element
2282 # @ingroup l2_modif_add
2283 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2284 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2286 ## Creates a volume of many faces, giving the IDs of the existing faces.
2287 # @param IdsOfFaces the list of face IDs for volume creation.
2289 # Note: The created volume will refer only to the nodes
2290 # of the given faces, not to the faces themselves.
2291 # @return the Id of the new volumic element
2292 # @ingroup l2_modif_add
2293 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2294 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2297 ## @brief Binds a node to a vertex
2298 # @param NodeID a node ID
2299 # @param Vertex a vertex or vertex ID
2300 # @return True if succeed else raises an exception
2301 # @ingroup l2_modif_add
2302 def SetNodeOnVertex(self, NodeID, Vertex):
2303 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2304 VertexID = Vertex.GetSubShapeIndices()[0]
2308 self.editor.SetNodeOnVertex(NodeID, VertexID)
2309 except SALOME.SALOME_Exception, inst:
2310 raise ValueError, inst.details.text
2314 ## @brief Stores the node position on an edge
2315 # @param NodeID a node ID
2316 # @param Edge an edge or edge ID
2317 # @param paramOnEdge a parameter on the edge where the node is located
2318 # @return True if succeed else raises an exception
2319 # @ingroup l2_modif_add
2320 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2321 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2322 EdgeID = Edge.GetSubShapeIndices()[0]
2326 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2327 except SALOME.SALOME_Exception, inst:
2328 raise ValueError, inst.details.text
2331 ## @brief Stores node position on a face
2332 # @param NodeID a node ID
2333 # @param Face a face or face ID
2334 # @param u U parameter on the face where the node is located
2335 # @param v V parameter on the face where the node is located
2336 # @return True if succeed else raises an exception
2337 # @ingroup l2_modif_add
2338 def SetNodeOnFace(self, NodeID, Face, u, v):
2339 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2340 FaceID = Face.GetSubShapeIndices()[0]
2344 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2345 except SALOME.SALOME_Exception, inst:
2346 raise ValueError, inst.details.text
2349 ## @brief Binds a node to a solid
2350 # @param NodeID a node ID
2351 # @param Solid a solid or solid ID
2352 # @return True if succeed else raises an exception
2353 # @ingroup l2_modif_add
2354 def SetNodeInVolume(self, NodeID, Solid):
2355 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2356 SolidID = Solid.GetSubShapeIndices()[0]
2360 self.editor.SetNodeInVolume(NodeID, SolidID)
2361 except SALOME.SALOME_Exception, inst:
2362 raise ValueError, inst.details.text
2365 ## @brief Bind an element to a shape
2366 # @param ElementID an element ID
2367 # @param Shape a shape or shape ID
2368 # @return True if succeed else raises an exception
2369 # @ingroup l2_modif_add
2370 def SetMeshElementOnShape(self, ElementID, Shape):
2371 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2372 ShapeID = Shape.GetSubShapeIndices()[0]
2376 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2377 except SALOME.SALOME_Exception, inst:
2378 raise ValueError, inst.details.text
2382 ## Moves the node with the given id
2383 # @param NodeID the id of the node
2384 # @param x a new X coordinate
2385 # @param y a new Y coordinate
2386 # @param z a new Z coordinate
2387 # @return True if succeed else False
2388 # @ingroup l2_modif_movenode
2389 def MoveNode(self, NodeID, x, y, z):
2390 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2391 self.mesh.SetParameters(Parameters)
2392 return self.editor.MoveNode(NodeID, x, y, z)
2394 ## Finds the node closest to a point and moves it to a point location
2395 # @param x the X coordinate of a point
2396 # @param y the Y coordinate of a point
2397 # @param z the Z coordinate of a point
2398 # @param NodeID if specified (>0), the node with this ID is moved,
2399 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2400 # @return the ID of a node
2401 # @ingroup l2_modif_throughp
2402 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2403 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2404 self.mesh.SetParameters(Parameters)
2405 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2407 ## Finds the node closest to a point
2408 # @param x the X coordinate of a point
2409 # @param y the Y coordinate of a point
2410 # @param z the Z coordinate of a point
2411 # @return the ID of a node
2412 # @ingroup l2_modif_throughp
2413 def FindNodeClosestTo(self, x, y, z):
2414 #preview = self.mesh.GetMeshEditPreviewer()
2415 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2416 return self.editor.FindNodeClosestTo(x, y, z)
2418 ## Finds the elements where a point lays IN or ON
2419 # @param x the X coordinate of a point
2420 # @param y the Y coordinate of a point
2421 # @param z the Z coordinate of a point
2422 # @param elementType type of elements to find (SMESH.ALL type
2423 # means elements of any type excluding nodes and 0D elements)
2424 # @return list of IDs of found elements
2425 # @ingroup l2_modif_throughp
2426 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2427 return self.editor.FindElementsByPoint(x, y, z, elementType)
2429 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2430 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2432 def GetPointState(self, x, y, z):
2433 return self.editor.GetPointState(x, y, z)
2435 ## Finds the node closest to a point and moves it to a point location
2436 # @param x the X coordinate of a point
2437 # @param y the Y coordinate of a point
2438 # @param z the Z coordinate of a point
2439 # @return the ID of a moved node
2440 # @ingroup l2_modif_throughp
2441 def MeshToPassThroughAPoint(self, x, y, z):
2442 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2444 ## Replaces two neighbour triangles sharing Node1-Node2 link
2445 # with the triangles built on the same 4 nodes but having other common link.
2446 # @param NodeID1 the ID of the first node
2447 # @param NodeID2 the ID of the second node
2448 # @return false if proper faces were not found
2449 # @ingroup l2_modif_invdiag
2450 def InverseDiag(self, NodeID1, NodeID2):
2451 return self.editor.InverseDiag(NodeID1, NodeID2)
2453 ## Replaces two neighbour triangles sharing Node1-Node2 link
2454 # with a quadrangle built on the same 4 nodes.
2455 # @param NodeID1 the ID of the first node
2456 # @param NodeID2 the ID of the second node
2457 # @return false if proper faces were not found
2458 # @ingroup l2_modif_unitetri
2459 def DeleteDiag(self, NodeID1, NodeID2):
2460 return self.editor.DeleteDiag(NodeID1, NodeID2)
2462 ## Reorients elements by ids
2463 # @param IDsOfElements if undefined reorients all mesh elements
2464 # @return True if succeed else False
2465 # @ingroup l2_modif_changori
2466 def Reorient(self, IDsOfElements=None):
2467 if IDsOfElements == None:
2468 IDsOfElements = self.GetElementsId()
2469 return self.editor.Reorient(IDsOfElements)
2471 ## Reorients all elements of the object
2472 # @param theObject mesh, submesh or group
2473 # @return True if succeed else False
2474 # @ingroup l2_modif_changori
2475 def ReorientObject(self, theObject):
2476 if ( isinstance( theObject, Mesh )):
2477 theObject = theObject.GetMesh()
2478 return self.editor.ReorientObject(theObject)
2480 ## Fuses the neighbouring triangles into quadrangles.
2481 # @param IDsOfElements The triangles to be fused,
2482 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2483 # @param MaxAngle is the maximum angle between element normals at which the fusion
2484 # is still performed; theMaxAngle is mesured in radians.
2485 # Also it could be a name of variable which defines angle in degrees.
2486 # @return TRUE in case of success, FALSE otherwise.
2487 # @ingroup l2_modif_unitetri
2488 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2490 if isinstance(MaxAngle,str):
2492 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2494 MaxAngle = DegreesToRadians(MaxAngle)
2495 if IDsOfElements == []:
2496 IDsOfElements = self.GetElementsId()
2497 self.mesh.SetParameters(Parameters)
2499 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2500 Functor = theCriterion
2502 Functor = self.smeshpyD.GetFunctor(theCriterion)
2503 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2505 ## Fuses the neighbouring triangles of the object into quadrangles
2506 # @param theObject is mesh, submesh or group
2507 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2508 # @param MaxAngle a max angle between element normals at which the fusion
2509 # is still performed; theMaxAngle is mesured in radians.
2510 # @return TRUE in case of success, FALSE otherwise.
2511 # @ingroup l2_modif_unitetri
2512 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2513 if ( isinstance( theObject, Mesh )):
2514 theObject = theObject.GetMesh()
2515 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2517 ## Splits quadrangles into triangles.
2518 # @param IDsOfElements the faces to be splitted.
2519 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2520 # @return TRUE in case of success, FALSE otherwise.
2521 # @ingroup l2_modif_cutquadr
2522 def QuadToTri (self, IDsOfElements, theCriterion):
2523 if IDsOfElements == []:
2524 IDsOfElements = self.GetElementsId()
2525 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2527 ## Splits quadrangles into triangles.
2528 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2529 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2530 # @return TRUE in case of success, FALSE otherwise.
2531 # @ingroup l2_modif_cutquadr
2532 def QuadToTriObject (self, theObject, theCriterion):
2533 if ( isinstance( theObject, Mesh )):
2534 theObject = theObject.GetMesh()
2535 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2537 ## Splits quadrangles into triangles.
2538 # @param IDsOfElements the faces to be splitted
2539 # @param Diag13 is used to choose a diagonal for splitting.
2540 # @return TRUE in case of success, FALSE otherwise.
2541 # @ingroup l2_modif_cutquadr
2542 def SplitQuad (self, IDsOfElements, Diag13):
2543 if IDsOfElements == []:
2544 IDsOfElements = self.GetElementsId()
2545 return self.editor.SplitQuad(IDsOfElements, Diag13)
2547 ## Splits quadrangles into triangles.
2548 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2549 # @param Diag13 is used to choose a diagonal for splitting.
2550 # @return TRUE in case of success, FALSE otherwise.
2551 # @ingroup l2_modif_cutquadr
2552 def SplitQuadObject (self, theObject, Diag13):
2553 if ( isinstance( theObject, Mesh )):
2554 theObject = theObject.GetMesh()
2555 return self.editor.SplitQuadObject(theObject, Diag13)
2557 ## Finds a better splitting of the given quadrangle.
2558 # @param IDOfQuad the ID of the quadrangle to be splitted.
2559 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2560 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2561 # diagonal is better, 0 if error occurs.
2562 # @ingroup l2_modif_cutquadr
2563 def BestSplit (self, IDOfQuad, theCriterion):
2564 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2566 ## Splits volumic elements into tetrahedrons
2567 # @param elemIDs either list of elements or mesh or group or submesh
2568 # @param method flags passing splitting method: Hex_5Tet, Hex_6Tet, Hex_24Tet
2569 # Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc
2570 # @ingroup l2_modif_cutquadr
2571 def SplitVolumesIntoTetra(self, elemIDs, method=Hex_5Tet ):
2572 if isinstance( elemIDs, Mesh ):
2573 elemIDs = elemIDs.GetMesh()
2574 if ( isinstance( elemIDs, list )):
2575 elemIDs = self.editor.MakeIDSource(elemIDs, SMESH.VOLUME)
2576 self.editor.SplitVolumesIntoTetra(elemIDs, method)
2578 ## Splits quadrangle faces near triangular facets of volumes
2580 # @ingroup l1_auxiliary
2581 def SplitQuadsNearTriangularFacets(self):
2582 faces_array = self.GetElementsByType(SMESH.FACE)
2583 for face_id in faces_array:
2584 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2585 quad_nodes = self.mesh.GetElemNodes(face_id)
2586 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2587 isVolumeFound = False
2588 for node1_elem in node1_elems:
2589 if not isVolumeFound:
2590 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2591 nb_nodes = self.GetElemNbNodes(node1_elem)
2592 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2593 volume_elem = node1_elem
2594 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2595 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2596 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2597 isVolumeFound = True
2598 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2599 self.SplitQuad([face_id], False) # diagonal 2-4
2600 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2601 isVolumeFound = True
2602 self.SplitQuad([face_id], True) # diagonal 1-3
2603 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2604 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2605 isVolumeFound = True
2606 self.SplitQuad([face_id], True) # diagonal 1-3
2608 ## @brief Splits hexahedrons into tetrahedrons.
2610 # This operation uses pattern mapping functionality for splitting.
2611 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2612 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2613 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2614 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2615 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2616 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2617 # @return TRUE in case of success, FALSE otherwise.
2618 # @ingroup l1_auxiliary
2619 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2620 # Pattern: 5.---------.6
2625 # (0,0,1) 4.---------.7 * |
2632 # (0,0,0) 0.---------.3
2633 pattern_tetra = "!!! Nb of points: \n 8 \n\
2643 !!! Indices of points of 6 tetras: \n\
2651 pattern = self.smeshpyD.GetPattern()
2652 isDone = pattern.LoadFromFile(pattern_tetra)
2654 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2657 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2658 isDone = pattern.MakeMesh(self.mesh, False, False)
2659 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2661 # split quafrangle faces near triangular facets of volumes
2662 self.SplitQuadsNearTriangularFacets()
2666 ## @brief Split hexahedrons into prisms.
2668 # Uses the pattern mapping functionality for splitting.
2669 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2670 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2671 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2672 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2673 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2674 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2675 # @return TRUE in case of success, FALSE otherwise.
2676 # @ingroup l1_auxiliary
2677 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2678 # Pattern: 5.---------.6
2683 # (0,0,1) 4.---------.7 |
2690 # (0,0,0) 0.---------.3
2691 pattern_prism = "!!! Nb of points: \n 8 \n\
2701 !!! Indices of points of 2 prisms: \n\
2705 pattern = self.smeshpyD.GetPattern()
2706 isDone = pattern.LoadFromFile(pattern_prism)
2708 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2711 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2712 isDone = pattern.MakeMesh(self.mesh, False, False)
2713 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2715 # Splits quafrangle faces near triangular facets of volumes
2716 self.SplitQuadsNearTriangularFacets()
2720 ## Smoothes elements
2721 # @param IDsOfElements the list if ids of elements to smooth
2722 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2723 # Note that nodes built on edges and boundary nodes are always fixed.
2724 # @param MaxNbOfIterations the maximum number of iterations
2725 # @param MaxAspectRatio varies in range [1.0, inf]
2726 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2727 # @return TRUE in case of success, FALSE otherwise.
2728 # @ingroup l2_modif_smooth
2729 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2730 MaxNbOfIterations, MaxAspectRatio, Method):
2731 if IDsOfElements == []:
2732 IDsOfElements = self.GetElementsId()
2733 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2734 self.mesh.SetParameters(Parameters)
2735 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2736 MaxNbOfIterations, MaxAspectRatio, Method)
2738 ## Smoothes elements which belong to the given object
2739 # @param theObject the object to smooth
2740 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2741 # Note that nodes built on edges and boundary nodes are always fixed.
2742 # @param MaxNbOfIterations the maximum number of iterations
2743 # @param MaxAspectRatio varies in range [1.0, inf]
2744 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2745 # @return TRUE in case of success, FALSE otherwise.
2746 # @ingroup l2_modif_smooth
2747 def SmoothObject(self, theObject, IDsOfFixedNodes,
2748 MaxNbOfIterations, MaxAspectRatio, Method):
2749 if ( isinstance( theObject, Mesh )):
2750 theObject = theObject.GetMesh()
2751 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2752 MaxNbOfIterations, MaxAspectRatio, Method)
2754 ## Parametrically smoothes the given elements
2755 # @param IDsOfElements the list if ids of elements to smooth
2756 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2757 # Note that nodes built on edges and boundary nodes are always fixed.
2758 # @param MaxNbOfIterations the maximum number of iterations
2759 # @param MaxAspectRatio varies in range [1.0, inf]
2760 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2761 # @return TRUE in case of success, FALSE otherwise.
2762 # @ingroup l2_modif_smooth
2763 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2764 MaxNbOfIterations, MaxAspectRatio, Method):
2765 if IDsOfElements == []:
2766 IDsOfElements = self.GetElementsId()
2767 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2768 self.mesh.SetParameters(Parameters)
2769 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2770 MaxNbOfIterations, MaxAspectRatio, Method)
2772 ## Parametrically smoothes the elements which belong to the given object
2773 # @param theObject the object to smooth
2774 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2775 # Note that nodes built on edges and boundary nodes are always fixed.
2776 # @param MaxNbOfIterations the maximum number of iterations
2777 # @param MaxAspectRatio varies in range [1.0, inf]
2778 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2779 # @return TRUE in case of success, FALSE otherwise.
2780 # @ingroup l2_modif_smooth
2781 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2782 MaxNbOfIterations, MaxAspectRatio, Method):
2783 if ( isinstance( theObject, Mesh )):
2784 theObject = theObject.GetMesh()
2785 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2786 MaxNbOfIterations, MaxAspectRatio, Method)
2788 ## Converts the mesh to quadratic, deletes old elements, replacing
2789 # them with quadratic with the same id.
2790 # @param theForce3d new node creation method:
2791 # 0 - the medium node lies at the geometrical edge from which the mesh element is built
2792 # 1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element
2793 # @ingroup l2_modif_tofromqu
2794 def ConvertToQuadratic(self, theForce3d):
2795 self.editor.ConvertToQuadratic(theForce3d)
2797 ## Converts the mesh from quadratic to ordinary,
2798 # deletes old quadratic elements, \n replacing
2799 # them with ordinary mesh elements with the same id.
2800 # @return TRUE in case of success, FALSE otherwise.
2801 # @ingroup l2_modif_tofromqu
2802 def ConvertFromQuadratic(self):
2803 return self.editor.ConvertFromQuadratic()
2805 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
2806 # @return TRUE if operation has been completed successfully, FALSE otherwise
2807 # @ingroup l2_modif_edit
2808 def Make2DMeshFrom3D(self):
2809 return self.editor. Make2DMeshFrom3D()
2811 ## Creates missing boundary elements
2812 # @param elements - elements whose boundary is to be checked:
2813 # mesh, group, sub-mesh or list of elements
2814 # @param dimension - defines type of boundary elements to create:
2815 # SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D
2816 # @param groupName - a name of group to store created boundary elements in,
2817 # "" means not to create the group
2818 # @param meshName - a name of new mesh to store created boundary elements in,
2819 # "" means not to create the new mesh
2820 # @param toCopyElements - if true, the checked elements will be copied into the new mesh
2821 # @param toCopyExistingBondary - if true, not only new but also pre-existing
2822 # boundary elements will be copied into the new mesh
2823 # @return tuple (mesh, group) where bondary elements were added to
2824 # @ingroup l2_modif_edit
2825 def MakeBoundaryMesh(self, elements, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
2826 toCopyElements=False, toCopyExistingBondary=False):
2827 if isinstance( elements, Mesh ):
2828 elements = elements.GetMesh()
2829 if ( isinstance( elements, list )):
2830 elemType = SMESH.ALL
2831 if elements: elemType = self.GetElementType( elements[0], iselem=True)
2832 elements = self.editor.MakeIDSource(elements, elemType)
2833 mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName,
2834 toCopyElements,toCopyExistingBondary)
2835 if mesh: mesh = self.smeshpyD.Mesh(mesh)
2838 ## Renumber mesh nodes
2839 # @ingroup l2_modif_renumber
2840 def RenumberNodes(self):
2841 self.editor.RenumberNodes()
2843 ## Renumber mesh elements
2844 # @ingroup l2_modif_renumber
2845 def RenumberElements(self):
2846 self.editor.RenumberElements()
2848 ## Generates new elements by rotation of the elements around the axis
2849 # @param IDsOfElements the list of ids of elements to sweep
2850 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2851 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2852 # @param NbOfSteps the number of steps
2853 # @param Tolerance tolerance
2854 # @param MakeGroups forces the generation of new groups from existing ones
2855 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2856 # of all steps, else - size of each step
2857 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2858 # @ingroup l2_modif_extrurev
2859 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2860 MakeGroups=False, TotalAngle=False):
2862 if isinstance(AngleInRadians,str):
2864 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2866 AngleInRadians = DegreesToRadians(AngleInRadians)
2867 if IDsOfElements == []:
2868 IDsOfElements = self.GetElementsId()
2869 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2870 Axis = self.smeshpyD.GetAxisStruct(Axis)
2871 Axis,AxisParameters = ParseAxisStruct(Axis)
2872 if TotalAngle and NbOfSteps:
2873 AngleInRadians /= NbOfSteps
2874 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2875 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2876 self.mesh.SetParameters(Parameters)
2878 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2879 AngleInRadians, NbOfSteps, Tolerance)
2880 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2883 ## Generates new elements by rotation of the elements of object around the axis
2884 # @param theObject object which elements should be sweeped
2885 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2886 # @param AngleInRadians the angle of Rotation
2887 # @param NbOfSteps number of steps
2888 # @param Tolerance tolerance
2889 # @param MakeGroups forces the generation of new groups from existing ones
2890 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2891 # of all steps, else - size of each step
2892 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2893 # @ingroup l2_modif_extrurev
2894 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2895 MakeGroups=False, TotalAngle=False):
2897 if isinstance(AngleInRadians,str):
2899 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2901 AngleInRadians = DegreesToRadians(AngleInRadians)
2902 if ( isinstance( theObject, Mesh )):
2903 theObject = theObject.GetMesh()
2904 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2905 Axis = self.smeshpyD.GetAxisStruct(Axis)
2906 Axis,AxisParameters = ParseAxisStruct(Axis)
2907 if TotalAngle and NbOfSteps:
2908 AngleInRadians /= NbOfSteps
2909 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2910 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2911 self.mesh.SetParameters(Parameters)
2913 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2914 NbOfSteps, Tolerance)
2915 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2918 ## Generates new elements by rotation of the elements of object around the axis
2919 # @param theObject object which elements should be sweeped
2920 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2921 # @param AngleInRadians the angle of Rotation
2922 # @param NbOfSteps number of steps
2923 # @param Tolerance tolerance
2924 # @param MakeGroups forces the generation of new groups from existing ones
2925 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2926 # of all steps, else - size of each step
2927 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2928 # @ingroup l2_modif_extrurev
2929 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2930 MakeGroups=False, TotalAngle=False):
2932 if isinstance(AngleInRadians,str):
2934 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2936 AngleInRadians = DegreesToRadians(AngleInRadians)
2937 if ( isinstance( theObject, Mesh )):
2938 theObject = theObject.GetMesh()
2939 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2940 Axis = self.smeshpyD.GetAxisStruct(Axis)
2941 Axis,AxisParameters = ParseAxisStruct(Axis)
2942 if TotalAngle and NbOfSteps:
2943 AngleInRadians /= NbOfSteps
2944 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2945 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2946 self.mesh.SetParameters(Parameters)
2948 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2949 NbOfSteps, Tolerance)
2950 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2953 ## Generates new elements by rotation of the elements of object around the axis
2954 # @param theObject object which elements should be sweeped
2955 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2956 # @param AngleInRadians the angle of Rotation
2957 # @param NbOfSteps number of steps
2958 # @param Tolerance tolerance
2959 # @param MakeGroups forces the generation of new groups from existing ones
2960 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2961 # of all steps, else - size of each step
2962 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2963 # @ingroup l2_modif_extrurev
2964 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2965 MakeGroups=False, TotalAngle=False):
2967 if isinstance(AngleInRadians,str):
2969 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2971 AngleInRadians = DegreesToRadians(AngleInRadians)
2972 if ( isinstance( theObject, Mesh )):
2973 theObject = theObject.GetMesh()
2974 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2975 Axis = self.smeshpyD.GetAxisStruct(Axis)
2976 Axis,AxisParameters = ParseAxisStruct(Axis)
2977 if TotalAngle and NbOfSteps:
2978 AngleInRadians /= NbOfSteps
2979 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2980 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2981 self.mesh.SetParameters(Parameters)
2983 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2984 NbOfSteps, Tolerance)
2985 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2988 ## Generates new elements by extrusion of the elements with given ids
2989 # @param IDsOfElements the list of elements ids for extrusion
2990 # @param StepVector vector, defining the direction and value of extrusion
2991 # @param NbOfSteps the number of steps
2992 # @param MakeGroups forces the generation of new groups from existing ones
2993 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2994 # @ingroup l2_modif_extrurev
2995 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2996 if IDsOfElements == []:
2997 IDsOfElements = self.GetElementsId()
2998 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2999 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3000 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3001 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3002 Parameters = StepVectorParameters + var_separator + Parameters
3003 self.mesh.SetParameters(Parameters)
3005 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
3006 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
3009 ## Generates new elements by extrusion of the elements with given ids
3010 # @param IDsOfElements is ids of elements
3011 # @param StepVector vector, defining the direction and value of extrusion
3012 # @param NbOfSteps the number of steps
3013 # @param ExtrFlags sets flags for extrusion
3014 # @param SewTolerance uses for comparing locations of nodes if flag
3015 # EXTRUSION_FLAG_SEW is set
3016 # @param MakeGroups forces the generation of new groups from existing ones
3017 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3018 # @ingroup l2_modif_extrurev
3019 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
3020 ExtrFlags, SewTolerance, MakeGroups=False):
3021 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3022 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3024 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
3025 ExtrFlags, SewTolerance)
3026 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
3027 ExtrFlags, SewTolerance)
3030 ## Generates new elements by extrusion of the elements which belong to the object
3031 # @param theObject the object which elements should be processed
3032 # @param StepVector vector, defining the direction and value of extrusion
3033 # @param NbOfSteps the number of steps
3034 # @param MakeGroups forces the generation of new groups from existing ones
3035 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3036 # @ingroup l2_modif_extrurev
3037 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3038 if ( isinstance( theObject, Mesh )):
3039 theObject = theObject.GetMesh()
3040 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3041 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3042 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3043 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3044 Parameters = StepVectorParameters + var_separator + Parameters
3045 self.mesh.SetParameters(Parameters)
3047 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3048 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
3051 ## Generates new elements by extrusion of the elements which belong to the object
3052 # @param theObject object which elements should be processed
3053 # @param StepVector vector, defining the direction and value of extrusion
3054 # @param NbOfSteps the number of steps
3055 # @param MakeGroups to generate new groups from existing ones
3056 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3057 # @ingroup l2_modif_extrurev
3058 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3059 if ( isinstance( theObject, Mesh )):
3060 theObject = theObject.GetMesh()
3061 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3062 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3063 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3064 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3065 Parameters = StepVectorParameters + var_separator + Parameters
3066 self.mesh.SetParameters(Parameters)
3068 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3069 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3072 ## Generates new elements by extrusion of the elements which belong to the object
3073 # @param theObject object which elements should be processed
3074 # @param StepVector vector, defining the direction and value of extrusion
3075 # @param NbOfSteps the number of steps
3076 # @param MakeGroups forces the generation of new groups from existing ones
3077 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3078 # @ingroup l2_modif_extrurev
3079 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3080 if ( isinstance( theObject, Mesh )):
3081 theObject = theObject.GetMesh()
3082 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3083 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3084 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3085 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3086 Parameters = StepVectorParameters + var_separator + Parameters
3087 self.mesh.SetParameters(Parameters)
3089 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3090 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3095 ## Generates new elements by extrusion of the given elements
3096 # The path of extrusion must be a meshed edge.
3097 # @param Base mesh or list of ids of elements for extrusion
3098 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3099 # @param NodeStart the start node from Path. Defines the direction of extrusion
3100 # @param HasAngles allows the shape to be rotated around the path
3101 # to get the resulting mesh in a helical fashion
3102 # @param Angles list of angles in radians
3103 # @param LinearVariation forces the computation of rotation angles as linear
3104 # variation of the given Angles along path steps
3105 # @param HasRefPoint allows using the reference point
3106 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3107 # The User can specify any point as the Reference Point.
3108 # @param MakeGroups forces the generation of new groups from existing ones
3109 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3110 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3111 # only SMESH::Extrusion_Error otherwise
3112 # @ingroup l2_modif_extrurev
3113 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3114 HasAngles, Angles, LinearVariation,
3115 HasRefPoint, RefPoint, MakeGroups, ElemType):
3116 Angles,AnglesParameters = ParseAngles(Angles)
3117 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3118 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3119 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3121 Parameters = AnglesParameters + var_separator + RefPointParameters
3122 self.mesh.SetParameters(Parameters)
3124 if isinstance(Base,list):
3126 if Base == []: IDsOfElements = self.GetElementsId()
3127 else: IDsOfElements = Base
3128 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3129 HasAngles, Angles, LinearVariation,
3130 HasRefPoint, RefPoint, MakeGroups, ElemType)
3132 if isinstance(Base,Mesh):
3133 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3134 HasAngles, Angles, LinearVariation,
3135 HasRefPoint, RefPoint, MakeGroups, ElemType)
3137 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3140 ## Generates new elements by extrusion of the given elements
3141 # The path of extrusion must be a meshed edge.
3142 # @param IDsOfElements ids of elements
3143 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3144 # @param PathShape shape(edge) defines the sub-mesh for the path
3145 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3146 # @param HasAngles allows the shape to be rotated around the path
3147 # to get the resulting mesh in a helical fashion
3148 # @param Angles list of angles in radians
3149 # @param HasRefPoint allows using the reference point
3150 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3151 # The User can specify any point as the Reference Point.
3152 # @param MakeGroups forces the generation of new groups from existing ones
3153 # @param LinearVariation forces the computation of rotation angles as linear
3154 # variation of the given Angles along path steps
3155 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3156 # only SMESH::Extrusion_Error otherwise
3157 # @ingroup l2_modif_extrurev
3158 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3159 HasAngles, Angles, HasRefPoint, RefPoint,
3160 MakeGroups=False, LinearVariation=False):
3161 Angles,AnglesParameters = ParseAngles(Angles)
3162 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3163 if IDsOfElements == []:
3164 IDsOfElements = self.GetElementsId()
3165 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3166 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3168 if ( isinstance( PathMesh, Mesh )):
3169 PathMesh = PathMesh.GetMesh()
3170 if HasAngles and Angles and LinearVariation:
3171 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3173 Parameters = AnglesParameters + var_separator + RefPointParameters
3174 self.mesh.SetParameters(Parameters)
3176 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3177 PathShape, NodeStart, HasAngles,
3178 Angles, HasRefPoint, RefPoint)
3179 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3180 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3182 ## Generates new elements by extrusion of the elements which belong to the object
3183 # The path of extrusion must be a meshed edge.
3184 # @param theObject the object which elements should be processed
3185 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3186 # @param PathShape shape(edge) defines the sub-mesh for the path
3187 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3188 # @param HasAngles allows the shape to be rotated around the path
3189 # to get the resulting mesh in a helical fashion
3190 # @param Angles list of angles
3191 # @param HasRefPoint allows using the reference point
3192 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3193 # The User can specify any point as the Reference Point.
3194 # @param MakeGroups forces the generation of new groups from existing ones
3195 # @param LinearVariation forces the computation of rotation angles as linear
3196 # variation of the given Angles along path steps
3197 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3198 # only SMESH::Extrusion_Error otherwise
3199 # @ingroup l2_modif_extrurev
3200 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3201 HasAngles, Angles, HasRefPoint, RefPoint,
3202 MakeGroups=False, LinearVariation=False):
3203 Angles,AnglesParameters = ParseAngles(Angles)
3204 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3205 if ( isinstance( theObject, Mesh )):
3206 theObject = theObject.GetMesh()
3207 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3208 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3209 if ( isinstance( PathMesh, Mesh )):
3210 PathMesh = PathMesh.GetMesh()
3211 if HasAngles and Angles and LinearVariation:
3212 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3214 Parameters = AnglesParameters + var_separator + RefPointParameters
3215 self.mesh.SetParameters(Parameters)
3217 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3218 PathShape, NodeStart, HasAngles,
3219 Angles, HasRefPoint, RefPoint)
3220 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3221 NodeStart, HasAngles, Angles, HasRefPoint,
3224 ## Generates new elements by extrusion of the elements which belong to the object
3225 # The path of extrusion must be a meshed edge.
3226 # @param theObject the object which elements should be processed
3227 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3228 # @param PathShape shape(edge) defines the sub-mesh for the path
3229 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3230 # @param HasAngles allows the shape to be rotated around the path
3231 # to get the resulting mesh in a helical fashion
3232 # @param Angles list of angles
3233 # @param HasRefPoint allows using the reference point
3234 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3235 # The User can specify any point as the Reference Point.
3236 # @param MakeGroups forces the generation of new groups from existing ones
3237 # @param LinearVariation forces the computation of rotation angles as linear
3238 # variation of the given Angles along path steps
3239 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3240 # only SMESH::Extrusion_Error otherwise
3241 # @ingroup l2_modif_extrurev
3242 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3243 HasAngles, Angles, HasRefPoint, RefPoint,
3244 MakeGroups=False, LinearVariation=False):
3245 Angles,AnglesParameters = ParseAngles(Angles)
3246 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3247 if ( isinstance( theObject, Mesh )):
3248 theObject = theObject.GetMesh()
3249 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3250 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3251 if ( isinstance( PathMesh, Mesh )):
3252 PathMesh = PathMesh.GetMesh()
3253 if HasAngles and Angles and LinearVariation:
3254 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3256 Parameters = AnglesParameters + var_separator + RefPointParameters
3257 self.mesh.SetParameters(Parameters)
3259 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3260 PathShape, NodeStart, HasAngles,
3261 Angles, HasRefPoint, RefPoint)
3262 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3263 NodeStart, HasAngles, Angles, HasRefPoint,
3266 ## Generates new elements by extrusion of the elements which belong to the object
3267 # The path of extrusion must be a meshed edge.
3268 # @param theObject the object which elements should be processed
3269 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3270 # @param PathShape shape(edge) defines the sub-mesh for the path
3271 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3272 # @param HasAngles allows the shape to be rotated around the path
3273 # to get the resulting mesh in a helical fashion
3274 # @param Angles list of angles
3275 # @param HasRefPoint allows using the reference point
3276 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3277 # The User can specify any point as the Reference Point.
3278 # @param MakeGroups forces the generation of new groups from existing ones
3279 # @param LinearVariation forces the computation of rotation angles as linear
3280 # variation of the given Angles along path steps
3281 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3282 # only SMESH::Extrusion_Error otherwise
3283 # @ingroup l2_modif_extrurev
3284 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3285 HasAngles, Angles, HasRefPoint, RefPoint,
3286 MakeGroups=False, LinearVariation=False):
3287 Angles,AnglesParameters = ParseAngles(Angles)
3288 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3289 if ( isinstance( theObject, Mesh )):
3290 theObject = theObject.GetMesh()
3291 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3292 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3293 if ( isinstance( PathMesh, Mesh )):
3294 PathMesh = PathMesh.GetMesh()
3295 if HasAngles and Angles and LinearVariation:
3296 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3298 Parameters = AnglesParameters + var_separator + RefPointParameters
3299 self.mesh.SetParameters(Parameters)
3301 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3302 PathShape, NodeStart, HasAngles,
3303 Angles, HasRefPoint, RefPoint)
3304 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3305 NodeStart, HasAngles, Angles, HasRefPoint,
3308 ## Creates a symmetrical copy of mesh elements
3309 # @param IDsOfElements list of elements ids
3310 # @param Mirror is AxisStruct or geom object(point, line, plane)
3311 # @param theMirrorType is POINT, AXIS or PLANE
3312 # If the Mirror is a geom object this parameter is unnecessary
3313 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3314 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3315 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3316 # @ingroup l2_modif_trsf
3317 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3318 if IDsOfElements == []:
3319 IDsOfElements = self.GetElementsId()
3320 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3321 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3322 Mirror,Parameters = ParseAxisStruct(Mirror)
3323 self.mesh.SetParameters(Parameters)
3324 if Copy and MakeGroups:
3325 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3326 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3329 ## Creates a new mesh by a symmetrical copy of mesh elements
3330 # @param IDsOfElements the list of elements ids
3331 # @param Mirror is AxisStruct or geom object (point, line, plane)
3332 # @param theMirrorType is POINT, AXIS or PLANE
3333 # If the Mirror is a geom object this parameter is unnecessary
3334 # @param MakeGroups to generate new groups from existing ones
3335 # @param NewMeshName a name of the new mesh to create
3336 # @return instance of Mesh class
3337 # @ingroup l2_modif_trsf
3338 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3339 if IDsOfElements == []:
3340 IDsOfElements = self.GetElementsId()
3341 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3342 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3343 Mirror,Parameters = ParseAxisStruct(Mirror)
3344 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3345 MakeGroups, NewMeshName)
3346 mesh.SetParameters(Parameters)
3347 return Mesh(self.smeshpyD,self.geompyD,mesh)
3349 ## Creates a symmetrical copy of the object
3350 # @param theObject mesh, submesh or group
3351 # @param Mirror AxisStruct or geom object (point, line, plane)
3352 # @param theMirrorType is POINT, AXIS or PLANE
3353 # If the Mirror is a geom object this parameter is unnecessary
3354 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3355 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3356 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3357 # @ingroup l2_modif_trsf
3358 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3359 if ( isinstance( theObject, Mesh )):
3360 theObject = theObject.GetMesh()
3361 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3362 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3363 Mirror,Parameters = ParseAxisStruct(Mirror)
3364 self.mesh.SetParameters(Parameters)
3365 if Copy and MakeGroups:
3366 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3367 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3370 ## Creates a new mesh by a symmetrical copy of the object
3371 # @param theObject mesh, submesh or group
3372 # @param Mirror AxisStruct or geom object (point, line, plane)
3373 # @param theMirrorType POINT, AXIS or PLANE
3374 # If the Mirror is a geom object this parameter is unnecessary
3375 # @param MakeGroups forces the generation of new groups from existing ones
3376 # @param NewMeshName the name of the new mesh to create
3377 # @return instance of Mesh class
3378 # @ingroup l2_modif_trsf
3379 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3380 if ( isinstance( theObject, Mesh )):
3381 theObject = theObject.GetMesh()
3382 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3383 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3384 Mirror,Parameters = ParseAxisStruct(Mirror)
3385 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3386 MakeGroups, NewMeshName)
3387 mesh.SetParameters(Parameters)
3388 return Mesh( self.smeshpyD,self.geompyD,mesh )
3390 ## Translates the elements
3391 # @param IDsOfElements list of elements ids
3392 # @param Vector the direction of translation (DirStruct or vector)
3393 # @param Copy allows copying the translated elements
3394 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3395 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3396 # @ingroup l2_modif_trsf
3397 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3398 if IDsOfElements == []:
3399 IDsOfElements = self.GetElementsId()
3400 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3401 Vector = self.smeshpyD.GetDirStruct(Vector)
3402 Vector,Parameters = ParseDirStruct(Vector)
3403 self.mesh.SetParameters(Parameters)
3404 if Copy and MakeGroups:
3405 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3406 self.editor.Translate(IDsOfElements, Vector, Copy)
3409 ## Creates a new mesh of translated elements
3410 # @param IDsOfElements list of elements ids
3411 # @param Vector the direction of translation (DirStruct or vector)
3412 # @param MakeGroups forces the generation of new groups from existing ones
3413 # @param NewMeshName the name of the newly created mesh
3414 # @return instance of Mesh class
3415 # @ingroup l2_modif_trsf
3416 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3417 if IDsOfElements == []:
3418 IDsOfElements = self.GetElementsId()
3419 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3420 Vector = self.smeshpyD.GetDirStruct(Vector)
3421 Vector,Parameters = ParseDirStruct(Vector)
3422 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3423 mesh.SetParameters(Parameters)
3424 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3426 ## Translates the object
3427 # @param theObject the object to translate (mesh, submesh, or group)
3428 # @param Vector direction of translation (DirStruct or geom vector)
3429 # @param Copy allows copying the translated elements
3430 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3431 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3432 # @ingroup l2_modif_trsf
3433 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3434 if ( isinstance( theObject, Mesh )):
3435 theObject = theObject.GetMesh()
3436 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3437 Vector = self.smeshpyD.GetDirStruct(Vector)
3438 Vector,Parameters = ParseDirStruct(Vector)
3439 self.mesh.SetParameters(Parameters)
3440 if Copy and MakeGroups:
3441 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3442 self.editor.TranslateObject(theObject, Vector, Copy)
3445 ## Creates a new mesh from the translated object
3446 # @param theObject the object to translate (mesh, submesh, or group)
3447 # @param Vector the direction of translation (DirStruct or geom vector)
3448 # @param MakeGroups forces the generation of new groups from existing ones
3449 # @param NewMeshName the name of the newly created mesh
3450 # @return instance of Mesh class
3451 # @ingroup l2_modif_trsf
3452 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3453 if (isinstance(theObject, Mesh)):
3454 theObject = theObject.GetMesh()
3455 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3456 Vector = self.smeshpyD.GetDirStruct(Vector)
3457 Vector,Parameters = ParseDirStruct(Vector)
3458 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3459 mesh.SetParameters(Parameters)
3460 return Mesh( self.smeshpyD, self.geompyD, mesh )
3464 ## Scales the object
3465 # @param theObject - the object to translate (mesh, submesh, or group)
3466 # @param thePoint - base point for scale
3467 # @param theScaleFact - list of 1-3 scale factors for axises
3468 # @param Copy - allows copying the translated elements
3469 # @param MakeGroups - forces the generation of new groups from existing
3471 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3472 # empty list otherwise
3473 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3474 if ( isinstance( theObject, Mesh )):
3475 theObject = theObject.GetMesh()
3476 if ( isinstance( theObject, list )):
3477 theObject = self.editor.MakeIDSource(theObject, SMESH.ALL)
3479 thePoint, Parameters = ParsePointStruct(thePoint)
3480 self.mesh.SetParameters(Parameters)
3482 if Copy and MakeGroups:
3483 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3484 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3487 ## Creates a new mesh from the translated object
3488 # @param theObject - the object to translate (mesh, submesh, or group)
3489 # @param thePoint - base point for scale
3490 # @param theScaleFact - list of 1-3 scale factors for axises
3491 # @param MakeGroups - forces the generation of new groups from existing ones
3492 # @param NewMeshName - the name of the newly created mesh
3493 # @return instance of Mesh class
3494 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3495 if (isinstance(theObject, Mesh)):
3496 theObject = theObject.GetMesh()
3497 if ( isinstance( theObject, list )):
3498 theObject = self.editor.MakeIDSource(theObject,SMESH.ALL)
3500 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3501 MakeGroups, NewMeshName)
3502 #mesh.SetParameters(Parameters)
3503 return Mesh( self.smeshpyD, self.geompyD, mesh )
3507 ## Rotates the elements
3508 # @param IDsOfElements list of elements ids
3509 # @param Axis the axis of rotation (AxisStruct or geom line)
3510 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3511 # @param Copy allows copying the rotated elements
3512 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3513 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3514 # @ingroup l2_modif_trsf
3515 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3517 if isinstance(AngleInRadians,str):
3519 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3521 AngleInRadians = DegreesToRadians(AngleInRadians)
3522 if IDsOfElements == []:
3523 IDsOfElements = self.GetElementsId()
3524 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3525 Axis = self.smeshpyD.GetAxisStruct(Axis)
3526 Axis,AxisParameters = ParseAxisStruct(Axis)
3527 Parameters = AxisParameters + var_separator + Parameters
3528 self.mesh.SetParameters(Parameters)
3529 if Copy and MakeGroups:
3530 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3531 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3534 ## Creates a new mesh of rotated elements
3535 # @param IDsOfElements list of element ids
3536 # @param Axis the axis of rotation (AxisStruct or geom line)
3537 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3538 # @param MakeGroups forces the generation of new groups from existing ones
3539 # @param NewMeshName the name of the newly created mesh
3540 # @return instance of Mesh class
3541 # @ingroup l2_modif_trsf
3542 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3544 if isinstance(AngleInRadians,str):
3546 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3548 AngleInRadians = DegreesToRadians(AngleInRadians)
3549 if IDsOfElements == []:
3550 IDsOfElements = self.GetElementsId()
3551 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3552 Axis = self.smeshpyD.GetAxisStruct(Axis)
3553 Axis,AxisParameters = ParseAxisStruct(Axis)
3554 Parameters = AxisParameters + var_separator + Parameters
3555 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3556 MakeGroups, NewMeshName)
3557 mesh.SetParameters(Parameters)
3558 return Mesh( self.smeshpyD, self.geompyD, mesh )
3560 ## Rotates the object
3561 # @param theObject the object to rotate( mesh, submesh, or group)
3562 # @param Axis the axis of rotation (AxisStruct or geom line)
3563 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3564 # @param Copy allows copying the rotated elements
3565 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3566 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3567 # @ingroup l2_modif_trsf
3568 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3570 if isinstance(AngleInRadians,str):
3572 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3574 AngleInRadians = DegreesToRadians(AngleInRadians)
3575 if (isinstance(theObject, Mesh)):
3576 theObject = theObject.GetMesh()
3577 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3578 Axis = self.smeshpyD.GetAxisStruct(Axis)
3579 Axis,AxisParameters = ParseAxisStruct(Axis)
3580 Parameters = AxisParameters + ":" + Parameters
3581 self.mesh.SetParameters(Parameters)
3582 if Copy and MakeGroups:
3583 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3584 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3587 ## Creates a new mesh from the rotated object
3588 # @param theObject the object to rotate (mesh, submesh, or group)
3589 # @param Axis the axis of rotation (AxisStruct or geom line)
3590 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3591 # @param MakeGroups forces the generation of new groups from existing ones
3592 # @param NewMeshName the name of the newly created mesh
3593 # @return instance of Mesh class
3594 # @ingroup l2_modif_trsf
3595 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3597 if isinstance(AngleInRadians,str):
3599 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3601 AngleInRadians = DegreesToRadians(AngleInRadians)
3602 if (isinstance( theObject, Mesh )):
3603 theObject = theObject.GetMesh()
3604 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3605 Axis = self.smeshpyD.GetAxisStruct(Axis)
3606 Axis,AxisParameters = ParseAxisStruct(Axis)
3607 Parameters = AxisParameters + ":" + Parameters
3608 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3609 MakeGroups, NewMeshName)
3610 mesh.SetParameters(Parameters)
3611 return Mesh( self.smeshpyD, self.geompyD, mesh )
3613 ## Finds groups of ajacent nodes within Tolerance.
3614 # @param Tolerance the value of tolerance
3615 # @return the list of groups of nodes
3616 # @ingroup l2_modif_trsf
3617 def FindCoincidentNodes (self, Tolerance):
3618 return self.editor.FindCoincidentNodes(Tolerance)
3620 ## Finds groups of ajacent nodes within Tolerance.
3621 # @param Tolerance the value of tolerance
3622 # @param SubMeshOrGroup SubMesh or Group
3623 # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
3624 # @return the list of groups of nodes
3625 # @ingroup l2_modif_trsf
3626 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
3627 if (isinstance( SubMeshOrGroup, Mesh )):
3628 SubMeshOrGroup = SubMeshOrGroup.GetMesh()
3629 if not isinstance( exceptNodes, list):
3630 exceptNodes = [ exceptNodes ]
3631 if exceptNodes and isinstance( exceptNodes[0], int):
3632 exceptNodes = [ self.editor.MakeIDSource( exceptNodes, SMESH.NODE)]
3633 return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes)
3636 # @param GroupsOfNodes the list of groups of nodes
3637 # @ingroup l2_modif_trsf
3638 def MergeNodes (self, GroupsOfNodes):
3639 self.editor.MergeNodes(GroupsOfNodes)
3641 ## Finds the elements built on the same nodes.
3642 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3643 # @return a list of groups of equal elements
3644 # @ingroup l2_modif_trsf
3645 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3646 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3647 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3648 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3650 ## Merges elements in each given group.
3651 # @param GroupsOfElementsID groups of elements for merging
3652 # @ingroup l2_modif_trsf
3653 def MergeElements(self, GroupsOfElementsID):
3654 self.editor.MergeElements(GroupsOfElementsID)
3656 ## Leaves one element and removes all other elements built on the same nodes.
3657 # @ingroup l2_modif_trsf
3658 def MergeEqualElements(self):
3659 self.editor.MergeEqualElements()
3661 ## Sews free borders
3662 # @return SMESH::Sew_Error
3663 # @ingroup l2_modif_trsf
3664 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3665 FirstNodeID2, SecondNodeID2, LastNodeID2,
3666 CreatePolygons, CreatePolyedrs):
3667 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3668 FirstNodeID2, SecondNodeID2, LastNodeID2,
3669 CreatePolygons, CreatePolyedrs)
3671 ## Sews conform free borders
3672 # @return SMESH::Sew_Error
3673 # @ingroup l2_modif_trsf
3674 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3675 FirstNodeID2, SecondNodeID2):
3676 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3677 FirstNodeID2, SecondNodeID2)
3679 ## Sews border to side
3680 # @return SMESH::Sew_Error
3681 # @ingroup l2_modif_trsf
3682 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3683 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3684 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3685 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3687 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3688 # merged with the nodes of elements of Side2.
3689 # The number of elements in theSide1 and in theSide2 must be
3690 # equal and they should have similar nodal connectivity.
3691 # The nodes to merge should belong to side borders and
3692 # the first node should be linked to the second.
3693 # @return SMESH::Sew_Error
3694 # @ingroup l2_modif_trsf
3695 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3696 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3697 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3698 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3699 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3700 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3702 ## Sets new nodes for the given element.
3703 # @param ide the element id
3704 # @param newIDs nodes ids
3705 # @return If the number of nodes does not correspond to the type of element - returns false
3706 # @ingroup l2_modif_edit
3707 def ChangeElemNodes(self, ide, newIDs):
3708 return self.editor.ChangeElemNodes(ide, newIDs)
3710 ## If during the last operation of MeshEditor some nodes were
3711 # created, this method returns the list of their IDs, \n
3712 # if new nodes were not created - returns empty list
3713 # @return the list of integer values (can be empty)
3714 # @ingroup l1_auxiliary
3715 def GetLastCreatedNodes(self):
3716 return self.editor.GetLastCreatedNodes()
3718 ## If during the last operation of MeshEditor some elements were
3719 # created this method returns the list of their IDs, \n
3720 # if new elements were not created - returns empty list
3721 # @return the list of integer values (can be empty)
3722 # @ingroup l1_auxiliary
3723 def GetLastCreatedElems(self):
3724 return self.editor.GetLastCreatedElems()
3726 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3727 # @param theNodes identifiers of nodes to be doubled
3728 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
3729 # nodes. If list of element identifiers is empty then nodes are doubled but
3730 # they not assigned to elements
3731 # @return TRUE if operation has been completed successfully, FALSE otherwise
3732 # @ingroup l2_modif_edit
3733 def DoubleNodes(self, theNodes, theModifiedElems):
3734 return self.editor.DoubleNodes(theNodes, theModifiedElems)
3736 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3737 # This method provided for convenience works as DoubleNodes() described above.
3738 # @param theNodeId identifiers of node to be doubled
3739 # @param theModifiedElems identifiers of elements to be updated
3740 # @return TRUE if operation has been completed successfully, FALSE otherwise
3741 # @ingroup l2_modif_edit
3742 def DoubleNode(self, theNodeId, theModifiedElems):
3743 return self.editor.DoubleNode(theNodeId, theModifiedElems)
3745 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3746 # This method provided for convenience works as DoubleNodes() described above.
3747 # @param theNodes group of nodes to be doubled
3748 # @param theModifiedElems group of elements to be updated.
3749 # @param theMakeGroup forces the generation of a group containing new nodes.
3750 # @return TRUE or a created group if operation has been completed successfully,
3751 # FALSE or None otherwise
3752 # @ingroup l2_modif_edit
3753 def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
3755 return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
3756 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3758 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3759 # This method provided for convenience works as DoubleNodes() described above.
3760 # @param theNodes list of groups of nodes to be doubled
3761 # @param theModifiedElems list of groups of elements to be updated.
3762 # @return TRUE if operation has been completed successfully, FALSE otherwise
3763 # @ingroup l2_modif_edit
3764 def DoubleNodeGroups(self, theNodes, theModifiedElems):
3765 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3767 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3768 # @param theElems - the list of elements (edges or faces) to be replicated
3769 # The nodes for duplication could be found from these elements
3770 # @param theNodesNot - list of nodes to NOT replicate
3771 # @param theAffectedElems - the list of elements (cells and edges) to which the
3772 # replicated nodes should be associated to.
3773 # @return TRUE if operation has been completed successfully, FALSE otherwise
3774 # @ingroup l2_modif_edit
3775 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
3776 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
3778 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3779 # @param theElems - the list of elements (edges or faces) to be replicated
3780 # The nodes for duplication could be found from these elements
3781 # @param theNodesNot - list of nodes to NOT replicate
3782 # @param theShape - shape to detect affected elements (element which geometric center
3783 # located on or inside shape).
3784 # The replicated nodes should be associated to affected elements.
3785 # @return TRUE if operation has been completed successfully, FALSE otherwise
3786 # @ingroup l2_modif_edit
3787 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
3788 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
3790 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3791 # This method provided for convenience works as DoubleNodes() described above.
3792 # @param theElems - group of of elements (edges or faces) to be replicated
3793 # @param theNodesNot - group of nodes not to replicated
3794 # @param theAffectedElems - group of elements to which the replicated nodes
3795 # should be associated to.
3796 # @param theMakeGroup forces the generation of a group containing new elements.
3797 # @ingroup l2_modif_edit
3798 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
3800 return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
3801 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
3803 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3804 # This method provided for convenience works as DoubleNodes() described above.
3805 # @param theElems - group of of elements (edges or faces) to be replicated
3806 # @param theNodesNot - group of nodes not to replicated
3807 # @param theShape - shape to detect affected elements (element which geometric center
3808 # located on or inside shape).
3809 # The replicated nodes should be associated to affected elements.
3810 # @ingroup l2_modif_edit
3811 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
3812 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
3814 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3815 # This method provided for convenience works as DoubleNodes() described above.
3816 # @param theElems - list of groups of elements (edges or faces) to be replicated
3817 # @param theNodesNot - list of groups of nodes not to replicated
3818 # @param theAffectedElems - group of elements to which the replicated nodes
3819 # should be associated to.
3820 # @return TRUE if operation has been completed successfully, FALSE otherwise
3821 # @ingroup l2_modif_edit
3822 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems):
3823 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
3825 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3826 # This method provided for convenience works as DoubleNodes() described above.
3827 # @param theElems - list of groups of elements (edges or faces) to be replicated
3828 # @param theNodesNot - list of groups of nodes not to replicated
3829 # @param theShape - shape to detect affected elements (element which geometric center
3830 # located on or inside shape).
3831 # The replicated nodes should be associated to affected elements.
3832 # @return TRUE if operation has been completed successfully, FALSE otherwise
3833 # @ingroup l2_modif_edit
3834 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
3835 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
3837 ## The mother class to define algorithm, it is not recommended to use it directly.
3840 # @ingroup l2_algorithms
3841 class Mesh_Algorithm:
3842 # @class Mesh_Algorithm
3843 # @brief Class Mesh_Algorithm
3845 #def __init__(self,smesh):
3853 ## Finds a hypothesis in the study by its type name and parameters.
3854 # Finds only the hypotheses created in smeshpyD engine.
3855 # @return SMESH.SMESH_Hypothesis
3856 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3857 study = smeshpyD.GetCurrentStudy()
3858 #to do: find component by smeshpyD object, not by its data type
3859 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3860 if scomp is not None:
3861 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3862 # Check if the root label of the hypotheses exists
3863 if res and hypRoot is not None:
3864 iter = study.NewChildIterator(hypRoot)
3865 # Check all published hypotheses
3867 hypo_so_i = iter.Value()
3868 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3869 if attr is not None:
3870 anIOR = attr.Value()
3871 hypo_o_i = salome.orb.string_to_object(anIOR)
3872 if hypo_o_i is not None:
3873 # Check if this is a hypothesis
3874 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3875 if hypo_i is not None:
3876 # Check if the hypothesis belongs to current engine
3877 if smeshpyD.GetObjectId(hypo_i) > 0:
3878 # Check if this is the required hypothesis
3879 if hypo_i.GetName() == hypname:
3881 if CompareMethod(hypo_i, args):
3895 ## Finds the algorithm in the study by its type name.
3896 # Finds only the algorithms, which have been created in smeshpyD engine.
3897 # @return SMESH.SMESH_Algo
3898 def FindAlgorithm (self, algoname, smeshpyD):
3899 study = smeshpyD.GetCurrentStudy()
3900 #to do: find component by smeshpyD object, not by its data type
3901 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3902 if scomp is not None:
3903 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3904 # Check if the root label of the algorithms exists
3905 if res and hypRoot is not None:
3906 iter = study.NewChildIterator(hypRoot)
3907 # Check all published algorithms
3909 algo_so_i = iter.Value()
3910 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3911 if attr is not None:
3912 anIOR = attr.Value()
3913 algo_o_i = salome.orb.string_to_object(anIOR)
3914 if algo_o_i is not None:
3915 # Check if this is an algorithm
3916 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3917 if algo_i is not None:
3918 # Checks if the algorithm belongs to the current engine
3919 if smeshpyD.GetObjectId(algo_i) > 0:
3920 # Check if this is the required algorithm
3921 if algo_i.GetName() == algoname:
3934 ## If the algorithm is global, returns 0; \n
3935 # else returns the submesh associated to this algorithm.
3936 def GetSubMesh(self):
3939 ## Returns the wrapped mesher.
3940 def GetAlgorithm(self):
3943 ## Gets the list of hypothesis that can be used with this algorithm
3944 def GetCompatibleHypothesis(self):
3947 mylist = self.algo.GetCompatibleHypothesis()
3950 ## Gets the name of the algorithm
3954 ## Sets the name to the algorithm
3955 def SetName(self, name):
3956 self.mesh.smeshpyD.SetName(self.algo, name)
3958 ## Gets the id of the algorithm
3960 return self.algo.GetId()
3963 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3965 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3966 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3968 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3970 self.Assign(algo, mesh, geom)
3974 def Assign(self, algo, mesh, geom):
3976 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3985 name = GetName(geom)
3988 name = mesh.geompyD.SubShapeName(geom, piece)
3989 mesh.geompyD.addToStudyInFather(piece, geom, name)
3991 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3994 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3995 TreatHypoStatus( status, algo.GetName(), name, True )
3997 def CompareHyp (self, hyp, args):
3998 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
4001 def CompareEqualHyp (self, hyp, args):
4005 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
4006 UseExisting=0, CompareMethod=""):
4009 if CompareMethod == "": CompareMethod = self.CompareHyp
4010 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
4013 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
4019 a = a + s + str(args[i])
4023 self.mesh.smeshpyD.SetName(hypo, hyp + a)
4025 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
4026 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
4029 ## Returns entry of the shape to mesh in the study
4030 def MainShapeEntry(self):
4032 if not self.mesh or not self.mesh.GetMesh(): return entry
4033 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
4034 study = self.mesh.smeshpyD.GetCurrentStudy()
4035 ior = salome.orb.object_to_string( self.mesh.GetShape() )
4036 sobj = study.FindObjectIOR(ior)
4037 if sobj: entry = sobj.GetID()
4038 if not entry: return ""
4041 # Public class: Mesh_Segment
4042 # --------------------------
4044 ## Class to define a segment 1D algorithm for discretization
4047 # @ingroup l3_algos_basic
4048 class Mesh_Segment(Mesh_Algorithm):
4050 ## Private constructor.
4051 def __init__(self, mesh, geom=0):
4052 Mesh_Algorithm.__init__(self)
4053 self.Create(mesh, geom, "Regular_1D")
4055 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
4056 # @param l for the length of segments that cut an edge
4057 # @param UseExisting if ==true - searches for an existing hypothesis created with
4058 # the same parameters, else (default) - creates a new one
4059 # @param p precision, used for calculation of the number of segments.
4060 # The precision should be a positive, meaningful value within the range [0,1].
4061 # In general, the number of segments is calculated with the formula:
4062 # nb = ceil((edge_length / l) - p)
4063 # Function ceil rounds its argument to the higher integer.
4064 # So, p=0 means rounding of (edge_length / l) to the higher integer,
4065 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
4066 # p=1 means rounding of (edge_length / l) to the lower integer.
4067 # Default value is 1e-07.
4068 # @return an instance of StdMeshers_LocalLength hypothesis
4069 # @ingroup l3_hypos_1dhyps
4070 def LocalLength(self, l, UseExisting=0, p=1e-07):
4071 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
4072 CompareMethod=self.CompareLocalLength)
4078 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
4079 def CompareLocalLength(self, hyp, args):
4080 if IsEqual(hyp.GetLength(), args[0]):
4081 return IsEqual(hyp.GetPrecision(), args[1])
4084 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
4085 # @param length is optional maximal allowed length of segment, if it is omitted
4086 # the preestimated length is used that depends on geometry size
4087 # @param UseExisting if ==true - searches for an existing hypothesis created with
4088 # the same parameters, else (default) - create a new one
4089 # @return an instance of StdMeshers_MaxLength hypothesis
4090 # @ingroup l3_hypos_1dhyps
4091 def MaxSize(self, length=0.0, UseExisting=0):
4092 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
4095 hyp.SetLength(length)
4097 # set preestimated length
4098 gen = self.mesh.smeshpyD
4099 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
4100 self.mesh.GetMesh(), self.mesh.GetShape(),
4102 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
4104 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
4107 hyp.SetUsePreestimatedLength( length == 0.0 )
4110 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
4111 # @param n for the number of segments that cut an edge
4112 # @param s for the scale factor (optional)
4113 # @param reversedEdges is a list of edges to mesh using reversed orientation
4114 # @param UseExisting if ==true - searches for an existing hypothesis created with
4115 # the same parameters, else (default) - create a new one
4116 # @return an instance of StdMeshers_NumberOfSegments hypothesis
4117 # @ingroup l3_hypos_1dhyps
4118 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4119 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4120 reversedEdges, UseExisting = [], reversedEdges
4121 entry = self.MainShapeEntry()
4123 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
4124 UseExisting=UseExisting,
4125 CompareMethod=self.CompareNumberOfSegments)
4127 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
4128 UseExisting=UseExisting,
4129 CompareMethod=self.CompareNumberOfSegments)
4130 hyp.SetDistrType( 1 )
4131 hyp.SetScaleFactor(s)
4132 hyp.SetNumberOfSegments(n)
4133 hyp.SetReversedEdges( reversedEdges )
4134 hyp.SetObjectEntry( entry )
4138 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4139 def CompareNumberOfSegments(self, hyp, args):
4140 if hyp.GetNumberOfSegments() == args[0]:
4142 if hyp.GetReversedEdges() == args[1]:
4143 if not args[1] or hyp.GetObjectEntry() == args[2]:
4146 if hyp.GetReversedEdges() == args[2]:
4147 if not args[2] or hyp.GetObjectEntry() == args[3]:
4148 if hyp.GetDistrType() == 1:
4149 if IsEqual(hyp.GetScaleFactor(), args[1]):
4153 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4154 # @param start defines the length of the first segment
4155 # @param end defines the length of the last segment
4156 # @param reversedEdges is a list of edges to mesh using reversed orientation
4157 # @param UseExisting if ==true - searches for an existing hypothesis created with
4158 # the same parameters, else (default) - creates a new one
4159 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4160 # @ingroup l3_hypos_1dhyps
4161 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4162 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4163 reversedEdges, UseExisting = [], reversedEdges
4164 entry = self.MainShapeEntry()
4165 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
4166 UseExisting=UseExisting,
4167 CompareMethod=self.CompareArithmetic1D)
4168 hyp.SetStartLength(start)
4169 hyp.SetEndLength(end)
4170 hyp.SetReversedEdges( reversedEdges )
4171 hyp.SetObjectEntry( entry )
4175 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4176 def CompareArithmetic1D(self, hyp, args):
4177 if IsEqual(hyp.GetLength(1), args[0]):
4178 if IsEqual(hyp.GetLength(0), args[1]):
4179 if hyp.GetReversedEdges() == args[2]:
4180 if not args[2] or hyp.GetObjectEntry() == args[3]:
4185 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4186 # on curve from 0 to 1 (additionally it is neecessary to check
4187 # orientation of edges and create list of reversed edges if it is
4188 # needed) and sets numbers of segments between given points (default
4189 # values are equals 1
4190 # @param points defines the list of parameters on curve
4191 # @param nbSegs defines the list of numbers of segments
4192 # @param reversedEdges is a list of edges to mesh using reversed orientation
4193 # @param UseExisting if ==true - searches for an existing hypothesis created with
4194 # the same parameters, else (default) - creates a new one
4195 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4196 # @ingroup l3_hypos_1dhyps
4197 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4198 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4199 reversedEdges, UseExisting = [], reversedEdges
4200 if reversedEdges and isinstance( reversedEdges[0], geompyDC.GEOM._objref_GEOM_Object ):
4201 for i in range( len( reversedEdges )):
4202 reversedEdges[i] = self.mesh.geompyD.GetSubShapeID(self.mesh.geom, reversedEdges[i] )
4203 entry = self.MainShapeEntry()
4204 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
4205 UseExisting=UseExisting,
4206 CompareMethod=self.CompareFixedPoints1D)
4207 hyp.SetPoints(points)
4208 hyp.SetNbSegments(nbSegs)
4209 hyp.SetReversedEdges(reversedEdges)
4210 hyp.SetObjectEntry(entry)
4214 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4215 ## as the given arguments
4216 def CompareFixedPoints1D(self, hyp, args):
4217 if hyp.GetPoints() == args[0]:
4218 if hyp.GetNbSegments() == args[1]:
4219 if hyp.GetReversedEdges() == args[2]:
4220 if not args[2] or hyp.GetObjectEntry() == args[3]:
4226 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4227 # @param start defines the length of the first segment
4228 # @param end defines the length of the last segment
4229 # @param reversedEdges is a list of edges to mesh using reversed orientation
4230 # @param UseExisting if ==true - searches for an existing hypothesis created with
4231 # the same parameters, else (default) - creates a new one
4232 # @return an instance of StdMeshers_StartEndLength hypothesis
4233 # @ingroup l3_hypos_1dhyps
4234 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4235 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4236 reversedEdges, UseExisting = [], reversedEdges
4237 entry = self.MainShapeEntry()
4238 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
4239 UseExisting=UseExisting,
4240 CompareMethod=self.CompareStartEndLength)
4241 hyp.SetStartLength(start)
4242 hyp.SetEndLength(end)
4243 hyp.SetReversedEdges( reversedEdges )
4244 hyp.SetObjectEntry( entry )
4247 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4248 def CompareStartEndLength(self, hyp, args):
4249 if IsEqual(hyp.GetLength(1), args[0]):
4250 if IsEqual(hyp.GetLength(0), args[1]):
4251 if hyp.GetReversedEdges() == args[2]:
4252 if not args[2] or hyp.GetObjectEntry() == args[3]:
4256 ## Defines "Deflection1D" hypothesis
4257 # @param d for the deflection
4258 # @param UseExisting if ==true - searches for an existing hypothesis created with
4259 # the same parameters, else (default) - create a new one
4260 # @ingroup l3_hypos_1dhyps
4261 def Deflection1D(self, d, UseExisting=0):
4262 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4263 CompareMethod=self.CompareDeflection1D)
4264 hyp.SetDeflection(d)
4267 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4268 def CompareDeflection1D(self, hyp, args):
4269 return IsEqual(hyp.GetDeflection(), args[0])
4271 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4272 # the opposite side in case of quadrangular faces
4273 # @ingroup l3_hypos_additi
4274 def Propagation(self):
4275 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4277 ## Defines "AutomaticLength" hypothesis
4278 # @param fineness for the fineness [0-1]
4279 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4280 # same parameters, else (default) - create a new one
4281 # @ingroup l3_hypos_1dhyps
4282 def AutomaticLength(self, fineness=0, UseExisting=0):
4283 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4284 CompareMethod=self.CompareAutomaticLength)
4285 hyp.SetFineness( fineness )
4288 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4289 def CompareAutomaticLength(self, hyp, args):
4290 return IsEqual(hyp.GetFineness(), args[0])
4292 ## Defines "SegmentLengthAroundVertex" hypothesis
4293 # @param length for the segment length
4294 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4295 # Any other integer value means that the hypothesis will be set on the
4296 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4297 # @param UseExisting if ==true - searches for an existing hypothesis created with
4298 # the same parameters, else (default) - creates a new one
4299 # @ingroup l3_algos_segmarv
4300 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4302 store_geom = self.geom
4303 if type(vertex) is types.IntType:
4304 if vertex == 0 or vertex == 1:
4305 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
4313 if self.geom is None:
4314 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4316 name = GetName(self.geom)
4319 piece = self.mesh.geom
4320 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
4321 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
4323 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4325 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4327 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4328 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4330 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4331 CompareMethod=self.CompareLengthNearVertex)
4332 self.geom = store_geom
4333 hyp.SetLength( length )
4336 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4337 # @ingroup l3_algos_segmarv
4338 def CompareLengthNearVertex(self, hyp, args):
4339 return IsEqual(hyp.GetLength(), args[0])
4341 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4342 # If the 2D mesher sees that all boundary edges are quadratic,
4343 # it generates quadratic faces, else it generates linear faces using
4344 # medium nodes as if they are vertices.
4345 # The 3D mesher generates quadratic volumes only if all boundary faces
4346 # are quadratic, else it fails.
4348 # @ingroup l3_hypos_additi
4349 def QuadraticMesh(self):
4350 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4353 # Public class: Mesh_CompositeSegment
4354 # --------------------------
4356 ## Defines a segment 1D algorithm for discretization
4358 # @ingroup l3_algos_basic
4359 class Mesh_CompositeSegment(Mesh_Segment):
4361 ## Private constructor.
4362 def __init__(self, mesh, geom=0):
4363 self.Create(mesh, geom, "CompositeSegment_1D")
4366 # Public class: Mesh_Segment_Python
4367 # ---------------------------------
4369 ## Defines a segment 1D algorithm for discretization with python function
4371 # @ingroup l3_algos_basic
4372 class Mesh_Segment_Python(Mesh_Segment):
4374 ## Private constructor.
4375 def __init__(self, mesh, geom=0):
4376 import Python1dPlugin
4377 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4379 ## Defines "PythonSplit1D" hypothesis
4380 # @param n for the number of segments that cut an edge
4381 # @param func for the python function that calculates the length of all segments
4382 # @param UseExisting if ==true - searches for the existing hypothesis created with
4383 # the same parameters, else (default) - creates a new one
4384 # @ingroup l3_hypos_1dhyps
4385 def PythonSplit1D(self, n, func, UseExisting=0):
4386 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4387 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4388 hyp.SetNumberOfSegments(n)
4389 hyp.SetPythonLog10RatioFunction(func)
4392 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4393 def ComparePythonSplit1D(self, hyp, args):
4394 #if hyp.GetNumberOfSegments() == args[0]:
4395 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4399 # Public class: Mesh_Triangle
4400 # ---------------------------
4402 ## Defines a triangle 2D algorithm
4404 # @ingroup l3_algos_basic
4405 class Mesh_Triangle(Mesh_Algorithm):
4414 ## Private constructor.
4415 def __init__(self, mesh, algoType, geom=0):
4416 Mesh_Algorithm.__init__(self)
4418 self.algoType = algoType
4419 if algoType == MEFISTO:
4420 self.Create(mesh, geom, "MEFISTO_2D")
4422 elif algoType == BLSURF:
4424 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4425 #self.SetPhysicalMesh() - PAL19680
4426 elif algoType == NETGEN:
4428 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4430 elif algoType == NETGEN_2D:
4432 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4435 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4436 # @param area for the maximum area of each triangle
4437 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4438 # same parameters, else (default) - creates a new one
4440 # Only for algoType == MEFISTO || NETGEN_2D
4441 # @ingroup l3_hypos_2dhyps
4442 def MaxElementArea(self, area, UseExisting=0):
4443 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4444 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4445 CompareMethod=self.CompareMaxElementArea)
4446 elif self.algoType == NETGEN:
4447 hyp = self.Parameters(SIMPLE)
4448 hyp.SetMaxElementArea(area)
4451 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4452 def CompareMaxElementArea(self, hyp, args):
4453 return IsEqual(hyp.GetMaxElementArea(), args[0])
4455 ## Defines "LengthFromEdges" hypothesis to build triangles
4456 # based on the length of the edges taken from the wire
4458 # Only for algoType == MEFISTO || NETGEN_2D
4459 # @ingroup l3_hypos_2dhyps
4460 def LengthFromEdges(self):
4461 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4462 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4464 elif self.algoType == NETGEN:
4465 hyp = self.Parameters(SIMPLE)
4466 hyp.LengthFromEdges()
4469 ## Sets a way to define size of mesh elements to generate.
4470 # @param thePhysicalMesh is: DefaultSize or Custom.
4471 # @ingroup l3_hypos_blsurf
4472 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4473 # Parameter of BLSURF algo
4474 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4476 ## Sets size of mesh elements to generate.
4477 # @ingroup l3_hypos_blsurf
4478 def SetPhySize(self, theVal):
4479 # Parameter of BLSURF algo
4480 self.SetPhysicalMesh(1) #Custom - else why to set the size?
4481 self.Parameters().SetPhySize(theVal)
4483 ## Sets lower boundary of mesh element size (PhySize).
4484 # @ingroup l3_hypos_blsurf
4485 def SetPhyMin(self, theVal=-1):
4486 # Parameter of BLSURF algo
4487 self.Parameters().SetPhyMin(theVal)
4489 ## Sets upper boundary of mesh element size (PhySize).
4490 # @ingroup l3_hypos_blsurf
4491 def SetPhyMax(self, theVal=-1):
4492 # Parameter of BLSURF algo
4493 self.Parameters().SetPhyMax(theVal)
4495 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4496 # @param theGeometricMesh is: 0 (None) or 1 (Custom)
4497 # @ingroup l3_hypos_blsurf
4498 def SetGeometricMesh(self, theGeometricMesh=0):
4499 # Parameter of BLSURF algo
4500 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4501 self.params.SetGeometricMesh(theGeometricMesh)
4503 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4504 # @ingroup l3_hypos_blsurf
4505 def SetAngleMeshS(self, theVal=_angleMeshS):
4506 # Parameter of BLSURF algo
4507 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4508 self.params.SetAngleMeshS(theVal)
4510 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4511 # @ingroup l3_hypos_blsurf
4512 def SetAngleMeshC(self, theVal=_angleMeshS):
4513 # Parameter of BLSURF algo
4514 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4515 self.params.SetAngleMeshC(theVal)
4517 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4518 # @ingroup l3_hypos_blsurf
4519 def SetGeoMin(self, theVal=-1):
4520 # Parameter of BLSURF algo
4521 self.Parameters().SetGeoMin(theVal)
4523 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4524 # @ingroup l3_hypos_blsurf
4525 def SetGeoMax(self, theVal=-1):
4526 # Parameter of BLSURF algo
4527 self.Parameters().SetGeoMax(theVal)
4529 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4530 # @ingroup l3_hypos_blsurf
4531 def SetGradation(self, theVal=_gradation):
4532 # Parameter of BLSURF algo
4533 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4534 self.params.SetGradation(theVal)
4536 ## Sets topology usage way.
4537 # @param way defines how mesh conformity is assured <ul>
4538 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4539 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4540 # @ingroup l3_hypos_blsurf
4541 def SetTopology(self, way):
4542 # Parameter of BLSURF algo
4543 self.Parameters().SetTopology(way)
4545 ## To respect geometrical edges or not.
4546 # @ingroup l3_hypos_blsurf
4547 def SetDecimesh(self, toIgnoreEdges=False):
4548 # Parameter of BLSURF algo
4549 self.Parameters().SetDecimesh(toIgnoreEdges)
4551 ## Sets verbosity level in the range 0 to 100.
4552 # @ingroup l3_hypos_blsurf
4553 def SetVerbosity(self, level):
4554 # Parameter of BLSURF algo
4555 self.Parameters().SetVerbosity(level)
4557 ## Sets advanced option value.
4558 # @ingroup l3_hypos_blsurf
4559 def SetOptionValue(self, optionName, level):
4560 # Parameter of BLSURF algo
4561 self.Parameters().SetOptionValue(optionName,level)
4563 ## Sets QuadAllowed flag.
4564 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
4565 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4566 def SetQuadAllowed(self, toAllow=True):
4567 if self.algoType == NETGEN_2D:
4568 if toAllow: # add QuadranglePreference
4569 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4570 else: # remove QuadranglePreference
4571 for hyp in self.mesh.GetHypothesisList( self.geom ):
4572 if hyp.GetName() == "QuadranglePreference":
4573 self.mesh.RemoveHypothesis( self.geom, hyp )
4578 if self.Parameters():
4579 self.params.SetQuadAllowed(toAllow)
4582 ## Defines hypothesis having several parameters
4584 # @ingroup l3_hypos_netgen
4585 def Parameters(self, which=SOLE):
4588 if self.algoType == NETGEN:
4590 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4591 "libNETGENEngine.so", UseExisting=0)
4593 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4594 "libNETGENEngine.so", UseExisting=0)
4596 elif self.algoType == MEFISTO:
4597 print "Mefisto algo support no multi-parameter hypothesis"
4599 elif self.algoType == NETGEN_2D:
4600 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4601 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4603 elif self.algoType == BLSURF:
4604 self.params = self.Hypothesis("BLSURF_Parameters", [],
4605 "libBLSURFEngine.so", UseExisting=0)
4608 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4613 # Only for algoType == NETGEN
4614 # @ingroup l3_hypos_netgen
4615 def SetMaxSize(self, theSize):
4616 if self.Parameters():
4617 self.params.SetMaxSize(theSize)
4619 ## Sets SecondOrder flag
4621 # Only for algoType == NETGEN
4622 # @ingroup l3_hypos_netgen
4623 def SetSecondOrder(self, theVal):
4624 if self.Parameters():
4625 self.params.SetSecondOrder(theVal)
4627 ## Sets Optimize flag
4629 # Only for algoType == NETGEN
4630 # @ingroup l3_hypos_netgen
4631 def SetOptimize(self, theVal):
4632 if self.Parameters():
4633 self.params.SetOptimize(theVal)
4636 # @param theFineness is:
4637 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4639 # Only for algoType == NETGEN
4640 # @ingroup l3_hypos_netgen
4641 def SetFineness(self, theFineness):
4642 if self.Parameters():
4643 self.params.SetFineness(theFineness)
4647 # Only for algoType == NETGEN
4648 # @ingroup l3_hypos_netgen
4649 def SetGrowthRate(self, theRate):
4650 if self.Parameters():
4651 self.params.SetGrowthRate(theRate)
4653 ## Sets NbSegPerEdge
4655 # Only for algoType == NETGEN
4656 # @ingroup l3_hypos_netgen
4657 def SetNbSegPerEdge(self, theVal):
4658 if self.Parameters():
4659 self.params.SetNbSegPerEdge(theVal)
4661 ## Sets NbSegPerRadius
4663 # Only for algoType == NETGEN
4664 # @ingroup l3_hypos_netgen
4665 def SetNbSegPerRadius(self, theVal):
4666 if self.Parameters():
4667 self.params.SetNbSegPerRadius(theVal)
4669 ## Sets number of segments overriding value set by SetLocalLength()
4671 # Only for algoType == NETGEN
4672 # @ingroup l3_hypos_netgen
4673 def SetNumberOfSegments(self, theVal):
4674 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4676 ## Sets number of segments overriding value set by SetNumberOfSegments()
4678 # Only for algoType == NETGEN
4679 # @ingroup l3_hypos_netgen
4680 def SetLocalLength(self, theVal):
4681 self.Parameters(SIMPLE).SetLocalLength(theVal)
4686 # Public class: Mesh_Quadrangle
4687 # -----------------------------
4689 ## Defines a quadrangle 2D algorithm
4691 # @ingroup l3_algos_basic
4692 class Mesh_Quadrangle(Mesh_Algorithm):
4694 ## Private constructor.
4695 def __init__(self, mesh, geom=0):
4696 Mesh_Algorithm.__init__(self)
4697 self.Create(mesh, geom, "Quadrangle_2D")
4699 ## Defines "QuadranglePreference" hypothesis, forcing construction
4700 # of quadrangles if the number of nodes on the opposite edges is not the same
4701 # while the total number of nodes on edges is even
4703 # @ingroup l3_hypos_additi
4704 def QuadranglePreference(self):
4705 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4706 CompareMethod=self.CompareEqualHyp)
4709 ## Defines "TrianglePreference" hypothesis, forcing construction
4710 # of triangles in the refinement area if the number of nodes
4711 # on the opposite edges is not the same
4713 # @ingroup l3_hypos_additi
4714 def TrianglePreference(self):
4715 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4716 CompareMethod=self.CompareEqualHyp)
4719 ## Defines "QuadrangleParams" hypothesis
4720 # @param vertex: vertex of a trilateral geometrical face, around which triangles
4721 # will be created while other elements will be quadrangles.
4722 # Vertex can be either a GEOM_Object or a vertex ID within the
4724 # @param UseExisting: if ==true - searches for the existing hypothesis created with
4725 # the same parameters, else (default) - creates a new one
4727 # @ingroup l3_hypos_additi
4728 def TriangleVertex(self, vertex, UseExisting=0):
4730 if isinstance( vertexID, geompyDC.GEOM._objref_GEOM_Object ):
4731 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, vertex )
4732 hyp = self.Hypothesis("QuadrangleParams", [vertexID], UseExisting = UseExisting,
4733 CompareMethod=lambda hyp,args: hyp.GetTriaVertex()==args[0])
4734 hyp.SetTriaVertex( vertexID )
4738 # Public class: Mesh_Tetrahedron
4739 # ------------------------------
4741 ## Defines a tetrahedron 3D algorithm
4743 # @ingroup l3_algos_basic
4744 class Mesh_Tetrahedron(Mesh_Algorithm):
4749 ## Private constructor.
4750 def __init__(self, mesh, algoType, geom=0):
4751 Mesh_Algorithm.__init__(self)
4753 if algoType == NETGEN:
4755 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4758 elif algoType == FULL_NETGEN:
4760 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4763 elif algoType == GHS3D:
4765 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4768 elif algoType == GHS3DPRL:
4769 CheckPlugin(GHS3DPRL)
4770 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4773 self.algoType = algoType
4775 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4776 # @param vol for the maximum volume of each tetrahedron
4777 # @param UseExisting if ==true - searches for the existing hypothesis created with
4778 # the same parameters, else (default) - creates a new one
4779 # @ingroup l3_hypos_maxvol
4780 def MaxElementVolume(self, vol, UseExisting=0):
4781 if self.algoType == NETGEN:
4782 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4783 CompareMethod=self.CompareMaxElementVolume)
4784 hyp.SetMaxElementVolume(vol)
4786 elif self.algoType == FULL_NETGEN:
4787 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4790 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4791 def CompareMaxElementVolume(self, hyp, args):
4792 return IsEqual(hyp.GetMaxElementVolume(), args[0])
4794 ## Defines hypothesis having several parameters
4796 # @ingroup l3_hypos_netgen
4797 def Parameters(self, which=SOLE):
4801 if self.algoType == FULL_NETGEN:
4803 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4804 "libNETGENEngine.so", UseExisting=0)
4806 self.params = self.Hypothesis("NETGEN_Parameters", [],
4807 "libNETGENEngine.so", UseExisting=0)
4810 if self.algoType == GHS3D:
4811 self.params = self.Hypothesis("GHS3D_Parameters", [],
4812 "libGHS3DEngine.so", UseExisting=0)
4815 if self.algoType == GHS3DPRL:
4816 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4817 "libGHS3DPRLEngine.so", UseExisting=0)
4820 print "Algo supports no multi-parameter hypothesis"
4824 # Parameter of FULL_NETGEN
4825 # @ingroup l3_hypos_netgen
4826 def SetMaxSize(self, theSize):
4827 self.Parameters().SetMaxSize(theSize)
4829 ## Sets SecondOrder flag
4830 # Parameter of FULL_NETGEN
4831 # @ingroup l3_hypos_netgen
4832 def SetSecondOrder(self, theVal):
4833 self.Parameters().SetSecondOrder(theVal)
4835 ## Sets Optimize flag
4836 # Parameter of FULL_NETGEN
4837 # @ingroup l3_hypos_netgen
4838 def SetOptimize(self, theVal):
4839 self.Parameters().SetOptimize(theVal)
4842 # @param theFineness is:
4843 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4844 # Parameter of FULL_NETGEN
4845 # @ingroup l3_hypos_netgen
4846 def SetFineness(self, theFineness):
4847 self.Parameters().SetFineness(theFineness)
4850 # Parameter of FULL_NETGEN
4851 # @ingroup l3_hypos_netgen
4852 def SetGrowthRate(self, theRate):
4853 self.Parameters().SetGrowthRate(theRate)
4855 ## Sets NbSegPerEdge
4856 # Parameter of FULL_NETGEN
4857 # @ingroup l3_hypos_netgen
4858 def SetNbSegPerEdge(self, theVal):
4859 self.Parameters().SetNbSegPerEdge(theVal)
4861 ## Sets NbSegPerRadius
4862 # Parameter of FULL_NETGEN
4863 # @ingroup l3_hypos_netgen
4864 def SetNbSegPerRadius(self, theVal):
4865 self.Parameters().SetNbSegPerRadius(theVal)
4867 ## Sets number of segments overriding value set by SetLocalLength()
4868 # Only for algoType == NETGEN_FULL
4869 # @ingroup l3_hypos_netgen
4870 def SetNumberOfSegments(self, theVal):
4871 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4873 ## Sets number of segments overriding value set by SetNumberOfSegments()
4874 # Only for algoType == NETGEN_FULL
4875 # @ingroup l3_hypos_netgen
4876 def SetLocalLength(self, theVal):
4877 self.Parameters(SIMPLE).SetLocalLength(theVal)
4879 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4880 # Overrides value set by LengthFromEdges()
4881 # Only for algoType == NETGEN_FULL
4882 # @ingroup l3_hypos_netgen
4883 def MaxElementArea(self, area):
4884 self.Parameters(SIMPLE).SetMaxElementArea(area)
4886 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4887 # Overrides value set by MaxElementArea()
4888 # Only for algoType == NETGEN_FULL
4889 # @ingroup l3_hypos_netgen
4890 def LengthFromEdges(self):
4891 self.Parameters(SIMPLE).LengthFromEdges()
4893 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4894 # Overrides value set by MaxElementVolume()
4895 # Only for algoType == NETGEN_FULL
4896 # @ingroup l3_hypos_netgen
4897 def LengthFromFaces(self):
4898 self.Parameters(SIMPLE).LengthFromFaces()
4900 ## To mesh "holes" in a solid or not. Default is to mesh.
4901 # @ingroup l3_hypos_ghs3dh
4902 def SetToMeshHoles(self, toMesh):
4903 # Parameter of GHS3D
4904 self.Parameters().SetToMeshHoles(toMesh)
4906 ## Set Optimization level:
4907 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
4908 # Strong_Optimization.
4909 # Default is Standard_Optimization
4910 # @ingroup l3_hypos_ghs3dh
4911 def SetOptimizationLevel(self, level):
4912 # Parameter of GHS3D
4913 self.Parameters().SetOptimizationLevel(level)
4915 ## Maximal size of memory to be used by the algorithm (in Megabytes).
4916 # @ingroup l3_hypos_ghs3dh
4917 def SetMaximumMemory(self, MB):
4918 # Advanced parameter of GHS3D
4919 self.Parameters().SetMaximumMemory(MB)
4921 ## Initial size of memory to be used by the algorithm (in Megabytes) in
4922 # automatic memory adjustment mode.
4923 # @ingroup l3_hypos_ghs3dh
4924 def SetInitialMemory(self, MB):
4925 # Advanced parameter of GHS3D
4926 self.Parameters().SetInitialMemory(MB)
4928 ## Path to working directory.
4929 # @ingroup l3_hypos_ghs3dh
4930 def SetWorkingDirectory(self, path):
4931 # Advanced parameter of GHS3D
4932 self.Parameters().SetWorkingDirectory(path)
4934 ## To keep working files or remove them. Log file remains in case of errors anyway.
4935 # @ingroup l3_hypos_ghs3dh
4936 def SetKeepFiles(self, toKeep):
4937 # Advanced parameter of GHS3D and GHS3DPRL
4938 self.Parameters().SetKeepFiles(toKeep)
4940 ## To set verbose level [0-10]. <ul>
4941 #<li> 0 - no standard output,
4942 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4943 # indicates when the final mesh is being saved. In addition the software
4944 # gives indication regarding the CPU time.
4945 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4946 # histogram of the skin mesh, quality statistics histogram together with
4947 # the characteristics of the final mesh.</ul>
4948 # @ingroup l3_hypos_ghs3dh
4949 def SetVerboseLevel(self, level):
4950 # Advanced parameter of GHS3D
4951 self.Parameters().SetVerboseLevel(level)
4953 ## To create new nodes.
4954 # @ingroup l3_hypos_ghs3dh
4955 def SetToCreateNewNodes(self, toCreate):
4956 # Advanced parameter of GHS3D
4957 self.Parameters().SetToCreateNewNodes(toCreate)
4959 ## To use boundary recovery version which tries to create mesh on a very poor
4960 # quality surface mesh.
4961 # @ingroup l3_hypos_ghs3dh
4962 def SetToUseBoundaryRecoveryVersion(self, toUse):
4963 # Advanced parameter of GHS3D
4964 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4966 ## Sets command line option as text.
4967 # @ingroup l3_hypos_ghs3dh
4968 def SetTextOption(self, option):
4969 # Advanced parameter of GHS3D
4970 self.Parameters().SetTextOption(option)
4972 ## Sets MED files name and path.
4973 def SetMEDName(self, value):
4974 self.Parameters().SetMEDName(value)
4976 ## Sets the number of partition of the initial mesh
4977 def SetNbPart(self, value):
4978 self.Parameters().SetNbPart(value)
4980 ## When big mesh, start tepal in background
4981 def SetBackground(self, value):
4982 self.Parameters().SetBackground(value)
4984 # Public class: Mesh_Hexahedron
4985 # ------------------------------
4987 ## Defines a hexahedron 3D algorithm
4989 # @ingroup l3_algos_basic
4990 class Mesh_Hexahedron(Mesh_Algorithm):
4995 ## Private constructor.
4996 def __init__(self, mesh, algoType=Hexa, geom=0):
4997 Mesh_Algorithm.__init__(self)
4999 self.algoType = algoType
5001 if algoType == Hexa:
5002 self.Create(mesh, geom, "Hexa_3D")
5005 elif algoType == Hexotic:
5006 CheckPlugin(Hexotic)
5007 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
5010 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
5011 # @ingroup l3_hypos_hexotic
5012 def MinMaxQuad(self, min=3, max=8, quad=True):
5013 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
5015 self.params.SetHexesMinLevel(min)
5016 self.params.SetHexesMaxLevel(max)
5017 self.params.SetHexoticQuadrangles(quad)
5020 # Deprecated, only for compatibility!
5021 # Public class: Mesh_Netgen
5022 # ------------------------------
5024 ## Defines a NETGEN-based 2D or 3D algorithm
5025 # that needs no discrete boundary (i.e. independent)
5027 # This class is deprecated, only for compatibility!
5030 # @ingroup l3_algos_basic
5031 class Mesh_Netgen(Mesh_Algorithm):
5035 ## Private constructor.
5036 def __init__(self, mesh, is3D, geom=0):
5037 Mesh_Algorithm.__init__(self)
5043 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5047 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
5050 ## Defines the hypothesis containing parameters of the algorithm
5051 def Parameters(self):
5053 hyp = self.Hypothesis("NETGEN_Parameters", [],
5054 "libNETGENEngine.so", UseExisting=0)
5056 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
5057 "libNETGENEngine.so", UseExisting=0)
5060 # Public class: Mesh_Projection1D
5061 # ------------------------------
5063 ## Defines a projection 1D algorithm
5064 # @ingroup l3_algos_proj
5066 class Mesh_Projection1D(Mesh_Algorithm):
5068 ## Private constructor.
5069 def __init__(self, mesh, geom=0):
5070 Mesh_Algorithm.__init__(self)
5071 self.Create(mesh, geom, "Projection_1D")
5073 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
5074 # a mesh pattern is taken, and, optionally, the association of vertices
5075 # between the source edge and a target edge (to which a hypothesis is assigned)
5076 # @param edge from which nodes distribution is taken
5077 # @param mesh from which nodes distribution is taken (optional)
5078 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
5079 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
5080 # to associate with \a srcV (optional)
5081 # @param UseExisting if ==true - searches for the existing hypothesis created with
5082 # the same parameters, else (default) - creates a new one
5083 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
5084 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
5086 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
5087 hyp.SetSourceEdge( edge )
5088 if not mesh is None and isinstance(mesh, Mesh):
5089 mesh = mesh.GetMesh()
5090 hyp.SetSourceMesh( mesh )
5091 hyp.SetVertexAssociation( srcV, tgtV )
5094 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
5095 #def CompareSourceEdge(self, hyp, args):
5096 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
5100 # Public class: Mesh_Projection2D
5101 # ------------------------------
5103 ## Defines a projection 2D algorithm
5104 # @ingroup l3_algos_proj
5106 class Mesh_Projection2D(Mesh_Algorithm):
5108 ## Private constructor.
5109 def __init__(self, mesh, geom=0):
5110 Mesh_Algorithm.__init__(self)
5111 self.Create(mesh, geom, "Projection_2D")
5113 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
5114 # a mesh pattern is taken, and, optionally, the association of vertices
5115 # between the source face and the target face (to which a hypothesis is assigned)
5116 # @param face from which the mesh pattern is taken
5117 # @param mesh from which the mesh pattern is taken (optional)
5118 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
5119 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
5120 # to associate with \a srcV1 (optional)
5121 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
5122 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
5123 # to associate with \a srcV2 (optional)
5124 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
5125 # the same parameters, else (default) - forces the creation a new one
5127 # Note: all association vertices must belong to one edge of a face
5128 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
5129 srcV2=None, tgtV2=None, UseExisting=0):
5130 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
5132 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
5133 hyp.SetSourceFace( face )
5134 if not mesh is None and isinstance(mesh, Mesh):
5135 mesh = mesh.GetMesh()
5136 hyp.SetSourceMesh( mesh )
5137 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5140 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
5141 #def CompareSourceFace(self, hyp, args):
5142 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
5145 # Public class: Mesh_Projection3D
5146 # ------------------------------
5148 ## Defines a projection 3D algorithm
5149 # @ingroup l3_algos_proj
5151 class Mesh_Projection3D(Mesh_Algorithm):
5153 ## Private constructor.
5154 def __init__(self, mesh, geom=0):
5155 Mesh_Algorithm.__init__(self)
5156 self.Create(mesh, geom, "Projection_3D")
5158 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
5159 # the mesh pattern is taken, and, optionally, the association of vertices
5160 # between the source and the target solid (to which a hipothesis is assigned)
5161 # @param solid from where the mesh pattern is taken
5162 # @param mesh from where the mesh pattern is taken (optional)
5163 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
5164 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
5165 # to associate with \a srcV1 (optional)
5166 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
5167 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
5168 # to associate with \a srcV2 (optional)
5169 # @param UseExisting - if ==true - searches for the existing hypothesis created with
5170 # the same parameters, else (default) - creates a new one
5172 # Note: association vertices must belong to one edge of a solid
5173 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
5174 srcV2=0, tgtV2=0, UseExisting=0):
5175 hyp = self.Hypothesis("ProjectionSource3D",
5176 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
5178 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
5179 hyp.SetSource3DShape( solid )
5180 if not mesh is None and isinstance(mesh, Mesh):
5181 mesh = mesh.GetMesh()
5182 hyp.SetSourceMesh( mesh )
5183 if srcV1 and srcV2 and tgtV1 and tgtV2:
5184 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5185 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
5188 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
5189 #def CompareSourceShape3D(self, hyp, args):
5190 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
5194 # Public class: Mesh_Prism
5195 # ------------------------
5197 ## Defines a 3D extrusion algorithm
5198 # @ingroup l3_algos_3dextr
5200 class Mesh_Prism3D(Mesh_Algorithm):
5202 ## Private constructor.
5203 def __init__(self, mesh, geom=0):
5204 Mesh_Algorithm.__init__(self)
5205 self.Create(mesh, geom, "Prism_3D")
5207 # Public class: Mesh_RadialPrism
5208 # -------------------------------
5210 ## Defines a Radial Prism 3D algorithm
5211 # @ingroup l3_algos_radialp
5213 class Mesh_RadialPrism3D(Mesh_Algorithm):
5215 ## Private constructor.
5216 def __init__(self, mesh, geom=0):
5217 Mesh_Algorithm.__init__(self)
5218 self.Create(mesh, geom, "RadialPrism_3D")
5220 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
5221 self.nbLayers = None
5223 ## Return 3D hypothesis holding the 1D one
5224 def Get3DHypothesis(self):
5225 return self.distribHyp
5227 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5228 # hypothesis. Returns the created hypothesis
5229 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5230 #print "OwnHypothesis",hypType
5231 if not self.nbLayers is None:
5232 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5233 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5234 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5235 self.mesh.smeshpyD.SetCurrentStudy( None )
5236 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5237 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5238 self.distribHyp.SetLayerDistribution( hyp )
5241 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
5242 # prisms to build between the inner and outer shells
5243 # @param n number of layers
5244 # @param UseExisting if ==true - searches for the existing hypothesis created with
5245 # the same parameters, else (default) - creates a new one
5246 def NumberOfLayers(self, n, UseExisting=0):
5247 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5248 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
5249 CompareMethod=self.CompareNumberOfLayers)
5250 self.nbLayers.SetNumberOfLayers( n )
5251 return self.nbLayers
5253 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5254 def CompareNumberOfLayers(self, hyp, args):
5255 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5257 ## Defines "LocalLength" hypothesis, specifying the segment length
5258 # to build between the inner and the outer shells
5259 # @param l the length of segments
5260 # @param p the precision of rounding
5261 def LocalLength(self, l, p=1e-07):
5262 hyp = self.OwnHypothesis("LocalLength", [l,p])
5267 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
5268 # prisms to build between the inner and the outer shells.
5269 # @param n the number of layers
5270 # @param s the scale factor (optional)
5271 def NumberOfSegments(self, n, s=[]):
5273 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5275 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5276 hyp.SetDistrType( 1 )
5277 hyp.SetScaleFactor(s)
5278 hyp.SetNumberOfSegments(n)
5281 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5282 # to build between the inner and the outer shells with a length that changes in arithmetic progression
5283 # @param start the length of the first segment
5284 # @param end the length of the last segment
5285 def Arithmetic1D(self, start, end ):
5286 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5287 hyp.SetLength(start, 1)
5288 hyp.SetLength(end , 0)
5291 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5292 # to build between the inner and the outer shells as geometric length increasing
5293 # @param start for the length of the first segment
5294 # @param end for the length of the last segment
5295 def StartEndLength(self, start, end):
5296 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5297 hyp.SetLength(start, 1)
5298 hyp.SetLength(end , 0)
5301 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5302 # to build between the inner and outer shells
5303 # @param fineness defines the quality of the mesh within the range [0-1]
5304 def AutomaticLength(self, fineness=0):
5305 hyp = self.OwnHypothesis("AutomaticLength")
5306 hyp.SetFineness( fineness )
5309 # Public class: Mesh_RadialQuadrangle1D2D
5310 # -------------------------------
5312 ## Defines a Radial Quadrangle 1D2D algorithm
5313 # @ingroup l2_algos_radialq
5315 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
5317 ## Private constructor.
5318 def __init__(self, mesh, geom=0):
5319 Mesh_Algorithm.__init__(self)
5320 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5322 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
5323 self.nbLayers = None
5325 ## Return 2D hypothesis holding the 1D one
5326 def Get2DHypothesis(self):
5327 return self.distribHyp
5329 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5330 # hypothesis. Returns the created hypothesis
5331 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5332 #print "OwnHypothesis",hypType
5334 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5335 if self.distribHyp is None:
5336 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5338 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5339 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5340 self.mesh.smeshpyD.SetCurrentStudy( None )
5341 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5342 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5343 self.distribHyp.SetLayerDistribution( hyp )
5346 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
5347 # @param n number of layers
5348 # @param UseExisting if ==true - searches for the existing hypothesis created with
5349 # the same parameters, else (default) - creates a new one
5350 def NumberOfLayers(self, n, UseExisting=0):
5352 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5353 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5354 CompareMethod=self.CompareNumberOfLayers)
5355 self.nbLayers.SetNumberOfLayers( n )
5356 return self.nbLayers
5358 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5359 def CompareNumberOfLayers(self, hyp, args):
5360 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5362 ## Defines "LocalLength" hypothesis, specifying the segment length
5363 # @param l the length of segments
5364 # @param p the precision of rounding
5365 def LocalLength(self, l, p=1e-07):
5366 hyp = self.OwnHypothesis("LocalLength", [l,p])
5371 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5372 # @param n the number of layers
5373 # @param s the scale factor (optional)
5374 def NumberOfSegments(self, n, s=[]):
5376 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5378 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5379 hyp.SetDistrType( 1 )
5380 hyp.SetScaleFactor(s)
5381 hyp.SetNumberOfSegments(n)
5384 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5385 # with a length that changes in arithmetic progression
5386 # @param start the length of the first segment
5387 # @param end the length of the last segment
5388 def Arithmetic1D(self, start, end ):
5389 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5390 hyp.SetLength(start, 1)
5391 hyp.SetLength(end , 0)
5394 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5395 # as geometric length increasing
5396 # @param start for the length of the first segment
5397 # @param end for the length of the last segment
5398 def StartEndLength(self, start, end):
5399 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5400 hyp.SetLength(start, 1)
5401 hyp.SetLength(end , 0)
5404 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5405 # @param fineness defines the quality of the mesh within the range [0-1]
5406 def AutomaticLength(self, fineness=0):
5407 hyp = self.OwnHypothesis("AutomaticLength")
5408 hyp.SetFineness( fineness )
5412 # Private class: Mesh_UseExisting
5413 # -------------------------------
5414 class Mesh_UseExisting(Mesh_Algorithm):
5416 def __init__(self, dim, mesh, geom=0):
5418 self.Create(mesh, geom, "UseExisting_1D")
5420 self.Create(mesh, geom, "UseExisting_2D")
5423 import salome_notebook
5424 notebook = salome_notebook.notebook
5426 ##Return values of the notebook variables
5427 def ParseParameters(last, nbParams,nbParam, value):
5431 listSize = len(last)
5432 for n in range(0,nbParams):
5434 if counter < listSize:
5435 strResult = strResult + last[counter]
5437 strResult = strResult + ""
5439 if isinstance(value, str):
5440 if notebook.isVariable(value):
5441 result = notebook.get(value)
5442 strResult=strResult+value
5444 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
5446 strResult=strResult+str(value)
5448 if nbParams - 1 != counter:
5449 strResult=strResult+var_separator #":"
5451 return result, strResult
5453 #Wrapper class for StdMeshers_LocalLength hypothesis
5454 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5456 ## Set Length parameter value
5457 # @param length numerical value or name of variable from notebook
5458 def SetLength(self, length):
5459 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
5460 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5461 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
5463 ## Set Precision parameter value
5464 # @param precision numerical value or name of variable from notebook
5465 def SetPrecision(self, precision):
5466 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
5467 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5468 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5470 #Registering the new proxy for LocalLength
5471 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5474 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5475 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5477 def SetLayerDistribution(self, hypo):
5478 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
5479 hypo.ClearParameters();
5480 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5482 #Registering the new proxy for LayerDistribution
5483 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5485 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5486 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5488 ## Set Length parameter value
5489 # @param length numerical value or name of variable from notebook
5490 def SetLength(self, length):
5491 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
5492 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
5493 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5495 #Registering the new proxy for SegmentLengthAroundVertex
5496 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5499 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5500 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5502 ## Set Length parameter value
5503 # @param length numerical value or name of variable from notebook
5504 # @param isStart true is length is Start Length, otherwise false
5505 def SetLength(self, length, isStart):
5509 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
5510 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
5511 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
5513 #Registering the new proxy for Arithmetic1D
5514 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
5516 #Wrapper class for StdMeshers_Deflection1D hypothesis
5517 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
5519 ## Set Deflection parameter value
5520 # @param deflection numerical value or name of variable from notebook
5521 def SetDeflection(self, deflection):
5522 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
5523 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
5524 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
5526 #Registering the new proxy for Deflection1D
5527 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
5529 #Wrapper class for StdMeshers_StartEndLength hypothesis
5530 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
5532 ## Set Length parameter value
5533 # @param length numerical value or name of variable from notebook
5534 # @param isStart true is length is Start Length, otherwise false
5535 def SetLength(self, length, isStart):
5539 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
5540 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
5541 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
5543 #Registering the new proxy for StartEndLength
5544 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
5546 #Wrapper class for StdMeshers_MaxElementArea hypothesis
5547 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
5549 ## Set Max Element Area parameter value
5550 # @param area numerical value or name of variable from notebook
5551 def SetMaxElementArea(self, area):
5552 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
5553 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
5554 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
5556 #Registering the new proxy for MaxElementArea
5557 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
5560 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
5561 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
5563 ## Set Max Element Volume parameter value
5564 # @param volume numerical value or name of variable from notebook
5565 def SetMaxElementVolume(self, volume):
5566 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
5567 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
5568 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
5570 #Registering the new proxy for MaxElementVolume
5571 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
5574 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
5575 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
5577 ## Set Number Of Layers parameter value
5578 # @param nbLayers numerical value or name of variable from notebook
5579 def SetNumberOfLayers(self, nbLayers):
5580 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
5581 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
5582 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
5584 #Registering the new proxy for NumberOfLayers
5585 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
5587 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
5588 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
5590 ## Set Number Of Segments parameter value
5591 # @param nbSeg numerical value or name of variable from notebook
5592 def SetNumberOfSegments(self, nbSeg):
5593 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
5594 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
5595 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5596 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
5598 ## Set Scale Factor parameter value
5599 # @param factor numerical value or name of variable from notebook
5600 def SetScaleFactor(self, factor):
5601 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
5602 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5603 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
5605 #Registering the new proxy for NumberOfSegments
5606 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
5608 if not noNETGENPlugin:
5609 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
5610 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
5612 ## Set Max Size parameter value
5613 # @param maxsize numerical value or name of variable from notebook
5614 def SetMaxSize(self, maxsize):
5615 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5616 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
5617 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5618 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
5620 ## Set Growth Rate parameter value
5621 # @param value numerical value or name of variable from notebook
5622 def SetGrowthRate(self, value):
5623 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5624 value, parameters = ParseParameters(lastParameters,4,2,value)
5625 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5626 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
5628 ## Set Number of Segments per Edge parameter value
5629 # @param value numerical value or name of variable from notebook
5630 def SetNbSegPerEdge(self, value):
5631 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5632 value, parameters = ParseParameters(lastParameters,4,3,value)
5633 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5634 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
5636 ## Set Number of Segments per Radius parameter value
5637 # @param value numerical value or name of variable from notebook
5638 def SetNbSegPerRadius(self, value):
5639 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5640 value, parameters = ParseParameters(lastParameters,4,4,value)
5641 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5642 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
5644 #Registering the new proxy for NETGENPlugin_Hypothesis
5645 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5648 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5649 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5652 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5653 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5655 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5656 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5658 ## Set Number of Segments parameter value
5659 # @param nbSeg numerical value or name of variable from notebook
5660 def SetNumberOfSegments(self, nbSeg):
5661 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5662 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5663 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5664 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5666 ## Set Local Length parameter value
5667 # @param length numerical value or name of variable from notebook
5668 def SetLocalLength(self, length):
5669 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5670 length, parameters = ParseParameters(lastParameters,2,1,length)
5671 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5672 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
5674 ## Set Max Element Area parameter value
5675 # @param area numerical value or name of variable from notebook
5676 def SetMaxElementArea(self, area):
5677 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5678 area, parameters = ParseParameters(lastParameters,2,2,area)
5679 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5680 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
5682 def LengthFromEdges(self):
5683 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5685 value, parameters = ParseParameters(lastParameters,2,2,value)
5686 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5687 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
5689 #Registering the new proxy for NETGEN_SimpleParameters_2D
5690 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
5693 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
5694 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
5695 ## Set Max Element Volume parameter value
5696 # @param volume numerical value or name of variable from notebook
5697 def SetMaxElementVolume(self, volume):
5698 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5699 volume, parameters = ParseParameters(lastParameters,3,3,volume)
5700 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5701 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5703 def LengthFromFaces(self):
5704 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5706 value, parameters = ParseParameters(lastParameters,3,3,value)
5707 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5708 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5710 #Registering the new proxy for NETGEN_SimpleParameters_3D
5711 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5713 pass # if not noNETGENPlugin:
5715 class Pattern(SMESH._objref_SMESH_Pattern):
5717 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5719 if isinstance(theNodeIndexOnKeyPoint1,str):
5721 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5723 theNodeIndexOnKeyPoint1 -= 1
5724 theMesh.SetParameters(Parameters)
5725 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5727 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5730 if isinstance(theNode000Index,str):
5732 if isinstance(theNode001Index,str):
5734 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5736 theNode000Index -= 1
5738 theNode001Index -= 1
5739 theMesh.SetParameters(Parameters)
5740 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5742 #Registering the new proxy for Pattern
5743 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)