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
90 ## @defgroup l1_measurements Measurements
95 import SMESH # This is necessary for back compatibility
103 # import NETGENPlugin module if possible
111 # import GHS3DPlugin module if possible
119 # import GHS3DPRLPlugin module if possible
122 import GHS3DPRLPlugin
127 # import HexoticPlugin module if possible
135 # import BLSURFPlugin module if possible
143 ## @addtogroup l1_auxiliary
146 # Types of algorithms
159 NETGEN_1D2D3D = FULL_NETGEN
160 NETGEN_FULL = FULL_NETGEN
168 # MirrorType enumeration
169 POINT = SMESH_MeshEditor.POINT
170 AXIS = SMESH_MeshEditor.AXIS
171 PLANE = SMESH_MeshEditor.PLANE
173 # Smooth_Method enumeration
174 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
175 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
177 # Fineness enumeration (for NETGEN)
185 # Optimization level of GHS3D
187 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
188 # V4.1 (partialy redefines V3.1). Issue 0020574
189 None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization, Strong_Optimization = 0,1,2,3,4
191 # Topology treatment way of BLSURF
192 FromCAD, PreProcess, PreProcessPlus = 0,1,2
194 # Element size flag of BLSURF
195 DefaultSize, DefaultGeom, Custom = 0,0,1
197 PrecisionConfusion = 1e-07
199 # TopAbs_State enumeration
200 [TopAbs_IN, TopAbs_OUT, TopAbs_ON, TopAbs_UNKNOWN] = range(4)
202 # Methods of splitting a hexahedron into tetrahedra
203 Hex_5Tet, Hex_6Tet, Hex_24Tet = 1, 2, 3
205 ## 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_ElemGeomType:
777 # Checks the treshold
779 aCriterion.Threshold = self.EnumToLong(aTreshold)
781 if isinstance(aTreshold, int):
782 aCriterion.Threshold = aTreshold
784 print "Error: The treshold should be an integer or SMESH.GeometryType."
788 elif CritType == FT_GroupColor:
789 # Checks the treshold
791 aCriterion.ThresholdStr = self.ColorToString(aTreshold)
793 print "Error: The threshold value should be of SALOMEDS.Color type"
796 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
797 FT_FreeFaces, FT_LinearOrQuadratic]:
798 # At this point the treshold is unnecessary
799 if aTreshold == FT_LogicalNOT:
800 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
801 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
802 aCriterion.BinaryOp = aTreshold
806 aTreshold = float(aTreshold)
807 aCriterion.Threshold = aTreshold
809 print "Error: The treshold should be a number."
812 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
813 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
815 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
816 aCriterion.BinaryOp = self.EnumToLong(Treshold)
818 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
819 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
821 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
822 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
826 ## Creates a filter with the given parameters
827 # @param elementType the type of elements in the group
828 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
829 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
830 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
831 # @param UnaryOp FT_LogicalNOT or FT_Undefined
832 # @return SMESH_Filter
833 # @ingroup l1_controls
834 def GetFilter(self,elementType,
835 CritType=FT_Undefined,
838 UnaryOp=FT_Undefined):
839 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
840 aFilterMgr = self.CreateFilterManager()
841 aFilter = aFilterMgr.CreateFilter()
843 aCriteria.append(aCriterion)
844 aFilter.SetCriteria(aCriteria)
848 ## Creates a numerical functor by its type
849 # @param theCriterion FT_...; functor type
850 # @return SMESH_NumericalFunctor
851 # @ingroup l1_controls
852 def GetFunctor(self,theCriterion):
853 aFilterMgr = self.CreateFilterManager()
854 if theCriterion == FT_AspectRatio:
855 return aFilterMgr.CreateAspectRatio()
856 elif theCriterion == FT_AspectRatio3D:
857 return aFilterMgr.CreateAspectRatio3D()
858 elif theCriterion == FT_Warping:
859 return aFilterMgr.CreateWarping()
860 elif theCriterion == FT_MinimumAngle:
861 return aFilterMgr.CreateMinimumAngle()
862 elif theCriterion == FT_Taper:
863 return aFilterMgr.CreateTaper()
864 elif theCriterion == FT_Skew:
865 return aFilterMgr.CreateSkew()
866 elif theCriterion == FT_Area:
867 return aFilterMgr.CreateArea()
868 elif theCriterion == FT_Volume3D:
869 return aFilterMgr.CreateVolume3D()
870 elif theCriterion == FT_MaxElementLength2D:
871 return aFilterMgr.CreateMaxElementLength2D()
872 elif theCriterion == FT_MaxElementLength3D:
873 return aFilterMgr.CreateMaxElementLength3D()
874 elif theCriterion == FT_MultiConnection:
875 return aFilterMgr.CreateMultiConnection()
876 elif theCriterion == FT_MultiConnection2D:
877 return aFilterMgr.CreateMultiConnection2D()
878 elif theCriterion == FT_Length:
879 return aFilterMgr.CreateLength()
880 elif theCriterion == FT_Length2D:
881 return aFilterMgr.CreateLength2D()
883 print "Error: given parameter is not numerucal functor type."
885 ## Creates hypothesis
886 # @param theHType mesh hypothesis type (string)
887 # @param theLibName mesh plug-in library name
888 # @return created hypothesis instance
889 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
890 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
892 ## Gets the mesh stattistic
893 # @return dictionary type element - count of elements
894 # @ingroup l1_meshinfo
895 def GetMeshInfo(self, obj):
896 if isinstance( obj, Mesh ):
899 if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource):
900 values = obj.GetMeshInfo()
901 for i in range(SMESH.Entity_Last._v):
902 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
907 #Registering the new proxy for SMESH_Gen
908 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
914 ## This class allows defining and managing a mesh.
915 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
916 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
917 # new nodes and elements and by changing the existing entities), to get information
918 # about a mesh and to export a mesh into different formats.
927 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
928 # sets the GUI name of this mesh to \a name.
929 # @param smeshpyD an instance of smeshDC class
930 # @param geompyD an instance of geompyDC class
931 # @param obj Shape to be meshed or SMESH_Mesh object
932 # @param name Study name of the mesh
933 # @ingroup l2_construct
934 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
935 self.smeshpyD=smeshpyD
940 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
942 self.mesh = self.smeshpyD.CreateMesh(self.geom)
943 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
946 self.mesh = self.smeshpyD.CreateEmptyMesh()
948 self.smeshpyD.SetName(self.mesh, name)
950 self.smeshpyD.SetName(self.mesh, GetName(obj))
953 self.geom = self.mesh.GetShapeToMesh()
955 self.editor = self.mesh.GetMeshEditor()
957 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
958 # @param theMesh a SMESH_Mesh object
959 # @ingroup l2_construct
960 def SetMesh(self, theMesh):
962 self.geom = self.mesh.GetShapeToMesh()
964 ## Returns the mesh, that is an instance of SMESH_Mesh interface
965 # @return a SMESH_Mesh object
966 # @ingroup l2_construct
970 ## Gets the name of the mesh
971 # @return the name of the mesh as a string
972 # @ingroup l2_construct
974 name = GetName(self.GetMesh())
977 ## Sets a name to the mesh
978 # @param name a new name of the mesh
979 # @ingroup l2_construct
980 def SetName(self, name):
981 self.smeshpyD.SetName(self.GetMesh(), name)
983 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
984 # The subMesh object gives access to the IDs of nodes and elements.
985 # @param theSubObject a geometrical object (shape)
986 # @param theName a name for the submesh
987 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
988 # @ingroup l2_submeshes
989 def GetSubMesh(self, theSubObject, theName):
990 submesh = self.mesh.GetSubMesh(theSubObject, theName)
993 ## Returns the shape associated to the mesh
994 # @return a GEOM_Object
995 # @ingroup l2_construct
999 ## Associates the given shape to the mesh (entails the recreation of the mesh)
1000 # @param geom the shape to be meshed (GEOM_Object)
1001 # @ingroup l2_construct
1002 def SetShape(self, geom):
1003 self.mesh = self.smeshpyD.CreateMesh(geom)
1005 ## Returns true if the hypotheses are defined well
1006 # @param theSubObject a subshape of a mesh shape
1007 # @return True or False
1008 # @ingroup l2_construct
1009 def IsReadyToCompute(self, theSubObject):
1010 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
1012 ## Returns errors of hypotheses definition.
1013 # The list of errors is empty if everything is OK.
1014 # @param theSubObject a subshape of a mesh shape
1015 # @return a list of errors
1016 # @ingroup l2_construct
1017 def GetAlgoState(self, theSubObject):
1018 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
1020 ## Returns a geometrical object on which the given element was built.
1021 # The returned geometrical object, if not nil, is either found in the
1022 # study or published by this method with the given name
1023 # @param theElementID the id of the mesh element
1024 # @param theGeomName the user-defined name of the geometrical object
1025 # @return GEOM::GEOM_Object instance
1026 # @ingroup l2_construct
1027 def GetGeometryByMeshElement(self, theElementID, theGeomName):
1028 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
1030 ## Returns the mesh dimension depending on the dimension of the underlying shape
1031 # @return mesh dimension as an integer value [0,3]
1032 # @ingroup l1_auxiliary
1033 def MeshDimension(self):
1034 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
1035 if len( shells ) > 0 :
1037 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
1039 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
1045 ## Creates a segment discretization 1D algorithm.
1046 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
1047 # \n If the optional \a geom parameter is not set, this algorithm is global.
1048 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1049 # @param algo the type of the required algorithm. Possible values are:
1051 # - smesh.PYTHON for discretization via a python function,
1052 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
1053 # @param geom If defined is the subshape to be meshed
1054 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
1055 # @ingroup l3_algos_basic
1056 def Segment(self, algo=REGULAR, geom=0):
1057 ## if Segment(geom) is called by mistake
1058 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
1059 algo, geom = geom, algo
1060 if not algo: algo = REGULAR
1063 return Mesh_Segment(self, geom)
1064 elif algo == PYTHON:
1065 return Mesh_Segment_Python(self, geom)
1066 elif algo == COMPOSITE:
1067 return Mesh_CompositeSegment(self, geom)
1069 return Mesh_Segment(self, geom)
1071 ## Enables creation of nodes and segments usable by 2D algoritms.
1072 # The added nodes and segments must be bound to edges and vertices by
1073 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
1074 # If the optional \a geom parameter is not set, this algorithm is global.
1075 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1076 # @param geom the subshape to be manually meshed
1077 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
1078 # @ingroup l3_algos_basic
1079 def UseExistingSegments(self, geom=0):
1080 algo = Mesh_UseExisting(1,self,geom)
1081 return algo.GetAlgorithm()
1083 ## Enables creation of nodes and faces usable by 3D algoritms.
1084 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
1085 # and SetMeshElementOnShape()
1086 # If the optional \a geom parameter is not set, this algorithm is global.
1087 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1088 # @param geom the subshape to be manually meshed
1089 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1090 # @ingroup l3_algos_basic
1091 def UseExistingFaces(self, geom=0):
1092 algo = Mesh_UseExisting(2,self,geom)
1093 return algo.GetAlgorithm()
1095 ## Creates a triangle 2D algorithm for faces.
1096 # If the optional \a geom parameter is not set, this algorithm is global.
1097 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1098 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1099 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1100 # @return an instance of Mesh_Triangle algorithm
1101 # @ingroup l3_algos_basic
1102 def Triangle(self, algo=MEFISTO, geom=0):
1103 ## if Triangle(geom) is called by mistake
1104 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1107 return Mesh_Triangle(self, algo, geom)
1109 ## Creates a quadrangle 2D algorithm for faces.
1110 # If the optional \a geom parameter is not set, this algorithm is global.
1111 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1112 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1113 # @param algo values are: smesh.QUADRANGLE || smesh.RADIAL_QUAD
1114 # @return an instance of Mesh_Quadrangle algorithm
1115 # @ingroup l3_algos_basic
1116 def Quadrangle(self, geom=0, algo=QUADRANGLE):
1117 if algo==RADIAL_QUAD:
1118 return Mesh_RadialQuadrangle1D2D(self,geom)
1120 return Mesh_Quadrangle(self, geom)
1122 ## Creates a tetrahedron 3D algorithm for solids.
1123 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1124 # If the optional \a geom parameter is not set, this algorithm is global.
1125 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1126 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1127 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1128 # @return an instance of Mesh_Tetrahedron algorithm
1129 # @ingroup l3_algos_basic
1130 def Tetrahedron(self, algo=NETGEN, geom=0):
1131 ## if Tetrahedron(geom) is called by mistake
1132 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1133 algo, geom = geom, algo
1134 if not algo: algo = NETGEN
1136 return Mesh_Tetrahedron(self, algo, geom)
1138 ## Creates a hexahedron 3D algorithm for solids.
1139 # If the optional \a geom parameter is not set, this algorithm is global.
1140 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1141 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1142 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1143 # @return an instance of Mesh_Hexahedron algorithm
1144 # @ingroup l3_algos_basic
1145 def Hexahedron(self, algo=Hexa, geom=0):
1146 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1147 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1148 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1149 elif geom == 0: algo, geom = Hexa, algo
1150 return Mesh_Hexahedron(self, algo, geom)
1152 ## Deprecated, used only for compatibility!
1153 # @return an instance of Mesh_Netgen algorithm
1154 # @ingroup l3_algos_basic
1155 def Netgen(self, is3D, geom=0):
1156 return Mesh_Netgen(self, is3D, geom)
1158 ## Creates a projection 1D algorithm for edges.
1159 # If the optional \a geom parameter is not set, this algorithm is global.
1160 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1161 # @param geom If defined, the subshape to be meshed
1162 # @return an instance of Mesh_Projection1D algorithm
1163 # @ingroup l3_algos_proj
1164 def Projection1D(self, geom=0):
1165 return Mesh_Projection1D(self, geom)
1167 ## Creates a projection 2D algorithm for faces.
1168 # If the optional \a geom parameter is not set, this algorithm is global.
1169 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1170 # @param geom If defined, the subshape to be meshed
1171 # @return an instance of Mesh_Projection2D algorithm
1172 # @ingroup l3_algos_proj
1173 def Projection2D(self, geom=0):
1174 return Mesh_Projection2D(self, geom)
1176 ## Creates a projection 3D algorithm for solids.
1177 # If the optional \a geom parameter is not set, this algorithm is global.
1178 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1179 # @param geom If defined, the subshape to be meshed
1180 # @return an instance of Mesh_Projection3D algorithm
1181 # @ingroup l3_algos_proj
1182 def Projection3D(self, geom=0):
1183 return Mesh_Projection3D(self, geom)
1185 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1186 # If the optional \a geom parameter is not set, this algorithm is global.
1187 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1188 # @param geom If defined, the subshape to be meshed
1189 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1190 # @ingroup l3_algos_radialp l3_algos_3dextr
1191 def Prism(self, geom=0):
1195 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1196 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1197 if nbSolids == 0 or nbSolids == nbShells:
1198 return Mesh_Prism3D(self, geom)
1199 return Mesh_RadialPrism3D(self, geom)
1201 ## Evaluates size of prospective mesh on a shape
1202 # @return True or False
1203 def Evaluate(self, geom=0):
1204 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1206 geom = self.mesh.GetShapeToMesh()
1209 return self.smeshpyD.Evaluate(self.mesh, geom)
1212 ## Computes the mesh and returns the status of the computation
1213 # @param geom geomtrical shape on which mesh data should be computed
1214 # @param discardModifs if True and the mesh has been edited since
1215 # a last total re-compute and that may prevent successful partial re-compute,
1216 # then the mesh is cleaned before Compute()
1217 # @return True or False
1218 # @ingroup l2_construct
1219 def Compute(self, geom=0, discardModifs=False):
1220 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1222 geom = self.mesh.GetShapeToMesh()
1227 if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693
1229 ok = self.smeshpyD.Compute(self.mesh, geom)
1230 except SALOME.SALOME_Exception, ex:
1231 print "Mesh computation failed, exception caught:"
1232 print " ", ex.details.text
1235 print "Mesh computation failed, exception caught:"
1236 traceback.print_exc()
1240 # Treat compute errors
1241 computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
1242 for err in computeErrors:
1244 if self.mesh.HasShapeToMesh():
1246 mainIOR = salome.orb.object_to_string(geom)
1247 for sname in salome.myStudyManager.GetOpenStudies():
1248 s = salome.myStudyManager.GetStudyByName(sname)
1250 mainSO = s.FindObjectIOR(mainIOR)
1251 if not mainSO: continue
1252 if err.subShapeID == 1:
1253 shapeText = ' on "%s"' % mainSO.GetName()
1254 subIt = s.NewChildIterator(mainSO)
1256 subSO = subIt.Value()
1258 obj = subSO.GetObject()
1259 if not obj: continue
1260 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
1262 ids = go.GetSubShapeIndices()
1263 if len(ids) == 1 and ids[0] == err.subShapeID:
1264 shapeText = ' on "%s"' % subSO.GetName()
1267 shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
1269 shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID)
1271 shapeText = " on subshape #%s" % (err.subShapeID)
1273 shapeText = " on subshape #%s" % (err.subShapeID)
1275 stdErrors = ["OK", #COMPERR_OK
1276 "Invalid input mesh", #COMPERR_BAD_INPUT_MESH
1277 "std::exception", #COMPERR_STD_EXCEPTION
1278 "OCC exception", #COMPERR_OCC_EXCEPTION
1279 "SALOME exception", #COMPERR_SLM_EXCEPTION
1280 "Unknown exception", #COMPERR_EXCEPTION
1281 "Memory allocation problem", #COMPERR_MEMORY_PB
1282 "Algorithm failed", #COMPERR_ALGO_FAILED
1283 "Unexpected geometry"]#COMPERR_BAD_SHAPE
1285 if err.code < len(stdErrors): errText = stdErrors[err.code]
1287 errText = "code %s" % -err.code
1288 if errText: errText += ". "
1289 errText += err.comment
1290 if allReasons != "":allReasons += "\n"
1291 allReasons += '"%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
1295 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1297 if err.isGlobalAlgo:
1305 reason = '%s %sD algorithm is missing' % (glob, dim)
1306 elif err.state == HYP_MISSING:
1307 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1308 % (glob, dim, name, dim))
1309 elif err.state == HYP_NOTCONFORM:
1310 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1311 elif err.state == HYP_BAD_PARAMETER:
1312 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1313 % ( glob, dim, name ))
1314 elif err.state == HYP_BAD_GEOMETRY:
1315 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1316 'geometry' % ( glob, dim, name ))
1318 reason = "For unknown reason."+\
1319 " Revise Mesh.Compute() implementation in smeshDC.py!"
1321 if allReasons != "":allReasons += "\n"
1322 allReasons += reason
1324 if allReasons != "":
1325 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1329 print '"' + GetName(self.mesh) + '"',"has not been computed."
1332 if salome.sg.hasDesktop():
1333 smeshgui = salome.ImportComponentGUI("SMESH")
1334 smeshgui.Init(self.mesh.GetStudyId())
1335 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1336 salome.sg.updateObjBrowser(1)
1340 ## Return submesh objects list in meshing order
1341 # @return list of list of submesh objects
1342 # @ingroup l2_construct
1343 def GetMeshOrder(self):
1344 return self.mesh.GetMeshOrder()
1346 ## Return submesh objects list in meshing order
1347 # @return list of list of submesh objects
1348 # @ingroup l2_construct
1349 def SetMeshOrder(self, submeshes):
1350 return self.mesh.SetMeshOrder(submeshes)
1352 ## Removes all nodes and elements
1353 # @ingroup l2_construct
1356 if salome.sg.hasDesktop():
1357 smeshgui = salome.ImportComponentGUI("SMESH")
1358 smeshgui.Init(self.mesh.GetStudyId())
1359 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1360 salome.sg.updateObjBrowser(1)
1362 ## Removes all nodes and elements of indicated shape
1363 # @ingroup l2_construct
1364 def ClearSubMesh(self, geomId):
1365 self.mesh.ClearSubMesh(geomId)
1366 if salome.sg.hasDesktop():
1367 smeshgui = salome.ImportComponentGUI("SMESH")
1368 smeshgui.Init(self.mesh.GetStudyId())
1369 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1370 salome.sg.updateObjBrowser(1)
1372 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1373 # @param fineness [0,-1] defines mesh fineness
1374 # @return True or False
1375 # @ingroup l3_algos_basic
1376 def AutomaticTetrahedralization(self, fineness=0):
1377 dim = self.MeshDimension()
1379 self.RemoveGlobalHypotheses()
1380 self.Segment().AutomaticLength(fineness)
1382 self.Triangle().LengthFromEdges()
1385 self.Tetrahedron(NETGEN)
1387 return self.Compute()
1389 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1390 # @param fineness [0,-1] defines mesh fineness
1391 # @return True or False
1392 # @ingroup l3_algos_basic
1393 def AutomaticHexahedralization(self, fineness=0):
1394 dim = self.MeshDimension()
1395 # assign the hypotheses
1396 self.RemoveGlobalHypotheses()
1397 self.Segment().AutomaticLength(fineness)
1404 return self.Compute()
1406 ## Assigns a hypothesis
1407 # @param hyp a hypothesis to assign
1408 # @param geom a subhape of mesh geometry
1409 # @return SMESH.Hypothesis_Status
1410 # @ingroup l2_hypotheses
1411 def AddHypothesis(self, hyp, geom=0):
1412 if isinstance( hyp, Mesh_Algorithm ):
1413 hyp = hyp.GetAlgorithm()
1418 geom = self.mesh.GetShapeToMesh()
1420 status = self.mesh.AddHypothesis(geom, hyp)
1421 isAlgo = hyp._narrow( SMESH_Algo )
1422 hyp_name = GetName( hyp )
1425 geom_name = GetName( geom )
1426 TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1429 ## Unassigns a hypothesis
1430 # @param hyp a hypothesis to unassign
1431 # @param geom a subshape of mesh geometry
1432 # @return SMESH.Hypothesis_Status
1433 # @ingroup l2_hypotheses
1434 def RemoveHypothesis(self, hyp, geom=0):
1435 if isinstance( hyp, Mesh_Algorithm ):
1436 hyp = hyp.GetAlgorithm()
1441 status = self.mesh.RemoveHypothesis(geom, hyp)
1444 ## Gets the list of hypotheses added on a geometry
1445 # @param geom a subshape of mesh geometry
1446 # @return the sequence of SMESH_Hypothesis
1447 # @ingroup l2_hypotheses
1448 def GetHypothesisList(self, geom):
1449 return self.mesh.GetHypothesisList( geom )
1451 ## Removes all global hypotheses
1452 # @ingroup l2_hypotheses
1453 def RemoveGlobalHypotheses(self):
1454 current_hyps = self.mesh.GetHypothesisList( self.geom )
1455 for hyp in current_hyps:
1456 self.mesh.RemoveHypothesis( self.geom, hyp )
1460 ## Creates a mesh group based on the geometric object \a grp
1461 # and gives a \a name, \n if this parameter is not defined
1462 # the name is the same as the geometric group name \n
1463 # Note: Works like GroupOnGeom().
1464 # @param grp a geometric group, a vertex, an edge, a face or a solid
1465 # @param name the name of the mesh group
1466 # @return SMESH_GroupOnGeom
1467 # @ingroup l2_grps_create
1468 def Group(self, grp, name=""):
1469 return self.GroupOnGeom(grp, name)
1471 ## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead.
1472 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1473 ## allowing to overwrite the file if it exists or add the exported data to its contents
1474 # @param f the file name
1475 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1476 # @param opt boolean parameter for creating/not creating
1477 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1478 # @param overwrite boolean parameter for overwriting/not overwriting the file
1479 # @ingroup l2_impexp
1480 def ExportToMED(self, f, version, opt=0, overwrite=1):
1481 self.mesh.ExportToMEDX(f, opt, version, overwrite)
1483 ## Exports the mesh in a file in MED format and chooses the \a version of MED format
1484 ## allowing to overwrite the file if it exists or add the exported data to its contents
1485 # @param f is the file name
1486 # @param auto_groups boolean parameter for creating/not creating
1487 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1488 # the typical use is auto_groups=false.
1489 # @param version MED format version(MED_V2_1 or MED_V2_2)
1490 # @param overwrite boolean parameter for overwriting/not overwriting the file
1491 # @ingroup l2_impexp
1492 def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1):
1493 self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
1495 ## Exports the mesh in a file in DAT format
1496 # @param f the file name
1497 # @ingroup l2_impexp
1498 def ExportDAT(self, f):
1499 self.mesh.ExportDAT(f)
1501 ## Exports the mesh in a file in UNV format
1502 # @param f the file name
1503 # @ingroup l2_impexp
1504 def ExportUNV(self, f):
1505 self.mesh.ExportUNV(f)
1507 ## Export the mesh in a file in STL format
1508 # @param f the file name
1509 # @param ascii defines the file encoding
1510 # @ingroup l2_impexp
1511 def ExportSTL(self, f, ascii=1):
1512 self.mesh.ExportSTL(f, ascii)
1515 # Operations with groups:
1516 # ----------------------
1518 ## Creates an empty mesh group
1519 # @param elementType the type of elements in the group
1520 # @param name the name of the mesh group
1521 # @return SMESH_Group
1522 # @ingroup l2_grps_create
1523 def CreateEmptyGroup(self, elementType, name):
1524 return self.mesh.CreateGroup(elementType, name)
1526 ## Creates a mesh group based on the geometrical object \a grp
1527 # and gives a \a name, \n if this parameter is not defined
1528 # the name is the same as the geometrical group name
1529 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1530 # @param name the name of the mesh group
1531 # @param typ the type of elements in the group. If not set, it is
1532 # automatically detected by the type of the geometry
1533 # @return SMESH_GroupOnGeom
1534 # @ingroup l2_grps_create
1535 def GroupOnGeom(self, grp, name="", typ=None):
1537 name = grp.GetName()
1540 tgeo = str(grp.GetShapeType())
1541 if tgeo == "VERTEX":
1543 elif tgeo == "EDGE":
1545 elif tgeo == "FACE":
1547 elif tgeo == "SOLID":
1549 elif tgeo == "SHELL":
1551 elif tgeo == "COMPOUND":
1552 try: # it raises on a compound of compounds
1553 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1554 print "Mesh.Group: empty geometric group", GetName( grp )
1559 if grp.GetType() == 37: # GEOMImpl_Types.hxx: #define GEOM_GROUP 37
1561 tgeo = self.geompyD.GetType(grp)
1562 if tgeo == geompyDC.ShapeType["VERTEX"]:
1564 elif tgeo == geompyDC.ShapeType["EDGE"]:
1566 elif tgeo == geompyDC.ShapeType["FACE"]:
1568 elif tgeo == geompyDC.ShapeType["SOLID"]:
1574 for elemType, shapeType in [[VOLUME,"SOLID"],[FACE,"FACE"],
1575 [EDGE,"EDGE"],[NODE,"VERTEX"]]:
1576 if self.geompyD.SubShapeAll(grp,geompyDC.ShapeType[shapeType]):
1584 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1587 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1589 ## Creates a mesh group by the given ids of elements
1590 # @param groupName the name of the mesh group
1591 # @param elementType the type of elements in the group
1592 # @param elemIDs the list of ids
1593 # @return SMESH_Group
1594 # @ingroup l2_grps_create
1595 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1596 group = self.mesh.CreateGroup(elementType, groupName)
1600 ## Creates a mesh group by the given conditions
1601 # @param groupName the name of the mesh group
1602 # @param elementType the type of elements in the group
1603 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1604 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1605 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1606 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1607 # @return SMESH_Group
1608 # @ingroup l2_grps_create
1612 CritType=FT_Undefined,
1615 UnaryOp=FT_Undefined):
1616 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1617 group = self.MakeGroupByCriterion(groupName, aCriterion)
1620 ## Creates a mesh group by the given criterion
1621 # @param groupName the name of the mesh group
1622 # @param Criterion the instance of Criterion class
1623 # @return SMESH_Group
1624 # @ingroup l2_grps_create
1625 def MakeGroupByCriterion(self, groupName, Criterion):
1626 aFilterMgr = self.smeshpyD.CreateFilterManager()
1627 aFilter = aFilterMgr.CreateFilter()
1629 aCriteria.append(Criterion)
1630 aFilter.SetCriteria(aCriteria)
1631 group = self.MakeGroupByFilter(groupName, aFilter)
1632 aFilterMgr.Destroy()
1635 ## Creates a mesh group by the given criteria (list of criteria)
1636 # @param groupName the name of the mesh group
1637 # @param theCriteria the list of criteria
1638 # @return SMESH_Group
1639 # @ingroup l2_grps_create
1640 def MakeGroupByCriteria(self, groupName, theCriteria):
1641 aFilterMgr = self.smeshpyD.CreateFilterManager()
1642 aFilter = aFilterMgr.CreateFilter()
1643 aFilter.SetCriteria(theCriteria)
1644 group = self.MakeGroupByFilter(groupName, aFilter)
1645 aFilterMgr.Destroy()
1648 ## Creates a mesh group by the given filter
1649 # @param groupName the name of the mesh group
1650 # @param theFilter the instance of Filter class
1651 # @return SMESH_Group
1652 # @ingroup l2_grps_create
1653 def MakeGroupByFilter(self, groupName, theFilter):
1654 anIds = theFilter.GetElementsId(self.mesh)
1655 anElemType = theFilter.GetElementType()
1656 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1659 ## Passes mesh elements through the given filter and return IDs of fitting elements
1660 # @param theFilter SMESH_Filter
1661 # @return a list of ids
1662 # @ingroup l1_controls
1663 def GetIdsFromFilter(self, theFilter):
1664 return theFilter.GetElementsId(self.mesh)
1666 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1667 # Returns a list of special structures (borders).
1668 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1669 # @ingroup l1_controls
1670 def GetFreeBorders(self):
1671 aFilterMgr = self.smeshpyD.CreateFilterManager()
1672 aPredicate = aFilterMgr.CreateFreeEdges()
1673 aPredicate.SetMesh(self.mesh)
1674 aBorders = aPredicate.GetBorders()
1675 aFilterMgr.Destroy()
1679 # @ingroup l2_grps_delete
1680 def RemoveGroup(self, group):
1681 self.mesh.RemoveGroup(group)
1683 ## Removes a group with its contents
1684 # @ingroup l2_grps_delete
1685 def RemoveGroupWithContents(self, group):
1686 self.mesh.RemoveGroupWithContents(group)
1688 ## Gets the list of groups existing in the mesh
1689 # @return a sequence of SMESH_GroupBase
1690 # @ingroup l2_grps_create
1691 def GetGroups(self):
1692 return self.mesh.GetGroups()
1694 ## Gets the number of groups existing in the mesh
1695 # @return the quantity of groups as an integer value
1696 # @ingroup l2_grps_create
1698 return self.mesh.NbGroups()
1700 ## Gets the list of names of groups existing in the mesh
1701 # @return list of strings
1702 # @ingroup l2_grps_create
1703 def GetGroupNames(self):
1704 groups = self.GetGroups()
1706 for group in groups:
1707 names.append(group.GetName())
1710 ## Produces a union of two groups
1711 # A new group is created. All mesh elements that are
1712 # present in the initial groups are added to the new one
1713 # @return an instance of SMESH_Group
1714 # @ingroup l2_grps_operon
1715 def UnionGroups(self, group1, group2, name):
1716 return self.mesh.UnionGroups(group1, group2, name)
1718 ## Produces a union list of groups
1719 # New group is created. All mesh elements that are present in
1720 # initial groups are added to the new one
1721 # @return an instance of SMESH_Group
1722 # @ingroup l2_grps_operon
1723 def UnionListOfGroups(self, groups, name):
1724 return self.mesh.UnionListOfGroups(groups, name)
1726 ## Prodices an intersection of two groups
1727 # A new group is created. All mesh elements that are common
1728 # for the two initial groups are added to the new one.
1729 # @return an instance of SMESH_Group
1730 # @ingroup l2_grps_operon
1731 def IntersectGroups(self, group1, group2, name):
1732 return self.mesh.IntersectGroups(group1, group2, name)
1734 ## Produces an intersection of groups
1735 # New group is created. All mesh elements that are present in all
1736 # initial groups simultaneously are added to the new one
1737 # @return an instance of SMESH_Group
1738 # @ingroup l2_grps_operon
1739 def IntersectListOfGroups(self, groups, name):
1740 return self.mesh.IntersectListOfGroups(groups, name)
1742 ## Produces a cut of two groups
1743 # A new group is created. All mesh elements that are present in
1744 # the main group but are not present in the tool group are added to the new one
1745 # @return an instance of SMESH_Group
1746 # @ingroup l2_grps_operon
1747 def CutGroups(self, main_group, tool_group, name):
1748 return self.mesh.CutGroups(main_group, tool_group, name)
1750 ## Produces a cut of groups
1751 # A new group is created. All mesh elements that are present in main groups
1752 # but do not present in tool groups are added to the new one
1753 # @return an instance of SMESH_Group
1754 # @ingroup l2_grps_operon
1755 def CutListOfGroups(self, main_groups, tool_groups, name):
1756 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1758 ## Produces a group of elements with specified element type using list of existing groups
1759 # A new group is created. System
1760 # 1) extract all nodes on which groups elements are built
1761 # 2) combine all elements of specified dimension laying on these nodes
1762 # @return an instance of SMESH_Group
1763 # @ingroup l2_grps_operon
1764 def CreateDimGroup(self, groups, elem_type, name):
1765 return self.mesh.CreateDimGroup(groups, elem_type, name)
1768 ## Convert group on geom into standalone group
1769 # @ingroup l2_grps_delete
1770 def ConvertToStandalone(self, group):
1771 return self.mesh.ConvertToStandalone(group)
1773 # Get some info about mesh:
1774 # ------------------------
1776 ## Returns the log of nodes and elements added or removed
1777 # since the previous clear of the log.
1778 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1779 # @return list of log_block structures:
1784 # @ingroup l1_auxiliary
1785 def GetLog(self, clearAfterGet):
1786 return self.mesh.GetLog(clearAfterGet)
1788 ## Clears the log of nodes and elements added or removed since the previous
1789 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1790 # @ingroup l1_auxiliary
1792 self.mesh.ClearLog()
1794 ## Toggles auto color mode on the object.
1795 # @param theAutoColor the flag which toggles auto color mode.
1796 # @ingroup l1_auxiliary
1797 def SetAutoColor(self, theAutoColor):
1798 self.mesh.SetAutoColor(theAutoColor)
1800 ## Gets flag of object auto color mode.
1801 # @return True or False
1802 # @ingroup l1_auxiliary
1803 def GetAutoColor(self):
1804 return self.mesh.GetAutoColor()
1806 ## Gets the internal ID
1807 # @return integer value, which is the internal Id of the mesh
1808 # @ingroup l1_auxiliary
1810 return self.mesh.GetId()
1813 # @return integer value, which is the study Id of the mesh
1814 # @ingroup l1_auxiliary
1815 def GetStudyId(self):
1816 return self.mesh.GetStudyId()
1818 ## Checks the group names for duplications.
1819 # Consider the maximum group name length stored in MED file.
1820 # @return True or False
1821 # @ingroup l1_auxiliary
1822 def HasDuplicatedGroupNamesMED(self):
1823 return self.mesh.HasDuplicatedGroupNamesMED()
1825 ## Obtains the mesh editor tool
1826 # @return an instance of SMESH_MeshEditor
1827 # @ingroup l1_modifying
1828 def GetMeshEditor(self):
1829 return self.mesh.GetMeshEditor()
1832 # @return an instance of SALOME_MED::MESH
1833 # @ingroup l1_auxiliary
1834 def GetMEDMesh(self):
1835 return self.mesh.GetMEDMesh()
1838 # Get informations about mesh contents:
1839 # ------------------------------------
1841 ## Gets the mesh stattistic
1842 # @return dictionary type element - count of elements
1843 # @ingroup l1_meshinfo
1844 def GetMeshInfo(self, obj = None):
1845 if not obj: obj = self.mesh
1846 return self.smeshpyD.GetMeshInfo(obj)
1848 ## Returns the number of nodes in the mesh
1849 # @return an integer value
1850 # @ingroup l1_meshinfo
1852 return self.mesh.NbNodes()
1854 ## Returns the number of elements in the mesh
1855 # @return an integer value
1856 # @ingroup l1_meshinfo
1857 def NbElements(self):
1858 return self.mesh.NbElements()
1860 ## Returns the number of 0d elements in the mesh
1861 # @return an integer value
1862 # @ingroup l1_meshinfo
1863 def Nb0DElements(self):
1864 return self.mesh.Nb0DElements()
1866 ## Returns the number of edges in the mesh
1867 # @return an integer value
1868 # @ingroup l1_meshinfo
1870 return self.mesh.NbEdges()
1872 ## Returns the number of edges with the given order in the mesh
1873 # @param elementOrder the order of elements:
1874 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1875 # @return an integer value
1876 # @ingroup l1_meshinfo
1877 def NbEdgesOfOrder(self, elementOrder):
1878 return self.mesh.NbEdgesOfOrder(elementOrder)
1880 ## Returns the number of faces in the mesh
1881 # @return an integer value
1882 # @ingroup l1_meshinfo
1884 return self.mesh.NbFaces()
1886 ## Returns the number of faces with the given order in the mesh
1887 # @param elementOrder the order of elements:
1888 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1889 # @return an integer value
1890 # @ingroup l1_meshinfo
1891 def NbFacesOfOrder(self, elementOrder):
1892 return self.mesh.NbFacesOfOrder(elementOrder)
1894 ## Returns the number of triangles in the mesh
1895 # @return an integer value
1896 # @ingroup l1_meshinfo
1897 def NbTriangles(self):
1898 return self.mesh.NbTriangles()
1900 ## Returns the number of triangles with the given order in the mesh
1901 # @param elementOrder is the order of elements:
1902 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1903 # @return an integer value
1904 # @ingroup l1_meshinfo
1905 def NbTrianglesOfOrder(self, elementOrder):
1906 return self.mesh.NbTrianglesOfOrder(elementOrder)
1908 ## Returns the number of quadrangles in the mesh
1909 # @return an integer value
1910 # @ingroup l1_meshinfo
1911 def NbQuadrangles(self):
1912 return self.mesh.NbQuadrangles()
1914 ## Returns the number of quadrangles with the given order in the mesh
1915 # @param elementOrder the order of elements:
1916 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1917 # @return an integer value
1918 # @ingroup l1_meshinfo
1919 def NbQuadranglesOfOrder(self, elementOrder):
1920 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1922 ## Returns the number of polygons in the mesh
1923 # @return an integer value
1924 # @ingroup l1_meshinfo
1925 def NbPolygons(self):
1926 return self.mesh.NbPolygons()
1928 ## Returns the number of volumes in the mesh
1929 # @return an integer value
1930 # @ingroup l1_meshinfo
1931 def NbVolumes(self):
1932 return self.mesh.NbVolumes()
1934 ## Returns the number of volumes with the given order in the mesh
1935 # @param elementOrder the order of elements:
1936 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1937 # @return an integer value
1938 # @ingroup l1_meshinfo
1939 def NbVolumesOfOrder(self, elementOrder):
1940 return self.mesh.NbVolumesOfOrder(elementOrder)
1942 ## Returns the number of tetrahedrons in the mesh
1943 # @return an integer value
1944 # @ingroup l1_meshinfo
1946 return self.mesh.NbTetras()
1948 ## Returns the number of tetrahedrons with the given order in the mesh
1949 # @param elementOrder the order of elements:
1950 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1951 # @return an integer value
1952 # @ingroup l1_meshinfo
1953 def NbTetrasOfOrder(self, elementOrder):
1954 return self.mesh.NbTetrasOfOrder(elementOrder)
1956 ## Returns the number of hexahedrons in the mesh
1957 # @return an integer value
1958 # @ingroup l1_meshinfo
1960 return self.mesh.NbHexas()
1962 ## Returns the number of hexahedrons with the given order in the mesh
1963 # @param elementOrder the order of elements:
1964 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1965 # @return an integer value
1966 # @ingroup l1_meshinfo
1967 def NbHexasOfOrder(self, elementOrder):
1968 return self.mesh.NbHexasOfOrder(elementOrder)
1970 ## Returns the number of pyramids in the mesh
1971 # @return an integer value
1972 # @ingroup l1_meshinfo
1973 def NbPyramids(self):
1974 return self.mesh.NbPyramids()
1976 ## Returns the number of pyramids with the given order in the mesh
1977 # @param elementOrder the order of elements:
1978 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1979 # @return an integer value
1980 # @ingroup l1_meshinfo
1981 def NbPyramidsOfOrder(self, elementOrder):
1982 return self.mesh.NbPyramidsOfOrder(elementOrder)
1984 ## Returns the number of prisms in the mesh
1985 # @return an integer value
1986 # @ingroup l1_meshinfo
1988 return self.mesh.NbPrisms()
1990 ## Returns the number of prisms with the given order in the mesh
1991 # @param elementOrder the order of elements:
1992 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1993 # @return an integer value
1994 # @ingroup l1_meshinfo
1995 def NbPrismsOfOrder(self, elementOrder):
1996 return self.mesh.NbPrismsOfOrder(elementOrder)
1998 ## Returns the number of polyhedrons in the mesh
1999 # @return an integer value
2000 # @ingroup l1_meshinfo
2001 def NbPolyhedrons(self):
2002 return self.mesh.NbPolyhedrons()
2004 ## Returns the number of submeshes in the mesh
2005 # @return an integer value
2006 # @ingroup l1_meshinfo
2007 def NbSubMesh(self):
2008 return self.mesh.NbSubMesh()
2010 ## Returns the list of mesh elements IDs
2011 # @return the list of integer values
2012 # @ingroup l1_meshinfo
2013 def GetElementsId(self):
2014 return self.mesh.GetElementsId()
2016 ## Returns the list of IDs of mesh elements with the given type
2017 # @param elementType the required type of elements (SMESH.NODE, SMESH.EDGE, SMESH.FACE or SMESH.VOLUME)
2018 # @return list of integer values
2019 # @ingroup l1_meshinfo
2020 def GetElementsByType(self, elementType):
2021 return self.mesh.GetElementsByType(elementType)
2023 ## Returns the list of mesh nodes IDs
2024 # @return the list of integer values
2025 # @ingroup l1_meshinfo
2026 def GetNodesId(self):
2027 return self.mesh.GetNodesId()
2029 # Get the information about mesh elements:
2030 # ------------------------------------
2032 ## Returns the type of mesh element
2033 # @return the value from SMESH::ElementType enumeration
2034 # @ingroup l1_meshinfo
2035 def GetElementType(self, id, iselem):
2036 return self.mesh.GetElementType(id, iselem)
2038 ## Returns the geometric type of mesh element
2039 # @return the value from SMESH::EntityType enumeration
2040 # @ingroup l1_meshinfo
2041 def GetElementGeomType(self, id):
2042 return self.mesh.GetElementGeomType(id)
2044 ## Returns the list of submesh elements IDs
2045 # @param Shape a geom object(subshape) IOR
2046 # Shape must be the subshape of a ShapeToMesh()
2047 # @return the list of integer values
2048 # @ingroup l1_meshinfo
2049 def GetSubMeshElementsId(self, Shape):
2050 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2051 ShapeID = Shape.GetSubShapeIndices()[0]
2054 return self.mesh.GetSubMeshElementsId(ShapeID)
2056 ## Returns the list of submesh nodes IDs
2057 # @param Shape a geom object(subshape) IOR
2058 # Shape must be the subshape of a ShapeToMesh()
2059 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
2060 # @return the list of integer values
2061 # @ingroup l1_meshinfo
2062 def GetSubMeshNodesId(self, Shape, all):
2063 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2064 ShapeID = Shape.GetSubShapeIndices()[0]
2067 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2069 ## Returns type of elements on given shape
2070 # @param Shape a geom object(subshape) IOR
2071 # Shape must be a subshape of a ShapeToMesh()
2072 # @return element type
2073 # @ingroup l1_meshinfo
2074 def GetSubMeshElementType(self, Shape):
2075 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2076 ShapeID = Shape.GetSubShapeIndices()[0]
2079 return self.mesh.GetSubMeshElementType(ShapeID)
2081 ## Gets the mesh description
2082 # @return string value
2083 # @ingroup l1_meshinfo
2085 return self.mesh.Dump()
2088 # Get the information about nodes and elements of a mesh by its IDs:
2089 # -----------------------------------------------------------
2091 ## Gets XYZ coordinates of a node
2092 # \n If there is no nodes for the given ID - returns an empty list
2093 # @return a list of double precision values
2094 # @ingroup l1_meshinfo
2095 def GetNodeXYZ(self, id):
2096 return self.mesh.GetNodeXYZ(id)
2098 ## Returns list of IDs of inverse elements for the given node
2099 # \n If there is no node for the given ID - returns an empty list
2100 # @return a list of integer values
2101 # @ingroup l1_meshinfo
2102 def GetNodeInverseElements(self, id):
2103 return self.mesh.GetNodeInverseElements(id)
2105 ## @brief Returns the position of a node on the shape
2106 # @return SMESH::NodePosition
2107 # @ingroup l1_meshinfo
2108 def GetNodePosition(self,NodeID):
2109 return self.mesh.GetNodePosition(NodeID)
2111 ## If the given element is a node, returns the ID of shape
2112 # \n If there is no node for the given ID - returns -1
2113 # @return an integer value
2114 # @ingroup l1_meshinfo
2115 def GetShapeID(self, id):
2116 return self.mesh.GetShapeID(id)
2118 ## Returns the ID of the result shape after
2119 # FindShape() from SMESH_MeshEditor for the given element
2120 # \n If there is no element for the given ID - returns -1
2121 # @return an integer value
2122 # @ingroup l1_meshinfo
2123 def GetShapeIDForElem(self,id):
2124 return self.mesh.GetShapeIDForElem(id)
2126 ## Returns the number of nodes for the given element
2127 # \n If there is no element for the given ID - returns -1
2128 # @return an integer value
2129 # @ingroup l1_meshinfo
2130 def GetElemNbNodes(self, id):
2131 return self.mesh.GetElemNbNodes(id)
2133 ## Returns the node ID the given index for the given element
2134 # \n If there is no element for the given ID - returns -1
2135 # \n If there is no node for the given index - returns -2
2136 # @return an integer value
2137 # @ingroup l1_meshinfo
2138 def GetElemNode(self, id, index):
2139 return self.mesh.GetElemNode(id, index)
2141 ## Returns the IDs of nodes of the given element
2142 # @return a list of integer values
2143 # @ingroup l1_meshinfo
2144 def GetElemNodes(self, id):
2145 return self.mesh.GetElemNodes(id)
2147 ## Returns true if the given node is the medium node in the given quadratic element
2148 # @ingroup l1_meshinfo
2149 def IsMediumNode(self, elementID, nodeID):
2150 return self.mesh.IsMediumNode(elementID, nodeID)
2152 ## Returns true if the given node is the medium node in one of quadratic elements
2153 # @ingroup l1_meshinfo
2154 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2155 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2157 ## Returns the number of edges for the given element
2158 # @ingroup l1_meshinfo
2159 def ElemNbEdges(self, id):
2160 return self.mesh.ElemNbEdges(id)
2162 ## Returns the number of faces for the given element
2163 # @ingroup l1_meshinfo
2164 def ElemNbFaces(self, id):
2165 return self.mesh.ElemNbFaces(id)
2167 ## Returns nodes of given face (counted from zero) for given volumic element.
2168 # @ingroup l1_meshinfo
2169 def GetElemFaceNodes(self,elemId, faceIndex):
2170 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2172 ## Returns an element based on all given nodes.
2173 # @ingroup l1_meshinfo
2174 def FindElementByNodes(self,nodes):
2175 return self.mesh.FindElementByNodes(nodes)
2177 ## Returns true if the given element is a polygon
2178 # @ingroup l1_meshinfo
2179 def IsPoly(self, id):
2180 return self.mesh.IsPoly(id)
2182 ## Returns true if the given element is quadratic
2183 # @ingroup l1_meshinfo
2184 def IsQuadratic(self, id):
2185 return self.mesh.IsQuadratic(id)
2187 ## Returns XYZ coordinates of the barycenter of the given element
2188 # \n If there is no element for the given ID - returns an empty list
2189 # @return a list of three double values
2190 # @ingroup l1_meshinfo
2191 def BaryCenter(self, id):
2192 return self.mesh.BaryCenter(id)
2195 # Get mesh measurements information:
2196 # ------------------------------------
2198 def MinDistance(self, id1, id2, isElem1=False, isElem2=False):
2199 aMeasure = self.GetMinDistance(id1, id2, isElem1, isElem2)
2200 return aMeasure.value
2202 # @param node1, node2 is nodes to measure distance
2203 # @return Measure structure
2204 def GetMinDistance(self, id1, id2, isElem1=False, isElem2=False):
2205 if isinstance( id1, int):
2207 id1 = self.editor.MakeIDSource([id1], SMESH.FACE)
2209 id1 = self.editor.MakeIDSource([id1], SMESH.NODE)
2210 if isinstance( id2, int):
2212 id2 = self.editor.MakeIDSource([id2], SMESH.FACE)
2214 id2 = self.editor.MakeIDSource([id2], SMESH.NODE)
2216 aMeasurements = self.smeshpyD.CreateMeasurements()
2217 aMeasure = aMeasurements.MinDistance(id1, id2)
2218 aMeasurements.Destroy()
2221 # @param IDsOfElements is a list of ids of elements or nodes
2222 # @return Measure structure
2223 def GetBoundingBox(self, IDs = None, isElem=True):
2224 if isinstance( IDs, Mesh ):
2228 elif isinstance( IDs, int):
2230 IDs = [ self.editor.MakeIDSource(IDs, SMESH.FACE) ]
2232 IDs = [ self.editor.MakeIDSource(IDs, SMESH.NODE) ]
2233 elif isinstance( IDs, list ) and isinstance( IDs[0], int):
2235 IDs = [ self.editor.MakeIDSource(IDs, SMESH.FACE) ]
2237 IDs = [ self.editor.MakeIDSource(IDs, SMESH.NODE) ]
2238 elif hasattr(IDs, "_narrow"):
2239 anIDs = IDs._narrow(SMESH.SMESH_IDSource)
2244 if isinstance(IDs, list):
2245 aMeasurements = self.smeshpyD.CreateMeasurements()
2246 aMeasure = aMeasurements.BoundingBox(IDs)
2247 aMeasurements.Destroy()
2251 # Mesh edition (SMESH_MeshEditor functionality):
2252 # ---------------------------------------------
2254 ## Removes the elements from the mesh by ids
2255 # @param IDsOfElements is a list of ids of elements to remove
2256 # @return True or False
2257 # @ingroup l2_modif_del
2258 def RemoveElements(self, IDsOfElements):
2259 return self.editor.RemoveElements(IDsOfElements)
2261 ## Removes nodes from mesh by ids
2262 # @param IDsOfNodes is a list of ids of nodes to remove
2263 # @return True or False
2264 # @ingroup l2_modif_del
2265 def RemoveNodes(self, IDsOfNodes):
2266 return self.editor.RemoveNodes(IDsOfNodes)
2268 ## Removes all orphan (free) nodes from mesh
2269 # @return number of the removed nodes
2270 # @ingroup l2_modif_del
2271 def RemoveOrphanNodes(self):
2272 return self.editor.RemoveOrphanNodes()
2274 ## Add a node to the mesh by coordinates
2275 # @return Id of the new node
2276 # @ingroup l2_modif_add
2277 def AddNode(self, x, y, z):
2278 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2279 self.mesh.SetParameters(Parameters)
2280 return self.editor.AddNode( x, y, z)
2282 ## Creates a 0D element on a node with given number.
2283 # @param IDOfNode the ID of node for creation of the element.
2284 # @return the Id of the new 0D element
2285 # @ingroup l2_modif_add
2286 def Add0DElement(self, IDOfNode):
2287 return self.editor.Add0DElement(IDOfNode)
2289 ## Creates a linear or quadratic edge (this is determined
2290 # by the number of given nodes).
2291 # @param IDsOfNodes the list of node IDs for creation of the element.
2292 # The order of nodes in this list should correspond to the description
2293 # of MED. \n This description is located by the following link:
2294 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2295 # @return the Id of the new edge
2296 # @ingroup l2_modif_add
2297 def AddEdge(self, IDsOfNodes):
2298 return self.editor.AddEdge(IDsOfNodes)
2300 ## Creates a linear or quadratic face (this is determined
2301 # by the number of given nodes).
2302 # @param IDsOfNodes the list of node IDs for creation of the element.
2303 # The order of nodes in this list should correspond to the description
2304 # of MED. \n This description is located by the following link:
2305 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2306 # @return the Id of the new face
2307 # @ingroup l2_modif_add
2308 def AddFace(self, IDsOfNodes):
2309 return self.editor.AddFace(IDsOfNodes)
2311 ## Adds a polygonal face to the mesh by the list of node IDs
2312 # @param IdsOfNodes the list of node IDs for creation of the element.
2313 # @return the Id of the new face
2314 # @ingroup l2_modif_add
2315 def AddPolygonalFace(self, IdsOfNodes):
2316 return self.editor.AddPolygonalFace(IdsOfNodes)
2318 ## Creates both simple and quadratic volume (this is determined
2319 # by the number of given nodes).
2320 # @param IDsOfNodes the list of node IDs for creation of the element.
2321 # The order of nodes in this list should correspond to the description
2322 # of MED. \n This description is located by the following link:
2323 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2324 # @return the Id of the new volumic element
2325 # @ingroup l2_modif_add
2326 def AddVolume(self, IDsOfNodes):
2327 return self.editor.AddVolume(IDsOfNodes)
2329 ## Creates a volume of many faces, giving nodes for each face.
2330 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2331 # @param Quantities the list of integer values, Quantities[i]
2332 # gives the quantity of nodes in face number i.
2333 # @return the Id of the new volumic element
2334 # @ingroup l2_modif_add
2335 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2336 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2338 ## Creates a volume of many faces, giving the IDs of the existing faces.
2339 # @param IdsOfFaces the list of face IDs for volume creation.
2341 # Note: The created volume will refer only to the nodes
2342 # of the given faces, not to the faces themselves.
2343 # @return the Id of the new volumic element
2344 # @ingroup l2_modif_add
2345 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2346 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2349 ## @brief Binds a node to a vertex
2350 # @param NodeID a node ID
2351 # @param Vertex a vertex or vertex ID
2352 # @return True if succeed else raises an exception
2353 # @ingroup l2_modif_add
2354 def SetNodeOnVertex(self, NodeID, Vertex):
2355 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2356 VertexID = Vertex.GetSubShapeIndices()[0]
2360 self.editor.SetNodeOnVertex(NodeID, VertexID)
2361 except SALOME.SALOME_Exception, inst:
2362 raise ValueError, inst.details.text
2366 ## @brief Stores the node position on an edge
2367 # @param NodeID a node ID
2368 # @param Edge an edge or edge ID
2369 # @param paramOnEdge a parameter on the edge where the node is located
2370 # @return True if succeed else raises an exception
2371 # @ingroup l2_modif_add
2372 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2373 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2374 EdgeID = Edge.GetSubShapeIndices()[0]
2378 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2379 except SALOME.SALOME_Exception, inst:
2380 raise ValueError, inst.details.text
2383 ## @brief Stores node position on a face
2384 # @param NodeID a node ID
2385 # @param Face a face or face ID
2386 # @param u U parameter on the face where the node is located
2387 # @param v V parameter on the face where the node is located
2388 # @return True if succeed else raises an exception
2389 # @ingroup l2_modif_add
2390 def SetNodeOnFace(self, NodeID, Face, u, v):
2391 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2392 FaceID = Face.GetSubShapeIndices()[0]
2396 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2397 except SALOME.SALOME_Exception, inst:
2398 raise ValueError, inst.details.text
2401 ## @brief Binds a node to a solid
2402 # @param NodeID a node ID
2403 # @param Solid a solid or solid ID
2404 # @return True if succeed else raises an exception
2405 # @ingroup l2_modif_add
2406 def SetNodeInVolume(self, NodeID, Solid):
2407 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2408 SolidID = Solid.GetSubShapeIndices()[0]
2412 self.editor.SetNodeInVolume(NodeID, SolidID)
2413 except SALOME.SALOME_Exception, inst:
2414 raise ValueError, inst.details.text
2417 ## @brief Bind an element to a shape
2418 # @param ElementID an element ID
2419 # @param Shape a shape or shape ID
2420 # @return True if succeed else raises an exception
2421 # @ingroup l2_modif_add
2422 def SetMeshElementOnShape(self, ElementID, Shape):
2423 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2424 ShapeID = Shape.GetSubShapeIndices()[0]
2428 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2429 except SALOME.SALOME_Exception, inst:
2430 raise ValueError, inst.details.text
2434 ## Moves the node with the given id
2435 # @param NodeID the id of the node
2436 # @param x a new X coordinate
2437 # @param y a new Y coordinate
2438 # @param z a new Z coordinate
2439 # @return True if succeed else False
2440 # @ingroup l2_modif_movenode
2441 def MoveNode(self, NodeID, x, y, z):
2442 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2443 self.mesh.SetParameters(Parameters)
2444 return self.editor.MoveNode(NodeID, x, y, z)
2446 ## Finds the node closest to a point and moves it to a point location
2447 # @param x the X coordinate of a point
2448 # @param y the Y coordinate of a point
2449 # @param z the Z coordinate of a point
2450 # @param NodeID if specified (>0), the node with this ID is moved,
2451 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2452 # @return the ID of a node
2453 # @ingroup l2_modif_throughp
2454 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2455 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2456 self.mesh.SetParameters(Parameters)
2457 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2459 ## Finds the node closest to a point
2460 # @param x the X coordinate of a point
2461 # @param y the Y coordinate of a point
2462 # @param z the Z coordinate of a point
2463 # @return the ID of a node
2464 # @ingroup l2_modif_throughp
2465 def FindNodeClosestTo(self, x, y, z):
2466 #preview = self.mesh.GetMeshEditPreviewer()
2467 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2468 return self.editor.FindNodeClosestTo(x, y, z)
2470 ## Finds the elements where a point lays IN or ON
2471 # @param x the X coordinate of a point
2472 # @param y the Y coordinate of a point
2473 # @param z the Z coordinate of a point
2474 # @param elementType type of elements to find (SMESH.ALL type
2475 # means elements of any type excluding nodes and 0D elements)
2476 # @return list of IDs of found elements
2477 # @ingroup l2_modif_throughp
2478 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2479 return self.editor.FindElementsByPoint(x, y, z, elementType)
2481 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2482 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2484 def GetPointState(self, x, y, z):
2485 return self.editor.GetPointState(x, y, z)
2487 ## Finds the node closest to a point and moves it to a point location
2488 # @param x the X coordinate of a point
2489 # @param y the Y coordinate of a point
2490 # @param z the Z coordinate of a point
2491 # @return the ID of a moved node
2492 # @ingroup l2_modif_throughp
2493 def MeshToPassThroughAPoint(self, x, y, z):
2494 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2496 ## Replaces two neighbour triangles sharing Node1-Node2 link
2497 # with the triangles built on the same 4 nodes but having other common link.
2498 # @param NodeID1 the ID of the first node
2499 # @param NodeID2 the ID of the second node
2500 # @return false if proper faces were not found
2501 # @ingroup l2_modif_invdiag
2502 def InverseDiag(self, NodeID1, NodeID2):
2503 return self.editor.InverseDiag(NodeID1, NodeID2)
2505 ## Replaces two neighbour triangles sharing Node1-Node2 link
2506 # with a quadrangle built on the same 4 nodes.
2507 # @param NodeID1 the ID of the first node
2508 # @param NodeID2 the ID of the second node
2509 # @return false if proper faces were not found
2510 # @ingroup l2_modif_unitetri
2511 def DeleteDiag(self, NodeID1, NodeID2):
2512 return self.editor.DeleteDiag(NodeID1, NodeID2)
2514 ## Reorients elements by ids
2515 # @param IDsOfElements if undefined reorients all mesh elements
2516 # @return True if succeed else False
2517 # @ingroup l2_modif_changori
2518 def Reorient(self, IDsOfElements=None):
2519 if IDsOfElements == None:
2520 IDsOfElements = self.GetElementsId()
2521 return self.editor.Reorient(IDsOfElements)
2523 ## Reorients all elements of the object
2524 # @param theObject mesh, submesh or group
2525 # @return True if succeed else False
2526 # @ingroup l2_modif_changori
2527 def ReorientObject(self, theObject):
2528 if ( isinstance( theObject, Mesh )):
2529 theObject = theObject.GetMesh()
2530 return self.editor.ReorientObject(theObject)
2532 ## Fuses the neighbouring triangles into quadrangles.
2533 # @param IDsOfElements The triangles to be fused,
2534 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2535 # @param MaxAngle is the maximum angle between element normals at which the fusion
2536 # is still performed; theMaxAngle is mesured in radians.
2537 # Also it could be a name of variable which defines angle in degrees.
2538 # @return TRUE in case of success, FALSE otherwise.
2539 # @ingroup l2_modif_unitetri
2540 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2542 if isinstance(MaxAngle,str):
2544 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2546 MaxAngle = DegreesToRadians(MaxAngle)
2547 if IDsOfElements == []:
2548 IDsOfElements = self.GetElementsId()
2549 self.mesh.SetParameters(Parameters)
2551 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2552 Functor = theCriterion
2554 Functor = self.smeshpyD.GetFunctor(theCriterion)
2555 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2557 ## Fuses the neighbouring triangles of the object into quadrangles
2558 # @param theObject is mesh, submesh or group
2559 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2560 # @param MaxAngle a max angle between element normals at which the fusion
2561 # is still performed; theMaxAngle is mesured in radians.
2562 # @return TRUE in case of success, FALSE otherwise.
2563 # @ingroup l2_modif_unitetri
2564 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2565 if ( isinstance( theObject, Mesh )):
2566 theObject = theObject.GetMesh()
2567 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2569 ## Splits quadrangles into triangles.
2570 # @param IDsOfElements the faces to be splitted.
2571 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2572 # @return TRUE in case of success, FALSE otherwise.
2573 # @ingroup l2_modif_cutquadr
2574 def QuadToTri (self, IDsOfElements, theCriterion):
2575 if IDsOfElements == []:
2576 IDsOfElements = self.GetElementsId()
2577 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2579 ## Splits quadrangles into triangles.
2580 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2581 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2582 # @return TRUE in case of success, FALSE otherwise.
2583 # @ingroup l2_modif_cutquadr
2584 def QuadToTriObject (self, theObject, theCriterion):
2585 if ( isinstance( theObject, Mesh )):
2586 theObject = theObject.GetMesh()
2587 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2589 ## Splits quadrangles into triangles.
2590 # @param IDsOfElements the faces to be splitted
2591 # @param Diag13 is used to choose a diagonal for splitting.
2592 # @return TRUE in case of success, FALSE otherwise.
2593 # @ingroup l2_modif_cutquadr
2594 def SplitQuad (self, IDsOfElements, Diag13):
2595 if IDsOfElements == []:
2596 IDsOfElements = self.GetElementsId()
2597 return self.editor.SplitQuad(IDsOfElements, Diag13)
2599 ## Splits quadrangles into triangles.
2600 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2601 # @param Diag13 is used to choose a diagonal for splitting.
2602 # @return TRUE in case of success, FALSE otherwise.
2603 # @ingroup l2_modif_cutquadr
2604 def SplitQuadObject (self, theObject, Diag13):
2605 if ( isinstance( theObject, Mesh )):
2606 theObject = theObject.GetMesh()
2607 return self.editor.SplitQuadObject(theObject, Diag13)
2609 ## Finds a better splitting of the given quadrangle.
2610 # @param IDOfQuad the ID of the quadrangle to be splitted.
2611 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2612 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2613 # diagonal is better, 0 if error occurs.
2614 # @ingroup l2_modif_cutquadr
2615 def BestSplit (self, IDOfQuad, theCriterion):
2616 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2618 ## Splits volumic elements into tetrahedrons
2619 # @param elemIDs either list of elements or mesh or group or submesh
2620 # @param method flags passing splitting method: Hex_5Tet, Hex_6Tet, Hex_24Tet
2621 # Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc
2622 # @ingroup l2_modif_cutquadr
2623 def SplitVolumesIntoTetra(self, elemIDs, method=Hex_5Tet ):
2624 if isinstance( elemIDs, Mesh ):
2625 elemIDs = elemIDs.GetMesh()
2626 self.editor.SplitVolumesIntoTetra(elemIDs, method)
2628 ## Splits quadrangle faces near triangular facets of volumes
2630 # @ingroup l1_auxiliary
2631 def SplitQuadsNearTriangularFacets(self):
2632 faces_array = self.GetElementsByType(SMESH.FACE)
2633 for face_id in faces_array:
2634 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2635 quad_nodes = self.mesh.GetElemNodes(face_id)
2636 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2637 isVolumeFound = False
2638 for node1_elem in node1_elems:
2639 if not isVolumeFound:
2640 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2641 nb_nodes = self.GetElemNbNodes(node1_elem)
2642 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2643 volume_elem = node1_elem
2644 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2645 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2646 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2647 isVolumeFound = True
2648 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2649 self.SplitQuad([face_id], False) # diagonal 2-4
2650 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2651 isVolumeFound = True
2652 self.SplitQuad([face_id], True) # diagonal 1-3
2653 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2654 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2655 isVolumeFound = True
2656 self.SplitQuad([face_id], True) # diagonal 1-3
2658 ## @brief Splits hexahedrons into tetrahedrons.
2660 # This operation uses pattern mapping functionality for splitting.
2661 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2662 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2663 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2664 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2665 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2666 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2667 # @return TRUE in case of success, FALSE otherwise.
2668 # @ingroup l1_auxiliary
2669 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2670 # Pattern: 5.---------.6
2675 # (0,0,1) 4.---------.7 * |
2682 # (0,0,0) 0.---------.3
2683 pattern_tetra = "!!! Nb of points: \n 8 \n\
2693 !!! Indices of points of 6 tetras: \n\
2701 pattern = self.smeshpyD.GetPattern()
2702 isDone = pattern.LoadFromFile(pattern_tetra)
2704 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2707 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2708 isDone = pattern.MakeMesh(self.mesh, False, False)
2709 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2711 # split quafrangle faces near triangular facets of volumes
2712 self.SplitQuadsNearTriangularFacets()
2716 ## @brief Split hexahedrons into prisms.
2718 # Uses the pattern mapping functionality for splitting.
2719 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2720 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2721 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2722 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2723 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2724 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2725 # @return TRUE in case of success, FALSE otherwise.
2726 # @ingroup l1_auxiliary
2727 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2728 # Pattern: 5.---------.6
2733 # (0,0,1) 4.---------.7 |
2740 # (0,0,0) 0.---------.3
2741 pattern_prism = "!!! Nb of points: \n 8 \n\
2751 !!! Indices of points of 2 prisms: \n\
2755 pattern = self.smeshpyD.GetPattern()
2756 isDone = pattern.LoadFromFile(pattern_prism)
2758 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2761 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2762 isDone = pattern.MakeMesh(self.mesh, False, False)
2763 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2765 # Splits quafrangle faces near triangular facets of volumes
2766 self.SplitQuadsNearTriangularFacets()
2770 ## Smoothes elements
2771 # @param IDsOfElements the list if ids of elements to smooth
2772 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2773 # Note that nodes built on edges and boundary nodes are always fixed.
2774 # @param MaxNbOfIterations the maximum number of iterations
2775 # @param MaxAspectRatio varies in range [1.0, inf]
2776 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2777 # @return TRUE in case of success, FALSE otherwise.
2778 # @ingroup l2_modif_smooth
2779 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2780 MaxNbOfIterations, MaxAspectRatio, Method):
2781 if IDsOfElements == []:
2782 IDsOfElements = self.GetElementsId()
2783 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2784 self.mesh.SetParameters(Parameters)
2785 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2786 MaxNbOfIterations, MaxAspectRatio, Method)
2788 ## Smoothes elements which belong to the given object
2789 # @param theObject the object to smooth
2790 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2791 # Note that nodes built on edges and boundary nodes are always fixed.
2792 # @param MaxNbOfIterations the maximum number of iterations
2793 # @param MaxAspectRatio varies in range [1.0, inf]
2794 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2795 # @return TRUE in case of success, FALSE otherwise.
2796 # @ingroup l2_modif_smooth
2797 def SmoothObject(self, theObject, IDsOfFixedNodes,
2798 MaxNbOfIterations, MaxAspectRatio, Method):
2799 if ( isinstance( theObject, Mesh )):
2800 theObject = theObject.GetMesh()
2801 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2802 MaxNbOfIterations, MaxAspectRatio, Method)
2804 ## Parametrically smoothes the given elements
2805 # @param IDsOfElements the list if ids of elements to smooth
2806 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2807 # Note that nodes built on edges and boundary nodes are always fixed.
2808 # @param MaxNbOfIterations the maximum number of iterations
2809 # @param MaxAspectRatio varies in range [1.0, inf]
2810 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2811 # @return TRUE in case of success, FALSE otherwise.
2812 # @ingroup l2_modif_smooth
2813 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2814 MaxNbOfIterations, MaxAspectRatio, Method):
2815 if IDsOfElements == []:
2816 IDsOfElements = self.GetElementsId()
2817 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2818 self.mesh.SetParameters(Parameters)
2819 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2820 MaxNbOfIterations, MaxAspectRatio, Method)
2822 ## Parametrically smoothes the elements which belong to the given object
2823 # @param theObject the object to smooth
2824 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2825 # Note that nodes built on edges and boundary nodes are always fixed.
2826 # @param MaxNbOfIterations the maximum number of iterations
2827 # @param MaxAspectRatio varies in range [1.0, inf]
2828 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2829 # @return TRUE in case of success, FALSE otherwise.
2830 # @ingroup l2_modif_smooth
2831 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2832 MaxNbOfIterations, MaxAspectRatio, Method):
2833 if ( isinstance( theObject, Mesh )):
2834 theObject = theObject.GetMesh()
2835 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2836 MaxNbOfIterations, MaxAspectRatio, Method)
2838 ## Converts the mesh to quadratic, deletes old elements, replacing
2839 # them with quadratic with the same id.
2840 # @param theForce3d new node creation method:
2841 # 0 - the medium node lies at the geometrical edge from which the mesh element is built
2842 # 1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element
2843 # @ingroup l2_modif_tofromqu
2844 def ConvertToQuadratic(self, theForce3d):
2845 self.editor.ConvertToQuadratic(theForce3d)
2847 ## Converts the mesh from quadratic to ordinary,
2848 # deletes old quadratic elements, \n replacing
2849 # them with ordinary mesh elements with the same id.
2850 # @return TRUE in case of success, FALSE otherwise.
2851 # @ingroup l2_modif_tofromqu
2852 def ConvertFromQuadratic(self):
2853 return self.editor.ConvertFromQuadratic()
2855 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
2856 # @return TRUE if operation has been completed successfully, FALSE otherwise
2857 # @ingroup l2_modif_edit
2858 def Make2DMeshFrom3D(self):
2859 return self.editor. Make2DMeshFrom3D()
2861 ## Renumber mesh nodes
2862 # @ingroup l2_modif_renumber
2863 def RenumberNodes(self):
2864 self.editor.RenumberNodes()
2866 ## Renumber mesh elements
2867 # @ingroup l2_modif_renumber
2868 def RenumberElements(self):
2869 self.editor.RenumberElements()
2871 ## Generates new elements by rotation of the elements around the axis
2872 # @param IDsOfElements the list of ids of elements to sweep
2873 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2874 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2875 # @param NbOfSteps the number of steps
2876 # @param Tolerance tolerance
2877 # @param MakeGroups forces the generation of new groups from existing ones
2878 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2879 # of all steps, else - size of each step
2880 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2881 # @ingroup l2_modif_extrurev
2882 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2883 MakeGroups=False, TotalAngle=False):
2885 if isinstance(AngleInRadians,str):
2887 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2889 AngleInRadians = DegreesToRadians(AngleInRadians)
2890 if IDsOfElements == []:
2891 IDsOfElements = self.GetElementsId()
2892 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2893 Axis = self.smeshpyD.GetAxisStruct(Axis)
2894 Axis,AxisParameters = ParseAxisStruct(Axis)
2895 if TotalAngle and NbOfSteps:
2896 AngleInRadians /= NbOfSteps
2897 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2898 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2899 self.mesh.SetParameters(Parameters)
2901 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2902 AngleInRadians, NbOfSteps, Tolerance)
2903 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2906 ## Generates new elements by rotation of the elements of object around the axis
2907 # @param theObject object which elements should be sweeped
2908 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2909 # @param AngleInRadians the angle of Rotation
2910 # @param NbOfSteps number of steps
2911 # @param Tolerance tolerance
2912 # @param MakeGroups forces the generation of new groups from existing ones
2913 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2914 # of all steps, else - size of each step
2915 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2916 # @ingroup l2_modif_extrurev
2917 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2918 MakeGroups=False, TotalAngle=False):
2920 if isinstance(AngleInRadians,str):
2922 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2924 AngleInRadians = DegreesToRadians(AngleInRadians)
2925 if ( isinstance( theObject, Mesh )):
2926 theObject = theObject.GetMesh()
2927 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2928 Axis = self.smeshpyD.GetAxisStruct(Axis)
2929 Axis,AxisParameters = ParseAxisStruct(Axis)
2930 if TotalAngle and NbOfSteps:
2931 AngleInRadians /= NbOfSteps
2932 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2933 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2934 self.mesh.SetParameters(Parameters)
2936 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2937 NbOfSteps, Tolerance)
2938 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2941 ## Generates new elements by rotation of the elements of object around the axis
2942 # @param theObject object which elements should be sweeped
2943 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2944 # @param AngleInRadians the angle of Rotation
2945 # @param NbOfSteps number of steps
2946 # @param Tolerance tolerance
2947 # @param MakeGroups forces the generation of new groups from existing ones
2948 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2949 # of all steps, else - size of each step
2950 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2951 # @ingroup l2_modif_extrurev
2952 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2953 MakeGroups=False, TotalAngle=False):
2955 if isinstance(AngleInRadians,str):
2957 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2959 AngleInRadians = DegreesToRadians(AngleInRadians)
2960 if ( isinstance( theObject, Mesh )):
2961 theObject = theObject.GetMesh()
2962 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2963 Axis = self.smeshpyD.GetAxisStruct(Axis)
2964 Axis,AxisParameters = ParseAxisStruct(Axis)
2965 if TotalAngle and NbOfSteps:
2966 AngleInRadians /= NbOfSteps
2967 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2968 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2969 self.mesh.SetParameters(Parameters)
2971 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2972 NbOfSteps, Tolerance)
2973 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2976 ## Generates new elements by rotation of the elements of object around the axis
2977 # @param theObject object which elements should be sweeped
2978 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2979 # @param AngleInRadians the angle of Rotation
2980 # @param NbOfSteps number of steps
2981 # @param Tolerance tolerance
2982 # @param MakeGroups forces the generation of new groups from existing ones
2983 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2984 # of all steps, else - size of each step
2985 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2986 # @ingroup l2_modif_extrurev
2987 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2988 MakeGroups=False, TotalAngle=False):
2990 if isinstance(AngleInRadians,str):
2992 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2994 AngleInRadians = DegreesToRadians(AngleInRadians)
2995 if ( isinstance( theObject, Mesh )):
2996 theObject = theObject.GetMesh()
2997 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2998 Axis = self.smeshpyD.GetAxisStruct(Axis)
2999 Axis,AxisParameters = ParseAxisStruct(Axis)
3000 if TotalAngle and NbOfSteps:
3001 AngleInRadians /= NbOfSteps
3002 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3003 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3004 self.mesh.SetParameters(Parameters)
3006 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
3007 NbOfSteps, Tolerance)
3008 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3011 ## Generates new elements by extrusion of the elements with given ids
3012 # @param IDsOfElements the list of elements ids for extrusion
3013 # @param StepVector vector, defining the direction and value of extrusion
3014 # @param NbOfSteps the number of steps
3015 # @param MakeGroups forces the generation of new groups from existing ones
3016 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3017 # @ingroup l2_modif_extrurev
3018 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
3019 if IDsOfElements == []:
3020 IDsOfElements = self.GetElementsId()
3021 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3022 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3023 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3024 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3025 Parameters = StepVectorParameters + var_separator + Parameters
3026 self.mesh.SetParameters(Parameters)
3028 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
3029 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
3032 ## Generates new elements by extrusion of the elements with given ids
3033 # @param IDsOfElements is ids of elements
3034 # @param StepVector vector, defining the direction and value of extrusion
3035 # @param NbOfSteps the number of steps
3036 # @param ExtrFlags sets flags for extrusion
3037 # @param SewTolerance uses for comparing locations of nodes if flag
3038 # EXTRUSION_FLAG_SEW is set
3039 # @param MakeGroups forces the generation of new groups from existing ones
3040 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3041 # @ingroup l2_modif_extrurev
3042 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
3043 ExtrFlags, SewTolerance, MakeGroups=False):
3044 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3045 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3047 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
3048 ExtrFlags, SewTolerance)
3049 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
3050 ExtrFlags, SewTolerance)
3053 ## Generates new elements by extrusion of the elements which belong to the object
3054 # @param theObject the object which elements should be processed
3055 # @param StepVector vector, defining the direction and value of extrusion
3056 # @param NbOfSteps the number of steps
3057 # @param MakeGroups forces the generation of new groups from existing ones
3058 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3059 # @ingroup l2_modif_extrurev
3060 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3061 if ( isinstance( theObject, Mesh )):
3062 theObject = theObject.GetMesh()
3063 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3064 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3065 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3066 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3067 Parameters = StepVectorParameters + var_separator + Parameters
3068 self.mesh.SetParameters(Parameters)
3070 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3071 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
3074 ## Generates new elements by extrusion of the elements which belong to the object
3075 # @param theObject object which elements should be processed
3076 # @param StepVector vector, defining the direction and value of extrusion
3077 # @param NbOfSteps the number of steps
3078 # @param MakeGroups to generate new groups from existing ones
3079 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3080 # @ingroup l2_modif_extrurev
3081 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3082 if ( isinstance( theObject, Mesh )):
3083 theObject = theObject.GetMesh()
3084 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3085 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3086 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3087 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3088 Parameters = StepVectorParameters + var_separator + Parameters
3089 self.mesh.SetParameters(Parameters)
3091 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3092 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3095 ## Generates new elements by extrusion of the elements which belong to the object
3096 # @param theObject object which elements should be processed
3097 # @param StepVector vector, defining the direction and value of extrusion
3098 # @param NbOfSteps the number of steps
3099 # @param MakeGroups forces the generation of new groups from existing ones
3100 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3101 # @ingroup l2_modif_extrurev
3102 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3103 if ( isinstance( theObject, Mesh )):
3104 theObject = theObject.GetMesh()
3105 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3106 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3107 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3108 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3109 Parameters = StepVectorParameters + var_separator + Parameters
3110 self.mesh.SetParameters(Parameters)
3112 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3113 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3118 ## Generates new elements by extrusion of the given elements
3119 # The path of extrusion must be a meshed edge.
3120 # @param Base mesh or list of ids of elements for extrusion
3121 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3122 # @param NodeStart the start node from Path. Defines the direction of extrusion
3123 # @param HasAngles allows the shape to be rotated around the path
3124 # to get the resulting mesh in a helical fashion
3125 # @param Angles list of angles in radians
3126 # @param LinearVariation forces the computation of rotation angles as linear
3127 # variation of the given Angles along path steps
3128 # @param HasRefPoint allows using the reference point
3129 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3130 # The User can specify any point as the Reference Point.
3131 # @param MakeGroups forces the generation of new groups from existing ones
3132 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3133 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3134 # only SMESH::Extrusion_Error otherwise
3135 # @ingroup l2_modif_extrurev
3136 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3137 HasAngles, Angles, LinearVariation,
3138 HasRefPoint, RefPoint, MakeGroups, ElemType):
3139 Angles,AnglesParameters = ParseAngles(Angles)
3140 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3141 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3142 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3144 Parameters = AnglesParameters + var_separator + RefPointParameters
3145 self.mesh.SetParameters(Parameters)
3147 if isinstance(Base,list):
3149 if Base == []: IDsOfElements = self.GetElementsId()
3150 else: IDsOfElements = Base
3151 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3152 HasAngles, Angles, LinearVariation,
3153 HasRefPoint, RefPoint, MakeGroups, ElemType)
3155 if isinstance(Base,Mesh):
3156 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3157 HasAngles, Angles, LinearVariation,
3158 HasRefPoint, RefPoint, MakeGroups, ElemType)
3160 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3163 ## Generates new elements by extrusion of the given elements
3164 # The path of extrusion must be a meshed edge.
3165 # @param IDsOfElements ids of elements
3166 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3167 # @param PathShape shape(edge) defines the sub-mesh for the path
3168 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3169 # @param HasAngles allows the shape to be rotated around the path
3170 # to get the resulting mesh in a helical fashion
3171 # @param Angles list of angles in radians
3172 # @param HasRefPoint allows using the reference point
3173 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3174 # The User can specify any point as the Reference Point.
3175 # @param MakeGroups forces the generation of new groups from existing ones
3176 # @param LinearVariation forces the computation of rotation angles as linear
3177 # variation of the given Angles along path steps
3178 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3179 # only SMESH::Extrusion_Error otherwise
3180 # @ingroup l2_modif_extrurev
3181 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3182 HasAngles, Angles, HasRefPoint, RefPoint,
3183 MakeGroups=False, LinearVariation=False):
3184 Angles,AnglesParameters = ParseAngles(Angles)
3185 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3186 if IDsOfElements == []:
3187 IDsOfElements = self.GetElementsId()
3188 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3189 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3191 if ( isinstance( PathMesh, Mesh )):
3192 PathMesh = PathMesh.GetMesh()
3193 if HasAngles and Angles and LinearVariation:
3194 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3196 Parameters = AnglesParameters + var_separator + RefPointParameters
3197 self.mesh.SetParameters(Parameters)
3199 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3200 PathShape, NodeStart, HasAngles,
3201 Angles, HasRefPoint, RefPoint)
3202 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3203 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3205 ## Generates new elements by extrusion of the elements which belong to the object
3206 # The path of extrusion must be a meshed edge.
3207 # @param theObject the object which elements should be processed
3208 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3209 # @param PathShape shape(edge) defines the sub-mesh for the path
3210 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3211 # @param HasAngles allows the shape to be rotated around the path
3212 # to get the resulting mesh in a helical fashion
3213 # @param Angles list of angles
3214 # @param HasRefPoint allows using the reference point
3215 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3216 # The User can specify any point as the Reference Point.
3217 # @param MakeGroups forces the generation of new groups from existing ones
3218 # @param LinearVariation forces the computation of rotation angles as linear
3219 # variation of the given Angles along path steps
3220 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3221 # only SMESH::Extrusion_Error otherwise
3222 # @ingroup l2_modif_extrurev
3223 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3224 HasAngles, Angles, HasRefPoint, RefPoint,
3225 MakeGroups=False, LinearVariation=False):
3226 Angles,AnglesParameters = ParseAngles(Angles)
3227 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3228 if ( isinstance( theObject, Mesh )):
3229 theObject = theObject.GetMesh()
3230 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3231 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3232 if ( isinstance( PathMesh, Mesh )):
3233 PathMesh = PathMesh.GetMesh()
3234 if HasAngles and Angles and LinearVariation:
3235 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3237 Parameters = AnglesParameters + var_separator + RefPointParameters
3238 self.mesh.SetParameters(Parameters)
3240 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3241 PathShape, NodeStart, HasAngles,
3242 Angles, HasRefPoint, RefPoint)
3243 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3244 NodeStart, HasAngles, Angles, HasRefPoint,
3247 ## Generates new elements by extrusion of the elements which belong to the object
3248 # The path of extrusion must be a meshed edge.
3249 # @param theObject the object which elements should be processed
3250 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3251 # @param PathShape shape(edge) defines the sub-mesh for the path
3252 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3253 # @param HasAngles allows the shape to be rotated around the path
3254 # to get the resulting mesh in a helical fashion
3255 # @param Angles list of angles
3256 # @param HasRefPoint allows using the reference point
3257 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3258 # The User can specify any point as the Reference Point.
3259 # @param MakeGroups forces the generation of new groups from existing ones
3260 # @param LinearVariation forces the computation of rotation angles as linear
3261 # variation of the given Angles along path steps
3262 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3263 # only SMESH::Extrusion_Error otherwise
3264 # @ingroup l2_modif_extrurev
3265 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3266 HasAngles, Angles, HasRefPoint, RefPoint,
3267 MakeGroups=False, LinearVariation=False):
3268 Angles,AnglesParameters = ParseAngles(Angles)
3269 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3270 if ( isinstance( theObject, Mesh )):
3271 theObject = theObject.GetMesh()
3272 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3273 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3274 if ( isinstance( PathMesh, Mesh )):
3275 PathMesh = PathMesh.GetMesh()
3276 if HasAngles and Angles and LinearVariation:
3277 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3279 Parameters = AnglesParameters + var_separator + RefPointParameters
3280 self.mesh.SetParameters(Parameters)
3282 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3283 PathShape, NodeStart, HasAngles,
3284 Angles, HasRefPoint, RefPoint)
3285 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3286 NodeStart, HasAngles, Angles, HasRefPoint,
3289 ## Generates new elements by extrusion of the elements which belong to the object
3290 # The path of extrusion must be a meshed edge.
3291 # @param theObject the object which elements should be processed
3292 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3293 # @param PathShape shape(edge) defines the sub-mesh for the path
3294 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3295 # @param HasAngles allows the shape to be rotated around the path
3296 # to get the resulting mesh in a helical fashion
3297 # @param Angles list of angles
3298 # @param HasRefPoint allows using the reference point
3299 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3300 # The User can specify any point as the Reference Point.
3301 # @param MakeGroups forces the generation of new groups from existing ones
3302 # @param LinearVariation forces the computation of rotation angles as linear
3303 # variation of the given Angles along path steps
3304 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3305 # only SMESH::Extrusion_Error otherwise
3306 # @ingroup l2_modif_extrurev
3307 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3308 HasAngles, Angles, HasRefPoint, RefPoint,
3309 MakeGroups=False, LinearVariation=False):
3310 Angles,AnglesParameters = ParseAngles(Angles)
3311 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3312 if ( isinstance( theObject, Mesh )):
3313 theObject = theObject.GetMesh()
3314 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3315 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3316 if ( isinstance( PathMesh, Mesh )):
3317 PathMesh = PathMesh.GetMesh()
3318 if HasAngles and Angles and LinearVariation:
3319 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3321 Parameters = AnglesParameters + var_separator + RefPointParameters
3322 self.mesh.SetParameters(Parameters)
3324 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3325 PathShape, NodeStart, HasAngles,
3326 Angles, HasRefPoint, RefPoint)
3327 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3328 NodeStart, HasAngles, Angles, HasRefPoint,
3331 ## Creates a symmetrical copy of mesh elements
3332 # @param IDsOfElements list of elements ids
3333 # @param Mirror is AxisStruct or geom object(point, line, plane)
3334 # @param theMirrorType is POINT, AXIS or PLANE
3335 # If the Mirror is a geom object this parameter is unnecessary
3336 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3337 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3338 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3339 # @ingroup l2_modif_trsf
3340 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3341 if IDsOfElements == []:
3342 IDsOfElements = self.GetElementsId()
3343 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3344 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3345 Mirror,Parameters = ParseAxisStruct(Mirror)
3346 self.mesh.SetParameters(Parameters)
3347 if Copy and MakeGroups:
3348 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3349 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3352 ## Creates a new mesh by a symmetrical copy of mesh elements
3353 # @param IDsOfElements the list of elements ids
3354 # @param Mirror is AxisStruct or geom object (point, line, plane)
3355 # @param theMirrorType is POINT, AXIS or PLANE
3356 # If the Mirror is a geom object this parameter is unnecessary
3357 # @param MakeGroups to generate new groups from existing ones
3358 # @param NewMeshName a name of the new mesh to create
3359 # @return instance of Mesh class
3360 # @ingroup l2_modif_trsf
3361 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3362 if IDsOfElements == []:
3363 IDsOfElements = self.GetElementsId()
3364 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3365 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3366 Mirror,Parameters = ParseAxisStruct(Mirror)
3367 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3368 MakeGroups, NewMeshName)
3369 mesh.SetParameters(Parameters)
3370 return Mesh(self.smeshpyD,self.geompyD,mesh)
3372 ## Creates a symmetrical copy of the object
3373 # @param theObject mesh, submesh or group
3374 # @param Mirror AxisStruct or geom object (point, line, plane)
3375 # @param theMirrorType is POINT, AXIS or PLANE
3376 # If the Mirror is a geom object this parameter is unnecessary
3377 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3378 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3379 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3380 # @ingroup l2_modif_trsf
3381 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3382 if ( isinstance( theObject, Mesh )):
3383 theObject = theObject.GetMesh()
3384 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3385 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3386 Mirror,Parameters = ParseAxisStruct(Mirror)
3387 self.mesh.SetParameters(Parameters)
3388 if Copy and MakeGroups:
3389 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3390 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3393 ## Creates a new mesh by a symmetrical copy of the object
3394 # @param theObject mesh, submesh or group
3395 # @param Mirror AxisStruct or geom object (point, line, plane)
3396 # @param theMirrorType POINT, AXIS or PLANE
3397 # If the Mirror is a geom object this parameter is unnecessary
3398 # @param MakeGroups forces the generation of new groups from existing ones
3399 # @param NewMeshName the name of the new mesh to create
3400 # @return instance of Mesh class
3401 # @ingroup l2_modif_trsf
3402 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3403 if ( isinstance( theObject, Mesh )):
3404 theObject = theObject.GetMesh()
3405 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3406 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3407 Mirror,Parameters = ParseAxisStruct(Mirror)
3408 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3409 MakeGroups, NewMeshName)
3410 mesh.SetParameters(Parameters)
3411 return Mesh( self.smeshpyD,self.geompyD,mesh )
3413 ## Translates the elements
3414 # @param IDsOfElements list of elements ids
3415 # @param Vector the direction of translation (DirStruct or vector)
3416 # @param Copy allows copying the translated elements
3417 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3418 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3419 # @ingroup l2_modif_trsf
3420 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3421 if IDsOfElements == []:
3422 IDsOfElements = self.GetElementsId()
3423 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3424 Vector = self.smeshpyD.GetDirStruct(Vector)
3425 Vector,Parameters = ParseDirStruct(Vector)
3426 self.mesh.SetParameters(Parameters)
3427 if Copy and MakeGroups:
3428 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3429 self.editor.Translate(IDsOfElements, Vector, Copy)
3432 ## Creates a new mesh of translated elements
3433 # @param IDsOfElements list of elements ids
3434 # @param Vector the direction of translation (DirStruct or vector)
3435 # @param MakeGroups forces the generation of new groups from existing ones
3436 # @param NewMeshName the name of the newly created mesh
3437 # @return instance of Mesh class
3438 # @ingroup l2_modif_trsf
3439 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3440 if IDsOfElements == []:
3441 IDsOfElements = self.GetElementsId()
3442 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3443 Vector = self.smeshpyD.GetDirStruct(Vector)
3444 Vector,Parameters = ParseDirStruct(Vector)
3445 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3446 mesh.SetParameters(Parameters)
3447 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3449 ## Translates the object
3450 # @param theObject the object to translate (mesh, submesh, or group)
3451 # @param Vector direction of translation (DirStruct or geom vector)
3452 # @param Copy allows copying the translated elements
3453 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3454 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3455 # @ingroup l2_modif_trsf
3456 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3457 if ( isinstance( theObject, Mesh )):
3458 theObject = theObject.GetMesh()
3459 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3460 Vector = self.smeshpyD.GetDirStruct(Vector)
3461 Vector,Parameters = ParseDirStruct(Vector)
3462 self.mesh.SetParameters(Parameters)
3463 if Copy and MakeGroups:
3464 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3465 self.editor.TranslateObject(theObject, Vector, Copy)
3468 ## Creates a new mesh from the translated object
3469 # @param theObject the object to translate (mesh, submesh, or group)
3470 # @param Vector the direction of translation (DirStruct or geom vector)
3471 # @param MakeGroups forces the generation of new groups from existing ones
3472 # @param NewMeshName the name of the newly created mesh
3473 # @return instance of Mesh class
3474 # @ingroup l2_modif_trsf
3475 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3476 if (isinstance(theObject, Mesh)):
3477 theObject = theObject.GetMesh()
3478 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3479 Vector = self.smeshpyD.GetDirStruct(Vector)
3480 Vector,Parameters = ParseDirStruct(Vector)
3481 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3482 mesh.SetParameters(Parameters)
3483 return Mesh( self.smeshpyD, self.geompyD, mesh )
3487 ## Scales the 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 Copy - allows copying the translated elements
3492 # @param MakeGroups - forces the generation of new groups from existing
3494 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3495 # empty list otherwise
3496 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3497 if ( isinstance( theObject, Mesh )):
3498 theObject = theObject.GetMesh()
3499 if ( isinstance( theObject, list )):
3500 theObject = self.editor.MakeIDSource(theObject, SMESH.ALL)
3502 thePoint, Parameters = ParsePointStruct(thePoint)
3503 self.mesh.SetParameters(Parameters)
3505 if Copy and MakeGroups:
3506 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3507 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3510 ## Creates a new mesh from the translated object
3511 # @param theObject - the object to translate (mesh, submesh, or group)
3512 # @param thePoint - base point for scale
3513 # @param theScaleFact - list of 1-3 scale factors for axises
3514 # @param MakeGroups - forces the generation of new groups from existing ones
3515 # @param NewMeshName - the name of the newly created mesh
3516 # @return instance of Mesh class
3517 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3518 if (isinstance(theObject, Mesh)):
3519 theObject = theObject.GetMesh()
3520 if ( isinstance( theObject, list )):
3521 theObject = self.editor.MakeIDSource(theObject,SMESH.ALL)
3523 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3524 MakeGroups, NewMeshName)
3525 #mesh.SetParameters(Parameters)
3526 return Mesh( self.smeshpyD, self.geompyD, mesh )
3530 ## Rotates the elements
3531 # @param IDsOfElements list of elements ids
3532 # @param Axis the axis of rotation (AxisStruct or geom line)
3533 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3534 # @param Copy allows copying the rotated elements
3535 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3536 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3537 # @ingroup l2_modif_trsf
3538 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3540 if isinstance(AngleInRadians,str):
3542 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3544 AngleInRadians = DegreesToRadians(AngleInRadians)
3545 if IDsOfElements == []:
3546 IDsOfElements = self.GetElementsId()
3547 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3548 Axis = self.smeshpyD.GetAxisStruct(Axis)
3549 Axis,AxisParameters = ParseAxisStruct(Axis)
3550 Parameters = AxisParameters + var_separator + Parameters
3551 self.mesh.SetParameters(Parameters)
3552 if Copy and MakeGroups:
3553 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3554 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3557 ## Creates a new mesh of rotated elements
3558 # @param IDsOfElements list of element ids
3559 # @param Axis the axis of rotation (AxisStruct or geom line)
3560 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3561 # @param MakeGroups forces the generation of new groups from existing ones
3562 # @param NewMeshName the name of the newly created mesh
3563 # @return instance of Mesh class
3564 # @ingroup l2_modif_trsf
3565 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3567 if isinstance(AngleInRadians,str):
3569 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3571 AngleInRadians = DegreesToRadians(AngleInRadians)
3572 if IDsOfElements == []:
3573 IDsOfElements = self.GetElementsId()
3574 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3575 Axis = self.smeshpyD.GetAxisStruct(Axis)
3576 Axis,AxisParameters = ParseAxisStruct(Axis)
3577 Parameters = AxisParameters + var_separator + Parameters
3578 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3579 MakeGroups, NewMeshName)
3580 mesh.SetParameters(Parameters)
3581 return Mesh( self.smeshpyD, self.geompyD, mesh )
3583 ## Rotates the object
3584 # @param theObject the object to rotate( mesh, submesh, or group)
3585 # @param Axis the axis of rotation (AxisStruct or geom line)
3586 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3587 # @param Copy allows copying the rotated elements
3588 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3589 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3590 # @ingroup l2_modif_trsf
3591 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3593 if isinstance(AngleInRadians,str):
3595 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3597 AngleInRadians = DegreesToRadians(AngleInRadians)
3598 if (isinstance(theObject, Mesh)):
3599 theObject = theObject.GetMesh()
3600 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3601 Axis = self.smeshpyD.GetAxisStruct(Axis)
3602 Axis,AxisParameters = ParseAxisStruct(Axis)
3603 Parameters = AxisParameters + ":" + Parameters
3604 self.mesh.SetParameters(Parameters)
3605 if Copy and MakeGroups:
3606 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3607 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3610 ## Creates a new mesh from the rotated object
3611 # @param theObject the object to rotate (mesh, submesh, or group)
3612 # @param Axis the axis of rotation (AxisStruct or geom line)
3613 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3614 # @param MakeGroups forces the generation of new groups from existing ones
3615 # @param NewMeshName the name of the newly created mesh
3616 # @return instance of Mesh class
3617 # @ingroup l2_modif_trsf
3618 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3620 if isinstance(AngleInRadians,str):
3622 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3624 AngleInRadians = DegreesToRadians(AngleInRadians)
3625 if (isinstance( theObject, Mesh )):
3626 theObject = theObject.GetMesh()
3627 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3628 Axis = self.smeshpyD.GetAxisStruct(Axis)
3629 Axis,AxisParameters = ParseAxisStruct(Axis)
3630 Parameters = AxisParameters + ":" + Parameters
3631 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3632 MakeGroups, NewMeshName)
3633 mesh.SetParameters(Parameters)
3634 return Mesh( self.smeshpyD, self.geompyD, mesh )
3636 ## Finds groups of ajacent nodes within Tolerance.
3637 # @param Tolerance the value of tolerance
3638 # @return the list of groups of nodes
3639 # @ingroup l2_modif_trsf
3640 def FindCoincidentNodes (self, Tolerance):
3641 return self.editor.FindCoincidentNodes(Tolerance)
3643 ## Finds groups of ajacent nodes within Tolerance.
3644 # @param Tolerance the value of tolerance
3645 # @param SubMeshOrGroup SubMesh or Group
3646 # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
3647 # @return the list of groups of nodes
3648 # @ingroup l2_modif_trsf
3649 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
3650 if (isinstance( SubMeshOrGroup, Mesh )):
3651 SubMeshOrGroup = SubMeshOrGroup.GetMesh()
3652 if not isinstance( ExceptSubMeshOrGroups, list):
3653 ExceptSubMeshOrGroups = [ ExceptSubMeshOrGroups ]
3654 if ExceptSubMeshOrGroups and isinstance( ExceptSubMeshOrGroups[0], int):
3655 ExceptSubMeshOrGroups = [ self.editor.MakeIDSource( ExceptSubMeshOrGroups, SMESH.NODE)]
3656 return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,ExceptSubMeshOrGroups)
3659 # @param GroupsOfNodes the list of groups of nodes
3660 # @ingroup l2_modif_trsf
3661 def MergeNodes (self, GroupsOfNodes):
3662 self.editor.MergeNodes(GroupsOfNodes)
3664 ## Finds the elements built on the same nodes.
3665 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3666 # @return a list of groups of equal elements
3667 # @ingroup l2_modif_trsf
3668 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3669 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3670 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3671 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3673 ## Merges elements in each given group.
3674 # @param GroupsOfElementsID groups of elements for merging
3675 # @ingroup l2_modif_trsf
3676 def MergeElements(self, GroupsOfElementsID):
3677 self.editor.MergeElements(GroupsOfElementsID)
3679 ## Leaves one element and removes all other elements built on the same nodes.
3680 # @ingroup l2_modif_trsf
3681 def MergeEqualElements(self):
3682 self.editor.MergeEqualElements()
3684 ## Sews free borders
3685 # @return SMESH::Sew_Error
3686 # @ingroup l2_modif_trsf
3687 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3688 FirstNodeID2, SecondNodeID2, LastNodeID2,
3689 CreatePolygons, CreatePolyedrs):
3690 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3691 FirstNodeID2, SecondNodeID2, LastNodeID2,
3692 CreatePolygons, CreatePolyedrs)
3694 ## Sews conform free borders
3695 # @return SMESH::Sew_Error
3696 # @ingroup l2_modif_trsf
3697 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3698 FirstNodeID2, SecondNodeID2):
3699 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3700 FirstNodeID2, SecondNodeID2)
3702 ## Sews border to side
3703 # @return SMESH::Sew_Error
3704 # @ingroup l2_modif_trsf
3705 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3706 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3707 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3708 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3710 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3711 # merged with the nodes of elements of Side2.
3712 # The number of elements in theSide1 and in theSide2 must be
3713 # equal and they should have similar nodal connectivity.
3714 # The nodes to merge should belong to side borders and
3715 # the first node should be linked to the second.
3716 # @return SMESH::Sew_Error
3717 # @ingroup l2_modif_trsf
3718 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3719 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3720 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3721 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3722 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3723 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3725 ## Sets new nodes for the given element.
3726 # @param ide the element id
3727 # @param newIDs nodes ids
3728 # @return If the number of nodes does not correspond to the type of element - returns false
3729 # @ingroup l2_modif_edit
3730 def ChangeElemNodes(self, ide, newIDs):
3731 return self.editor.ChangeElemNodes(ide, newIDs)
3733 ## If during the last operation of MeshEditor some nodes were
3734 # created, this method returns the list of their IDs, \n
3735 # if new nodes were not created - returns empty list
3736 # @return the list of integer values (can be empty)
3737 # @ingroup l1_auxiliary
3738 def GetLastCreatedNodes(self):
3739 return self.editor.GetLastCreatedNodes()
3741 ## If during the last operation of MeshEditor some elements were
3742 # created this method returns the list of their IDs, \n
3743 # if new elements were not created - returns empty list
3744 # @return the list of integer values (can be empty)
3745 # @ingroup l1_auxiliary
3746 def GetLastCreatedElems(self):
3747 return self.editor.GetLastCreatedElems()
3749 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3750 # @param theNodes identifiers of nodes to be doubled
3751 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
3752 # nodes. If list of element identifiers is empty then nodes are doubled but
3753 # they not assigned to elements
3754 # @return TRUE if operation has been completed successfully, FALSE otherwise
3755 # @ingroup l2_modif_edit
3756 def DoubleNodes(self, theNodes, theModifiedElems):
3757 return self.editor.DoubleNodes(theNodes, theModifiedElems)
3759 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3760 # This method provided for convenience works as DoubleNodes() described above.
3761 # @param theNodeId identifiers of node to be doubled
3762 # @param theModifiedElems identifiers of elements to be updated
3763 # @return TRUE if operation has been completed successfully, FALSE otherwise
3764 # @ingroup l2_modif_edit
3765 def DoubleNode(self, theNodeId, theModifiedElems):
3766 return self.editor.DoubleNode(theNodeId, theModifiedElems)
3768 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3769 # This method provided for convenience works as DoubleNodes() described above.
3770 # @param theNodes group of nodes to be doubled
3771 # @param theModifiedElems group of elements to be updated.
3772 # @param theMakeGroup forces the generation of a group containing new nodes.
3773 # @return TRUE or a created group if operation has been completed successfully,
3774 # FALSE or None otherwise
3775 # @ingroup l2_modif_edit
3776 def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
3778 return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
3779 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3781 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3782 # This method provided for convenience works as DoubleNodes() described above.
3783 # @param theNodes list of groups of nodes to be doubled
3784 # @param theModifiedElems list of groups of elements to be updated.
3785 # @return TRUE if operation has been completed successfully, FALSE otherwise
3786 # @ingroup l2_modif_edit
3787 def DoubleNodeGroups(self, theNodes, theModifiedElems):
3788 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3790 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3791 # @param theElems - the list of elements (edges or faces) to be replicated
3792 # The nodes for duplication could be found from these elements
3793 # @param theNodesNot - list of nodes to NOT replicate
3794 # @param theAffectedElems - the list of elements (cells and edges) to which the
3795 # replicated nodes should be associated to.
3796 # @return TRUE if operation has been completed successfully, FALSE otherwise
3797 # @ingroup l2_modif_edit
3798 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
3799 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
3801 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3802 # @param theElems - the list of elements (edges or faces) to be replicated
3803 # The nodes for duplication could be found from these elements
3804 # @param theNodesNot - list of nodes to NOT replicate
3805 # @param theShape - shape to detect affected elements (element which geometric center
3806 # located on or inside shape).
3807 # The replicated nodes should be associated to affected elements.
3808 # @return TRUE if operation has been completed successfully, FALSE otherwise
3809 # @ingroup l2_modif_edit
3810 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
3811 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
3813 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3814 # This method provided for convenience works as DoubleNodes() described above.
3815 # @param theElems - group of of elements (edges or faces) to be replicated
3816 # @param theNodesNot - group of nodes not to replicated
3817 # @param theAffectedElems - group of elements to which the replicated nodes
3818 # should be associated to.
3819 # @param theMakeGroup forces the generation of a group containing new elements.
3820 # @ingroup l2_modif_edit
3821 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
3823 return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
3824 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
3826 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3827 # This method provided for convenience works as DoubleNodes() described above.
3828 # @param theElems - group of of elements (edges or faces) to be replicated
3829 # @param theNodesNot - group of nodes not to replicated
3830 # @param theShape - shape to detect affected elements (element which geometric center
3831 # located on or inside shape).
3832 # The replicated nodes should be associated to affected elements.
3833 # @ingroup l2_modif_edit
3834 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
3835 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
3837 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3838 # This method provided for convenience works as DoubleNodes() described above.
3839 # @param theElems - list of groups of elements (edges or faces) to be replicated
3840 # @param theNodesNot - list of groups of nodes not to replicated
3841 # @param theAffectedElems - group of elements to which the replicated nodes
3842 # should be associated to.
3843 # @return TRUE if operation has been completed successfully, FALSE otherwise
3844 # @ingroup l2_modif_edit
3845 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems):
3846 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
3848 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3849 # This method provided for convenience works as DoubleNodes() described above.
3850 # @param theElems - list of groups of elements (edges or faces) to be replicated
3851 # @param theNodesNot - list of groups of nodes not to replicated
3852 # @param theShape - shape to detect affected elements (element which geometric center
3853 # located on or inside shape).
3854 # The replicated nodes should be associated to affected elements.
3855 # @return TRUE if operation has been completed successfully, FALSE otherwise
3856 # @ingroup l2_modif_edit
3857 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
3858 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
3860 def _valueFromFunctor(self, funcType, elemId):
3861 fn = self.smeshpyD.GetFunctor(funcType)
3862 fn.SetMesh(self.mesh)
3863 if fn.GetElementType() == self.GetElementType(elemId, True):
3864 val = fn.GetValue(elemId)
3869 ## Get length of 1D element.
3870 # @param elemId mesh element ID
3871 # @return element's length value
3872 # @ingroup l1_measurements
3873 def GetLength(self, elemId):
3874 return self._valueFromFunctor(SMESH.FT_Length, elemId)
3876 ## Get area of 2D element.
3877 # @param elemId mesh element ID
3878 # @return element's area value
3879 # @ingroup l1_measurements
3880 def GetArea(self, elemId):
3881 return self._valueFromFunctor(SMESH.FT_Area, elemId)
3883 ## Get volume of 3D element.
3884 # @param elemId mesh element ID
3885 # @return element's volume value
3886 # @ingroup l1_measurements
3887 def GetVolume(self, elemId):
3888 return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
3890 ## Get maximum element length.
3891 # @param elemId mesh element ID
3892 # @return element's maximum length value
3893 # @ingroup l1_measurements
3894 def GetMaxElementLength(self, elemId):
3895 if self.GetElementType(elemId, True) == SMESH.VOLUME:
3896 ftype = SMESH.FT_MaxElementLength3D
3898 ftype = SMESH.FT_MaxElementLength2D
3899 return self._valueFromFunctor(ftype, elemId)
3901 ## Get aspect ratio of 2D or 3D element.
3902 # @param elemId mesh element ID
3903 # @return element's aspect ratio value
3904 # @ingroup l1_measurements
3905 def GetAspectRatio(self, elemId):
3906 if self.GetElementType(elemId, True) == SMESH.VOLUME:
3907 ftype = SMESH.FT_AspectRatio3D
3909 ftype = SMESH.FT_AspectRatio
3910 return self._valueFromFunctor(ftype, elemId)
3912 ## Get warping angle of 2D element.
3913 # @param elemId mesh element ID
3914 # @return element's warping angle value
3915 # @ingroup l1_measurements
3916 def GetWarping(self, elemId):
3917 return self._valueFromFunctor(SMESH.FT_Warping, elemId)
3919 ## Get minimum angle of 2D element.
3920 # @param elemId mesh element ID
3921 # @return element's minimum angle value
3922 # @ingroup l1_measurements
3923 def GetMinimumAngle(self, elemId):
3924 return self._valueFromFunctor(SMESH.FT_MinimumAngle, elemId)
3926 ## Get taper of 2D element.
3927 # @param elemId mesh element ID
3928 # @return element's taper value
3929 # @ingroup l1_measurements
3930 def GetTaper(self, elemId):
3931 return self._valueFromFunctor(SMESH.FT_Taper, elemId)
3933 ## Get skew of 2D element.
3934 # @param elemId mesh element ID
3935 # @return element's skew value
3936 # @ingroup l1_measurements
3937 def GetSkew(self, elemId):
3938 return self._valueFromFunctor(SMESH.FT_Skew, elemId)
3940 ## The mother class to define algorithm, it is not recommended to use it directly.
3943 # @ingroup l2_algorithms
3944 class Mesh_Algorithm:
3945 # @class Mesh_Algorithm
3946 # @brief Class Mesh_Algorithm
3948 #def __init__(self,smesh):
3956 ## Finds a hypothesis in the study by its type name and parameters.
3957 # Finds only the hypotheses created in smeshpyD engine.
3958 # @return SMESH.SMESH_Hypothesis
3959 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3960 study = smeshpyD.GetCurrentStudy()
3961 #to do: find component by smeshpyD object, not by its data type
3962 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3963 if scomp is not None:
3964 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3965 # Check if the root label of the hypotheses exists
3966 if res and hypRoot is not None:
3967 iter = study.NewChildIterator(hypRoot)
3968 # Check all published hypotheses
3970 hypo_so_i = iter.Value()
3971 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3972 if attr is not None:
3973 anIOR = attr.Value()
3974 hypo_o_i = salome.orb.string_to_object(anIOR)
3975 if hypo_o_i is not None:
3976 # Check if this is a hypothesis
3977 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3978 if hypo_i is not None:
3979 # Check if the hypothesis belongs to current engine
3980 if smeshpyD.GetObjectId(hypo_i) > 0:
3981 # Check if this is the required hypothesis
3982 if hypo_i.GetName() == hypname:
3984 if CompareMethod(hypo_i, args):
3998 ## Finds the algorithm in the study by its type name.
3999 # Finds only the algorithms, which have been created in smeshpyD engine.
4000 # @return SMESH.SMESH_Algo
4001 def FindAlgorithm (self, algoname, smeshpyD):
4002 study = smeshpyD.GetCurrentStudy()
4003 #to do: find component by smeshpyD object, not by its data type
4004 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4005 if scomp is not None:
4006 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
4007 # Check if the root label of the algorithms exists
4008 if res and hypRoot is not None:
4009 iter = study.NewChildIterator(hypRoot)
4010 # Check all published algorithms
4012 algo_so_i = iter.Value()
4013 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
4014 if attr is not None:
4015 anIOR = attr.Value()
4016 algo_o_i = salome.orb.string_to_object(anIOR)
4017 if algo_o_i is not None:
4018 # Check if this is an algorithm
4019 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
4020 if algo_i is not None:
4021 # Checks if the algorithm belongs to the current engine
4022 if smeshpyD.GetObjectId(algo_i) > 0:
4023 # Check if this is the required algorithm
4024 if algo_i.GetName() == algoname:
4037 ## If the algorithm is global, returns 0; \n
4038 # else returns the submesh associated to this algorithm.
4039 def GetSubMesh(self):
4042 ## Returns the wrapped mesher.
4043 def GetAlgorithm(self):
4046 ## Gets the list of hypothesis that can be used with this algorithm
4047 def GetCompatibleHypothesis(self):
4050 mylist = self.algo.GetCompatibleHypothesis()
4053 ## Gets the name of the algorithm
4057 ## Sets the name to the algorithm
4058 def SetName(self, name):
4059 self.mesh.smeshpyD.SetName(self.algo, name)
4061 ## Gets the id of the algorithm
4063 return self.algo.GetId()
4066 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
4068 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
4069 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
4071 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
4073 self.Assign(algo, mesh, geom)
4077 def Assign(self, algo, mesh, geom):
4079 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
4088 name = GetName(geom)
4091 name = mesh.geompyD.SubShapeName(geom, piece)
4092 mesh.geompyD.addToStudyInFather(piece, geom, name)
4094 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
4097 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
4098 TreatHypoStatus( status, algo.GetName(), name, True )
4100 def CompareHyp (self, hyp, args):
4101 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
4104 def CompareEqualHyp (self, hyp, args):
4108 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
4109 UseExisting=0, CompareMethod=""):
4112 if CompareMethod == "": CompareMethod = self.CompareHyp
4113 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
4116 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
4122 a = a + s + str(args[i])
4126 self.mesh.smeshpyD.SetName(hypo, hyp + a)
4128 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
4129 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
4132 ## Returns entry of the shape to mesh in the study
4133 def MainShapeEntry(self):
4135 if not self.mesh or not self.mesh.GetMesh(): return entry
4136 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
4137 study = self.mesh.smeshpyD.GetCurrentStudy()
4138 ior = salome.orb.object_to_string( self.mesh.GetShape() )
4139 sobj = study.FindObjectIOR(ior)
4140 if sobj: entry = sobj.GetID()
4141 if not entry: return ""
4144 # Public class: Mesh_Segment
4145 # --------------------------
4147 ## Class to define a segment 1D algorithm for discretization
4150 # @ingroup l3_algos_basic
4151 class Mesh_Segment(Mesh_Algorithm):
4153 ## Private constructor.
4154 def __init__(self, mesh, geom=0):
4155 Mesh_Algorithm.__init__(self)
4156 self.Create(mesh, geom, "Regular_1D")
4158 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
4159 # @param l for the length of segments that cut an edge
4160 # @param UseExisting if ==true - searches for an existing hypothesis created with
4161 # the same parameters, else (default) - creates a new one
4162 # @param p precision, used for calculation of the number of segments.
4163 # The precision should be a positive, meaningful value within the range [0,1].
4164 # In general, the number of segments is calculated with the formula:
4165 # nb = ceil((edge_length / l) - p)
4166 # Function ceil rounds its argument to the higher integer.
4167 # So, p=0 means rounding of (edge_length / l) to the higher integer,
4168 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
4169 # p=1 means rounding of (edge_length / l) to the lower integer.
4170 # Default value is 1e-07.
4171 # @return an instance of StdMeshers_LocalLength hypothesis
4172 # @ingroup l3_hypos_1dhyps
4173 def LocalLength(self, l, UseExisting=0, p=1e-07):
4174 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
4175 CompareMethod=self.CompareLocalLength)
4181 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
4182 def CompareLocalLength(self, hyp, args):
4183 if IsEqual(hyp.GetLength(), args[0]):
4184 return IsEqual(hyp.GetPrecision(), args[1])
4187 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
4188 # @param length is optional maximal allowed length of segment, if it is omitted
4189 # the preestimated length is used that depends on geometry size
4190 # @param UseExisting if ==true - searches for an existing hypothesis created with
4191 # the same parameters, else (default) - create a new one
4192 # @return an instance of StdMeshers_MaxLength hypothesis
4193 # @ingroup l3_hypos_1dhyps
4194 def MaxSize(self, length=0.0, UseExisting=0):
4195 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
4198 hyp.SetLength(length)
4200 # set preestimated length
4201 gen = self.mesh.smeshpyD
4202 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
4203 self.mesh.GetMesh(), self.mesh.GetShape(),
4205 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
4207 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
4210 hyp.SetUsePreestimatedLength( length == 0.0 )
4213 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
4214 # @param n for the number of segments that cut an edge
4215 # @param s for the scale factor (optional)
4216 # @param reversedEdges is a list of edges to mesh using reversed orientation
4217 # @param UseExisting if ==true - searches for an existing hypothesis created with
4218 # the same parameters, else (default) - create a new one
4219 # @return an instance of StdMeshers_NumberOfSegments hypothesis
4220 # @ingroup l3_hypos_1dhyps
4221 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4222 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4223 reversedEdges, UseExisting = [], reversedEdges
4224 entry = self.MainShapeEntry()
4226 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
4227 UseExisting=UseExisting,
4228 CompareMethod=self.CompareNumberOfSegments)
4230 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
4231 UseExisting=UseExisting,
4232 CompareMethod=self.CompareNumberOfSegments)
4233 hyp.SetDistrType( 1 )
4234 hyp.SetScaleFactor(s)
4235 hyp.SetNumberOfSegments(n)
4236 hyp.SetReversedEdges( reversedEdges )
4237 hyp.SetObjectEntry( entry )
4241 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4242 def CompareNumberOfSegments(self, hyp, args):
4243 if hyp.GetNumberOfSegments() == args[0]:
4245 if hyp.GetReversedEdges() == args[1]:
4246 if not args[1] or hyp.GetObjectEntry() == args[2]:
4249 if hyp.GetReversedEdges() == args[2]:
4250 if not args[2] or hyp.GetObjectEntry() == args[3]:
4251 if hyp.GetDistrType() == 1:
4252 if IsEqual(hyp.GetScaleFactor(), args[1]):
4256 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4257 # @param start defines the length of the first segment
4258 # @param end defines the length of the last segment
4259 # @param reversedEdges is a list of edges to mesh using reversed orientation
4260 # @param UseExisting if ==true - searches for an existing hypothesis created with
4261 # the same parameters, else (default) - creates a new one
4262 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4263 # @ingroup l3_hypos_1dhyps
4264 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4265 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4266 reversedEdges, UseExisting = [], reversedEdges
4267 entry = self.MainShapeEntry()
4268 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
4269 UseExisting=UseExisting,
4270 CompareMethod=self.CompareArithmetic1D)
4271 hyp.SetStartLength(start)
4272 hyp.SetEndLength(end)
4273 hyp.SetReversedEdges( reversedEdges )
4274 hyp.SetObjectEntry( entry )
4278 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4279 def CompareArithmetic1D(self, hyp, args):
4280 if IsEqual(hyp.GetLength(1), args[0]):
4281 if IsEqual(hyp.GetLength(0), args[1]):
4282 if hyp.GetReversedEdges() == args[2]:
4283 if not args[2] or hyp.GetObjectEntry() == args[3]:
4288 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4289 # on curve from 0 to 1 (additionally it is neecessary to check
4290 # orientation of edges and create list of reversed edges if it is
4291 # needed) and sets numbers of segments between given points (default
4292 # values are equals 1
4293 # @param points defines the list of parameters on curve
4294 # @param nbSegs defines the list of numbers of segments
4295 # @param reversedEdges is a list of edges to mesh using reversed orientation
4296 # @param UseExisting if ==true - searches for an existing hypothesis created with
4297 # the same parameters, else (default) - creates a new one
4298 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4299 # @ingroup l3_hypos_1dhyps
4300 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4301 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4302 reversedEdges, UseExisting = [], reversedEdges
4303 if reversedEdges and isinstance( reversedEdges[0], geompyDC.GEOM._objref_GEOM_Object ):
4304 for i in range( len( reversedEdges )):
4305 reversedEdges[i] = self.mesh.geompyD.GetSubShapeID(self.mesh.geom, reversedEdges[i] )
4306 entry = self.MainShapeEntry()
4307 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
4308 UseExisting=UseExisting,
4309 CompareMethod=self.CompareFixedPoints1D)
4310 hyp.SetPoints(points)
4311 hyp.SetNbSegments(nbSegs)
4312 hyp.SetReversedEdges(reversedEdges)
4313 hyp.SetObjectEntry(entry)
4317 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4318 ## as the given arguments
4319 def CompareFixedPoints1D(self, hyp, args):
4320 if hyp.GetPoints() == args[0]:
4321 if hyp.GetNbSegments() == args[1]:
4322 if hyp.GetReversedEdges() == args[2]:
4323 if not args[2] or hyp.GetObjectEntry() == args[3]:
4329 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4330 # @param start defines the length of the first segment
4331 # @param end defines the length of the last segment
4332 # @param reversedEdges is a list of edges to mesh using reversed orientation
4333 # @param UseExisting if ==true - searches for an existing hypothesis created with
4334 # the same parameters, else (default) - creates a new one
4335 # @return an instance of StdMeshers_StartEndLength hypothesis
4336 # @ingroup l3_hypos_1dhyps
4337 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4338 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4339 reversedEdges, UseExisting = [], reversedEdges
4340 entry = self.MainShapeEntry()
4341 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
4342 UseExisting=UseExisting,
4343 CompareMethod=self.CompareStartEndLength)
4344 hyp.SetStartLength(start)
4345 hyp.SetEndLength(end)
4346 hyp.SetReversedEdges( reversedEdges )
4347 hyp.SetObjectEntry( entry )
4350 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4351 def CompareStartEndLength(self, hyp, args):
4352 if IsEqual(hyp.GetLength(1), args[0]):
4353 if IsEqual(hyp.GetLength(0), args[1]):
4354 if hyp.GetReversedEdges() == args[2]:
4355 if not args[2] or hyp.GetObjectEntry() == args[3]:
4359 ## Defines "Deflection1D" hypothesis
4360 # @param d for the deflection
4361 # @param UseExisting if ==true - searches for an existing hypothesis created with
4362 # the same parameters, else (default) - create a new one
4363 # @ingroup l3_hypos_1dhyps
4364 def Deflection1D(self, d, UseExisting=0):
4365 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4366 CompareMethod=self.CompareDeflection1D)
4367 hyp.SetDeflection(d)
4370 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4371 def CompareDeflection1D(self, hyp, args):
4372 return IsEqual(hyp.GetDeflection(), args[0])
4374 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4375 # the opposite side in case of quadrangular faces
4376 # @ingroup l3_hypos_additi
4377 def Propagation(self):
4378 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4380 ## Defines "AutomaticLength" hypothesis
4381 # @param fineness for the fineness [0-1]
4382 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4383 # same parameters, else (default) - create a new one
4384 # @ingroup l3_hypos_1dhyps
4385 def AutomaticLength(self, fineness=0, UseExisting=0):
4386 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4387 CompareMethod=self.CompareAutomaticLength)
4388 hyp.SetFineness( fineness )
4391 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4392 def CompareAutomaticLength(self, hyp, args):
4393 return IsEqual(hyp.GetFineness(), args[0])
4395 ## Defines "SegmentLengthAroundVertex" hypothesis
4396 # @param length for the segment length
4397 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4398 # Any other integer value means that the hypothesis will be set on the
4399 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4400 # @param UseExisting if ==true - searches for an existing hypothesis created with
4401 # the same parameters, else (default) - creates a new one
4402 # @ingroup l3_algos_segmarv
4403 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4405 store_geom = self.geom
4406 if type(vertex) is types.IntType:
4407 if vertex == 0 or vertex == 1:
4408 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
4416 if self.geom is None:
4417 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4419 name = GetName(self.geom)
4422 piece = self.mesh.geom
4423 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
4424 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
4426 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4428 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4430 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4431 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4433 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4434 CompareMethod=self.CompareLengthNearVertex)
4435 self.geom = store_geom
4436 hyp.SetLength( length )
4439 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4440 # @ingroup l3_algos_segmarv
4441 def CompareLengthNearVertex(self, hyp, args):
4442 return IsEqual(hyp.GetLength(), args[0])
4444 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4445 # If the 2D mesher sees that all boundary edges are quadratic,
4446 # it generates quadratic faces, else it generates linear faces using
4447 # medium nodes as if they are vertices.
4448 # The 3D mesher generates quadratic volumes only if all boundary faces
4449 # are quadratic, else it fails.
4451 # @ingroup l3_hypos_additi
4452 def QuadraticMesh(self):
4453 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4456 # Public class: Mesh_CompositeSegment
4457 # --------------------------
4459 ## Defines a segment 1D algorithm for discretization
4461 # @ingroup l3_algos_basic
4462 class Mesh_CompositeSegment(Mesh_Segment):
4464 ## Private constructor.
4465 def __init__(self, mesh, geom=0):
4466 self.Create(mesh, geom, "CompositeSegment_1D")
4469 # Public class: Mesh_Segment_Python
4470 # ---------------------------------
4472 ## Defines a segment 1D algorithm for discretization with python function
4474 # @ingroup l3_algos_basic
4475 class Mesh_Segment_Python(Mesh_Segment):
4477 ## Private constructor.
4478 def __init__(self, mesh, geom=0):
4479 import Python1dPlugin
4480 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4482 ## Defines "PythonSplit1D" hypothesis
4483 # @param n for the number of segments that cut an edge
4484 # @param func for the python function that calculates the length of all segments
4485 # @param UseExisting if ==true - searches for the existing hypothesis created with
4486 # the same parameters, else (default) - creates a new one
4487 # @ingroup l3_hypos_1dhyps
4488 def PythonSplit1D(self, n, func, UseExisting=0):
4489 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4490 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4491 hyp.SetNumberOfSegments(n)
4492 hyp.SetPythonLog10RatioFunction(func)
4495 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4496 def ComparePythonSplit1D(self, hyp, args):
4497 #if hyp.GetNumberOfSegments() == args[0]:
4498 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4502 # Public class: Mesh_Triangle
4503 # ---------------------------
4505 ## Defines a triangle 2D algorithm
4507 # @ingroup l3_algos_basic
4508 class Mesh_Triangle(Mesh_Algorithm):
4517 ## Private constructor.
4518 def __init__(self, mesh, algoType, geom=0):
4519 Mesh_Algorithm.__init__(self)
4521 self.algoType = algoType
4522 if algoType == MEFISTO:
4523 self.Create(mesh, geom, "MEFISTO_2D")
4525 elif algoType == BLSURF:
4527 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4528 #self.SetPhysicalMesh() - PAL19680
4529 elif algoType == NETGEN:
4531 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4533 elif algoType == NETGEN_2D:
4535 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4538 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4539 # @param area for the maximum area of each triangle
4540 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4541 # same parameters, else (default) - creates a new one
4543 # Only for algoType == MEFISTO || NETGEN_2D
4544 # @ingroup l3_hypos_2dhyps
4545 def MaxElementArea(self, area, UseExisting=0):
4546 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4547 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4548 CompareMethod=self.CompareMaxElementArea)
4549 elif self.algoType == NETGEN:
4550 hyp = self.Parameters(SIMPLE)
4551 hyp.SetMaxElementArea(area)
4554 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4555 def CompareMaxElementArea(self, hyp, args):
4556 return IsEqual(hyp.GetMaxElementArea(), args[0])
4558 ## Defines "LengthFromEdges" hypothesis to build triangles
4559 # based on the length of the edges taken from the wire
4561 # Only for algoType == MEFISTO || NETGEN_2D
4562 # @ingroup l3_hypos_2dhyps
4563 def LengthFromEdges(self):
4564 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4565 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4567 elif self.algoType == NETGEN:
4568 hyp = self.Parameters(SIMPLE)
4569 hyp.LengthFromEdges()
4572 ## Sets a way to define size of mesh elements to generate.
4573 # @param thePhysicalMesh is: DefaultSize or Custom.
4574 # @ingroup l3_hypos_blsurf
4575 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4576 # Parameter of BLSURF algo
4577 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4579 ## Sets size of mesh elements to generate.
4580 # @ingroup l3_hypos_blsurf
4581 def SetPhySize(self, theVal):
4582 # Parameter of BLSURF algo
4583 self.SetPhysicalMesh(1) #Custom - else why to set the size?
4584 self.Parameters().SetPhySize(theVal)
4586 ## Sets lower boundary of mesh element size (PhySize).
4587 # @ingroup l3_hypos_blsurf
4588 def SetPhyMin(self, theVal=-1):
4589 # Parameter of BLSURF algo
4590 self.Parameters().SetPhyMin(theVal)
4592 ## Sets upper boundary of mesh element size (PhySize).
4593 # @ingroup l3_hypos_blsurf
4594 def SetPhyMax(self, theVal=-1):
4595 # Parameter of BLSURF algo
4596 self.Parameters().SetPhyMax(theVal)
4598 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4599 # @param theGeometricMesh is: 0 (None) or 1 (Custom)
4600 # @ingroup l3_hypos_blsurf
4601 def SetGeometricMesh(self, theGeometricMesh=0):
4602 # Parameter of BLSURF algo
4603 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4604 self.params.SetGeometricMesh(theGeometricMesh)
4606 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4607 # @ingroup l3_hypos_blsurf
4608 def SetAngleMeshS(self, theVal=_angleMeshS):
4609 # Parameter of BLSURF algo
4610 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4611 self.params.SetAngleMeshS(theVal)
4613 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4614 # @ingroup l3_hypos_blsurf
4615 def SetAngleMeshC(self, theVal=_angleMeshS):
4616 # Parameter of BLSURF algo
4617 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4618 self.params.SetAngleMeshC(theVal)
4620 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4621 # @ingroup l3_hypos_blsurf
4622 def SetGeoMin(self, theVal=-1):
4623 # Parameter of BLSURF algo
4624 self.Parameters().SetGeoMin(theVal)
4626 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4627 # @ingroup l3_hypos_blsurf
4628 def SetGeoMax(self, theVal=-1):
4629 # Parameter of BLSURF algo
4630 self.Parameters().SetGeoMax(theVal)
4632 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4633 # @ingroup l3_hypos_blsurf
4634 def SetGradation(self, theVal=_gradation):
4635 # Parameter of BLSURF algo
4636 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4637 self.params.SetGradation(theVal)
4639 ## Sets topology usage way.
4640 # @param way defines how mesh conformity is assured <ul>
4641 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4642 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4643 # @ingroup l3_hypos_blsurf
4644 def SetTopology(self, way):
4645 # Parameter of BLSURF algo
4646 self.Parameters().SetTopology(way)
4648 ## To respect geometrical edges or not.
4649 # @ingroup l3_hypos_blsurf
4650 def SetDecimesh(self, toIgnoreEdges=False):
4651 # Parameter of BLSURF algo
4652 self.Parameters().SetDecimesh(toIgnoreEdges)
4654 ## Sets verbosity level in the range 0 to 100.
4655 # @ingroup l3_hypos_blsurf
4656 def SetVerbosity(self, level):
4657 # Parameter of BLSURF algo
4658 self.Parameters().SetVerbosity(level)
4660 ## Sets advanced option value.
4661 # @ingroup l3_hypos_blsurf
4662 def SetOptionValue(self, optionName, level):
4663 # Parameter of BLSURF algo
4664 self.Parameters().SetOptionValue(optionName,level)
4666 ## Sets QuadAllowed flag.
4667 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
4668 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4669 def SetQuadAllowed(self, toAllow=True):
4670 if self.algoType == NETGEN_2D:
4671 if toAllow: # add QuadranglePreference
4672 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4673 else: # remove QuadranglePreference
4674 for hyp in self.mesh.GetHypothesisList( self.geom ):
4675 if hyp.GetName() == "QuadranglePreference":
4676 self.mesh.RemoveHypothesis( self.geom, hyp )
4681 if self.Parameters():
4682 self.params.SetQuadAllowed(toAllow)
4685 ## Defines hypothesis having several parameters
4687 # @ingroup l3_hypos_netgen
4688 def Parameters(self, which=SOLE):
4691 if self.algoType == NETGEN:
4693 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4694 "libNETGENEngine.so", UseExisting=0)
4696 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4697 "libNETGENEngine.so", UseExisting=0)
4699 elif self.algoType == MEFISTO:
4700 print "Mefisto algo support no multi-parameter hypothesis"
4702 elif self.algoType == NETGEN_2D:
4703 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4704 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4706 elif self.algoType == BLSURF:
4707 self.params = self.Hypothesis("BLSURF_Parameters", [],
4708 "libBLSURFEngine.so", UseExisting=0)
4711 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4716 # Only for algoType == NETGEN
4717 # @ingroup l3_hypos_netgen
4718 def SetMaxSize(self, theSize):
4719 if self.Parameters():
4720 self.params.SetMaxSize(theSize)
4722 ## Sets SecondOrder flag
4724 # Only for algoType == NETGEN
4725 # @ingroup l3_hypos_netgen
4726 def SetSecondOrder(self, theVal):
4727 if self.Parameters():
4728 self.params.SetSecondOrder(theVal)
4730 ## Sets Optimize flag
4732 # Only for algoType == NETGEN
4733 # @ingroup l3_hypos_netgen
4734 def SetOptimize(self, theVal):
4735 if self.Parameters():
4736 self.params.SetOptimize(theVal)
4739 # @param theFineness is:
4740 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4742 # Only for algoType == NETGEN
4743 # @ingroup l3_hypos_netgen
4744 def SetFineness(self, theFineness):
4745 if self.Parameters():
4746 self.params.SetFineness(theFineness)
4750 # Only for algoType == NETGEN
4751 # @ingroup l3_hypos_netgen
4752 def SetGrowthRate(self, theRate):
4753 if self.Parameters():
4754 self.params.SetGrowthRate(theRate)
4756 ## Sets NbSegPerEdge
4758 # Only for algoType == NETGEN
4759 # @ingroup l3_hypos_netgen
4760 def SetNbSegPerEdge(self, theVal):
4761 if self.Parameters():
4762 self.params.SetNbSegPerEdge(theVal)
4764 ## Sets NbSegPerRadius
4766 # Only for algoType == NETGEN
4767 # @ingroup l3_hypos_netgen
4768 def SetNbSegPerRadius(self, theVal):
4769 if self.Parameters():
4770 self.params.SetNbSegPerRadius(theVal)
4772 ## Sets number of segments overriding value set by SetLocalLength()
4774 # Only for algoType == NETGEN
4775 # @ingroup l3_hypos_netgen
4776 def SetNumberOfSegments(self, theVal):
4777 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4779 ## Sets number of segments overriding value set by SetNumberOfSegments()
4781 # Only for algoType == NETGEN
4782 # @ingroup l3_hypos_netgen
4783 def SetLocalLength(self, theVal):
4784 self.Parameters(SIMPLE).SetLocalLength(theVal)
4789 # Public class: Mesh_Quadrangle
4790 # -----------------------------
4792 ## Defines a quadrangle 2D algorithm
4794 # @ingroup l3_algos_basic
4795 class Mesh_Quadrangle(Mesh_Algorithm):
4797 ## Private constructor.
4798 def __init__(self, mesh, geom=0):
4799 Mesh_Algorithm.__init__(self)
4800 self.Create(mesh, geom, "Quadrangle_2D")
4802 ## Defines "QuadranglePreference" hypothesis, forcing construction
4803 # of quadrangles if the number of nodes on the opposite edges is not the same
4804 # while the total number of nodes on edges is even
4806 # @ingroup l3_hypos_additi
4807 def QuadranglePreference(self):
4808 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4809 CompareMethod=self.CompareEqualHyp)
4812 ## Defines "TrianglePreference" hypothesis, forcing construction
4813 # of triangles in the refinement area if the number of nodes
4814 # on the opposite edges is not the same
4816 # @ingroup l3_hypos_additi
4817 def TrianglePreference(self):
4818 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4819 CompareMethod=self.CompareEqualHyp)
4822 ## Defines "QuadrangleParams" hypothesis
4823 # @param vertex: vertex of a trilateral geometrical face, around which triangles
4824 # will be created while other elements will be quadrangles.
4825 # Vertex can be either a GEOM_Object or a vertex ID within the
4827 # @param UseExisting: if ==true - searches for the existing hypothesis created with
4828 # the same parameters, else (default) - creates a new one
4830 # @ingroup l3_hypos_additi
4831 def TriangleVertex(self, vertex, UseExisting=0):
4833 if isinstance( vertexID, geompyDC.GEOM._objref_GEOM_Object ):
4834 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, vertex )
4835 hyp = self.Hypothesis("QuadrangleParams", [vertexID], UseExisting = UseExisting,
4836 CompareMethod=lambda hyp,args: hyp.GetTriaVertex()==args[0])
4837 hyp.SetTriaVertex( vertexID )
4841 # Public class: Mesh_Tetrahedron
4842 # ------------------------------
4844 ## Defines a tetrahedron 3D algorithm
4846 # @ingroup l3_algos_basic
4847 class Mesh_Tetrahedron(Mesh_Algorithm):
4852 ## Private constructor.
4853 def __init__(self, mesh, algoType, geom=0):
4854 Mesh_Algorithm.__init__(self)
4856 if algoType == NETGEN:
4858 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4861 elif algoType == FULL_NETGEN:
4863 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4866 elif algoType == GHS3D:
4868 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4871 elif algoType == GHS3DPRL:
4872 CheckPlugin(GHS3DPRL)
4873 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4876 self.algoType = algoType
4878 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4879 # @param vol for the maximum volume of each tetrahedron
4880 # @param UseExisting if ==true - searches for the existing hypothesis created with
4881 # the same parameters, else (default) - creates a new one
4882 # @ingroup l3_hypos_maxvol
4883 def MaxElementVolume(self, vol, UseExisting=0):
4884 if self.algoType == NETGEN:
4885 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4886 CompareMethod=self.CompareMaxElementVolume)
4887 hyp.SetMaxElementVolume(vol)
4889 elif self.algoType == FULL_NETGEN:
4890 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4893 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4894 def CompareMaxElementVolume(self, hyp, args):
4895 return IsEqual(hyp.GetMaxElementVolume(), args[0])
4897 ## Defines hypothesis having several parameters
4899 # @ingroup l3_hypos_netgen
4900 def Parameters(self, which=SOLE):
4904 if self.algoType == FULL_NETGEN:
4906 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4907 "libNETGENEngine.so", UseExisting=0)
4909 self.params = self.Hypothesis("NETGEN_Parameters", [],
4910 "libNETGENEngine.so", UseExisting=0)
4913 if self.algoType == GHS3D:
4914 self.params = self.Hypothesis("GHS3D_Parameters", [],
4915 "libGHS3DEngine.so", UseExisting=0)
4918 if self.algoType == GHS3DPRL:
4919 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4920 "libGHS3DPRLEngine.so", UseExisting=0)
4923 print "Algo supports no multi-parameter hypothesis"
4927 # Parameter of FULL_NETGEN
4928 # @ingroup l3_hypos_netgen
4929 def SetMaxSize(self, theSize):
4930 self.Parameters().SetMaxSize(theSize)
4932 ## Sets SecondOrder flag
4933 # Parameter of FULL_NETGEN
4934 # @ingroup l3_hypos_netgen
4935 def SetSecondOrder(self, theVal):
4936 self.Parameters().SetSecondOrder(theVal)
4938 ## Sets Optimize flag
4939 # Parameter of FULL_NETGEN
4940 # @ingroup l3_hypos_netgen
4941 def SetOptimize(self, theVal):
4942 self.Parameters().SetOptimize(theVal)
4945 # @param theFineness is:
4946 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4947 # Parameter of FULL_NETGEN
4948 # @ingroup l3_hypos_netgen
4949 def SetFineness(self, theFineness):
4950 self.Parameters().SetFineness(theFineness)
4953 # Parameter of FULL_NETGEN
4954 # @ingroup l3_hypos_netgen
4955 def SetGrowthRate(self, theRate):
4956 self.Parameters().SetGrowthRate(theRate)
4958 ## Sets NbSegPerEdge
4959 # Parameter of FULL_NETGEN
4960 # @ingroup l3_hypos_netgen
4961 def SetNbSegPerEdge(self, theVal):
4962 self.Parameters().SetNbSegPerEdge(theVal)
4964 ## Sets NbSegPerRadius
4965 # Parameter of FULL_NETGEN
4966 # @ingroup l3_hypos_netgen
4967 def SetNbSegPerRadius(self, theVal):
4968 self.Parameters().SetNbSegPerRadius(theVal)
4970 ## Sets number of segments overriding value set by SetLocalLength()
4971 # Only for algoType == NETGEN_FULL
4972 # @ingroup l3_hypos_netgen
4973 def SetNumberOfSegments(self, theVal):
4974 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4976 ## Sets number of segments overriding value set by SetNumberOfSegments()
4977 # Only for algoType == NETGEN_FULL
4978 # @ingroup l3_hypos_netgen
4979 def SetLocalLength(self, theVal):
4980 self.Parameters(SIMPLE).SetLocalLength(theVal)
4982 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4983 # Overrides value set by LengthFromEdges()
4984 # Only for algoType == NETGEN_FULL
4985 # @ingroup l3_hypos_netgen
4986 def MaxElementArea(self, area):
4987 self.Parameters(SIMPLE).SetMaxElementArea(area)
4989 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4990 # Overrides value set by MaxElementArea()
4991 # Only for algoType == NETGEN_FULL
4992 # @ingroup l3_hypos_netgen
4993 def LengthFromEdges(self):
4994 self.Parameters(SIMPLE).LengthFromEdges()
4996 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4997 # Overrides value set by MaxElementVolume()
4998 # Only for algoType == NETGEN_FULL
4999 # @ingroup l3_hypos_netgen
5000 def LengthFromFaces(self):
5001 self.Parameters(SIMPLE).LengthFromFaces()
5003 ## To mesh "holes" in a solid or not. Default is to mesh.
5004 # @ingroup l3_hypos_ghs3dh
5005 def SetToMeshHoles(self, toMesh):
5006 # Parameter of GHS3D
5007 self.Parameters().SetToMeshHoles(toMesh)
5009 ## Set Optimization level:
5010 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
5011 # Strong_Optimization.
5012 # Default is Standard_Optimization
5013 # @ingroup l3_hypos_ghs3dh
5014 def SetOptimizationLevel(self, level):
5015 # Parameter of GHS3D
5016 self.Parameters().SetOptimizationLevel(level)
5018 ## Maximal size of memory to be used by the algorithm (in Megabytes).
5019 # @ingroup l3_hypos_ghs3dh
5020 def SetMaximumMemory(self, MB):
5021 # Advanced parameter of GHS3D
5022 self.Parameters().SetMaximumMemory(MB)
5024 ## Initial size of memory to be used by the algorithm (in Megabytes) in
5025 # automatic memory adjustment mode.
5026 # @ingroup l3_hypos_ghs3dh
5027 def SetInitialMemory(self, MB):
5028 # Advanced parameter of GHS3D
5029 self.Parameters().SetInitialMemory(MB)
5031 ## Path to working directory.
5032 # @ingroup l3_hypos_ghs3dh
5033 def SetWorkingDirectory(self, path):
5034 # Advanced parameter of GHS3D
5035 self.Parameters().SetWorkingDirectory(path)
5037 ## To keep working files or remove them. Log file remains in case of errors anyway.
5038 # @ingroup l3_hypos_ghs3dh
5039 def SetKeepFiles(self, toKeep):
5040 # Advanced parameter of GHS3D and GHS3DPRL
5041 self.Parameters().SetKeepFiles(toKeep)
5043 ## To set verbose level [0-10]. <ul>
5044 #<li> 0 - no standard output,
5045 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
5046 # indicates when the final mesh is being saved. In addition the software
5047 # gives indication regarding the CPU time.
5048 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
5049 # histogram of the skin mesh, quality statistics histogram together with
5050 # the characteristics of the final mesh.</ul>
5051 # @ingroup l3_hypos_ghs3dh
5052 def SetVerboseLevel(self, level):
5053 # Advanced parameter of GHS3D
5054 self.Parameters().SetVerboseLevel(level)
5056 ## To create new nodes.
5057 # @ingroup l3_hypos_ghs3dh
5058 def SetToCreateNewNodes(self, toCreate):
5059 # Advanced parameter of GHS3D
5060 self.Parameters().SetToCreateNewNodes(toCreate)
5062 ## To use boundary recovery version which tries to create mesh on a very poor
5063 # quality surface mesh.
5064 # @ingroup l3_hypos_ghs3dh
5065 def SetToUseBoundaryRecoveryVersion(self, toUse):
5066 # Advanced parameter of GHS3D
5067 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
5069 ## Sets command line option as text.
5070 # @ingroup l3_hypos_ghs3dh
5071 def SetTextOption(self, option):
5072 # Advanced parameter of GHS3D
5073 self.Parameters().SetTextOption(option)
5075 ## Sets MED files name and path.
5076 def SetMEDName(self, value):
5077 self.Parameters().SetMEDName(value)
5079 ## Sets the number of partition of the initial mesh
5080 def SetNbPart(self, value):
5081 self.Parameters().SetNbPart(value)
5083 ## When big mesh, start tepal in background
5084 def SetBackground(self, value):
5085 self.Parameters().SetBackground(value)
5087 # Public class: Mesh_Hexahedron
5088 # ------------------------------
5090 ## Defines a hexahedron 3D algorithm
5092 # @ingroup l3_algos_basic
5093 class Mesh_Hexahedron(Mesh_Algorithm):
5098 ## Private constructor.
5099 def __init__(self, mesh, algoType=Hexa, geom=0):
5100 Mesh_Algorithm.__init__(self)
5102 self.algoType = algoType
5104 if algoType == Hexa:
5105 self.Create(mesh, geom, "Hexa_3D")
5108 elif algoType == Hexotic:
5109 CheckPlugin(Hexotic)
5110 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
5113 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
5114 # @ingroup l3_hypos_hexotic
5115 def MinMaxQuad(self, min=3, max=8, quad=True):
5116 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
5118 self.params.SetHexesMinLevel(min)
5119 self.params.SetHexesMaxLevel(max)
5120 self.params.SetHexoticQuadrangles(quad)
5123 # Deprecated, only for compatibility!
5124 # Public class: Mesh_Netgen
5125 # ------------------------------
5127 ## Defines a NETGEN-based 2D or 3D algorithm
5128 # that needs no discrete boundary (i.e. independent)
5130 # This class is deprecated, only for compatibility!
5133 # @ingroup l3_algos_basic
5134 class Mesh_Netgen(Mesh_Algorithm):
5138 ## Private constructor.
5139 def __init__(self, mesh, is3D, geom=0):
5140 Mesh_Algorithm.__init__(self)
5146 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5150 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
5153 ## Defines the hypothesis containing parameters of the algorithm
5154 def Parameters(self):
5156 hyp = self.Hypothesis("NETGEN_Parameters", [],
5157 "libNETGENEngine.so", UseExisting=0)
5159 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
5160 "libNETGENEngine.so", UseExisting=0)
5163 # Public class: Mesh_Projection1D
5164 # ------------------------------
5166 ## Defines a projection 1D algorithm
5167 # @ingroup l3_algos_proj
5169 class Mesh_Projection1D(Mesh_Algorithm):
5171 ## Private constructor.
5172 def __init__(self, mesh, geom=0):
5173 Mesh_Algorithm.__init__(self)
5174 self.Create(mesh, geom, "Projection_1D")
5176 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
5177 # a mesh pattern is taken, and, optionally, the association of vertices
5178 # between the source edge and a target edge (to which a hypothesis is assigned)
5179 # @param edge from which nodes distribution is taken
5180 # @param mesh from which nodes distribution is taken (optional)
5181 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
5182 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
5183 # to associate with \a srcV (optional)
5184 # @param UseExisting if ==true - searches for the existing hypothesis created with
5185 # the same parameters, else (default) - creates a new one
5186 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
5187 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
5189 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
5190 hyp.SetSourceEdge( edge )
5191 if not mesh is None and isinstance(mesh, Mesh):
5192 mesh = mesh.GetMesh()
5193 hyp.SetSourceMesh( mesh )
5194 hyp.SetVertexAssociation( srcV, tgtV )
5197 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
5198 #def CompareSourceEdge(self, hyp, args):
5199 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
5203 # Public class: Mesh_Projection2D
5204 # ------------------------------
5206 ## Defines a projection 2D algorithm
5207 # @ingroup l3_algos_proj
5209 class Mesh_Projection2D(Mesh_Algorithm):
5211 ## Private constructor.
5212 def __init__(self, mesh, geom=0):
5213 Mesh_Algorithm.__init__(self)
5214 self.Create(mesh, geom, "Projection_2D")
5216 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
5217 # a mesh pattern is taken, and, optionally, the association of vertices
5218 # between the source face and the target face (to which a hypothesis is assigned)
5219 # @param face from which the mesh pattern is taken
5220 # @param mesh from which the mesh pattern is taken (optional)
5221 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
5222 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
5223 # to associate with \a srcV1 (optional)
5224 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
5225 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
5226 # to associate with \a srcV2 (optional)
5227 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
5228 # the same parameters, else (default) - forces the creation a new one
5230 # Note: all association vertices must belong to one edge of a face
5231 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
5232 srcV2=None, tgtV2=None, UseExisting=0):
5233 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
5235 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
5236 hyp.SetSourceFace( face )
5237 if not mesh is None and isinstance(mesh, Mesh):
5238 mesh = mesh.GetMesh()
5239 hyp.SetSourceMesh( mesh )
5240 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5243 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
5244 #def CompareSourceFace(self, hyp, args):
5245 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
5248 # Public class: Mesh_Projection3D
5249 # ------------------------------
5251 ## Defines a projection 3D algorithm
5252 # @ingroup l3_algos_proj
5254 class Mesh_Projection3D(Mesh_Algorithm):
5256 ## Private constructor.
5257 def __init__(self, mesh, geom=0):
5258 Mesh_Algorithm.__init__(self)
5259 self.Create(mesh, geom, "Projection_3D")
5261 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
5262 # the mesh pattern is taken, and, optionally, the association of vertices
5263 # between the source and the target solid (to which a hipothesis is assigned)
5264 # @param solid from where the mesh pattern is taken
5265 # @param mesh from where the mesh pattern is taken (optional)
5266 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
5267 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
5268 # to associate with \a srcV1 (optional)
5269 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
5270 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
5271 # to associate with \a srcV2 (optional)
5272 # @param UseExisting - if ==true - searches for the existing hypothesis created with
5273 # the same parameters, else (default) - creates a new one
5275 # Note: association vertices must belong to one edge of a solid
5276 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
5277 srcV2=0, tgtV2=0, UseExisting=0):
5278 hyp = self.Hypothesis("ProjectionSource3D",
5279 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
5281 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
5282 hyp.SetSource3DShape( solid )
5283 if not mesh is None and isinstance(mesh, Mesh):
5284 mesh = mesh.GetMesh()
5285 hyp.SetSourceMesh( mesh )
5286 if srcV1 and srcV2 and tgtV1 and tgtV2:
5287 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5288 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
5291 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
5292 #def CompareSourceShape3D(self, hyp, args):
5293 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
5297 # Public class: Mesh_Prism
5298 # ------------------------
5300 ## Defines a 3D extrusion algorithm
5301 # @ingroup l3_algos_3dextr
5303 class Mesh_Prism3D(Mesh_Algorithm):
5305 ## Private constructor.
5306 def __init__(self, mesh, geom=0):
5307 Mesh_Algorithm.__init__(self)
5308 self.Create(mesh, geom, "Prism_3D")
5310 # Public class: Mesh_RadialPrism
5311 # -------------------------------
5313 ## Defines a Radial Prism 3D algorithm
5314 # @ingroup l3_algos_radialp
5316 class Mesh_RadialPrism3D(Mesh_Algorithm):
5318 ## Private constructor.
5319 def __init__(self, mesh, geom=0):
5320 Mesh_Algorithm.__init__(self)
5321 self.Create(mesh, geom, "RadialPrism_3D")
5323 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
5324 self.nbLayers = None
5326 ## Return 3D hypothesis holding the 1D one
5327 def Get3DHypothesis(self):
5328 return self.distribHyp
5330 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5331 # hypothesis. Returns the created hypothesis
5332 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5333 #print "OwnHypothesis",hypType
5334 if not self.nbLayers is None:
5335 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5336 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5337 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5338 self.mesh.smeshpyD.SetCurrentStudy( None )
5339 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5340 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5341 self.distribHyp.SetLayerDistribution( hyp )
5344 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
5345 # prisms to build between the inner and outer shells
5346 # @param n number of layers
5347 # @param UseExisting if ==true - searches for the existing hypothesis created with
5348 # the same parameters, else (default) - creates a new one
5349 def NumberOfLayers(self, n, UseExisting=0):
5350 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5351 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
5352 CompareMethod=self.CompareNumberOfLayers)
5353 self.nbLayers.SetNumberOfLayers( n )
5354 return self.nbLayers
5356 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5357 def CompareNumberOfLayers(self, hyp, args):
5358 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5360 ## Defines "LocalLength" hypothesis, specifying the segment length
5361 # to build between the inner and the outer shells
5362 # @param l the length of segments
5363 # @param p the precision of rounding
5364 def LocalLength(self, l, p=1e-07):
5365 hyp = self.OwnHypothesis("LocalLength", [l,p])
5370 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
5371 # prisms to build between the inner and the outer shells.
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 # to build between the inner and the outer shells 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 # to build between the inner and the outer shells 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 # to build between the inner and outer shells
5406 # @param fineness defines the quality of the mesh within the range [0-1]
5407 def AutomaticLength(self, fineness=0):
5408 hyp = self.OwnHypothesis("AutomaticLength")
5409 hyp.SetFineness( fineness )
5412 # Public class: Mesh_RadialQuadrangle1D2D
5413 # -------------------------------
5415 ## Defines a Radial Quadrangle 1D2D algorithm
5416 # @ingroup l2_algos_radialq
5418 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
5420 ## Private constructor.
5421 def __init__(self, mesh, geom=0):
5422 Mesh_Algorithm.__init__(self)
5423 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5425 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
5426 self.nbLayers = None
5428 ## Return 2D hypothesis holding the 1D one
5429 def Get2DHypothesis(self):
5430 return self.distribHyp
5432 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5433 # hypothesis. Returns the created hypothesis
5434 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5435 #print "OwnHypothesis",hypType
5437 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5438 if self.distribHyp is None:
5439 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5441 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5442 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5443 self.mesh.smeshpyD.SetCurrentStudy( None )
5444 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5445 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5446 self.distribHyp.SetLayerDistribution( hyp )
5449 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
5450 # @param n number of layers
5451 # @param UseExisting if ==true - searches for the existing hypothesis created with
5452 # the same parameters, else (default) - creates a new one
5453 def NumberOfLayers(self, n, UseExisting=0):
5455 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5456 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5457 CompareMethod=self.CompareNumberOfLayers)
5458 self.nbLayers.SetNumberOfLayers( n )
5459 return self.nbLayers
5461 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5462 def CompareNumberOfLayers(self, hyp, args):
5463 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5465 ## Defines "LocalLength" hypothesis, specifying the segment length
5466 # @param l the length of segments
5467 # @param p the precision of rounding
5468 def LocalLength(self, l, p=1e-07):
5469 hyp = self.OwnHypothesis("LocalLength", [l,p])
5474 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5475 # @param n the number of layers
5476 # @param s the scale factor (optional)
5477 def NumberOfSegments(self, n, s=[]):
5479 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5481 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5482 hyp.SetDistrType( 1 )
5483 hyp.SetScaleFactor(s)
5484 hyp.SetNumberOfSegments(n)
5487 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5488 # with a length that changes in arithmetic progression
5489 # @param start the length of the first segment
5490 # @param end the length of the last segment
5491 def Arithmetic1D(self, start, end ):
5492 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5493 hyp.SetLength(start, 1)
5494 hyp.SetLength(end , 0)
5497 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5498 # as geometric length increasing
5499 # @param start for the length of the first segment
5500 # @param end for the length of the last segment
5501 def StartEndLength(self, start, end):
5502 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5503 hyp.SetLength(start, 1)
5504 hyp.SetLength(end , 0)
5507 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5508 # @param fineness defines the quality of the mesh within the range [0-1]
5509 def AutomaticLength(self, fineness=0):
5510 hyp = self.OwnHypothesis("AutomaticLength")
5511 hyp.SetFineness( fineness )
5515 # Private class: Mesh_UseExisting
5516 # -------------------------------
5517 class Mesh_UseExisting(Mesh_Algorithm):
5519 def __init__(self, dim, mesh, geom=0):
5521 self.Create(mesh, geom, "UseExisting_1D")
5523 self.Create(mesh, geom, "UseExisting_2D")
5526 import salome_notebook
5527 notebook = salome_notebook.notebook
5529 ##Return values of the notebook variables
5530 def ParseParameters(last, nbParams,nbParam, value):
5534 listSize = len(last)
5535 for n in range(0,nbParams):
5537 if counter < listSize:
5538 strResult = strResult + last[counter]
5540 strResult = strResult + ""
5542 if isinstance(value, str):
5543 if notebook.isVariable(value):
5544 result = notebook.get(value)
5545 strResult=strResult+value
5547 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
5549 strResult=strResult+str(value)
5551 if nbParams - 1 != counter:
5552 strResult=strResult+var_separator #":"
5554 return result, strResult
5556 #Wrapper class for StdMeshers_LocalLength hypothesis
5557 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5559 ## Set Length parameter value
5560 # @param length numerical value or name of variable from notebook
5561 def SetLength(self, length):
5562 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
5563 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5564 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
5566 ## Set Precision parameter value
5567 # @param precision numerical value or name of variable from notebook
5568 def SetPrecision(self, precision):
5569 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
5570 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5571 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5573 #Registering the new proxy for LocalLength
5574 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5577 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5578 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5580 def SetLayerDistribution(self, hypo):
5581 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
5582 hypo.ClearParameters();
5583 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5585 #Registering the new proxy for LayerDistribution
5586 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5588 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5589 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5591 ## Set Length parameter value
5592 # @param length numerical value or name of variable from notebook
5593 def SetLength(self, length):
5594 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
5595 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
5596 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5598 #Registering the new proxy for SegmentLengthAroundVertex
5599 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5602 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5603 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5605 ## Set Length parameter value
5606 # @param length numerical value or name of variable from notebook
5607 # @param isStart true is length is Start Length, otherwise false
5608 def SetLength(self, length, isStart):
5612 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
5613 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
5614 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
5616 #Registering the new proxy for Arithmetic1D
5617 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
5619 #Wrapper class for StdMeshers_Deflection1D hypothesis
5620 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
5622 ## Set Deflection parameter value
5623 # @param deflection numerical value or name of variable from notebook
5624 def SetDeflection(self, deflection):
5625 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
5626 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
5627 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
5629 #Registering the new proxy for Deflection1D
5630 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
5632 #Wrapper class for StdMeshers_StartEndLength hypothesis
5633 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
5635 ## Set Length parameter value
5636 # @param length numerical value or name of variable from notebook
5637 # @param isStart true is length is Start Length, otherwise false
5638 def SetLength(self, length, isStart):
5642 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
5643 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
5644 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
5646 #Registering the new proxy for StartEndLength
5647 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
5649 #Wrapper class for StdMeshers_MaxElementArea hypothesis
5650 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
5652 ## Set Max Element Area parameter value
5653 # @param area numerical value or name of variable from notebook
5654 def SetMaxElementArea(self, area):
5655 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
5656 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
5657 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
5659 #Registering the new proxy for MaxElementArea
5660 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
5663 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
5664 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
5666 ## Set Max Element Volume parameter value
5667 # @param volume numerical value or name of variable from notebook
5668 def SetMaxElementVolume(self, volume):
5669 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
5670 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
5671 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
5673 #Registering the new proxy for MaxElementVolume
5674 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
5677 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
5678 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
5680 ## Set Number Of Layers parameter value
5681 # @param nbLayers numerical value or name of variable from notebook
5682 def SetNumberOfLayers(self, nbLayers):
5683 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
5684 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
5685 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
5687 #Registering the new proxy for NumberOfLayers
5688 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
5690 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
5691 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
5693 ## Set Number Of Segments parameter value
5694 # @param nbSeg numerical value or name of variable from notebook
5695 def SetNumberOfSegments(self, nbSeg):
5696 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
5697 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
5698 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5699 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
5701 ## Set Scale Factor parameter value
5702 # @param factor numerical value or name of variable from notebook
5703 def SetScaleFactor(self, factor):
5704 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
5705 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5706 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
5708 #Registering the new proxy for NumberOfSegments
5709 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
5711 if not noNETGENPlugin:
5712 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
5713 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
5715 ## Set Max Size parameter value
5716 # @param maxsize numerical value or name of variable from notebook
5717 def SetMaxSize(self, maxsize):
5718 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5719 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
5720 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5721 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
5723 ## Set Growth Rate parameter value
5724 # @param value numerical value or name of variable from notebook
5725 def SetGrowthRate(self, value):
5726 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5727 value, parameters = ParseParameters(lastParameters,4,2,value)
5728 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5729 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
5731 ## Set Number of Segments per Edge parameter value
5732 # @param value numerical value or name of variable from notebook
5733 def SetNbSegPerEdge(self, value):
5734 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5735 value, parameters = ParseParameters(lastParameters,4,3,value)
5736 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5737 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
5739 ## Set Number of Segments per Radius parameter value
5740 # @param value numerical value or name of variable from notebook
5741 def SetNbSegPerRadius(self, value):
5742 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5743 value, parameters = ParseParameters(lastParameters,4,4,value)
5744 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5745 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
5747 #Registering the new proxy for NETGENPlugin_Hypothesis
5748 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5751 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5752 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5755 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5756 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5758 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5759 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5761 ## Set Number of Segments parameter value
5762 # @param nbSeg numerical value or name of variable from notebook
5763 def SetNumberOfSegments(self, nbSeg):
5764 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5765 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5766 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5767 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5769 ## Set Local Length parameter value
5770 # @param length numerical value or name of variable from notebook
5771 def SetLocalLength(self, length):
5772 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5773 length, parameters = ParseParameters(lastParameters,2,1,length)
5774 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5775 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
5777 ## Set Max Element Area parameter value
5778 # @param area numerical value or name of variable from notebook
5779 def SetMaxElementArea(self, area):
5780 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5781 area, parameters = ParseParameters(lastParameters,2,2,area)
5782 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5783 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
5785 def LengthFromEdges(self):
5786 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5788 value, parameters = ParseParameters(lastParameters,2,2,value)
5789 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5790 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
5792 #Registering the new proxy for NETGEN_SimpleParameters_2D
5793 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
5796 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
5797 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
5798 ## Set Max Element Volume parameter value
5799 # @param volume numerical value or name of variable from notebook
5800 def SetMaxElementVolume(self, volume):
5801 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5802 volume, parameters = ParseParameters(lastParameters,3,3,volume)
5803 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5804 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5806 def LengthFromFaces(self):
5807 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5809 value, parameters = ParseParameters(lastParameters,3,3,value)
5810 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5811 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5813 #Registering the new proxy for NETGEN_SimpleParameters_3D
5814 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5816 pass # if not noNETGENPlugin:
5818 class Pattern(SMESH._objref_SMESH_Pattern):
5820 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5822 if isinstance(theNodeIndexOnKeyPoint1,str):
5824 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5826 theNodeIndexOnKeyPoint1 -= 1
5827 theMesh.SetParameters(Parameters)
5828 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5830 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5833 if isinstance(theNode000Index,str):
5835 if isinstance(theNode001Index,str):
5837 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5839 theNode000Index -= 1
5841 theNode001Index -= 1
5842 theMesh.SetParameters(Parameters)
5843 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5845 #Registering the new proxy for Pattern
5846 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)