1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 # Author : Francis KLOSS, OCC
30 ## @defgroup l1_auxiliary Auxiliary methods and structures
31 ## @defgroup l1_creating Creating meshes
33 ## @defgroup l2_impexp Importing and exporting meshes
34 ## @defgroup l2_construct Constructing meshes
35 ## @defgroup l2_algorithms Defining Algorithms
37 ## @defgroup l3_algos_basic Basic meshing algorithms
38 ## @defgroup l3_algos_proj Projection Algorithms
39 ## @defgroup l3_algos_radialp Radial Prism
40 ## @defgroup l3_algos_segmarv Segments around Vertex
41 ## @defgroup l3_algos_3dextr 3D extrusion meshing algorithm
44 ## @defgroup l2_hypotheses Defining hypotheses
46 ## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
47 ## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
48 ## @defgroup l3_hypos_maxvol Max Element Volume hypothesis
49 ## @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
50 ## @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
51 ## @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
52 ## @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
53 ## @defgroup l3_hypos_additi Additional Hypotheses
56 ## @defgroup l2_submeshes Constructing submeshes
57 ## @defgroup l2_compounds Building Compounds
58 ## @defgroup l2_editing Editing Meshes
61 ## @defgroup l1_meshinfo Mesh Information
62 ## @defgroup l1_controls Quality controls and Filtering
63 ## @defgroup l1_grouping Grouping elements
65 ## @defgroup l2_grps_create Creating groups
66 ## @defgroup l2_grps_edit Editing groups
67 ## @defgroup l2_grps_operon Using operations on groups
68 ## @defgroup l2_grps_delete Deleting Groups
71 ## @defgroup l1_modifying Modifying meshes
73 ## @defgroup l2_modif_add Adding nodes and elements
74 ## @defgroup l2_modif_del Removing nodes and elements
75 ## @defgroup l2_modif_edit Modifying nodes and elements
76 ## @defgroup l2_modif_renumber Renumbering nodes and elements
77 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
78 ## @defgroup l2_modif_movenode Moving nodes
79 ## @defgroup l2_modif_throughp Mesh through point
80 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
81 ## @defgroup l2_modif_unitetri Uniting triangles
82 ## @defgroup l2_modif_changori Changing orientation of elements
83 ## @defgroup l2_modif_cutquadr Cutting quadrangles
84 ## @defgroup l2_modif_smooth Smoothing
85 ## @defgroup l2_modif_extrurev Extrusion and Revolution
86 ## @defgroup l2_modif_patterns Pattern mapping
87 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
94 import SMESH # This is necessary for back compatibility
102 # import NETGENPlugin module if possible
110 # import GHS3DPlugin module if possible
118 # import GHS3DPRLPlugin module if possible
121 import GHS3DPRLPlugin
126 # import HexoticPlugin module if possible
134 # import BLSURFPlugin module if possible
142 ## @addtogroup l1_auxiliary
145 # Types of algorithms
158 NETGEN_1D2D3D = FULL_NETGEN
159 NETGEN_FULL = FULL_NETGEN
167 # MirrorType enumeration
168 POINT = SMESH_MeshEditor.POINT
169 AXIS = SMESH_MeshEditor.AXIS
170 PLANE = SMESH_MeshEditor.PLANE
172 # Smooth_Method enumeration
173 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
174 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
176 # Fineness enumeration (for NETGEN)
184 # Optimization level of GHS3D
186 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
187 # V4.1 (partialy redefines V3.1). Issue 0020574
188 None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization, Strong_Optimization = 0,1,2,3,4
190 # Topology treatment way of BLSURF
191 FromCAD, PreProcess, PreProcessPlus = 0,1,2
193 # Element size flag of BLSURF
194 DefaultSize, DefaultGeom, Custom = 0,0,1
196 PrecisionConfusion = 1e-07
198 # TopAbs_State enumeration
199 [TopAbs_IN, TopAbs_OUT, TopAbs_ON, TopAbs_UNKNOWN] = range(4)
201 # Methods of splitting a hexahedron into tetrahedra
202 Hex_5Tet, Hex_6Tet, Hex_24Tet = 1, 2, 3
205 ## Converts an angle from degrees to radians
206 def DegreesToRadians(AngleInDegrees):
208 return AngleInDegrees * pi / 180.0
210 # Salome notebook variable separator
213 # Parametrized substitute for PointStruct
214 class PointStructStr:
223 def __init__(self, xStr, yStr, zStr):
227 if isinstance(xStr, str) and notebook.isVariable(xStr):
228 self.x = notebook.get(xStr)
231 if isinstance(yStr, str) and notebook.isVariable(yStr):
232 self.y = notebook.get(yStr)
235 if isinstance(zStr, str) and notebook.isVariable(zStr):
236 self.z = notebook.get(zStr)
240 # Parametrized substitute for PointStruct (with 6 parameters)
241 class PointStructStr6:
256 def __init__(self, x1Str, x2Str, y1Str, y2Str, z1Str, z2Str):
263 if isinstance(x1Str, str) and notebook.isVariable(x1Str):
264 self.x1 = notebook.get(x1Str)
267 if isinstance(x2Str, str) and notebook.isVariable(x2Str):
268 self.x2 = notebook.get(x2Str)
271 if isinstance(y1Str, str) and notebook.isVariable(y1Str):
272 self.y1 = notebook.get(y1Str)
275 if isinstance(y2Str, str) and notebook.isVariable(y2Str):
276 self.y2 = notebook.get(y2Str)
279 if isinstance(z1Str, str) and notebook.isVariable(z1Str):
280 self.z1 = notebook.get(z1Str)
283 if isinstance(z2Str, str) and notebook.isVariable(z2Str):
284 self.z2 = notebook.get(z2Str)
288 # Parametrized substitute for AxisStruct
304 def __init__(self, xStr, yStr, zStr, dxStr, dyStr, dzStr):
311 if isinstance(xStr, str) and notebook.isVariable(xStr):
312 self.x = notebook.get(xStr)
315 if isinstance(yStr, str) and notebook.isVariable(yStr):
316 self.y = notebook.get(yStr)
319 if isinstance(zStr, str) and notebook.isVariable(zStr):
320 self.z = notebook.get(zStr)
323 if isinstance(dxStr, str) and notebook.isVariable(dxStr):
324 self.dx = notebook.get(dxStr)
327 if isinstance(dyStr, str) and notebook.isVariable(dyStr):
328 self.dy = notebook.get(dyStr)
331 if isinstance(dzStr, str) and notebook.isVariable(dzStr):
332 self.dz = notebook.get(dzStr)
336 # Parametrized substitute for DirStruct
339 def __init__(self, pointStruct):
340 self.pointStruct = pointStruct
342 # Returns list of variable values from salome notebook
343 def ParsePointStruct(Point):
344 Parameters = 2*var_separator
345 if isinstance(Point, PointStructStr):
346 Parameters = str(Point.xStr) + var_separator + str(Point.yStr) + var_separator + str(Point.zStr)
347 Point = PointStruct(Point.x, Point.y, Point.z)
348 return Point, Parameters
350 # Returns list of variable values from salome notebook
351 def ParseDirStruct(Dir):
352 Parameters = 2*var_separator
353 if isinstance(Dir, DirStructStr):
354 pntStr = Dir.pointStruct
355 if isinstance(pntStr, PointStructStr6):
356 Parameters = str(pntStr.x1Str) + var_separator + str(pntStr.x2Str) + var_separator
357 Parameters += str(pntStr.y1Str) + var_separator + str(pntStr.y2Str) + var_separator
358 Parameters += str(pntStr.z1Str) + var_separator + str(pntStr.z2Str)
359 Point = PointStruct(pntStr.x2 - pntStr.x1, pntStr.y2 - pntStr.y1, pntStr.z2 - pntStr.z1)
361 Parameters = str(pntStr.xStr) + var_separator + str(pntStr.yStr) + var_separator + str(pntStr.zStr)
362 Point = PointStruct(pntStr.x, pntStr.y, pntStr.z)
363 Dir = DirStruct(Point)
364 return Dir, Parameters
366 # Returns list of variable values from salome notebook
367 def ParseAxisStruct(Axis):
368 Parameters = 5*var_separator
369 if isinstance(Axis, AxisStructStr):
370 Parameters = str(Axis.xStr) + var_separator + str(Axis.yStr) + var_separator + str(Axis.zStr) + var_separator
371 Parameters += str(Axis.dxStr) + var_separator + str(Axis.dyStr) + var_separator + str(Axis.dzStr)
372 Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz)
373 return Axis, Parameters
375 ## Return list of variable values from salome notebook
376 def ParseAngles(list):
379 for parameter in list:
380 if isinstance(parameter,str) and notebook.isVariable(parameter):
381 Result.append(DegreesToRadians(notebook.get(parameter)))
384 Result.append(parameter)
387 Parameters = Parameters + str(parameter)
388 Parameters = Parameters + var_separator
390 Parameters = Parameters[:len(Parameters)-1]
391 return Result, Parameters
393 def IsEqual(val1, val2, tol=PrecisionConfusion):
394 if abs(val1 - val2) < tol:
404 if isinstance(obj, SALOMEDS._objref_SObject):
407 ior = salome.orb.object_to_string(obj)
410 studies = salome.myStudyManager.GetOpenStudies()
411 for sname in studies:
412 s = salome.myStudyManager.GetStudyByName(sname)
414 sobj = s.FindObjectIOR(ior)
415 if not sobj: continue
416 return sobj.GetName()
417 if hasattr(obj, "GetName"):
418 # unknown CORBA object, having GetName() method
421 # unknown CORBA object, no GetName() method
424 if hasattr(obj, "GetName"):
425 # unknown non-CORBA object, having GetName() method
428 raise RuntimeError, "Null or invalid object"
430 ## Prints error message if a hypothesis was not assigned.
431 def TreatHypoStatus(status, hypName, geomName, isAlgo):
433 hypType = "algorithm"
435 hypType = "hypothesis"
437 if status == HYP_UNKNOWN_FATAL :
438 reason = "for unknown reason"
439 elif status == HYP_INCOMPATIBLE :
440 reason = "this hypothesis mismatches the algorithm"
441 elif status == HYP_NOTCONFORM :
442 reason = "a non-conform mesh would be built"
443 elif status == HYP_ALREADY_EXIST :
444 if isAlgo: return # it does not influence anything
445 reason = hypType + " of the same dimension is already assigned to this shape"
446 elif status == HYP_BAD_DIM :
447 reason = hypType + " mismatches the shape"
448 elif status == HYP_CONCURENT :
449 reason = "there are concurrent hypotheses on sub-shapes"
450 elif status == HYP_BAD_SUBSHAPE :
451 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
452 elif status == HYP_BAD_GEOMETRY:
453 reason = "geometry mismatches the expectation of the algorithm"
454 elif status == HYP_HIDDEN_ALGO:
455 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
456 elif status == HYP_HIDING_ALGO:
457 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
458 elif status == HYP_NEED_SHAPE:
459 reason = "Algorithm can't work without shape"
462 hypName = '"' + hypName + '"'
463 geomName= '"' + geomName+ '"'
464 if status < HYP_UNKNOWN_FATAL and not geomName =='""':
465 print hypName, "was assigned to", geomName,"but", reason
466 elif not geomName == '""':
467 print hypName, "was not assigned to",geomName,":", reason
469 print hypName, "was not assigned:", reason
472 ## Check meshing plugin availability
473 def CheckPlugin(plugin):
474 if plugin == NETGEN and noNETGENPlugin:
475 print "Warning: NETGENPlugin module unavailable"
477 elif plugin == GHS3D and noGHS3DPlugin:
478 print "Warning: GHS3DPlugin module unavailable"
480 elif plugin == GHS3DPRL and noGHS3DPRLPlugin:
481 print "Warning: GHS3DPRLPlugin module unavailable"
483 elif plugin == Hexotic and noHexoticPlugin:
484 print "Warning: HexoticPlugin module unavailable"
486 elif plugin == BLSURF and noBLSURFPlugin:
487 print "Warning: BLSURFPlugin module unavailable"
491 # end of l1_auxiliary
494 # All methods of this class are accessible directly from the smesh.py package.
495 class smeshDC(SMESH._objref_SMESH_Gen):
497 ## Sets the current study and Geometry component
498 # @ingroup l1_auxiliary
499 def init_smesh(self,theStudy,geompyD):
500 self.SetCurrentStudy(theStudy,geompyD)
502 ## Creates an empty Mesh. This mesh can have an underlying geometry.
503 # @param obj the Geometrical object on which the mesh is built. If not defined,
504 # the mesh will have no underlying geometry.
505 # @param name the name for the new mesh.
506 # @return an instance of Mesh class.
507 # @ingroup l2_construct
508 def Mesh(self, obj=0, name=0):
509 if isinstance(obj,str):
511 return Mesh(self,self.geompyD,obj,name)
513 ## Returns a long value from enumeration
514 # Should be used for SMESH.FunctorType enumeration
515 # @ingroup l1_controls
516 def EnumToLong(self,theItem):
519 ## Returns a string representation of the color.
520 # To be used with filters.
521 # @param c color value (SALOMEDS.Color)
522 # @ingroup l1_controls
523 def ColorToString(self,c):
525 if isinstance(c, SALOMEDS.Color):
526 val = "%s;%s;%s" % (c.R, c.G, c.B)
527 elif isinstance(c, str):
530 raise ValueError, "Color value should be of string or SALOMEDS.Color type"
533 ## Gets PointStruct from vertex
534 # @param theVertex a GEOM object(vertex)
535 # @return SMESH.PointStruct
536 # @ingroup l1_auxiliary
537 def GetPointStruct(self,theVertex):
538 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
539 return PointStruct(x,y,z)
541 ## Gets DirStruct from vector
542 # @param theVector a GEOM object(vector)
543 # @return SMESH.DirStruct
544 # @ingroup l1_auxiliary
545 def GetDirStruct(self,theVector):
546 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
547 if(len(vertices) != 2):
548 print "Error: vector object is incorrect."
550 p1 = self.geompyD.PointCoordinates(vertices[0])
551 p2 = self.geompyD.PointCoordinates(vertices[1])
552 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
553 dirst = DirStruct(pnt)
556 ## Makes DirStruct from a triplet
557 # @param x,y,z vector components
558 # @return SMESH.DirStruct
559 # @ingroup l1_auxiliary
560 def MakeDirStruct(self,x,y,z):
561 pnt = PointStruct(x,y,z)
562 return DirStruct(pnt)
564 ## Get AxisStruct from object
565 # @param theObj a GEOM object (line or plane)
566 # @return SMESH.AxisStruct
567 # @ingroup l1_auxiliary
568 def GetAxisStruct(self,theObj):
569 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
571 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
572 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
573 vertex1 = self.geompyD.PointCoordinates(vertex1)
574 vertex2 = self.geompyD.PointCoordinates(vertex2)
575 vertex3 = self.geompyD.PointCoordinates(vertex3)
576 vertex4 = self.geompyD.PointCoordinates(vertex4)
577 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
578 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
579 normal = [ v1[1]*v2[2]-v2[1]*v1[2], v1[2]*v2[0]-v2[2]*v1[0], v1[0]*v2[1]-v2[0]*v1[1] ]
580 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
582 elif len(edges) == 1:
583 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
584 p1 = self.geompyD.PointCoordinates( vertex1 )
585 p2 = self.geompyD.PointCoordinates( vertex2 )
586 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
590 # From SMESH_Gen interface:
591 # ------------------------
593 ## Sets the given name to the object
594 # @param obj the object to rename
595 # @param name a new object name
596 # @ingroup l1_auxiliary
597 def SetName(self, obj, name):
598 if isinstance( obj, Mesh ):
600 elif isinstance( obj, Mesh_Algorithm ):
601 obj = obj.GetAlgorithm()
602 ior = salome.orb.object_to_string(obj)
603 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
605 ## Sets the current mode
606 # @ingroup l1_auxiliary
607 def SetEmbeddedMode( self,theMode ):
608 #self.SetEmbeddedMode(theMode)
609 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
611 ## Gets the current mode
612 # @ingroup l1_auxiliary
613 def IsEmbeddedMode(self):
614 #return self.IsEmbeddedMode()
615 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
617 ## Sets the current study
618 # @ingroup l1_auxiliary
619 def SetCurrentStudy( self, theStudy, geompyD = None ):
620 #self.SetCurrentStudy(theStudy)
623 geompyD = geompy.geom
626 self.SetGeomEngine(geompyD)
627 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
629 ## Gets the current study
630 # @ingroup l1_auxiliary
631 def GetCurrentStudy(self):
632 #return self.GetCurrentStudy()
633 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
635 ## Creates a Mesh object importing data from the given UNV file
636 # @return an instance of Mesh class
638 def CreateMeshesFromUNV( self,theFileName ):
639 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
640 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
643 ## Creates a Mesh object(s) importing data from the given MED file
644 # @return a list of Mesh class instances
646 def CreateMeshesFromMED( self,theFileName ):
647 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
649 for iMesh in range(len(aSmeshMeshes)) :
650 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
651 aMeshes.append(aMesh)
652 return aMeshes, aStatus
654 ## Creates a Mesh object importing data from the given STL file
655 # @return an instance of Mesh class
657 def CreateMeshesFromSTL( self, theFileName ):
658 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
659 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
662 ## From SMESH_Gen interface
663 # @return the list of integer values
664 # @ingroup l1_auxiliary
665 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
666 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
668 ## From SMESH_Gen interface. Creates a pattern
669 # @return an instance of SMESH_Pattern
671 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
672 # @ingroup l2_modif_patterns
673 def GetPattern(self):
674 return SMESH._objref_SMESH_Gen.GetPattern(self)
676 ## Sets number of segments per diagonal of boundary box of geometry by which
677 # default segment length of appropriate 1D hypotheses is defined.
678 # Default value is 10
679 # @ingroup l1_auxiliary
680 def SetBoundaryBoxSegmentation(self, nbSegments):
681 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
683 ## Concatenate the given meshes into one mesh.
684 # @return an instance of Mesh class
685 # @param meshes the meshes to combine into one mesh
686 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
687 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
688 # @param mergeTolerance tolerance for merging nodes
689 # @param allGroups forces creation of groups of all elements
690 def Concatenate( self, meshes, uniteIdenticalGroups,
691 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
692 mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
693 for i,m in enumerate(meshes):
694 if isinstance(m, Mesh):
695 meshes[i] = m.GetMesh()
697 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
698 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
700 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
701 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
702 aSmeshMesh.SetParameters(Parameters)
703 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
706 # Filtering. Auxiliary functions:
707 # ------------------------------
709 ## Creates an empty criterion
710 # @return SMESH.Filter.Criterion
711 # @ingroup l1_controls
712 def GetEmptyCriterion(self):
713 Type = self.EnumToLong(FT_Undefined)
714 Compare = self.EnumToLong(FT_Undefined)
718 UnaryOp = self.EnumToLong(FT_Undefined)
719 BinaryOp = self.EnumToLong(FT_Undefined)
722 Precision = -1 ##@1e-07
723 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
724 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
726 ## Creates a criterion by the given parameters
727 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
728 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
729 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
730 # @param Treshold the threshold value (range of ids as string, shape, numeric)
731 # @param UnaryOp FT_LogicalNOT or FT_Undefined
732 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
733 # FT_Undefined (must be for the last criterion of all criteria)
734 # @return SMESH.Filter.Criterion
735 # @ingroup l1_controls
736 def GetCriterion(self,elementType,
738 Compare = FT_EqualTo,
740 UnaryOp=FT_Undefined,
741 BinaryOp=FT_Undefined):
742 aCriterion = self.GetEmptyCriterion()
743 aCriterion.TypeOfElement = elementType
744 aCriterion.Type = self.EnumToLong(CritType)
748 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
749 aCriterion.Compare = self.EnumToLong(Compare)
750 elif Compare == "=" or Compare == "==":
751 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
753 aCriterion.Compare = self.EnumToLong(FT_LessThan)
755 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
757 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
760 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
761 FT_BelongToCylinder, FT_LyingOnGeom]:
762 # Checks the treshold
763 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
764 aCriterion.ThresholdStr = GetName(aTreshold)
765 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
767 print "Error: The treshold should be a shape."
769 elif CritType == FT_RangeOfIds:
770 # Checks the treshold
771 if isinstance(aTreshold, str):
772 aCriterion.ThresholdStr = aTreshold
774 print "Error: The treshold should be a string."
776 elif CritType == FT_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)
847 ## Creates a numerical functor by its type
848 # @param theCriterion FT_...; functor type
849 # @return SMESH_NumericalFunctor
850 # @ingroup l1_controls
851 def GetFunctor(self,theCriterion):
852 aFilterMgr = self.CreateFilterManager()
853 if theCriterion == FT_AspectRatio:
854 return aFilterMgr.CreateAspectRatio()
855 elif theCriterion == FT_AspectRatio3D:
856 return aFilterMgr.CreateAspectRatio3D()
857 elif theCriterion == FT_Warping:
858 return aFilterMgr.CreateWarping()
859 elif theCriterion == FT_MinimumAngle:
860 return aFilterMgr.CreateMinimumAngle()
861 elif theCriterion == FT_Taper:
862 return aFilterMgr.CreateTaper()
863 elif theCriterion == FT_Skew:
864 return aFilterMgr.CreateSkew()
865 elif theCriterion == FT_Area:
866 return aFilterMgr.CreateArea()
867 elif theCriterion == FT_Volume3D:
868 return aFilterMgr.CreateVolume3D()
869 elif theCriterion == FT_MultiConnection:
870 return aFilterMgr.CreateMultiConnection()
871 elif theCriterion == FT_MultiConnection2D:
872 return aFilterMgr.CreateMultiConnection2D()
873 elif theCriterion == FT_Length:
874 return aFilterMgr.CreateLength()
875 elif theCriterion == FT_Length2D:
876 return aFilterMgr.CreateLength2D()
878 print "Error: given parameter is not numerucal functor type."
880 ## Creates hypothesis
881 # @param theHType mesh hypothesis type (string)
882 # @param theLibName mesh plug-in library name
883 # @return created hypothesis instance
884 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
885 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
887 ## Gets the mesh stattistic
888 # @return dictionary type element - count of elements
889 # @ingroup l1_meshinfo
890 def GetMeshInfo(self, obj):
891 if isinstance( obj, Mesh ):
894 if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource):
895 values = obj.GetMeshInfo()
896 for i in range(SMESH.Entity_Last._v):
897 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
902 #Registering the new proxy for SMESH_Gen
903 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
909 ## This class allows defining and managing a mesh.
910 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
911 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
912 # new nodes and elements and by changing the existing entities), to get information
913 # about a mesh and to export a mesh into different formats.
922 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
923 # sets the GUI name of this mesh to \a name.
924 # @param smeshpyD an instance of smeshDC class
925 # @param geompyD an instance of geompyDC class
926 # @param obj Shape to be meshed or SMESH_Mesh object
927 # @param name Study name of the mesh
928 # @ingroup l2_construct
929 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
930 self.smeshpyD=smeshpyD
935 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
937 self.mesh = self.smeshpyD.CreateMesh(self.geom)
938 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
941 self.mesh = self.smeshpyD.CreateEmptyMesh()
943 self.smeshpyD.SetName(self.mesh, name)
945 self.smeshpyD.SetName(self.mesh, GetName(obj))
948 self.geom = self.mesh.GetShapeToMesh()
950 self.editor = self.mesh.GetMeshEditor()
952 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
953 # @param theMesh a SMESH_Mesh object
954 # @ingroup l2_construct
955 def SetMesh(self, theMesh):
957 self.geom = self.mesh.GetShapeToMesh()
959 ## Returns the mesh, that is an instance of SMESH_Mesh interface
960 # @return a SMESH_Mesh object
961 # @ingroup l2_construct
965 ## Gets the name of the mesh
966 # @return the name of the mesh as a string
967 # @ingroup l2_construct
969 name = GetName(self.GetMesh())
972 ## Sets a name to the mesh
973 # @param name a new name of the mesh
974 # @ingroup l2_construct
975 def SetName(self, name):
976 self.smeshpyD.SetName(self.GetMesh(), name)
978 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
979 # The subMesh object gives access to the IDs of nodes and elements.
980 # @param theSubObject a geometrical object (shape)
981 # @param theName a name for the submesh
982 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
983 # @ingroup l2_submeshes
984 def GetSubMesh(self, theSubObject, theName):
985 submesh = self.mesh.GetSubMesh(theSubObject, theName)
988 ## Returns the shape associated to the mesh
989 # @return a GEOM_Object
990 # @ingroup l2_construct
994 ## Associates the given shape to the mesh (entails the recreation of the mesh)
995 # @param geom the shape to be meshed (GEOM_Object)
996 # @ingroup l2_construct
997 def SetShape(self, geom):
998 self.mesh = self.smeshpyD.CreateMesh(geom)
1000 ## Returns true if the hypotheses are defined well
1001 # @param theSubObject a subshape of a mesh shape
1002 # @return True or False
1003 # @ingroup l2_construct
1004 def IsReadyToCompute(self, theSubObject):
1005 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
1007 ## Returns errors of hypotheses definition.
1008 # The list of errors is empty if everything is OK.
1009 # @param theSubObject a subshape of a mesh shape
1010 # @return a list of errors
1011 # @ingroup l2_construct
1012 def GetAlgoState(self, theSubObject):
1013 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
1015 ## Returns a geometrical object on which the given element was built.
1016 # The returned geometrical object, if not nil, is either found in the
1017 # study or published by this method with the given name
1018 # @param theElementID the id of the mesh element
1019 # @param theGeomName the user-defined name of the geometrical object
1020 # @return GEOM::GEOM_Object instance
1021 # @ingroup l2_construct
1022 def GetGeometryByMeshElement(self, theElementID, theGeomName):
1023 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
1025 ## Returns the mesh dimension depending on the dimension of the underlying shape
1026 # @return mesh dimension as an integer value [0,3]
1027 # @ingroup l1_auxiliary
1028 def MeshDimension(self):
1029 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
1030 if len( shells ) > 0 :
1032 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
1034 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
1040 ## Creates a segment discretization 1D algorithm.
1041 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
1042 # \n If the optional \a geom parameter is not set, this algorithm is global.
1043 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1044 # @param algo the type of the required algorithm. Possible values are:
1046 # - smesh.PYTHON for discretization via a python function,
1047 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
1048 # @param geom If defined is the subshape to be meshed
1049 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
1050 # @ingroup l3_algos_basic
1051 def Segment(self, algo=REGULAR, geom=0):
1052 ## if Segment(geom) is called by mistake
1053 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
1054 algo, geom = geom, algo
1055 if not algo: algo = REGULAR
1058 return Mesh_Segment(self, geom)
1059 elif algo == PYTHON:
1060 return Mesh_Segment_Python(self, geom)
1061 elif algo == COMPOSITE:
1062 return Mesh_CompositeSegment(self, geom)
1064 return Mesh_Segment(self, geom)
1066 ## Enables creation of nodes and segments usable by 2D algoritms.
1067 # The added nodes and segments must be bound to edges and vertices by
1068 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
1069 # If the optional \a geom parameter is not set, this algorithm is global.
1070 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1071 # @param geom the subshape to be manually meshed
1072 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
1073 # @ingroup l3_algos_basic
1074 def UseExistingSegments(self, geom=0):
1075 algo = Mesh_UseExisting(1,self,geom)
1076 return algo.GetAlgorithm()
1078 ## Enables creation of nodes and faces usable by 3D algoritms.
1079 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
1080 # and SetMeshElementOnShape()
1081 # If the optional \a geom parameter is not set, this algorithm is global.
1082 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1083 # @param geom the subshape to be manually meshed
1084 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1085 # @ingroup l3_algos_basic
1086 def UseExistingFaces(self, geom=0):
1087 algo = Mesh_UseExisting(2,self,geom)
1088 return algo.GetAlgorithm()
1090 ## Creates a triangle 2D algorithm for faces.
1091 # If the optional \a geom parameter is not set, this algorithm is global.
1092 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1093 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1094 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1095 # @return an instance of Mesh_Triangle algorithm
1096 # @ingroup l3_algos_basic
1097 def Triangle(self, algo=MEFISTO, geom=0):
1098 ## if Triangle(geom) is called by mistake
1099 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1102 return Mesh_Triangle(self, algo, geom)
1104 ## Creates a quadrangle 2D algorithm for faces.
1105 # If the optional \a geom parameter is not set, this algorithm is global.
1106 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1107 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1108 # @param algo values are: smesh.QUADRANGLE || smesh.RADIAL_QUAD
1109 # @return an instance of Mesh_Quadrangle algorithm
1110 # @ingroup l3_algos_basic
1111 def Quadrangle(self, geom=0, algo=QUADRANGLE):
1112 if algo==RADIAL_QUAD:
1113 return Mesh_RadialQuadrangle1D2D(self,geom)
1115 return Mesh_Quadrangle(self, geom)
1117 ## Creates a tetrahedron 3D algorithm for solids.
1118 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1119 # If the optional \a geom parameter is not set, this algorithm is global.
1120 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1121 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1122 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1123 # @return an instance of Mesh_Tetrahedron algorithm
1124 # @ingroup l3_algos_basic
1125 def Tetrahedron(self, algo=NETGEN, geom=0):
1126 ## if Tetrahedron(geom) is called by mistake
1127 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1128 algo, geom = geom, algo
1129 if not algo: algo = NETGEN
1131 return Mesh_Tetrahedron(self, algo, geom)
1133 ## Creates a hexahedron 3D algorithm for solids.
1134 # If the optional \a geom parameter is not set, this algorithm is global.
1135 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1136 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1137 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1138 # @return an instance of Mesh_Hexahedron algorithm
1139 # @ingroup l3_algos_basic
1140 def Hexahedron(self, algo=Hexa, geom=0):
1141 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1142 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1143 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1144 elif geom == 0: algo, geom = Hexa, algo
1145 return Mesh_Hexahedron(self, algo, geom)
1147 ## Deprecated, used only for compatibility!
1148 # @return an instance of Mesh_Netgen algorithm
1149 # @ingroup l3_algos_basic
1150 def Netgen(self, is3D, geom=0):
1151 return Mesh_Netgen(self, is3D, geom)
1153 ## Creates a projection 1D algorithm for edges.
1154 # If the optional \a geom parameter is not set, this algorithm is global.
1155 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1156 # @param geom If defined, the subshape to be meshed
1157 # @return an instance of Mesh_Projection1D algorithm
1158 # @ingroup l3_algos_proj
1159 def Projection1D(self, geom=0):
1160 return Mesh_Projection1D(self, geom)
1162 ## Creates a projection 2D algorithm for faces.
1163 # If the optional \a geom parameter is not set, this algorithm is global.
1164 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1165 # @param geom If defined, the subshape to be meshed
1166 # @return an instance of Mesh_Projection2D algorithm
1167 # @ingroup l3_algos_proj
1168 def Projection2D(self, geom=0):
1169 return Mesh_Projection2D(self, geom)
1171 ## Creates a projection 3D algorithm for solids.
1172 # If the optional \a geom parameter is not set, this algorithm is global.
1173 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1174 # @param geom If defined, the subshape to be meshed
1175 # @return an instance of Mesh_Projection3D algorithm
1176 # @ingroup l3_algos_proj
1177 def Projection3D(self, geom=0):
1178 return Mesh_Projection3D(self, geom)
1180 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1181 # If the optional \a geom parameter is not set, this algorithm is global.
1182 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1183 # @param geom If defined, the subshape to be meshed
1184 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1185 # @ingroup l3_algos_radialp l3_algos_3dextr
1186 def Prism(self, geom=0):
1190 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1191 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1192 if nbSolids == 0 or nbSolids == nbShells:
1193 return Mesh_Prism3D(self, geom)
1194 return Mesh_RadialPrism3D(self, geom)
1196 ## Evaluates size of prospective mesh on a shape
1197 # @return True or False
1198 def Evaluate(self, geom=0):
1199 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1201 geom = self.mesh.GetShapeToMesh()
1204 return self.smeshpyD.Evaluate(self.mesh, geom)
1207 ## Computes the mesh and returns the status of the computation
1208 # @param geom geomtrical shape on which mesh data should be computed
1209 # @param discardModifs if True and the mesh has been edited since
1210 # a last total re-compute and that may prevent successful partial re-compute,
1211 # then the mesh is cleaned before Compute()
1212 # @return True or False
1213 # @ingroup l2_construct
1214 def Compute(self, geom=0, discardModifs=False):
1215 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1217 geom = self.mesh.GetShapeToMesh()
1222 if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693
1224 ok = self.smeshpyD.Compute(self.mesh, geom)
1225 except SALOME.SALOME_Exception, ex:
1226 print "Mesh computation failed, exception caught:"
1227 print " ", ex.details.text
1230 print "Mesh computation failed, exception caught:"
1231 traceback.print_exc()
1235 # Treat compute errors
1236 computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
1237 for err in computeErrors:
1239 if self.mesh.HasShapeToMesh():
1241 mainIOR = salome.orb.object_to_string(geom)
1242 for sname in salome.myStudyManager.GetOpenStudies():
1243 s = salome.myStudyManager.GetStudyByName(sname)
1245 mainSO = s.FindObjectIOR(mainIOR)
1246 if not mainSO: continue
1247 if err.subShapeID == 1:
1248 shapeText = ' on "%s"' % mainSO.GetName()
1249 subIt = s.NewChildIterator(mainSO)
1251 subSO = subIt.Value()
1253 obj = subSO.GetObject()
1254 if not obj: continue
1255 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
1257 ids = go.GetSubShapeIndices()
1258 if len(ids) == 1 and ids[0] == err.subShapeID:
1259 shapeText = ' on "%s"' % subSO.GetName()
1262 shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
1264 shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID)
1266 shapeText = " on subshape #%s" % (err.subShapeID)
1268 shapeText = " on subshape #%s" % (err.subShapeID)
1270 stdErrors = ["OK", #COMPERR_OK
1271 "Invalid input mesh", #COMPERR_BAD_INPUT_MESH
1272 "std::exception", #COMPERR_STD_EXCEPTION
1273 "OCC exception", #COMPERR_OCC_EXCEPTION
1274 "SALOME exception", #COMPERR_SLM_EXCEPTION
1275 "Unknown exception", #COMPERR_EXCEPTION
1276 "Memory allocation problem", #COMPERR_MEMORY_PB
1277 "Algorithm failed", #COMPERR_ALGO_FAILED
1278 "Unexpected geometry"]#COMPERR_BAD_SHAPE
1280 if err.code < len(stdErrors): errText = stdErrors[err.code]
1282 errText = "code %s" % -err.code
1283 if errText: errText += ". "
1284 errText += err.comment
1285 if allReasons != "":allReasons += "\n"
1286 allReasons += '"%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
1290 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1292 if err.isGlobalAlgo:
1300 reason = '%s %sD algorithm is missing' % (glob, dim)
1301 elif err.state == HYP_MISSING:
1302 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1303 % (glob, dim, name, dim))
1304 elif err.state == HYP_NOTCONFORM:
1305 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1306 elif err.state == HYP_BAD_PARAMETER:
1307 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1308 % ( glob, dim, name ))
1309 elif err.state == HYP_BAD_GEOMETRY:
1310 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1311 'geometry' % ( glob, dim, name ))
1313 reason = "For unknown reason."+\
1314 " Revise Mesh.Compute() implementation in smeshDC.py!"
1316 if allReasons != "":allReasons += "\n"
1317 allReasons += reason
1319 if allReasons != "":
1320 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1324 print '"' + GetName(self.mesh) + '"',"has not been computed."
1327 if salome.sg.hasDesktop():
1328 smeshgui = salome.ImportComponentGUI("SMESH")
1329 smeshgui.Init(self.mesh.GetStudyId())
1330 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1331 salome.sg.updateObjBrowser(1)
1335 ## Return submesh objects list in meshing order
1336 # @return list of list of submesh objects
1337 # @ingroup l2_construct
1338 def GetMeshOrder(self):
1339 return self.mesh.GetMeshOrder()
1341 ## Return submesh objects list in meshing order
1342 # @return list of list of submesh objects
1343 # @ingroup l2_construct
1344 def SetMeshOrder(self, submeshes):
1345 return self.mesh.SetMeshOrder(submeshes)
1347 ## Removes all nodes and elements
1348 # @ingroup l2_construct
1351 if salome.sg.hasDesktop():
1352 smeshgui = salome.ImportComponentGUI("SMESH")
1353 smeshgui.Init(self.mesh.GetStudyId())
1354 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1355 salome.sg.updateObjBrowser(1)
1357 ## Removes all nodes and elements of indicated shape
1358 # @ingroup l2_construct
1359 def ClearSubMesh(self, geomId):
1360 self.mesh.ClearSubMesh(geomId)
1361 if salome.sg.hasDesktop():
1362 smeshgui = salome.ImportComponentGUI("SMESH")
1363 smeshgui.Init(self.mesh.GetStudyId())
1364 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1365 salome.sg.updateObjBrowser(1)
1367 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1368 # @param fineness [0,-1] defines mesh fineness
1369 # @return True or False
1370 # @ingroup l3_algos_basic
1371 def AutomaticTetrahedralization(self, fineness=0):
1372 dim = self.MeshDimension()
1374 self.RemoveGlobalHypotheses()
1375 self.Segment().AutomaticLength(fineness)
1377 self.Triangle().LengthFromEdges()
1380 self.Tetrahedron(NETGEN)
1382 return self.Compute()
1384 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1385 # @param fineness [0,-1] defines mesh fineness
1386 # @return True or False
1387 # @ingroup l3_algos_basic
1388 def AutomaticHexahedralization(self, fineness=0):
1389 dim = self.MeshDimension()
1390 # assign the hypotheses
1391 self.RemoveGlobalHypotheses()
1392 self.Segment().AutomaticLength(fineness)
1399 return self.Compute()
1401 ## Assigns a hypothesis
1402 # @param hyp a hypothesis to assign
1403 # @param geom a subhape of mesh geometry
1404 # @return SMESH.Hypothesis_Status
1405 # @ingroup l2_hypotheses
1406 def AddHypothesis(self, hyp, geom=0):
1407 if isinstance( hyp, Mesh_Algorithm ):
1408 hyp = hyp.GetAlgorithm()
1413 geom = self.mesh.GetShapeToMesh()
1415 status = self.mesh.AddHypothesis(geom, hyp)
1416 isAlgo = hyp._narrow( SMESH_Algo )
1417 hyp_name = GetName( hyp )
1420 geom_name = GetName( geom )
1421 TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1424 ## Unassigns a hypothesis
1425 # @param hyp a hypothesis to unassign
1426 # @param geom a subshape of mesh geometry
1427 # @return SMESH.Hypothesis_Status
1428 # @ingroup l2_hypotheses
1429 def RemoveHypothesis(self, hyp, geom=0):
1430 if isinstance( hyp, Mesh_Algorithm ):
1431 hyp = hyp.GetAlgorithm()
1436 status = self.mesh.RemoveHypothesis(geom, hyp)
1439 ## Gets the list of hypotheses added on a geometry
1440 # @param geom a subshape of mesh geometry
1441 # @return the sequence of SMESH_Hypothesis
1442 # @ingroup l2_hypotheses
1443 def GetHypothesisList(self, geom):
1444 return self.mesh.GetHypothesisList( geom )
1446 ## Removes all global hypotheses
1447 # @ingroup l2_hypotheses
1448 def RemoveGlobalHypotheses(self):
1449 current_hyps = self.mesh.GetHypothesisList( self.geom )
1450 for hyp in current_hyps:
1451 self.mesh.RemoveHypothesis( self.geom, hyp )
1455 ## Creates a mesh group based on the geometric object \a grp
1456 # and gives a \a name, \n if this parameter is not defined
1457 # the name is the same as the geometric group name \n
1458 # Note: Works like GroupOnGeom().
1459 # @param grp a geometric group, a vertex, an edge, a face or a solid
1460 # @param name the name of the mesh group
1461 # @return SMESH_GroupOnGeom
1462 # @ingroup l2_grps_create
1463 def Group(self, grp, name=""):
1464 return self.GroupOnGeom(grp, name)
1466 ## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead.
1467 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1468 ## allowing to overwrite the file if it exists or add the exported data to its contents
1469 # @param f the file name
1470 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1471 # @param opt boolean parameter for creating/not creating
1472 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1473 # @param overwrite boolean parameter for overwriting/not overwriting the file
1474 # @ingroup l2_impexp
1475 def ExportToMED(self, f, version, opt=0, overwrite=1):
1476 self.mesh.ExportToMEDX(f, opt, version, overwrite)
1478 ## Exports the mesh in a file in MED format and chooses the \a version of MED format
1479 ## allowing to overwrite the file if it exists or add the exported data to its contents
1480 # @param f is the file name
1481 # @param auto_groups boolean parameter for creating/not creating
1482 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1483 # the typical use is auto_groups=false.
1484 # @param version MED format version(MED_V2_1 or MED_V2_2)
1485 # @param overwrite boolean parameter for overwriting/not overwriting the file
1486 # @ingroup l2_impexp
1487 def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1):
1488 self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
1490 ## Exports the mesh in a file in DAT format
1491 # @param f the file name
1492 # @ingroup l2_impexp
1493 def ExportDAT(self, f):
1494 self.mesh.ExportDAT(f)
1496 ## Exports the mesh in a file in UNV format
1497 # @param f the file name
1498 # @ingroup l2_impexp
1499 def ExportUNV(self, f):
1500 self.mesh.ExportUNV(f)
1502 ## Export the mesh in a file in STL format
1503 # @param f the file name
1504 # @param ascii defines the file encoding
1505 # @ingroup l2_impexp
1506 def ExportSTL(self, f, ascii=1):
1507 self.mesh.ExportSTL(f, ascii)
1510 # Operations with groups:
1511 # ----------------------
1513 ## Creates an empty mesh group
1514 # @param elementType the type of elements in the group
1515 # @param name the name of the mesh group
1516 # @return SMESH_Group
1517 # @ingroup l2_grps_create
1518 def CreateEmptyGroup(self, elementType, name):
1519 return self.mesh.CreateGroup(elementType, name)
1521 ## Creates a mesh group based on the geometrical object \a grp
1522 # and gives a \a name, \n if this parameter is not defined
1523 # the name is the same as the geometrical group name
1524 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1525 # @param name the name of the mesh group
1526 # @param typ the type of elements in the group. If not set, it is
1527 # automatically detected by the type of the geometry
1528 # @return SMESH_GroupOnGeom
1529 # @ingroup l2_grps_create
1530 def GroupOnGeom(self, grp, name="", typ=None):
1532 name = grp.GetName()
1535 tgeo = str(grp.GetShapeType())
1536 if tgeo == "VERTEX":
1538 elif tgeo == "EDGE":
1540 elif tgeo == "FACE":
1542 elif tgeo == "SOLID":
1544 elif tgeo == "SHELL":
1546 elif tgeo == "COMPOUND":
1547 try: # it raises on a compound of compounds
1548 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1549 print "Mesh.Group: empty geometric group", GetName( grp )
1554 if grp.GetType() == 37: # GEOMImpl_Types.hxx: #define GEOM_GROUP 37
1556 tgeo = self.geompyD.GetType(grp)
1557 if tgeo == geompyDC.ShapeType["VERTEX"]:
1559 elif tgeo == geompyDC.ShapeType["EDGE"]:
1561 elif tgeo == geompyDC.ShapeType["FACE"]:
1563 elif tgeo == geompyDC.ShapeType["SOLID"]:
1569 for elemType, shapeType in [[VOLUME,"SOLID"],[FACE,"FACE"],
1570 [EDGE,"EDGE"],[NODE,"VERTEX"]]:
1571 if self.geompyD.SubShapeAll(grp,geompyDC.ShapeType[shapeType]):
1579 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1582 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1584 ## Creates a mesh group by the given ids of elements
1585 # @param groupName the name of the mesh group
1586 # @param elementType the type of elements in the group
1587 # @param elemIDs the list of ids
1588 # @return SMESH_Group
1589 # @ingroup l2_grps_create
1590 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1591 group = self.mesh.CreateGroup(elementType, groupName)
1595 ## Creates a mesh group by the given conditions
1596 # @param groupName the name of the mesh group
1597 # @param elementType the type of elements in the group
1598 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1599 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1600 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1601 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1602 # @return SMESH_Group
1603 # @ingroup l2_grps_create
1607 CritType=FT_Undefined,
1610 UnaryOp=FT_Undefined):
1611 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1612 group = self.MakeGroupByCriterion(groupName, aCriterion)
1615 ## Creates a mesh group by the given criterion
1616 # @param groupName the name of the mesh group
1617 # @param Criterion the instance of Criterion class
1618 # @return SMESH_Group
1619 # @ingroup l2_grps_create
1620 def MakeGroupByCriterion(self, groupName, Criterion):
1621 aFilterMgr = self.smeshpyD.CreateFilterManager()
1622 aFilter = aFilterMgr.CreateFilter()
1624 aCriteria.append(Criterion)
1625 aFilter.SetCriteria(aCriteria)
1626 group = self.MakeGroupByFilter(groupName, aFilter)
1629 ## Creates a mesh group by the given criteria (list of criteria)
1630 # @param groupName the name of the mesh group
1631 # @param theCriteria the list of criteria
1632 # @return SMESH_Group
1633 # @ingroup l2_grps_create
1634 def MakeGroupByCriteria(self, groupName, theCriteria):
1635 aFilterMgr = self.smeshpyD.CreateFilterManager()
1636 aFilter = aFilterMgr.CreateFilter()
1637 aFilter.SetCriteria(theCriteria)
1638 group = self.MakeGroupByFilter(groupName, aFilter)
1641 ## Creates a mesh group by the given filter
1642 # @param groupName the name of the mesh group
1643 # @param theFilter the instance of Filter class
1644 # @return SMESH_Group
1645 # @ingroup l2_grps_create
1646 def MakeGroupByFilter(self, groupName, theFilter):
1647 anIds = theFilter.GetElementsId(self.mesh)
1648 anElemType = theFilter.GetElementType()
1649 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1652 ## Passes mesh elements through the given filter and return IDs of fitting elements
1653 # @param theFilter SMESH_Filter
1654 # @return a list of ids
1655 # @ingroup l1_controls
1656 def GetIdsFromFilter(self, theFilter):
1657 return theFilter.GetElementsId(self.mesh)
1659 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1660 # Returns a list of special structures (borders).
1661 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1662 # @ingroup l1_controls
1663 def GetFreeBorders(self):
1664 aFilterMgr = self.smeshpyD.CreateFilterManager()
1665 aPredicate = aFilterMgr.CreateFreeEdges()
1666 aPredicate.SetMesh(self.mesh)
1667 aBorders = aPredicate.GetBorders()
1671 # @ingroup l2_grps_delete
1672 def RemoveGroup(self, group):
1673 self.mesh.RemoveGroup(group)
1675 ## Removes a group with its contents
1676 # @ingroup l2_grps_delete
1677 def RemoveGroupWithContents(self, group):
1678 self.mesh.RemoveGroupWithContents(group)
1680 ## Gets the list of groups existing in the mesh
1681 # @return a sequence of SMESH_GroupBase
1682 # @ingroup l2_grps_create
1683 def GetGroups(self):
1684 return self.mesh.GetGroups()
1686 ## Gets the number of groups existing in the mesh
1687 # @return the quantity of groups as an integer value
1688 # @ingroup l2_grps_create
1690 return self.mesh.NbGroups()
1692 ## Gets the list of names of groups existing in the mesh
1693 # @return list of strings
1694 # @ingroup l2_grps_create
1695 def GetGroupNames(self):
1696 groups = self.GetGroups()
1698 for group in groups:
1699 names.append(group.GetName())
1702 ## Produces a union of two groups
1703 # A new group is created. All mesh elements that are
1704 # present in the initial groups are added to the new one
1705 # @return an instance of SMESH_Group
1706 # @ingroup l2_grps_operon
1707 def UnionGroups(self, group1, group2, name):
1708 return self.mesh.UnionGroups(group1, group2, name)
1710 ## Produces a union list of groups
1711 # New group is created. All mesh elements that are present in
1712 # initial groups are added to the new one
1713 # @return an instance of SMESH_Group
1714 # @ingroup l2_grps_operon
1715 def UnionListOfGroups(self, groups, name):
1716 return self.mesh.UnionListOfGroups(groups, name)
1718 ## Prodices an intersection of two groups
1719 # A new group is created. All mesh elements that are common
1720 # for the two initial groups are added to the new one.
1721 # @return an instance of SMESH_Group
1722 # @ingroup l2_grps_operon
1723 def IntersectGroups(self, group1, group2, name):
1724 return self.mesh.IntersectGroups(group1, group2, name)
1726 ## Produces an intersection of groups
1727 # New group is created. All mesh elements that are present in all
1728 # initial groups simultaneously are added to the new one
1729 # @return an instance of SMESH_Group
1730 # @ingroup l2_grps_operon
1731 def IntersectListOfGroups(self, groups, name):
1732 return self.mesh.IntersectListOfGroups(groups, name)
1734 ## Produces a cut of two groups
1735 # A new group is created. All mesh elements that are present in
1736 # the main group but are not present in the tool group are added to the new one
1737 # @return an instance of SMESH_Group
1738 # @ingroup l2_grps_operon
1739 def CutGroups(self, main_group, tool_group, name):
1740 return self.mesh.CutGroups(main_group, tool_group, name)
1742 ## Produces a cut of groups
1743 # A new group is created. All mesh elements that are present in main groups
1744 # but do not present in tool groups are added to the new one
1745 # @return an instance of SMESH_Group
1746 # @ingroup l2_grps_operon
1747 def CutListOfGroups(self, main_groups, tool_groups, name):
1748 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1750 ## Produces a group of elements with specified element type using list of existing groups
1751 # A new group is created. System
1752 # 1) extract all nodes on which groups elements are built
1753 # 2) combine all elements of specified dimension laying on these nodes
1754 # @return an instance of SMESH_Group
1755 # @ingroup l2_grps_operon
1756 def CreateDimGroup(self, groups, elem_type, name):
1757 return self.mesh.CreateDimGroup(groups, elem_type, name)
1760 ## Convert group on geom into standalone group
1761 # @ingroup l2_grps_delete
1762 def ConvertToStandalone(self, group):
1763 return self.mesh.ConvertToStandalone(group)
1765 # Get some info about mesh:
1766 # ------------------------
1768 ## Returns the log of nodes and elements added or removed
1769 # since the previous clear of the log.
1770 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1771 # @return list of log_block structures:
1776 # @ingroup l1_auxiliary
1777 def GetLog(self, clearAfterGet):
1778 return self.mesh.GetLog(clearAfterGet)
1780 ## Clears the log of nodes and elements added or removed since the previous
1781 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1782 # @ingroup l1_auxiliary
1784 self.mesh.ClearLog()
1786 ## Toggles auto color mode on the object.
1787 # @param theAutoColor the flag which toggles auto color mode.
1788 # @ingroup l1_auxiliary
1789 def SetAutoColor(self, theAutoColor):
1790 self.mesh.SetAutoColor(theAutoColor)
1792 ## Gets flag of object auto color mode.
1793 # @return True or False
1794 # @ingroup l1_auxiliary
1795 def GetAutoColor(self):
1796 return self.mesh.GetAutoColor()
1798 ## Gets the internal ID
1799 # @return integer value, which is the internal Id of the mesh
1800 # @ingroup l1_auxiliary
1802 return self.mesh.GetId()
1805 # @return integer value, which is the study Id of the mesh
1806 # @ingroup l1_auxiliary
1807 def GetStudyId(self):
1808 return self.mesh.GetStudyId()
1810 ## Checks the group names for duplications.
1811 # Consider the maximum group name length stored in MED file.
1812 # @return True or False
1813 # @ingroup l1_auxiliary
1814 def HasDuplicatedGroupNamesMED(self):
1815 return self.mesh.HasDuplicatedGroupNamesMED()
1817 ## Obtains the mesh editor tool
1818 # @return an instance of SMESH_MeshEditor
1819 # @ingroup l1_modifying
1820 def GetMeshEditor(self):
1821 return self.mesh.GetMeshEditor()
1824 # @return an instance of SALOME_MED::MESH
1825 # @ingroup l1_auxiliary
1826 def GetMEDMesh(self):
1827 return self.mesh.GetMEDMesh()
1830 # Get informations about mesh contents:
1831 # ------------------------------------
1833 ## Gets the mesh stattistic
1834 # @return dictionary type element - count of elements
1835 # @ingroup l1_meshinfo
1836 def GetMeshInfo(self, obj = None):
1837 if not obj: obj = self.mesh
1838 return self.smeshpyD.GetMeshInfo(obj)
1840 ## Returns the number of nodes in the mesh
1841 # @return an integer value
1842 # @ingroup l1_meshinfo
1844 return self.mesh.NbNodes()
1846 ## Returns the number of elements in the mesh
1847 # @return an integer value
1848 # @ingroup l1_meshinfo
1849 def NbElements(self):
1850 return self.mesh.NbElements()
1852 ## Returns the number of 0d elements in the mesh
1853 # @return an integer value
1854 # @ingroup l1_meshinfo
1855 def Nb0DElements(self):
1856 return self.mesh.Nb0DElements()
1858 ## Returns the number of edges in the mesh
1859 # @return an integer value
1860 # @ingroup l1_meshinfo
1862 return self.mesh.NbEdges()
1864 ## Returns the number of edges with the given order in the mesh
1865 # @param elementOrder the order of elements:
1866 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1867 # @return an integer value
1868 # @ingroup l1_meshinfo
1869 def NbEdgesOfOrder(self, elementOrder):
1870 return self.mesh.NbEdgesOfOrder(elementOrder)
1872 ## Returns the number of faces in the mesh
1873 # @return an integer value
1874 # @ingroup l1_meshinfo
1876 return self.mesh.NbFaces()
1878 ## Returns the number of faces with the given order in the mesh
1879 # @param elementOrder the order of elements:
1880 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1881 # @return an integer value
1882 # @ingroup l1_meshinfo
1883 def NbFacesOfOrder(self, elementOrder):
1884 return self.mesh.NbFacesOfOrder(elementOrder)
1886 ## Returns the number of triangles in the mesh
1887 # @return an integer value
1888 # @ingroup l1_meshinfo
1889 def NbTriangles(self):
1890 return self.mesh.NbTriangles()
1892 ## Returns the number of triangles with the given order in the mesh
1893 # @param elementOrder is the order of elements:
1894 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1895 # @return an integer value
1896 # @ingroup l1_meshinfo
1897 def NbTrianglesOfOrder(self, elementOrder):
1898 return self.mesh.NbTrianglesOfOrder(elementOrder)
1900 ## Returns the number of quadrangles in the mesh
1901 # @return an integer value
1902 # @ingroup l1_meshinfo
1903 def NbQuadrangles(self):
1904 return self.mesh.NbQuadrangles()
1906 ## Returns the number of quadrangles with the given order in the mesh
1907 # @param elementOrder the order of elements:
1908 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1909 # @return an integer value
1910 # @ingroup l1_meshinfo
1911 def NbQuadranglesOfOrder(self, elementOrder):
1912 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1914 ## Returns the number of polygons in the mesh
1915 # @return an integer value
1916 # @ingroup l1_meshinfo
1917 def NbPolygons(self):
1918 return self.mesh.NbPolygons()
1920 ## Returns the number of volumes in the mesh
1921 # @return an integer value
1922 # @ingroup l1_meshinfo
1923 def NbVolumes(self):
1924 return self.mesh.NbVolumes()
1926 ## Returns the number of volumes with the given order in the mesh
1927 # @param elementOrder the order of elements:
1928 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1929 # @return an integer value
1930 # @ingroup l1_meshinfo
1931 def NbVolumesOfOrder(self, elementOrder):
1932 return self.mesh.NbVolumesOfOrder(elementOrder)
1934 ## Returns the number of tetrahedrons in the mesh
1935 # @return an integer value
1936 # @ingroup l1_meshinfo
1938 return self.mesh.NbTetras()
1940 ## Returns the number of tetrahedrons with the given order in the mesh
1941 # @param elementOrder the order of elements:
1942 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1943 # @return an integer value
1944 # @ingroup l1_meshinfo
1945 def NbTetrasOfOrder(self, elementOrder):
1946 return self.mesh.NbTetrasOfOrder(elementOrder)
1948 ## Returns the number of hexahedrons in the mesh
1949 # @return an integer value
1950 # @ingroup l1_meshinfo
1952 return self.mesh.NbHexas()
1954 ## Returns the number of hexahedrons with the given order in the mesh
1955 # @param elementOrder the order of elements:
1956 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1957 # @return an integer value
1958 # @ingroup l1_meshinfo
1959 def NbHexasOfOrder(self, elementOrder):
1960 return self.mesh.NbHexasOfOrder(elementOrder)
1962 ## Returns the number of pyramids in the mesh
1963 # @return an integer value
1964 # @ingroup l1_meshinfo
1965 def NbPyramids(self):
1966 return self.mesh.NbPyramids()
1968 ## Returns the number of pyramids with the given order in the mesh
1969 # @param elementOrder the order of elements:
1970 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1971 # @return an integer value
1972 # @ingroup l1_meshinfo
1973 def NbPyramidsOfOrder(self, elementOrder):
1974 return self.mesh.NbPyramidsOfOrder(elementOrder)
1976 ## Returns the number of prisms in the mesh
1977 # @return an integer value
1978 # @ingroup l1_meshinfo
1980 return self.mesh.NbPrisms()
1982 ## Returns the number of prisms with the given order in the mesh
1983 # @param elementOrder the order of elements:
1984 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1985 # @return an integer value
1986 # @ingroup l1_meshinfo
1987 def NbPrismsOfOrder(self, elementOrder):
1988 return self.mesh.NbPrismsOfOrder(elementOrder)
1990 ## Returns the number of polyhedrons in the mesh
1991 # @return an integer value
1992 # @ingroup l1_meshinfo
1993 def NbPolyhedrons(self):
1994 return self.mesh.NbPolyhedrons()
1996 ## Returns the number of submeshes in the mesh
1997 # @return an integer value
1998 # @ingroup l1_meshinfo
1999 def NbSubMesh(self):
2000 return self.mesh.NbSubMesh()
2002 ## Returns the list of mesh elements IDs
2003 # @return the list of integer values
2004 # @ingroup l1_meshinfo
2005 def GetElementsId(self):
2006 return self.mesh.GetElementsId()
2008 ## Returns the list of IDs of mesh elements with the given type
2009 # @param elementType the required type of elements (SMESH.NODE, SMESH.EDGE, SMESH.FACE or SMESH.VOLUME)
2010 # @return list of integer values
2011 # @ingroup l1_meshinfo
2012 def GetElementsByType(self, elementType):
2013 return self.mesh.GetElementsByType(elementType)
2015 ## Returns the list of mesh nodes IDs
2016 # @return the list of integer values
2017 # @ingroup l1_meshinfo
2018 def GetNodesId(self):
2019 return self.mesh.GetNodesId()
2021 # Get the information about mesh elements:
2022 # ------------------------------------
2024 ## Returns the type of mesh element
2025 # @return the value from SMESH::ElementType enumeration
2026 # @ingroup l1_meshinfo
2027 def GetElementType(self, id, iselem):
2028 return self.mesh.GetElementType(id, iselem)
2030 ## Returns the geometric type of mesh element
2031 # @return the value from SMESH::EntityType enumeration
2032 # @ingroup l1_meshinfo
2033 def GetElementGeomType(self, id):
2034 return self.mesh.GetElementGeomType(id)
2036 ## Returns the list of submesh elements IDs
2037 # @param Shape a geom object(subshape) IOR
2038 # Shape must be the subshape of a ShapeToMesh()
2039 # @return the list of integer values
2040 # @ingroup l1_meshinfo
2041 def GetSubMeshElementsId(self, Shape):
2042 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2043 ShapeID = Shape.GetSubShapeIndices()[0]
2046 return self.mesh.GetSubMeshElementsId(ShapeID)
2048 ## Returns the list of submesh nodes IDs
2049 # @param Shape a geom object(subshape) IOR
2050 # Shape must be the subshape of a ShapeToMesh()
2051 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
2052 # @return the list of integer values
2053 # @ingroup l1_meshinfo
2054 def GetSubMeshNodesId(self, Shape, all):
2055 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2056 ShapeID = Shape.GetSubShapeIndices()[0]
2059 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2061 ## Returns type of elements on given shape
2062 # @param Shape a geom object(subshape) IOR
2063 # Shape must be a subshape of a ShapeToMesh()
2064 # @return element type
2065 # @ingroup l1_meshinfo
2066 def GetSubMeshElementType(self, Shape):
2067 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2068 ShapeID = Shape.GetSubShapeIndices()[0]
2071 return self.mesh.GetSubMeshElementType(ShapeID)
2073 ## Gets the mesh description
2074 # @return string value
2075 # @ingroup l1_meshinfo
2077 return self.mesh.Dump()
2080 # Get the information about nodes and elements of a mesh by its IDs:
2081 # -----------------------------------------------------------
2083 ## Gets XYZ coordinates of a node
2084 # \n If there is no nodes for the given ID - returns an empty list
2085 # @return a list of double precision values
2086 # @ingroup l1_meshinfo
2087 def GetNodeXYZ(self, id):
2088 return self.mesh.GetNodeXYZ(id)
2090 ## Returns list of IDs of inverse elements for the given node
2091 # \n If there is no node for the given ID - returns an empty list
2092 # @return a list of integer values
2093 # @ingroup l1_meshinfo
2094 def GetNodeInverseElements(self, id):
2095 return self.mesh.GetNodeInverseElements(id)
2097 ## @brief Returns the position of a node on the shape
2098 # @return SMESH::NodePosition
2099 # @ingroup l1_meshinfo
2100 def GetNodePosition(self,NodeID):
2101 return self.mesh.GetNodePosition(NodeID)
2103 ## If the given element is a node, returns the ID of shape
2104 # \n If there is no node for the given ID - returns -1
2105 # @return an integer value
2106 # @ingroup l1_meshinfo
2107 def GetShapeID(self, id):
2108 return self.mesh.GetShapeID(id)
2110 ## Returns the ID of the result shape after
2111 # FindShape() from SMESH_MeshEditor for the given element
2112 # \n If there is no element for the given ID - returns -1
2113 # @return an integer value
2114 # @ingroup l1_meshinfo
2115 def GetShapeIDForElem(self,id):
2116 return self.mesh.GetShapeIDForElem(id)
2118 ## Returns the number of nodes for the given element
2119 # \n If there is no element for the given ID - returns -1
2120 # @return an integer value
2121 # @ingroup l1_meshinfo
2122 def GetElemNbNodes(self, id):
2123 return self.mesh.GetElemNbNodes(id)
2125 ## Returns the node ID the given index for the given element
2126 # \n If there is no element for the given ID - returns -1
2127 # \n If there is no node for the given index - returns -2
2128 # @return an integer value
2129 # @ingroup l1_meshinfo
2130 def GetElemNode(self, id, index):
2131 return self.mesh.GetElemNode(id, index)
2133 ## Returns the IDs of nodes of the given element
2134 # @return a list of integer values
2135 # @ingroup l1_meshinfo
2136 def GetElemNodes(self, id):
2137 return self.mesh.GetElemNodes(id)
2139 ## Returns true if the given node is the medium node in the given quadratic element
2140 # @ingroup l1_meshinfo
2141 def IsMediumNode(self, elementID, nodeID):
2142 return self.mesh.IsMediumNode(elementID, nodeID)
2144 ## Returns true if the given node is the medium node in one of quadratic elements
2145 # @ingroup l1_meshinfo
2146 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2147 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2149 ## Returns the number of edges for the given element
2150 # @ingroup l1_meshinfo
2151 def ElemNbEdges(self, id):
2152 return self.mesh.ElemNbEdges(id)
2154 ## Returns the number of faces for the given element
2155 # @ingroup l1_meshinfo
2156 def ElemNbFaces(self, id):
2157 return self.mesh.ElemNbFaces(id)
2159 ## Returns nodes of given face (counted from zero) for given volumic element.
2160 # @ingroup l1_meshinfo
2161 def GetElemFaceNodes(self,elemId, faceIndex):
2162 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2164 ## Returns an element based on all given nodes.
2165 # @ingroup l1_meshinfo
2166 def FindElementByNodes(self,nodes):
2167 return self.mesh.FindElementByNodes(nodes)
2169 ## Returns true if the given element is a polygon
2170 # @ingroup l1_meshinfo
2171 def IsPoly(self, id):
2172 return self.mesh.IsPoly(id)
2174 ## Returns true if the given element is quadratic
2175 # @ingroup l1_meshinfo
2176 def IsQuadratic(self, id):
2177 return self.mesh.IsQuadratic(id)
2179 ## Returns XYZ coordinates of the barycenter of the given element
2180 # \n If there is no element for the given ID - returns an empty list
2181 # @return a list of three double values
2182 # @ingroup l1_meshinfo
2183 def BaryCenter(self, id):
2184 return self.mesh.BaryCenter(id)
2187 # Mesh edition (SMESH_MeshEditor functionality):
2188 # ---------------------------------------------
2190 ## Removes the elements from the mesh by ids
2191 # @param IDsOfElements is a list of ids of elements to remove
2192 # @return True or False
2193 # @ingroup l2_modif_del
2194 def RemoveElements(self, IDsOfElements):
2195 return self.editor.RemoveElements(IDsOfElements)
2197 ## Removes nodes from mesh by ids
2198 # @param IDsOfNodes is a list of ids of nodes to remove
2199 # @return True or False
2200 # @ingroup l2_modif_del
2201 def RemoveNodes(self, IDsOfNodes):
2202 return self.editor.RemoveNodes(IDsOfNodes)
2204 ## Removes all orphan (free) nodes from mesh
2205 # @return number of the removed nodes
2206 # @ingroup l2_modif_del
2207 def RemoveOrphanNodes(self):
2208 return self.editor.RemoveOrphanNodes()
2210 ## Add a node to the mesh by coordinates
2211 # @return Id of the new node
2212 # @ingroup l2_modif_add
2213 def AddNode(self, x, y, z):
2214 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2215 self.mesh.SetParameters(Parameters)
2216 return self.editor.AddNode( x, y, z)
2218 ## Creates a 0D element on a node with given number.
2219 # @param IDOfNode the ID of node for creation of the element.
2220 # @return the Id of the new 0D element
2221 # @ingroup l2_modif_add
2222 def Add0DElement(self, IDOfNode):
2223 return self.editor.Add0DElement(IDOfNode)
2225 ## Creates a linear or quadratic edge (this is determined
2226 # by the number of given nodes).
2227 # @param IDsOfNodes the list of node IDs for creation of the element.
2228 # The order of nodes in this list should correspond to the description
2229 # of MED. \n This description is located by the following link:
2230 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2231 # @return the Id of the new edge
2232 # @ingroup l2_modif_add
2233 def AddEdge(self, IDsOfNodes):
2234 return self.editor.AddEdge(IDsOfNodes)
2236 ## Creates a linear or quadratic face (this is determined
2237 # by the number of given nodes).
2238 # @param IDsOfNodes the list of node IDs for creation of the element.
2239 # The order of nodes in this list should correspond to the description
2240 # of MED. \n This description is located by the following link:
2241 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2242 # @return the Id of the new face
2243 # @ingroup l2_modif_add
2244 def AddFace(self, IDsOfNodes):
2245 return self.editor.AddFace(IDsOfNodes)
2247 ## Adds a polygonal face to the mesh by the list of node IDs
2248 # @param IdsOfNodes the list of node IDs for creation of the element.
2249 # @return the Id of the new face
2250 # @ingroup l2_modif_add
2251 def AddPolygonalFace(self, IdsOfNodes):
2252 return self.editor.AddPolygonalFace(IdsOfNodes)
2254 ## Creates both simple and quadratic volume (this is determined
2255 # by the number of given nodes).
2256 # @param IDsOfNodes the list of node IDs for creation of the element.
2257 # The order of nodes in this list should correspond to the description
2258 # of MED. \n This description is located by the following link:
2259 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2260 # @return the Id of the new volumic element
2261 # @ingroup l2_modif_add
2262 def AddVolume(self, IDsOfNodes):
2263 return self.editor.AddVolume(IDsOfNodes)
2265 ## Creates a volume of many faces, giving nodes for each face.
2266 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2267 # @param Quantities the list of integer values, Quantities[i]
2268 # gives the quantity of nodes in face number i.
2269 # @return the Id of the new volumic element
2270 # @ingroup l2_modif_add
2271 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2272 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2274 ## Creates a volume of many faces, giving the IDs of the existing faces.
2275 # @param IdsOfFaces the list of face IDs for volume creation.
2277 # Note: The created volume will refer only to the nodes
2278 # of the given faces, not to the faces themselves.
2279 # @return the Id of the new volumic element
2280 # @ingroup l2_modif_add
2281 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2282 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2285 ## @brief Binds a node to a vertex
2286 # @param NodeID a node ID
2287 # @param Vertex a vertex or vertex ID
2288 # @return True if succeed else raises an exception
2289 # @ingroup l2_modif_add
2290 def SetNodeOnVertex(self, NodeID, Vertex):
2291 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2292 VertexID = Vertex.GetSubShapeIndices()[0]
2296 self.editor.SetNodeOnVertex(NodeID, VertexID)
2297 except SALOME.SALOME_Exception, inst:
2298 raise ValueError, inst.details.text
2302 ## @brief Stores the node position on an edge
2303 # @param NodeID a node ID
2304 # @param Edge an edge or edge ID
2305 # @param paramOnEdge a parameter on the edge where the node is located
2306 # @return True if succeed else raises an exception
2307 # @ingroup l2_modif_add
2308 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2309 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2310 EdgeID = Edge.GetSubShapeIndices()[0]
2314 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2315 except SALOME.SALOME_Exception, inst:
2316 raise ValueError, inst.details.text
2319 ## @brief Stores node position on a face
2320 # @param NodeID a node ID
2321 # @param Face a face or face ID
2322 # @param u U parameter on the face where the node is located
2323 # @param v V parameter on the face where the node is located
2324 # @return True if succeed else raises an exception
2325 # @ingroup l2_modif_add
2326 def SetNodeOnFace(self, NodeID, Face, u, v):
2327 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2328 FaceID = Face.GetSubShapeIndices()[0]
2332 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2333 except SALOME.SALOME_Exception, inst:
2334 raise ValueError, inst.details.text
2337 ## @brief Binds a node to a solid
2338 # @param NodeID a node ID
2339 # @param Solid a solid or solid ID
2340 # @return True if succeed else raises an exception
2341 # @ingroup l2_modif_add
2342 def SetNodeInVolume(self, NodeID, Solid):
2343 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2344 SolidID = Solid.GetSubShapeIndices()[0]
2348 self.editor.SetNodeInVolume(NodeID, SolidID)
2349 except SALOME.SALOME_Exception, inst:
2350 raise ValueError, inst.details.text
2353 ## @brief Bind an element to a shape
2354 # @param ElementID an element ID
2355 # @param Shape a shape or shape ID
2356 # @return True if succeed else raises an exception
2357 # @ingroup l2_modif_add
2358 def SetMeshElementOnShape(self, ElementID, Shape):
2359 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2360 ShapeID = Shape.GetSubShapeIndices()[0]
2364 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2365 except SALOME.SALOME_Exception, inst:
2366 raise ValueError, inst.details.text
2370 ## Moves the node with the given id
2371 # @param NodeID the id of the node
2372 # @param x a new X coordinate
2373 # @param y a new Y coordinate
2374 # @param z a new Z coordinate
2375 # @return True if succeed else False
2376 # @ingroup l2_modif_movenode
2377 def MoveNode(self, NodeID, x, y, z):
2378 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2379 self.mesh.SetParameters(Parameters)
2380 return self.editor.MoveNode(NodeID, x, y, z)
2382 ## Finds the node closest to a point and moves it to a point location
2383 # @param x the X coordinate of a point
2384 # @param y the Y coordinate of a point
2385 # @param z the Z coordinate of a point
2386 # @param NodeID if specified (>0), the node with this ID is moved,
2387 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2388 # @return the ID of a node
2389 # @ingroup l2_modif_throughp
2390 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2391 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2392 self.mesh.SetParameters(Parameters)
2393 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2395 ## Finds the node closest to a point
2396 # @param x the X coordinate of a point
2397 # @param y the Y coordinate of a point
2398 # @param z the Z coordinate of a point
2399 # @return the ID of a node
2400 # @ingroup l2_modif_throughp
2401 def FindNodeClosestTo(self, x, y, z):
2402 #preview = self.mesh.GetMeshEditPreviewer()
2403 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2404 return self.editor.FindNodeClosestTo(x, y, z)
2406 ## Finds the elements where a point lays IN or ON
2407 # @param x the X coordinate of a point
2408 # @param y the Y coordinate of a point
2409 # @param z the Z coordinate of a point
2410 # @param elementType type of elements to find (SMESH.ALL type
2411 # means elements of any type excluding nodes and 0D elements)
2412 # @return list of IDs of found elements
2413 # @ingroup l2_modif_throughp
2414 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2415 return self.editor.FindElementsByPoint(x, y, z, elementType)
2417 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2418 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2420 def GetPointState(self, x, y, z):
2421 return self.editor.GetPointState(x, y, z)
2423 ## Finds the node closest to a point and moves it to a point location
2424 # @param x the X coordinate of a point
2425 # @param y the Y coordinate of a point
2426 # @param z the Z coordinate of a point
2427 # @return the ID of a moved node
2428 # @ingroup l2_modif_throughp
2429 def MeshToPassThroughAPoint(self, x, y, z):
2430 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2432 ## Replaces two neighbour triangles sharing Node1-Node2 link
2433 # with the triangles built on the same 4 nodes but having other common link.
2434 # @param NodeID1 the ID of the first node
2435 # @param NodeID2 the ID of the second node
2436 # @return false if proper faces were not found
2437 # @ingroup l2_modif_invdiag
2438 def InverseDiag(self, NodeID1, NodeID2):
2439 return self.editor.InverseDiag(NodeID1, NodeID2)
2441 ## Replaces two neighbour triangles sharing Node1-Node2 link
2442 # with a quadrangle built on the same 4 nodes.
2443 # @param NodeID1 the ID of the first node
2444 # @param NodeID2 the ID of the second node
2445 # @return false if proper faces were not found
2446 # @ingroup l2_modif_unitetri
2447 def DeleteDiag(self, NodeID1, NodeID2):
2448 return self.editor.DeleteDiag(NodeID1, NodeID2)
2450 ## Reorients elements by ids
2451 # @param IDsOfElements if undefined reorients all mesh elements
2452 # @return True if succeed else False
2453 # @ingroup l2_modif_changori
2454 def Reorient(self, IDsOfElements=None):
2455 if IDsOfElements == None:
2456 IDsOfElements = self.GetElementsId()
2457 return self.editor.Reorient(IDsOfElements)
2459 ## Reorients all elements of the object
2460 # @param theObject mesh, submesh or group
2461 # @return True if succeed else False
2462 # @ingroup l2_modif_changori
2463 def ReorientObject(self, theObject):
2464 if ( isinstance( theObject, Mesh )):
2465 theObject = theObject.GetMesh()
2466 return self.editor.ReorientObject(theObject)
2468 ## Fuses the neighbouring triangles into quadrangles.
2469 # @param IDsOfElements The triangles to be fused,
2470 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2471 # @param MaxAngle is the maximum angle between element normals at which the fusion
2472 # is still performed; theMaxAngle is mesured in radians.
2473 # Also it could be a name of variable which defines angle in degrees.
2474 # @return TRUE in case of success, FALSE otherwise.
2475 # @ingroup l2_modif_unitetri
2476 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2478 if isinstance(MaxAngle,str):
2480 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2482 MaxAngle = DegreesToRadians(MaxAngle)
2483 if IDsOfElements == []:
2484 IDsOfElements = self.GetElementsId()
2485 self.mesh.SetParameters(Parameters)
2487 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2488 Functor = theCriterion
2490 Functor = self.smeshpyD.GetFunctor(theCriterion)
2491 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2493 ## Fuses the neighbouring triangles of the object into quadrangles
2494 # @param theObject is mesh, submesh or group
2495 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2496 # @param MaxAngle a max angle between element normals at which the fusion
2497 # is still performed; theMaxAngle is mesured in radians.
2498 # @return TRUE in case of success, FALSE otherwise.
2499 # @ingroup l2_modif_unitetri
2500 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2501 if ( isinstance( theObject, Mesh )):
2502 theObject = theObject.GetMesh()
2503 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2505 ## Splits quadrangles into triangles.
2506 # @param IDsOfElements the faces to be splitted.
2507 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2508 # @return TRUE in case of success, FALSE otherwise.
2509 # @ingroup l2_modif_cutquadr
2510 def QuadToTri (self, IDsOfElements, theCriterion):
2511 if IDsOfElements == []:
2512 IDsOfElements = self.GetElementsId()
2513 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2515 ## Splits quadrangles into triangles.
2516 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2517 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2518 # @return TRUE in case of success, FALSE otherwise.
2519 # @ingroup l2_modif_cutquadr
2520 def QuadToTriObject (self, theObject, theCriterion):
2521 if ( isinstance( theObject, Mesh )):
2522 theObject = theObject.GetMesh()
2523 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2525 ## Splits quadrangles into triangles.
2526 # @param IDsOfElements the faces to be splitted
2527 # @param Diag13 is used to choose a diagonal for splitting.
2528 # @return TRUE in case of success, FALSE otherwise.
2529 # @ingroup l2_modif_cutquadr
2530 def SplitQuad (self, IDsOfElements, Diag13):
2531 if IDsOfElements == []:
2532 IDsOfElements = self.GetElementsId()
2533 return self.editor.SplitQuad(IDsOfElements, Diag13)
2535 ## Splits quadrangles into triangles.
2536 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2537 # @param Diag13 is used to choose a diagonal for splitting.
2538 # @return TRUE in case of success, FALSE otherwise.
2539 # @ingroup l2_modif_cutquadr
2540 def SplitQuadObject (self, theObject, Diag13):
2541 if ( isinstance( theObject, Mesh )):
2542 theObject = theObject.GetMesh()
2543 return self.editor.SplitQuadObject(theObject, Diag13)
2545 ## Finds a better splitting of the given quadrangle.
2546 # @param IDOfQuad the ID of the quadrangle to be splitted.
2547 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2548 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2549 # diagonal is better, 0 if error occurs.
2550 # @ingroup l2_modif_cutquadr
2551 def BestSplit (self, IDOfQuad, theCriterion):
2552 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2554 ## Splits volumic elements into tetrahedrons
2555 # @param elemIDs either list of elements or mesh or group or submesh
2556 # @param method flags passing splitting method: Hex_5Tet, Hex_6Tet, Hex_24Tet
2557 # Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc
2558 # @ingroup l2_modif_cutquadr
2559 def SplitVolumesIntoTetra(self, elemIDs, method=Hex_5Tet ):
2560 if isinstance( elemIDs, Mesh ):
2561 elemIDs = elemIDs.GetMesh()
2562 if ( isinstance( elemIDs, list )):
2563 elemIDs = self.editor.MakeIDSource(elemIDs, SMESH.VOLUME)
2564 self.editor.SplitVolumesIntoTetra(elemIDs, method)
2566 ## Splits quadrangle faces near triangular facets of volumes
2568 # @ingroup l1_auxiliary
2569 def SplitQuadsNearTriangularFacets(self):
2570 faces_array = self.GetElementsByType(SMESH.FACE)
2571 for face_id in faces_array:
2572 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2573 quad_nodes = self.mesh.GetElemNodes(face_id)
2574 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2575 isVolumeFound = False
2576 for node1_elem in node1_elems:
2577 if not isVolumeFound:
2578 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2579 nb_nodes = self.GetElemNbNodes(node1_elem)
2580 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2581 volume_elem = node1_elem
2582 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2583 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2584 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2585 isVolumeFound = True
2586 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2587 self.SplitQuad([face_id], False) # diagonal 2-4
2588 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2589 isVolumeFound = True
2590 self.SplitQuad([face_id], True) # diagonal 1-3
2591 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2592 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2593 isVolumeFound = True
2594 self.SplitQuad([face_id], True) # diagonal 1-3
2596 ## @brief Splits hexahedrons into tetrahedrons.
2598 # This operation uses pattern mapping functionality for splitting.
2599 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2600 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2601 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2602 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2603 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2604 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2605 # @return TRUE in case of success, FALSE otherwise.
2606 # @ingroup l1_auxiliary
2607 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2608 # Pattern: 5.---------.6
2613 # (0,0,1) 4.---------.7 * |
2620 # (0,0,0) 0.---------.3
2621 pattern_tetra = "!!! Nb of points: \n 8 \n\
2631 !!! Indices of points of 6 tetras: \n\
2639 pattern = self.smeshpyD.GetPattern()
2640 isDone = pattern.LoadFromFile(pattern_tetra)
2642 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2645 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2646 isDone = pattern.MakeMesh(self.mesh, False, False)
2647 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2649 # split quafrangle faces near triangular facets of volumes
2650 self.SplitQuadsNearTriangularFacets()
2654 ## @brief Split hexahedrons into prisms.
2656 # Uses the pattern mapping functionality for splitting.
2657 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2658 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2659 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2660 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2661 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2662 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2663 # @return TRUE in case of success, FALSE otherwise.
2664 # @ingroup l1_auxiliary
2665 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2666 # Pattern: 5.---------.6
2671 # (0,0,1) 4.---------.7 |
2678 # (0,0,0) 0.---------.3
2679 pattern_prism = "!!! Nb of points: \n 8 \n\
2689 !!! Indices of points of 2 prisms: \n\
2693 pattern = self.smeshpyD.GetPattern()
2694 isDone = pattern.LoadFromFile(pattern_prism)
2696 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2699 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2700 isDone = pattern.MakeMesh(self.mesh, False, False)
2701 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2703 # Splits quafrangle faces near triangular facets of volumes
2704 self.SplitQuadsNearTriangularFacets()
2708 ## Smoothes elements
2709 # @param IDsOfElements the list if ids of elements to smooth
2710 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2711 # Note that nodes built on edges and boundary nodes are always fixed.
2712 # @param MaxNbOfIterations the maximum number of iterations
2713 # @param MaxAspectRatio varies in range [1.0, inf]
2714 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2715 # @return TRUE in case of success, FALSE otherwise.
2716 # @ingroup l2_modif_smooth
2717 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2718 MaxNbOfIterations, MaxAspectRatio, Method):
2719 if IDsOfElements == []:
2720 IDsOfElements = self.GetElementsId()
2721 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2722 self.mesh.SetParameters(Parameters)
2723 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2724 MaxNbOfIterations, MaxAspectRatio, Method)
2726 ## Smoothes elements which belong to the given object
2727 # @param theObject the object to smooth
2728 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2729 # Note that nodes built on edges and boundary nodes are always fixed.
2730 # @param MaxNbOfIterations the maximum number of iterations
2731 # @param MaxAspectRatio varies in range [1.0, inf]
2732 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2733 # @return TRUE in case of success, FALSE otherwise.
2734 # @ingroup l2_modif_smooth
2735 def SmoothObject(self, theObject, IDsOfFixedNodes,
2736 MaxNbOfIterations, MaxAspectRatio, Method):
2737 if ( isinstance( theObject, Mesh )):
2738 theObject = theObject.GetMesh()
2739 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2740 MaxNbOfIterations, MaxAspectRatio, Method)
2742 ## Parametrically smoothes the given elements
2743 # @param IDsOfElements the list if ids of elements to smooth
2744 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2745 # Note that nodes built on edges and boundary nodes are always fixed.
2746 # @param MaxNbOfIterations the maximum number of iterations
2747 # @param MaxAspectRatio varies in range [1.0, inf]
2748 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2749 # @return TRUE in case of success, FALSE otherwise.
2750 # @ingroup l2_modif_smooth
2751 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2752 MaxNbOfIterations, MaxAspectRatio, Method):
2753 if IDsOfElements == []:
2754 IDsOfElements = self.GetElementsId()
2755 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2756 self.mesh.SetParameters(Parameters)
2757 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2758 MaxNbOfIterations, MaxAspectRatio, Method)
2760 ## Parametrically smoothes the elements which belong to the given object
2761 # @param theObject the object to smooth
2762 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2763 # Note that nodes built on edges and boundary nodes are always fixed.
2764 # @param MaxNbOfIterations the maximum number of iterations
2765 # @param MaxAspectRatio varies in range [1.0, inf]
2766 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2767 # @return TRUE in case of success, FALSE otherwise.
2768 # @ingroup l2_modif_smooth
2769 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2770 MaxNbOfIterations, MaxAspectRatio, Method):
2771 if ( isinstance( theObject, Mesh )):
2772 theObject = theObject.GetMesh()
2773 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2774 MaxNbOfIterations, MaxAspectRatio, Method)
2776 ## Converts the mesh to quadratic, deletes old elements, replacing
2777 # them with quadratic with the same id.
2778 # @param theForce3d new node creation method:
2779 # 0 - the medium node lies at the geometrical edge from which the mesh element is built
2780 # 1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element
2781 # @ingroup l2_modif_tofromqu
2782 def ConvertToQuadratic(self, theForce3d):
2783 self.editor.ConvertToQuadratic(theForce3d)
2785 ## Converts the mesh from quadratic to ordinary,
2786 # deletes old quadratic elements, \n replacing
2787 # them with ordinary mesh elements with the same id.
2788 # @return TRUE in case of success, FALSE otherwise.
2789 # @ingroup l2_modif_tofromqu
2790 def ConvertFromQuadratic(self):
2791 return self.editor.ConvertFromQuadratic()
2793 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
2794 # @return TRUE if operation has been completed successfully, FALSE otherwise
2795 # @ingroup l2_modif_edit
2796 def Make2DMeshFrom3D(self):
2797 return self.editor. Make2DMeshFrom3D()
2799 ## Creates missing boundary elements
2800 # @param elements - elements whose boundary is to be checked:
2801 # mesh, group, sub-mesh or list of elements
2802 # @param dimension - defines type of boundary elements to create:
2803 # SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D
2804 # @param groupName - a name of group to store created boundary elements in,
2805 # "" means not to create the group
2806 # @param meshName - a name of new mesh to store created boundary elements in,
2807 # "" means not to create the new mesh
2808 # @param toCopyElements - if true, the checked elements will be copied into the new mesh
2809 # @param toCopyExistingBondary - if true, not only new but also pre-existing
2810 # boundary elements will be copied into the new mesh
2811 # @return tuple (mesh, group) where bondary elements were added to
2812 # @ingroup l2_modif_edit
2813 def MakeBoundaryMesh(self, elements, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
2814 toCopyElements=False, toCopyExistingBondary=False):
2815 if isinstance( elements, Mesh ):
2816 elements = elements.GetMesh()
2817 if ( isinstance( elements, list )):
2818 elemType = SMESH.ALL
2819 if elements: elemType = self.GetElementType( elements[0], iselem=True)
2820 elements = self.editor.MakeIDSource(elements, elemType)
2821 mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName,
2822 toCopyElements,toCopyExistingBondary)
2823 if mesh: mesh = self.smeshpyD.Mesh(mesh)
2826 ## Renumber mesh nodes
2827 # @ingroup l2_modif_renumber
2828 def RenumberNodes(self):
2829 self.editor.RenumberNodes()
2831 ## Renumber mesh elements
2832 # @ingroup l2_modif_renumber
2833 def RenumberElements(self):
2834 self.editor.RenumberElements()
2836 ## Generates new elements by rotation of the elements around the axis
2837 # @param IDsOfElements the list of ids of elements to sweep
2838 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2839 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2840 # @param NbOfSteps the number of steps
2841 # @param Tolerance tolerance
2842 # @param MakeGroups forces the generation of new groups from existing ones
2843 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2844 # of all steps, else - size of each step
2845 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2846 # @ingroup l2_modif_extrurev
2847 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2848 MakeGroups=False, TotalAngle=False):
2850 if isinstance(AngleInRadians,str):
2852 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2854 AngleInRadians = DegreesToRadians(AngleInRadians)
2855 if IDsOfElements == []:
2856 IDsOfElements = self.GetElementsId()
2857 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2858 Axis = self.smeshpyD.GetAxisStruct(Axis)
2859 Axis,AxisParameters = ParseAxisStruct(Axis)
2860 if TotalAngle and NbOfSteps:
2861 AngleInRadians /= NbOfSteps
2862 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2863 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2864 self.mesh.SetParameters(Parameters)
2866 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2867 AngleInRadians, NbOfSteps, Tolerance)
2868 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2871 ## Generates new elements by rotation of the elements of object around the axis
2872 # @param theObject object which elements should be sweeped
2873 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2874 # @param AngleInRadians the angle of Rotation
2875 # @param NbOfSteps 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 RotationSweepObject(self, theObject, 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 ( isinstance( theObject, Mesh )):
2891 theObject = theObject.GetMesh()
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.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2902 NbOfSteps, Tolerance)
2903 self.editor.RotationSweepObject(theObject, 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 RotationSweepObject1D(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.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2937 NbOfSteps, Tolerance)
2938 self.editor.RotationSweepObject1D(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 RotationSweepObject2D(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.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2972 NbOfSteps, Tolerance)
2973 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2976 ## Generates new elements by extrusion of the elements with given ids
2977 # @param IDsOfElements the list of elements ids for extrusion
2978 # @param StepVector vector, defining the direction and value of extrusion
2979 # @param NbOfSteps the number of steps
2980 # @param MakeGroups forces the generation of new groups from existing ones
2981 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2982 # @ingroup l2_modif_extrurev
2983 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2984 if IDsOfElements == []:
2985 IDsOfElements = self.GetElementsId()
2986 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2987 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2988 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2989 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2990 Parameters = StepVectorParameters + var_separator + Parameters
2991 self.mesh.SetParameters(Parameters)
2993 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2994 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2997 ## Generates new elements by extrusion of the elements with given ids
2998 # @param IDsOfElements is ids of elements
2999 # @param StepVector vector, defining the direction and value of extrusion
3000 # @param NbOfSteps the number of steps
3001 # @param ExtrFlags sets flags for extrusion
3002 # @param SewTolerance uses for comparing locations of nodes if flag
3003 # EXTRUSION_FLAG_SEW is set
3004 # @param MakeGroups forces the generation of new groups from existing ones
3005 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3006 # @ingroup l2_modif_extrurev
3007 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
3008 ExtrFlags, SewTolerance, MakeGroups=False):
3009 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3010 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3012 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
3013 ExtrFlags, SewTolerance)
3014 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
3015 ExtrFlags, SewTolerance)
3018 ## Generates new elements by extrusion of the elements which belong to the object
3019 # @param theObject the object which elements should be processed
3020 # @param StepVector vector, defining the direction and value of extrusion
3021 # @param NbOfSteps the number of steps
3022 # @param MakeGroups forces the generation of new groups from existing ones
3023 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3024 # @ingroup l2_modif_extrurev
3025 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3026 if ( isinstance( theObject, Mesh )):
3027 theObject = theObject.GetMesh()
3028 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3029 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3030 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3031 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3032 Parameters = StepVectorParameters + var_separator + Parameters
3033 self.mesh.SetParameters(Parameters)
3035 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3036 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
3039 ## Generates new elements by extrusion of the elements which belong to the object
3040 # @param theObject object which elements should be processed
3041 # @param StepVector vector, defining the direction and value of extrusion
3042 # @param NbOfSteps the number of steps
3043 # @param MakeGroups to generate new groups from existing ones
3044 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3045 # @ingroup l2_modif_extrurev
3046 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3047 if ( isinstance( theObject, Mesh )):
3048 theObject = theObject.GetMesh()
3049 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3050 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3051 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3052 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3053 Parameters = StepVectorParameters + var_separator + Parameters
3054 self.mesh.SetParameters(Parameters)
3056 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3057 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3060 ## Generates new elements by extrusion of the elements which belong to the object
3061 # @param theObject object which elements should be processed
3062 # @param StepVector vector, defining the direction and value of extrusion
3063 # @param NbOfSteps the number of steps
3064 # @param MakeGroups forces the generation of new groups from existing ones
3065 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3066 # @ingroup l2_modif_extrurev
3067 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3068 if ( isinstance( theObject, Mesh )):
3069 theObject = theObject.GetMesh()
3070 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3071 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3072 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3073 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3074 Parameters = StepVectorParameters + var_separator + Parameters
3075 self.mesh.SetParameters(Parameters)
3077 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3078 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3083 ## Generates new elements by extrusion of the given elements
3084 # The path of extrusion must be a meshed edge.
3085 # @param Base mesh or list of ids of elements for extrusion
3086 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3087 # @param NodeStart the start node from Path. Defines the direction of extrusion
3088 # @param HasAngles allows the shape to be rotated around the path
3089 # to get the resulting mesh in a helical fashion
3090 # @param Angles list of angles in radians
3091 # @param LinearVariation forces the computation of rotation angles as linear
3092 # variation of the given Angles along path steps
3093 # @param HasRefPoint allows using the reference point
3094 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3095 # The User can specify any point as the Reference Point.
3096 # @param MakeGroups forces the generation of new groups from existing ones
3097 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3098 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3099 # only SMESH::Extrusion_Error otherwise
3100 # @ingroup l2_modif_extrurev
3101 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3102 HasAngles, Angles, LinearVariation,
3103 HasRefPoint, RefPoint, MakeGroups, ElemType):
3104 Angles,AnglesParameters = ParseAngles(Angles)
3105 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3106 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3107 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3109 Parameters = AnglesParameters + var_separator + RefPointParameters
3110 self.mesh.SetParameters(Parameters)
3112 if isinstance(Base,list):
3114 if Base == []: IDsOfElements = self.GetElementsId()
3115 else: IDsOfElements = Base
3116 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3117 HasAngles, Angles, LinearVariation,
3118 HasRefPoint, RefPoint, MakeGroups, ElemType)
3120 if isinstance(Base,Mesh):
3121 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3122 HasAngles, Angles, LinearVariation,
3123 HasRefPoint, RefPoint, MakeGroups, ElemType)
3125 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3128 ## Generates new elements by extrusion of the given elements
3129 # The path of extrusion must be a meshed edge.
3130 # @param IDsOfElements ids of elements
3131 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3132 # @param PathShape shape(edge) defines the sub-mesh for the path
3133 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3134 # @param HasAngles allows the shape to be rotated around the path
3135 # to get the resulting mesh in a helical fashion
3136 # @param Angles list of angles in radians
3137 # @param HasRefPoint allows using the reference point
3138 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3139 # The User can specify any point as the Reference Point.
3140 # @param MakeGroups forces the generation of new groups from existing ones
3141 # @param LinearVariation forces the computation of rotation angles as linear
3142 # variation of the given Angles along path steps
3143 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3144 # only SMESH::Extrusion_Error otherwise
3145 # @ingroup l2_modif_extrurev
3146 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3147 HasAngles, Angles, HasRefPoint, RefPoint,
3148 MakeGroups=False, LinearVariation=False):
3149 Angles,AnglesParameters = ParseAngles(Angles)
3150 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3151 if IDsOfElements == []:
3152 IDsOfElements = self.GetElementsId()
3153 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3154 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3156 if ( isinstance( PathMesh, Mesh )):
3157 PathMesh = PathMesh.GetMesh()
3158 if HasAngles and Angles and LinearVariation:
3159 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3161 Parameters = AnglesParameters + var_separator + RefPointParameters
3162 self.mesh.SetParameters(Parameters)
3164 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3165 PathShape, NodeStart, HasAngles,
3166 Angles, HasRefPoint, RefPoint)
3167 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3168 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3170 ## Generates new elements by extrusion of the elements which belong to the object
3171 # The path of extrusion must be a meshed edge.
3172 # @param theObject the object which elements should be processed
3173 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3174 # @param PathShape shape(edge) defines the sub-mesh for the path
3175 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3176 # @param HasAngles allows the shape to be rotated around the path
3177 # to get the resulting mesh in a helical fashion
3178 # @param Angles list of angles
3179 # @param HasRefPoint allows using the reference point
3180 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3181 # The User can specify any point as the Reference Point.
3182 # @param MakeGroups forces the generation of new groups from existing ones
3183 # @param LinearVariation forces the computation of rotation angles as linear
3184 # variation of the given Angles along path steps
3185 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3186 # only SMESH::Extrusion_Error otherwise
3187 # @ingroup l2_modif_extrurev
3188 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3189 HasAngles, Angles, HasRefPoint, RefPoint,
3190 MakeGroups=False, LinearVariation=False):
3191 Angles,AnglesParameters = ParseAngles(Angles)
3192 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3193 if ( isinstance( theObject, Mesh )):
3194 theObject = theObject.GetMesh()
3195 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3196 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3197 if ( isinstance( PathMesh, Mesh )):
3198 PathMesh = PathMesh.GetMesh()
3199 if HasAngles and Angles and LinearVariation:
3200 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3202 Parameters = AnglesParameters + var_separator + RefPointParameters
3203 self.mesh.SetParameters(Parameters)
3205 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3206 PathShape, NodeStart, HasAngles,
3207 Angles, HasRefPoint, RefPoint)
3208 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3209 NodeStart, HasAngles, Angles, HasRefPoint,
3212 ## Generates new elements by extrusion of the elements which belong to the object
3213 # The path of extrusion must be a meshed edge.
3214 # @param theObject the object which elements should be processed
3215 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3216 # @param PathShape shape(edge) defines the sub-mesh for the path
3217 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3218 # @param HasAngles allows the shape to be rotated around the path
3219 # to get the resulting mesh in a helical fashion
3220 # @param Angles list of angles
3221 # @param HasRefPoint allows using the reference point
3222 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3223 # The User can specify any point as the Reference Point.
3224 # @param MakeGroups forces the generation of new groups from existing ones
3225 # @param LinearVariation forces the computation of rotation angles as linear
3226 # variation of the given Angles along path steps
3227 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3228 # only SMESH::Extrusion_Error otherwise
3229 # @ingroup l2_modif_extrurev
3230 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3231 HasAngles, Angles, HasRefPoint, RefPoint,
3232 MakeGroups=False, LinearVariation=False):
3233 Angles,AnglesParameters = ParseAngles(Angles)
3234 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3235 if ( isinstance( theObject, Mesh )):
3236 theObject = theObject.GetMesh()
3237 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3238 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3239 if ( isinstance( PathMesh, Mesh )):
3240 PathMesh = PathMesh.GetMesh()
3241 if HasAngles and Angles and LinearVariation:
3242 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3244 Parameters = AnglesParameters + var_separator + RefPointParameters
3245 self.mesh.SetParameters(Parameters)
3247 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3248 PathShape, NodeStart, HasAngles,
3249 Angles, HasRefPoint, RefPoint)
3250 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3251 NodeStart, HasAngles, Angles, HasRefPoint,
3254 ## Generates new elements by extrusion of the elements which belong to the object
3255 # The path of extrusion must be a meshed edge.
3256 # @param theObject the object which elements should be processed
3257 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3258 # @param PathShape shape(edge) defines the sub-mesh for the path
3259 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3260 # @param HasAngles allows the shape to be rotated around the path
3261 # to get the resulting mesh in a helical fashion
3262 # @param Angles list of angles
3263 # @param HasRefPoint allows using the reference point
3264 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3265 # The User can specify any point as the Reference Point.
3266 # @param MakeGroups forces the generation of new groups from existing ones
3267 # @param LinearVariation forces the computation of rotation angles as linear
3268 # variation of the given Angles along path steps
3269 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3270 # only SMESH::Extrusion_Error otherwise
3271 # @ingroup l2_modif_extrurev
3272 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3273 HasAngles, Angles, HasRefPoint, RefPoint,
3274 MakeGroups=False, LinearVariation=False):
3275 Angles,AnglesParameters = ParseAngles(Angles)
3276 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3277 if ( isinstance( theObject, Mesh )):
3278 theObject = theObject.GetMesh()
3279 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3280 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3281 if ( isinstance( PathMesh, Mesh )):
3282 PathMesh = PathMesh.GetMesh()
3283 if HasAngles and Angles and LinearVariation:
3284 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3286 Parameters = AnglesParameters + var_separator + RefPointParameters
3287 self.mesh.SetParameters(Parameters)
3289 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3290 PathShape, NodeStart, HasAngles,
3291 Angles, HasRefPoint, RefPoint)
3292 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3293 NodeStart, HasAngles, Angles, HasRefPoint,
3296 ## Creates a symmetrical copy of mesh elements
3297 # @param IDsOfElements list of elements ids
3298 # @param Mirror is AxisStruct or geom object(point, line, plane)
3299 # @param theMirrorType is POINT, AXIS or PLANE
3300 # If the Mirror is a geom object this parameter is unnecessary
3301 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3302 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3303 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3304 # @ingroup l2_modif_trsf
3305 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3306 if IDsOfElements == []:
3307 IDsOfElements = self.GetElementsId()
3308 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3309 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3310 Mirror,Parameters = ParseAxisStruct(Mirror)
3311 self.mesh.SetParameters(Parameters)
3312 if Copy and MakeGroups:
3313 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3314 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3317 ## Creates a new mesh by a symmetrical copy of mesh elements
3318 # @param IDsOfElements the list of elements ids
3319 # @param Mirror is AxisStruct or geom object (point, line, plane)
3320 # @param theMirrorType is POINT, AXIS or PLANE
3321 # If the Mirror is a geom object this parameter is unnecessary
3322 # @param MakeGroups to generate new groups from existing ones
3323 # @param NewMeshName a name of the new mesh to create
3324 # @return instance of Mesh class
3325 # @ingroup l2_modif_trsf
3326 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3327 if IDsOfElements == []:
3328 IDsOfElements = self.GetElementsId()
3329 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3330 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3331 Mirror,Parameters = ParseAxisStruct(Mirror)
3332 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3333 MakeGroups, NewMeshName)
3334 mesh.SetParameters(Parameters)
3335 return Mesh(self.smeshpyD,self.geompyD,mesh)
3337 ## Creates a symmetrical copy of the object
3338 # @param theObject mesh, submesh or group
3339 # @param Mirror AxisStruct or geom object (point, line, plane)
3340 # @param theMirrorType is POINT, AXIS or PLANE
3341 # If the Mirror is a geom object this parameter is unnecessary
3342 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3343 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3344 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3345 # @ingroup l2_modif_trsf
3346 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3347 if ( isinstance( theObject, Mesh )):
3348 theObject = theObject.GetMesh()
3349 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3350 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3351 Mirror,Parameters = ParseAxisStruct(Mirror)
3352 self.mesh.SetParameters(Parameters)
3353 if Copy and MakeGroups:
3354 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3355 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3358 ## Creates a new mesh by a symmetrical copy of the object
3359 # @param theObject mesh, submesh or group
3360 # @param Mirror AxisStruct or geom object (point, line, plane)
3361 # @param theMirrorType POINT, AXIS or PLANE
3362 # If the Mirror is a geom object this parameter is unnecessary
3363 # @param MakeGroups forces the generation of new groups from existing ones
3364 # @param NewMeshName the name of the new mesh to create
3365 # @return instance of Mesh class
3366 # @ingroup l2_modif_trsf
3367 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3368 if ( isinstance( theObject, Mesh )):
3369 theObject = theObject.GetMesh()
3370 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3371 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3372 Mirror,Parameters = ParseAxisStruct(Mirror)
3373 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3374 MakeGroups, NewMeshName)
3375 mesh.SetParameters(Parameters)
3376 return Mesh( self.smeshpyD,self.geompyD,mesh )
3378 ## Translates the elements
3379 # @param IDsOfElements list of elements ids
3380 # @param Vector the direction of translation (DirStruct or vector)
3381 # @param Copy allows copying the translated elements
3382 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3383 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3384 # @ingroup l2_modif_trsf
3385 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3386 if IDsOfElements == []:
3387 IDsOfElements = self.GetElementsId()
3388 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3389 Vector = self.smeshpyD.GetDirStruct(Vector)
3390 Vector,Parameters = ParseDirStruct(Vector)
3391 self.mesh.SetParameters(Parameters)
3392 if Copy and MakeGroups:
3393 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3394 self.editor.Translate(IDsOfElements, Vector, Copy)
3397 ## Creates a new mesh of translated elements
3398 # @param IDsOfElements list of elements ids
3399 # @param Vector the direction of translation (DirStruct or vector)
3400 # @param MakeGroups forces the generation of new groups from existing ones
3401 # @param NewMeshName the name of the newly created mesh
3402 # @return instance of Mesh class
3403 # @ingroup l2_modif_trsf
3404 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3405 if IDsOfElements == []:
3406 IDsOfElements = self.GetElementsId()
3407 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3408 Vector = self.smeshpyD.GetDirStruct(Vector)
3409 Vector,Parameters = ParseDirStruct(Vector)
3410 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3411 mesh.SetParameters(Parameters)
3412 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3414 ## Translates the object
3415 # @param theObject the object to translate (mesh, submesh, or group)
3416 # @param Vector direction of translation (DirStruct or geom vector)
3417 # @param Copy allows copying the translated elements
3418 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3419 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3420 # @ingroup l2_modif_trsf
3421 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3422 if ( isinstance( theObject, Mesh )):
3423 theObject = theObject.GetMesh()
3424 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3425 Vector = self.smeshpyD.GetDirStruct(Vector)
3426 Vector,Parameters = ParseDirStruct(Vector)
3427 self.mesh.SetParameters(Parameters)
3428 if Copy and MakeGroups:
3429 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3430 self.editor.TranslateObject(theObject, Vector, Copy)
3433 ## Creates a new mesh from the translated object
3434 # @param theObject the object to translate (mesh, submesh, or group)
3435 # @param Vector the direction of translation (DirStruct or geom vector)
3436 # @param MakeGroups forces the generation of new groups from existing ones
3437 # @param NewMeshName the name of the newly created mesh
3438 # @return instance of Mesh class
3439 # @ingroup l2_modif_trsf
3440 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3441 if (isinstance(theObject, Mesh)):
3442 theObject = theObject.GetMesh()
3443 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3444 Vector = self.smeshpyD.GetDirStruct(Vector)
3445 Vector,Parameters = ParseDirStruct(Vector)
3446 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3447 mesh.SetParameters(Parameters)
3448 return Mesh( self.smeshpyD, self.geompyD, mesh )
3452 ## Scales the object
3453 # @param theObject - the object to translate (mesh, submesh, or group)
3454 # @param thePoint - base point for scale
3455 # @param theScaleFact - list of 1-3 scale factors for axises
3456 # @param Copy - allows copying the translated elements
3457 # @param MakeGroups - forces the generation of new groups from existing
3459 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3460 # empty list otherwise
3461 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3462 if ( isinstance( theObject, Mesh )):
3463 theObject = theObject.GetMesh()
3464 if ( isinstance( theObject, list )):
3465 theObject = self.editor.MakeIDSource(theObject, SMESH.ALL)
3467 thePoint, Parameters = ParsePointStruct(thePoint)
3468 self.mesh.SetParameters(Parameters)
3470 if Copy and MakeGroups:
3471 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3472 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3475 ## Creates a new mesh from the translated object
3476 # @param theObject - the object to translate (mesh, submesh, or group)
3477 # @param thePoint - base point for scale
3478 # @param theScaleFact - list of 1-3 scale factors for axises
3479 # @param MakeGroups - forces the generation of new groups from existing ones
3480 # @param NewMeshName - the name of the newly created mesh
3481 # @return instance of Mesh class
3482 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3483 if (isinstance(theObject, Mesh)):
3484 theObject = theObject.GetMesh()
3485 if ( isinstance( theObject, list )):
3486 theObject = self.editor.MakeIDSource(theObject,SMESH.ALL)
3488 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3489 MakeGroups, NewMeshName)
3490 #mesh.SetParameters(Parameters)
3491 return Mesh( self.smeshpyD, self.geompyD, mesh )
3495 ## Rotates the elements
3496 # @param IDsOfElements list of elements ids
3497 # @param Axis the axis of rotation (AxisStruct or geom line)
3498 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3499 # @param Copy allows copying the rotated elements
3500 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3501 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3502 # @ingroup l2_modif_trsf
3503 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3505 if isinstance(AngleInRadians,str):
3507 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3509 AngleInRadians = DegreesToRadians(AngleInRadians)
3510 if IDsOfElements == []:
3511 IDsOfElements = self.GetElementsId()
3512 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3513 Axis = self.smeshpyD.GetAxisStruct(Axis)
3514 Axis,AxisParameters = ParseAxisStruct(Axis)
3515 Parameters = AxisParameters + var_separator + Parameters
3516 self.mesh.SetParameters(Parameters)
3517 if Copy and MakeGroups:
3518 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3519 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3522 ## Creates a new mesh of rotated elements
3523 # @param IDsOfElements list of element ids
3524 # @param Axis the axis of rotation (AxisStruct or geom line)
3525 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3526 # @param MakeGroups forces the generation of new groups from existing ones
3527 # @param NewMeshName the name of the newly created mesh
3528 # @return instance of Mesh class
3529 # @ingroup l2_modif_trsf
3530 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3532 if isinstance(AngleInRadians,str):
3534 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3536 AngleInRadians = DegreesToRadians(AngleInRadians)
3537 if IDsOfElements == []:
3538 IDsOfElements = self.GetElementsId()
3539 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3540 Axis = self.smeshpyD.GetAxisStruct(Axis)
3541 Axis,AxisParameters = ParseAxisStruct(Axis)
3542 Parameters = AxisParameters + var_separator + Parameters
3543 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3544 MakeGroups, NewMeshName)
3545 mesh.SetParameters(Parameters)
3546 return Mesh( self.smeshpyD, self.geompyD, mesh )
3548 ## Rotates the object
3549 # @param theObject the object to rotate( mesh, submesh, or group)
3550 # @param Axis the axis of rotation (AxisStruct or geom line)
3551 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3552 # @param Copy allows copying the rotated elements
3553 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3554 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3555 # @ingroup l2_modif_trsf
3556 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3558 if isinstance(AngleInRadians,str):
3560 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3562 AngleInRadians = DegreesToRadians(AngleInRadians)
3563 if (isinstance(theObject, Mesh)):
3564 theObject = theObject.GetMesh()
3565 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3566 Axis = self.smeshpyD.GetAxisStruct(Axis)
3567 Axis,AxisParameters = ParseAxisStruct(Axis)
3568 Parameters = AxisParameters + ":" + Parameters
3569 self.mesh.SetParameters(Parameters)
3570 if Copy and MakeGroups:
3571 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3572 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3575 ## Creates a new mesh from the rotated object
3576 # @param theObject the object to rotate (mesh, submesh, or group)
3577 # @param Axis the axis of rotation (AxisStruct or geom line)
3578 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3579 # @param MakeGroups forces the generation of new groups from existing ones
3580 # @param NewMeshName the name of the newly created mesh
3581 # @return instance of Mesh class
3582 # @ingroup l2_modif_trsf
3583 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3585 if isinstance(AngleInRadians,str):
3587 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3589 AngleInRadians = DegreesToRadians(AngleInRadians)
3590 if (isinstance( theObject, Mesh )):
3591 theObject = theObject.GetMesh()
3592 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3593 Axis = self.smeshpyD.GetAxisStruct(Axis)
3594 Axis,AxisParameters = ParseAxisStruct(Axis)
3595 Parameters = AxisParameters + ":" + Parameters
3596 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3597 MakeGroups, NewMeshName)
3598 mesh.SetParameters(Parameters)
3599 return Mesh( self.smeshpyD, self.geompyD, mesh )
3601 ## Finds groups of ajacent nodes within Tolerance.
3602 # @param Tolerance the value of tolerance
3603 # @return the list of groups of nodes
3604 # @ingroup l2_modif_trsf
3605 def FindCoincidentNodes (self, Tolerance):
3606 return self.editor.FindCoincidentNodes(Tolerance)
3608 ## Finds groups of ajacent nodes within Tolerance.
3609 # @param Tolerance the value of tolerance
3610 # @param SubMeshOrGroup SubMesh or Group
3611 # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
3612 # @return the list of groups of nodes
3613 # @ingroup l2_modif_trsf
3614 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
3615 if (isinstance( SubMeshOrGroup, Mesh )):
3616 SubMeshOrGroup = SubMeshOrGroup.GetMesh()
3617 if not isinstance( exceptNodes, list):
3618 exceptNodes = [ exceptNodes ]
3619 if exceptNodes and isinstance( exceptNodes[0], int):
3620 exceptNodes = [ self.editor.MakeIDSource( exceptNodes, SMESH.NODE)]
3621 return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes)
3624 # @param GroupsOfNodes the list of groups of nodes
3625 # @ingroup l2_modif_trsf
3626 def MergeNodes (self, GroupsOfNodes):
3627 self.editor.MergeNodes(GroupsOfNodes)
3629 ## Finds the elements built on the same nodes.
3630 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3631 # @return a list of groups of equal elements
3632 # @ingroup l2_modif_trsf
3633 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3634 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3635 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3636 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3638 ## Merges elements in each given group.
3639 # @param GroupsOfElementsID groups of elements for merging
3640 # @ingroup l2_modif_trsf
3641 def MergeElements(self, GroupsOfElementsID):
3642 self.editor.MergeElements(GroupsOfElementsID)
3644 ## Leaves one element and removes all other elements built on the same nodes.
3645 # @ingroup l2_modif_trsf
3646 def MergeEqualElements(self):
3647 self.editor.MergeEqualElements()
3649 ## Sews free borders
3650 # @return SMESH::Sew_Error
3651 # @ingroup l2_modif_trsf
3652 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3653 FirstNodeID2, SecondNodeID2, LastNodeID2,
3654 CreatePolygons, CreatePolyedrs):
3655 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3656 FirstNodeID2, SecondNodeID2, LastNodeID2,
3657 CreatePolygons, CreatePolyedrs)
3659 ## Sews conform free borders
3660 # @return SMESH::Sew_Error
3661 # @ingroup l2_modif_trsf
3662 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3663 FirstNodeID2, SecondNodeID2):
3664 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3665 FirstNodeID2, SecondNodeID2)
3667 ## Sews border to side
3668 # @return SMESH::Sew_Error
3669 # @ingroup l2_modif_trsf
3670 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3671 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3672 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3673 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3675 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3676 # merged with the nodes of elements of Side2.
3677 # The number of elements in theSide1 and in theSide2 must be
3678 # equal and they should have similar nodal connectivity.
3679 # The nodes to merge should belong to side borders and
3680 # the first node should be linked to the second.
3681 # @return SMESH::Sew_Error
3682 # @ingroup l2_modif_trsf
3683 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3684 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3685 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3686 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3687 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3688 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3690 ## Sets new nodes for the given element.
3691 # @param ide the element id
3692 # @param newIDs nodes ids
3693 # @return If the number of nodes does not correspond to the type of element - returns false
3694 # @ingroup l2_modif_edit
3695 def ChangeElemNodes(self, ide, newIDs):
3696 return self.editor.ChangeElemNodes(ide, newIDs)
3698 ## If during the last operation of MeshEditor some nodes were
3699 # created, this method returns the list of their IDs, \n
3700 # if new nodes were not created - returns empty list
3701 # @return the list of integer values (can be empty)
3702 # @ingroup l1_auxiliary
3703 def GetLastCreatedNodes(self):
3704 return self.editor.GetLastCreatedNodes()
3706 ## If during the last operation of MeshEditor some elements were
3707 # created this method returns the list of their IDs, \n
3708 # if new elements were not created - returns empty list
3709 # @return the list of integer values (can be empty)
3710 # @ingroup l1_auxiliary
3711 def GetLastCreatedElems(self):
3712 return self.editor.GetLastCreatedElems()
3714 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3715 # @param theNodes identifiers of nodes to be doubled
3716 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
3717 # nodes. If list of element identifiers is empty then nodes are doubled but
3718 # they not assigned to elements
3719 # @return TRUE if operation has been completed successfully, FALSE otherwise
3720 # @ingroup l2_modif_edit
3721 def DoubleNodes(self, theNodes, theModifiedElems):
3722 return self.editor.DoubleNodes(theNodes, theModifiedElems)
3724 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3725 # This method provided for convenience works as DoubleNodes() described above.
3726 # @param theNodeId identifiers of node to be doubled
3727 # @param theModifiedElems identifiers of elements to be updated
3728 # @return TRUE if operation has been completed successfully, FALSE otherwise
3729 # @ingroup l2_modif_edit
3730 def DoubleNode(self, theNodeId, theModifiedElems):
3731 return self.editor.DoubleNode(theNodeId, theModifiedElems)
3733 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3734 # This method provided for convenience works as DoubleNodes() described above.
3735 # @param theNodes group of nodes to be doubled
3736 # @param theModifiedElems group of elements to be updated.
3737 # @param theMakeGroup forces the generation of a group containing new nodes.
3738 # @return TRUE or a created group if operation has been completed successfully,
3739 # FALSE or None otherwise
3740 # @ingroup l2_modif_edit
3741 def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
3743 return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
3744 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3746 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3747 # This method provided for convenience works as DoubleNodes() described above.
3748 # @param theNodes list of groups of nodes to be doubled
3749 # @param theModifiedElems list of groups of elements to be updated.
3750 # @return TRUE if operation has been completed successfully, FALSE otherwise
3751 # @ingroup l2_modif_edit
3752 def DoubleNodeGroups(self, theNodes, theModifiedElems):
3753 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3755 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3756 # @param theElems - the list of elements (edges or faces) to be replicated
3757 # The nodes for duplication could be found from these elements
3758 # @param theNodesNot - list of nodes to NOT replicate
3759 # @param theAffectedElems - the list of elements (cells and edges) to which the
3760 # replicated nodes should be associated to.
3761 # @return TRUE if operation has been completed successfully, FALSE otherwise
3762 # @ingroup l2_modif_edit
3763 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
3764 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
3766 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3767 # @param theElems - the list of elements (edges or faces) to be replicated
3768 # The nodes for duplication could be found from these elements
3769 # @param theNodesNot - list of nodes to NOT replicate
3770 # @param theShape - shape to detect affected elements (element which geometric center
3771 # located on or inside shape).
3772 # The replicated nodes should be associated to affected elements.
3773 # @return TRUE if operation has been completed successfully, FALSE otherwise
3774 # @ingroup l2_modif_edit
3775 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
3776 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
3778 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3779 # This method provided for convenience works as DoubleNodes() described above.
3780 # @param theElems - group of of elements (edges or faces) to be replicated
3781 # @param theNodesNot - group of nodes not to replicated
3782 # @param theAffectedElems - group of elements to which the replicated nodes
3783 # should be associated to.
3784 # @param theMakeGroup forces the generation of a group containing new elements.
3785 # @ingroup l2_modif_edit
3786 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
3788 return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
3789 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
3791 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3792 # This method provided for convenience works as DoubleNodes() described above.
3793 # @param theElems - group of of elements (edges or faces) to be replicated
3794 # @param theNodesNot - group of nodes not to replicated
3795 # @param theShape - shape to detect affected elements (element which geometric center
3796 # located on or inside shape).
3797 # The replicated nodes should be associated to affected elements.
3798 # @ingroup l2_modif_edit
3799 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
3800 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
3802 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3803 # This method provided for convenience works as DoubleNodes() described above.
3804 # @param theElems - list of groups of elements (edges or faces) to be replicated
3805 # @param theNodesNot - list of groups of nodes not to replicated
3806 # @param theAffectedElems - group of elements to which the replicated nodes
3807 # should be associated to.
3808 # @return TRUE if operation has been completed successfully, FALSE otherwise
3809 # @ingroup l2_modif_edit
3810 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems):
3811 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
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 - list of groups of elements (edges or faces) to be replicated
3816 # @param theNodesNot - list of groups of nodes not to replicated
3817 # @param theShape - shape to detect affected elements (element which geometric center
3818 # located on or inside shape).
3819 # The replicated nodes should be associated to affected elements.
3820 # @return TRUE if operation has been completed successfully, FALSE otherwise
3821 # @ingroup l2_modif_edit
3822 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
3823 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
3825 ## The mother class to define algorithm, it is not recommended to use it directly.
3828 # @ingroup l2_algorithms
3829 class Mesh_Algorithm:
3830 # @class Mesh_Algorithm
3831 # @brief Class Mesh_Algorithm
3833 #def __init__(self,smesh):
3841 ## Finds a hypothesis in the study by its type name and parameters.
3842 # Finds only the hypotheses created in smeshpyD engine.
3843 # @return SMESH.SMESH_Hypothesis
3844 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3845 study = smeshpyD.GetCurrentStudy()
3846 #to do: find component by smeshpyD object, not by its data type
3847 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3848 if scomp is not None:
3849 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3850 # Check if the root label of the hypotheses exists
3851 if res and hypRoot is not None:
3852 iter = study.NewChildIterator(hypRoot)
3853 # Check all published hypotheses
3855 hypo_so_i = iter.Value()
3856 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3857 if attr is not None:
3858 anIOR = attr.Value()
3859 hypo_o_i = salome.orb.string_to_object(anIOR)
3860 if hypo_o_i is not None:
3861 # Check if this is a hypothesis
3862 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3863 if hypo_i is not None:
3864 # Check if the hypothesis belongs to current engine
3865 if smeshpyD.GetObjectId(hypo_i) > 0:
3866 # Check if this is the required hypothesis
3867 if hypo_i.GetName() == hypname:
3869 if CompareMethod(hypo_i, args):
3883 ## Finds the algorithm in the study by its type name.
3884 # Finds only the algorithms, which have been created in smeshpyD engine.
3885 # @return SMESH.SMESH_Algo
3886 def FindAlgorithm (self, algoname, smeshpyD):
3887 study = smeshpyD.GetCurrentStudy()
3888 #to do: find component by smeshpyD object, not by its data type
3889 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3890 if scomp is not None:
3891 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3892 # Check if the root label of the algorithms exists
3893 if res and hypRoot is not None:
3894 iter = study.NewChildIterator(hypRoot)
3895 # Check all published algorithms
3897 algo_so_i = iter.Value()
3898 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3899 if attr is not None:
3900 anIOR = attr.Value()
3901 algo_o_i = salome.orb.string_to_object(anIOR)
3902 if algo_o_i is not None:
3903 # Check if this is an algorithm
3904 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3905 if algo_i is not None:
3906 # Checks if the algorithm belongs to the current engine
3907 if smeshpyD.GetObjectId(algo_i) > 0:
3908 # Check if this is the required algorithm
3909 if algo_i.GetName() == algoname:
3922 ## If the algorithm is global, returns 0; \n
3923 # else returns the submesh associated to this algorithm.
3924 def GetSubMesh(self):
3927 ## Returns the wrapped mesher.
3928 def GetAlgorithm(self):
3931 ## Gets the list of hypothesis that can be used with this algorithm
3932 def GetCompatibleHypothesis(self):
3935 mylist = self.algo.GetCompatibleHypothesis()
3938 ## Gets the name of the algorithm
3942 ## Sets the name to the algorithm
3943 def SetName(self, name):
3944 self.mesh.smeshpyD.SetName(self.algo, name)
3946 ## Gets the id of the algorithm
3948 return self.algo.GetId()
3951 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3953 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3954 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3956 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3958 self.Assign(algo, mesh, geom)
3962 def Assign(self, algo, mesh, geom):
3964 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3973 name = GetName(geom)
3976 name = mesh.geompyD.SubShapeName(geom, piece)
3977 mesh.geompyD.addToStudyInFather(piece, geom, name)
3979 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3982 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3983 TreatHypoStatus( status, algo.GetName(), name, True )
3985 def CompareHyp (self, hyp, args):
3986 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3989 def CompareEqualHyp (self, hyp, args):
3993 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3994 UseExisting=0, CompareMethod=""):
3997 if CompareMethod == "": CompareMethod = self.CompareHyp
3998 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
4001 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
4007 a = a + s + str(args[i])
4011 self.mesh.smeshpyD.SetName(hypo, hyp + a)
4013 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
4014 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
4017 ## Returns entry of the shape to mesh in the study
4018 def MainShapeEntry(self):
4020 if not self.mesh or not self.mesh.GetMesh(): return entry
4021 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
4022 study = self.mesh.smeshpyD.GetCurrentStudy()
4023 ior = salome.orb.object_to_string( self.mesh.GetShape() )
4024 sobj = study.FindObjectIOR(ior)
4025 if sobj: entry = sobj.GetID()
4026 if not entry: return ""
4029 # Public class: Mesh_Segment
4030 # --------------------------
4032 ## Class to define a segment 1D algorithm for discretization
4035 # @ingroup l3_algos_basic
4036 class Mesh_Segment(Mesh_Algorithm):
4038 ## Private constructor.
4039 def __init__(self, mesh, geom=0):
4040 Mesh_Algorithm.__init__(self)
4041 self.Create(mesh, geom, "Regular_1D")
4043 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
4044 # @param l for the length of segments that cut an edge
4045 # @param UseExisting if ==true - searches for an existing hypothesis created with
4046 # the same parameters, else (default) - creates a new one
4047 # @param p precision, used for calculation of the number of segments.
4048 # The precision should be a positive, meaningful value within the range [0,1].
4049 # In general, the number of segments is calculated with the formula:
4050 # nb = ceil((edge_length / l) - p)
4051 # Function ceil rounds its argument to the higher integer.
4052 # So, p=0 means rounding of (edge_length / l) to the higher integer,
4053 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
4054 # p=1 means rounding of (edge_length / l) to the lower integer.
4055 # Default value is 1e-07.
4056 # @return an instance of StdMeshers_LocalLength hypothesis
4057 # @ingroup l3_hypos_1dhyps
4058 def LocalLength(self, l, UseExisting=0, p=1e-07):
4059 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
4060 CompareMethod=self.CompareLocalLength)
4066 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
4067 def CompareLocalLength(self, hyp, args):
4068 if IsEqual(hyp.GetLength(), args[0]):
4069 return IsEqual(hyp.GetPrecision(), args[1])
4072 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
4073 # @param length is optional maximal allowed length of segment, if it is omitted
4074 # the preestimated length is used that depends on geometry size
4075 # @param UseExisting if ==true - searches for an existing hypothesis created with
4076 # the same parameters, else (default) - create a new one
4077 # @return an instance of StdMeshers_MaxLength hypothesis
4078 # @ingroup l3_hypos_1dhyps
4079 def MaxSize(self, length=0.0, UseExisting=0):
4080 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
4083 hyp.SetLength(length)
4085 # set preestimated length
4086 gen = self.mesh.smeshpyD
4087 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
4088 self.mesh.GetMesh(), self.mesh.GetShape(),
4090 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
4092 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
4095 hyp.SetUsePreestimatedLength( length == 0.0 )
4098 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
4099 # @param n for the number of segments that cut an edge
4100 # @param s for the scale factor (optional)
4101 # @param reversedEdges is a list of edges to mesh using reversed orientation
4102 # @param UseExisting if ==true - searches for an existing hypothesis created with
4103 # the same parameters, else (default) - create a new one
4104 # @return an instance of StdMeshers_NumberOfSegments hypothesis
4105 # @ingroup l3_hypos_1dhyps
4106 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4107 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4108 reversedEdges, UseExisting = [], reversedEdges
4109 entry = self.MainShapeEntry()
4111 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
4112 UseExisting=UseExisting,
4113 CompareMethod=self.CompareNumberOfSegments)
4115 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
4116 UseExisting=UseExisting,
4117 CompareMethod=self.CompareNumberOfSegments)
4118 hyp.SetDistrType( 1 )
4119 hyp.SetScaleFactor(s)
4120 hyp.SetNumberOfSegments(n)
4121 hyp.SetReversedEdges( reversedEdges )
4122 hyp.SetObjectEntry( entry )
4126 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4127 def CompareNumberOfSegments(self, hyp, args):
4128 if hyp.GetNumberOfSegments() == args[0]:
4130 if hyp.GetReversedEdges() == args[1]:
4131 if not args[1] or hyp.GetObjectEntry() == args[2]:
4134 if hyp.GetReversedEdges() == args[2]:
4135 if not args[2] or hyp.GetObjectEntry() == args[3]:
4136 if hyp.GetDistrType() == 1:
4137 if IsEqual(hyp.GetScaleFactor(), args[1]):
4141 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4142 # @param start defines the length of the first segment
4143 # @param end defines the length of the last segment
4144 # @param reversedEdges is a list of edges to mesh using reversed orientation
4145 # @param UseExisting if ==true - searches for an existing hypothesis created with
4146 # the same parameters, else (default) - creates a new one
4147 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4148 # @ingroup l3_hypos_1dhyps
4149 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4150 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4151 reversedEdges, UseExisting = [], reversedEdges
4152 entry = self.MainShapeEntry()
4153 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
4154 UseExisting=UseExisting,
4155 CompareMethod=self.CompareArithmetic1D)
4156 hyp.SetStartLength(start)
4157 hyp.SetEndLength(end)
4158 hyp.SetReversedEdges( reversedEdges )
4159 hyp.SetObjectEntry( entry )
4163 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4164 def CompareArithmetic1D(self, hyp, args):
4165 if IsEqual(hyp.GetLength(1), args[0]):
4166 if IsEqual(hyp.GetLength(0), args[1]):
4167 if hyp.GetReversedEdges() == args[2]:
4168 if not args[2] or hyp.GetObjectEntry() == args[3]:
4173 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4174 # on curve from 0 to 1 (additionally it is neecessary to check
4175 # orientation of edges and create list of reversed edges if it is
4176 # needed) and sets numbers of segments between given points (default
4177 # values are equals 1
4178 # @param points defines the list of parameters on curve
4179 # @param nbSegs defines the list of numbers of segments
4180 # @param reversedEdges is a list of edges to mesh using reversed orientation
4181 # @param UseExisting if ==true - searches for an existing hypothesis created with
4182 # the same parameters, else (default) - creates a new one
4183 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4184 # @ingroup l3_hypos_1dhyps
4185 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4186 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4187 reversedEdges, UseExisting = [], reversedEdges
4188 if reversedEdges and isinstance( reversedEdges[0], geompyDC.GEOM._objref_GEOM_Object ):
4189 for i in range( len( reversedEdges )):
4190 reversedEdges[i] = self.mesh.geompyD.GetSubShapeID(self.mesh.geom, reversedEdges[i] )
4191 entry = self.MainShapeEntry()
4192 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
4193 UseExisting=UseExisting,
4194 CompareMethod=self.CompareFixedPoints1D)
4195 hyp.SetPoints(points)
4196 hyp.SetNbSegments(nbSegs)
4197 hyp.SetReversedEdges(reversedEdges)
4198 hyp.SetObjectEntry(entry)
4202 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4203 ## as the given arguments
4204 def CompareFixedPoints1D(self, hyp, args):
4205 if hyp.GetPoints() == args[0]:
4206 if hyp.GetNbSegments() == args[1]:
4207 if hyp.GetReversedEdges() == args[2]:
4208 if not args[2] or hyp.GetObjectEntry() == args[3]:
4214 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4215 # @param start defines the length of the first segment
4216 # @param end defines the length of the last segment
4217 # @param reversedEdges is a list of edges to mesh using reversed orientation
4218 # @param UseExisting if ==true - searches for an existing hypothesis created with
4219 # the same parameters, else (default) - creates a new one
4220 # @return an instance of StdMeshers_StartEndLength hypothesis
4221 # @ingroup l3_hypos_1dhyps
4222 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4223 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4224 reversedEdges, UseExisting = [], reversedEdges
4225 entry = self.MainShapeEntry()
4226 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
4227 UseExisting=UseExisting,
4228 CompareMethod=self.CompareStartEndLength)
4229 hyp.SetStartLength(start)
4230 hyp.SetEndLength(end)
4231 hyp.SetReversedEdges( reversedEdges )
4232 hyp.SetObjectEntry( entry )
4235 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4236 def CompareStartEndLength(self, hyp, args):
4237 if IsEqual(hyp.GetLength(1), args[0]):
4238 if IsEqual(hyp.GetLength(0), args[1]):
4239 if hyp.GetReversedEdges() == args[2]:
4240 if not args[2] or hyp.GetObjectEntry() == args[3]:
4244 ## Defines "Deflection1D" hypothesis
4245 # @param d for the deflection
4246 # @param UseExisting if ==true - searches for an existing hypothesis created with
4247 # the same parameters, else (default) - create a new one
4248 # @ingroup l3_hypos_1dhyps
4249 def Deflection1D(self, d, UseExisting=0):
4250 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4251 CompareMethod=self.CompareDeflection1D)
4252 hyp.SetDeflection(d)
4255 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4256 def CompareDeflection1D(self, hyp, args):
4257 return IsEqual(hyp.GetDeflection(), args[0])
4259 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4260 # the opposite side in case of quadrangular faces
4261 # @ingroup l3_hypos_additi
4262 def Propagation(self):
4263 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4265 ## Defines "AutomaticLength" hypothesis
4266 # @param fineness for the fineness [0-1]
4267 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4268 # same parameters, else (default) - create a new one
4269 # @ingroup l3_hypos_1dhyps
4270 def AutomaticLength(self, fineness=0, UseExisting=0):
4271 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4272 CompareMethod=self.CompareAutomaticLength)
4273 hyp.SetFineness( fineness )
4276 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4277 def CompareAutomaticLength(self, hyp, args):
4278 return IsEqual(hyp.GetFineness(), args[0])
4280 ## Defines "SegmentLengthAroundVertex" hypothesis
4281 # @param length for the segment length
4282 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4283 # Any other integer value means that the hypothesis will be set on the
4284 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4285 # @param UseExisting if ==true - searches for an existing hypothesis created with
4286 # the same parameters, else (default) - creates a new one
4287 # @ingroup l3_algos_segmarv
4288 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4290 store_geom = self.geom
4291 if type(vertex) is types.IntType:
4292 if vertex == 0 or vertex == 1:
4293 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
4301 if self.geom is None:
4302 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4304 name = GetName(self.geom)
4307 piece = self.mesh.geom
4308 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
4309 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
4311 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4313 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4315 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4316 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4318 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4319 CompareMethod=self.CompareLengthNearVertex)
4320 self.geom = store_geom
4321 hyp.SetLength( length )
4324 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4325 # @ingroup l3_algos_segmarv
4326 def CompareLengthNearVertex(self, hyp, args):
4327 return IsEqual(hyp.GetLength(), args[0])
4329 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4330 # If the 2D mesher sees that all boundary edges are quadratic,
4331 # it generates quadratic faces, else it generates linear faces using
4332 # medium nodes as if they are vertices.
4333 # The 3D mesher generates quadratic volumes only if all boundary faces
4334 # are quadratic, else it fails.
4336 # @ingroup l3_hypos_additi
4337 def QuadraticMesh(self):
4338 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4341 # Public class: Mesh_CompositeSegment
4342 # --------------------------
4344 ## Defines a segment 1D algorithm for discretization
4346 # @ingroup l3_algos_basic
4347 class Mesh_CompositeSegment(Mesh_Segment):
4349 ## Private constructor.
4350 def __init__(self, mesh, geom=0):
4351 self.Create(mesh, geom, "CompositeSegment_1D")
4354 # Public class: Mesh_Segment_Python
4355 # ---------------------------------
4357 ## Defines a segment 1D algorithm for discretization with python function
4359 # @ingroup l3_algos_basic
4360 class Mesh_Segment_Python(Mesh_Segment):
4362 ## Private constructor.
4363 def __init__(self, mesh, geom=0):
4364 import Python1dPlugin
4365 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4367 ## Defines "PythonSplit1D" hypothesis
4368 # @param n for the number of segments that cut an edge
4369 # @param func for the python function that calculates the length of all segments
4370 # @param UseExisting if ==true - searches for the existing hypothesis created with
4371 # the same parameters, else (default) - creates a new one
4372 # @ingroup l3_hypos_1dhyps
4373 def PythonSplit1D(self, n, func, UseExisting=0):
4374 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4375 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4376 hyp.SetNumberOfSegments(n)
4377 hyp.SetPythonLog10RatioFunction(func)
4380 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4381 def ComparePythonSplit1D(self, hyp, args):
4382 #if hyp.GetNumberOfSegments() == args[0]:
4383 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4387 # Public class: Mesh_Triangle
4388 # ---------------------------
4390 ## Defines a triangle 2D algorithm
4392 # @ingroup l3_algos_basic
4393 class Mesh_Triangle(Mesh_Algorithm):
4402 ## Private constructor.
4403 def __init__(self, mesh, algoType, geom=0):
4404 Mesh_Algorithm.__init__(self)
4406 self.algoType = algoType
4407 if algoType == MEFISTO:
4408 self.Create(mesh, geom, "MEFISTO_2D")
4410 elif algoType == BLSURF:
4412 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4413 #self.SetPhysicalMesh() - PAL19680
4414 elif algoType == NETGEN:
4416 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4418 elif algoType == NETGEN_2D:
4420 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4423 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4424 # @param area for the maximum area of each triangle
4425 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4426 # same parameters, else (default) - creates a new one
4428 # Only for algoType == MEFISTO || NETGEN_2D
4429 # @ingroup l3_hypos_2dhyps
4430 def MaxElementArea(self, area, UseExisting=0):
4431 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4432 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4433 CompareMethod=self.CompareMaxElementArea)
4434 elif self.algoType == NETGEN:
4435 hyp = self.Parameters(SIMPLE)
4436 hyp.SetMaxElementArea(area)
4439 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4440 def CompareMaxElementArea(self, hyp, args):
4441 return IsEqual(hyp.GetMaxElementArea(), args[0])
4443 ## Defines "LengthFromEdges" hypothesis to build triangles
4444 # based on the length of the edges taken from the wire
4446 # Only for algoType == MEFISTO || NETGEN_2D
4447 # @ingroup l3_hypos_2dhyps
4448 def LengthFromEdges(self):
4449 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4450 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4452 elif self.algoType == NETGEN:
4453 hyp = self.Parameters(SIMPLE)
4454 hyp.LengthFromEdges()
4457 ## Sets a way to define size of mesh elements to generate.
4458 # @param thePhysicalMesh is: DefaultSize or Custom.
4459 # @ingroup l3_hypos_blsurf
4460 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4461 # Parameter of BLSURF algo
4462 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4464 ## Sets size of mesh elements to generate.
4465 # @ingroup l3_hypos_blsurf
4466 def SetPhySize(self, theVal):
4467 # Parameter of BLSURF algo
4468 self.SetPhysicalMesh(1) #Custom - else why to set the size?
4469 self.Parameters().SetPhySize(theVal)
4471 ## Sets lower boundary of mesh element size (PhySize).
4472 # @ingroup l3_hypos_blsurf
4473 def SetPhyMin(self, theVal=-1):
4474 # Parameter of BLSURF algo
4475 self.Parameters().SetPhyMin(theVal)
4477 ## Sets upper boundary of mesh element size (PhySize).
4478 # @ingroup l3_hypos_blsurf
4479 def SetPhyMax(self, theVal=-1):
4480 # Parameter of BLSURF algo
4481 self.Parameters().SetPhyMax(theVal)
4483 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4484 # @param theGeometricMesh is: 0 (None) or 1 (Custom)
4485 # @ingroup l3_hypos_blsurf
4486 def SetGeometricMesh(self, theGeometricMesh=0):
4487 # Parameter of BLSURF algo
4488 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4489 self.params.SetGeometricMesh(theGeometricMesh)
4491 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4492 # @ingroup l3_hypos_blsurf
4493 def SetAngleMeshS(self, theVal=_angleMeshS):
4494 # Parameter of BLSURF algo
4495 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4496 self.params.SetAngleMeshS(theVal)
4498 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4499 # @ingroup l3_hypos_blsurf
4500 def SetAngleMeshC(self, theVal=_angleMeshS):
4501 # Parameter of BLSURF algo
4502 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4503 self.params.SetAngleMeshC(theVal)
4505 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4506 # @ingroup l3_hypos_blsurf
4507 def SetGeoMin(self, theVal=-1):
4508 # Parameter of BLSURF algo
4509 self.Parameters().SetGeoMin(theVal)
4511 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4512 # @ingroup l3_hypos_blsurf
4513 def SetGeoMax(self, theVal=-1):
4514 # Parameter of BLSURF algo
4515 self.Parameters().SetGeoMax(theVal)
4517 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4518 # @ingroup l3_hypos_blsurf
4519 def SetGradation(self, theVal=_gradation):
4520 # Parameter of BLSURF algo
4521 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4522 self.params.SetGradation(theVal)
4524 ## Sets topology usage way.
4525 # @param way defines how mesh conformity is assured <ul>
4526 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4527 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4528 # @ingroup l3_hypos_blsurf
4529 def SetTopology(self, way):
4530 # Parameter of BLSURF algo
4531 self.Parameters().SetTopology(way)
4533 ## To respect geometrical edges or not.
4534 # @ingroup l3_hypos_blsurf
4535 def SetDecimesh(self, toIgnoreEdges=False):
4536 # Parameter of BLSURF algo
4537 self.Parameters().SetDecimesh(toIgnoreEdges)
4539 ## Sets verbosity level in the range 0 to 100.
4540 # @ingroup l3_hypos_blsurf
4541 def SetVerbosity(self, level):
4542 # Parameter of BLSURF algo
4543 self.Parameters().SetVerbosity(level)
4545 ## Sets advanced option value.
4546 # @ingroup l3_hypos_blsurf
4547 def SetOptionValue(self, optionName, level):
4548 # Parameter of BLSURF algo
4549 self.Parameters().SetOptionValue(optionName,level)
4551 ## Sets QuadAllowed flag.
4552 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
4553 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4554 def SetQuadAllowed(self, toAllow=True):
4555 if self.algoType == NETGEN_2D:
4556 if toAllow: # add QuadranglePreference
4557 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4558 else: # remove QuadranglePreference
4559 for hyp in self.mesh.GetHypothesisList( self.geom ):
4560 if hyp.GetName() == "QuadranglePreference":
4561 self.mesh.RemoveHypothesis( self.geom, hyp )
4566 if self.Parameters():
4567 self.params.SetQuadAllowed(toAllow)
4570 ## Defines hypothesis having several parameters
4572 # @ingroup l3_hypos_netgen
4573 def Parameters(self, which=SOLE):
4576 if self.algoType == NETGEN:
4578 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4579 "libNETGENEngine.so", UseExisting=0)
4581 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4582 "libNETGENEngine.so", UseExisting=0)
4584 elif self.algoType == MEFISTO:
4585 print "Mefisto algo support no multi-parameter hypothesis"
4587 elif self.algoType == NETGEN_2D:
4588 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4589 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4591 elif self.algoType == BLSURF:
4592 self.params = self.Hypothesis("BLSURF_Parameters", [],
4593 "libBLSURFEngine.so", UseExisting=0)
4596 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4601 # Only for algoType == NETGEN
4602 # @ingroup l3_hypos_netgen
4603 def SetMaxSize(self, theSize):
4604 if self.Parameters():
4605 self.params.SetMaxSize(theSize)
4607 ## Sets SecondOrder flag
4609 # Only for algoType == NETGEN
4610 # @ingroup l3_hypos_netgen
4611 def SetSecondOrder(self, theVal):
4612 if self.Parameters():
4613 self.params.SetSecondOrder(theVal)
4615 ## Sets Optimize flag
4617 # Only for algoType == NETGEN
4618 # @ingroup l3_hypos_netgen
4619 def SetOptimize(self, theVal):
4620 if self.Parameters():
4621 self.params.SetOptimize(theVal)
4624 # @param theFineness is:
4625 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4627 # Only for algoType == NETGEN
4628 # @ingroup l3_hypos_netgen
4629 def SetFineness(self, theFineness):
4630 if self.Parameters():
4631 self.params.SetFineness(theFineness)
4635 # Only for algoType == NETGEN
4636 # @ingroup l3_hypos_netgen
4637 def SetGrowthRate(self, theRate):
4638 if self.Parameters():
4639 self.params.SetGrowthRate(theRate)
4641 ## Sets NbSegPerEdge
4643 # Only for algoType == NETGEN
4644 # @ingroup l3_hypos_netgen
4645 def SetNbSegPerEdge(self, theVal):
4646 if self.Parameters():
4647 self.params.SetNbSegPerEdge(theVal)
4649 ## Sets NbSegPerRadius
4651 # Only for algoType == NETGEN
4652 # @ingroup l3_hypos_netgen
4653 def SetNbSegPerRadius(self, theVal):
4654 if self.Parameters():
4655 self.params.SetNbSegPerRadius(theVal)
4657 ## Sets number of segments overriding value set by SetLocalLength()
4659 # Only for algoType == NETGEN
4660 # @ingroup l3_hypos_netgen
4661 def SetNumberOfSegments(self, theVal):
4662 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4664 ## Sets number of segments overriding value set by SetNumberOfSegments()
4666 # Only for algoType == NETGEN
4667 # @ingroup l3_hypos_netgen
4668 def SetLocalLength(self, theVal):
4669 self.Parameters(SIMPLE).SetLocalLength(theVal)
4674 # Public class: Mesh_Quadrangle
4675 # -----------------------------
4677 ## Defines a quadrangle 2D algorithm
4679 # @ingroup l3_algos_basic
4680 class Mesh_Quadrangle(Mesh_Algorithm):
4682 ## Private constructor.
4683 def __init__(self, mesh, geom=0):
4684 Mesh_Algorithm.__init__(self)
4685 self.Create(mesh, geom, "Quadrangle_2D")
4687 ## Defines "QuadranglePreference" hypothesis, forcing construction
4688 # of quadrangles if the number of nodes on the opposite edges is not the same
4689 # while the total number of nodes on edges is even
4691 # @ingroup l3_hypos_additi
4692 def QuadranglePreference(self):
4693 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4694 CompareMethod=self.CompareEqualHyp)
4697 ## Defines "TrianglePreference" hypothesis, forcing construction
4698 # of triangles in the refinement area if the number of nodes
4699 # on the opposite edges is not the same
4701 # @ingroup l3_hypos_additi
4702 def TrianglePreference(self):
4703 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4704 CompareMethod=self.CompareEqualHyp)
4707 ## Defines "QuadrangleParams" hypothesis
4708 # @param vertex: vertex of a trilateral geometrical face, around which triangles
4709 # will be created while other elements will be quadrangles.
4710 # Vertex can be either a GEOM_Object or a vertex ID within the
4712 # @param UseExisting: if ==true - searches for the existing hypothesis created with
4713 # the same parameters, else (default) - creates a new one
4715 # @ingroup l3_hypos_additi
4716 def TriangleVertex(self, vertex, UseExisting=0):
4718 if isinstance( vertexID, geompyDC.GEOM._objref_GEOM_Object ):
4719 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, vertex )
4720 hyp = self.Hypothesis("QuadrangleParams", [vertexID], UseExisting = UseExisting,
4721 CompareMethod=lambda hyp,args: hyp.GetTriaVertex()==args[0])
4722 hyp.SetTriaVertex( vertexID )
4726 # Public class: Mesh_Tetrahedron
4727 # ------------------------------
4729 ## Defines a tetrahedron 3D algorithm
4731 # @ingroup l3_algos_basic
4732 class Mesh_Tetrahedron(Mesh_Algorithm):
4737 ## Private constructor.
4738 def __init__(self, mesh, algoType, geom=0):
4739 Mesh_Algorithm.__init__(self)
4741 if algoType == NETGEN:
4743 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4746 elif algoType == FULL_NETGEN:
4748 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4751 elif algoType == GHS3D:
4753 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4756 elif algoType == GHS3DPRL:
4757 CheckPlugin(GHS3DPRL)
4758 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4761 self.algoType = algoType
4763 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4764 # @param vol for the maximum volume of each tetrahedron
4765 # @param UseExisting if ==true - searches for the existing hypothesis created with
4766 # the same parameters, else (default) - creates a new one
4767 # @ingroup l3_hypos_maxvol
4768 def MaxElementVolume(self, vol, UseExisting=0):
4769 if self.algoType == NETGEN:
4770 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4771 CompareMethod=self.CompareMaxElementVolume)
4772 hyp.SetMaxElementVolume(vol)
4774 elif self.algoType == FULL_NETGEN:
4775 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4778 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4779 def CompareMaxElementVolume(self, hyp, args):
4780 return IsEqual(hyp.GetMaxElementVolume(), args[0])
4782 ## Defines hypothesis having several parameters
4784 # @ingroup l3_hypos_netgen
4785 def Parameters(self, which=SOLE):
4789 if self.algoType == FULL_NETGEN:
4791 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4792 "libNETGENEngine.so", UseExisting=0)
4794 self.params = self.Hypothesis("NETGEN_Parameters", [],
4795 "libNETGENEngine.so", UseExisting=0)
4798 if self.algoType == GHS3D:
4799 self.params = self.Hypothesis("GHS3D_Parameters", [],
4800 "libGHS3DEngine.so", UseExisting=0)
4803 if self.algoType == GHS3DPRL:
4804 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4805 "libGHS3DPRLEngine.so", UseExisting=0)
4808 print "Algo supports no multi-parameter hypothesis"
4812 # Parameter of FULL_NETGEN
4813 # @ingroup l3_hypos_netgen
4814 def SetMaxSize(self, theSize):
4815 self.Parameters().SetMaxSize(theSize)
4817 ## Sets SecondOrder flag
4818 # Parameter of FULL_NETGEN
4819 # @ingroup l3_hypos_netgen
4820 def SetSecondOrder(self, theVal):
4821 self.Parameters().SetSecondOrder(theVal)
4823 ## Sets Optimize flag
4824 # Parameter of FULL_NETGEN
4825 # @ingroup l3_hypos_netgen
4826 def SetOptimize(self, theVal):
4827 self.Parameters().SetOptimize(theVal)
4830 # @param theFineness is:
4831 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4832 # Parameter of FULL_NETGEN
4833 # @ingroup l3_hypos_netgen
4834 def SetFineness(self, theFineness):
4835 self.Parameters().SetFineness(theFineness)
4838 # Parameter of FULL_NETGEN
4839 # @ingroup l3_hypos_netgen
4840 def SetGrowthRate(self, theRate):
4841 self.Parameters().SetGrowthRate(theRate)
4843 ## Sets NbSegPerEdge
4844 # Parameter of FULL_NETGEN
4845 # @ingroup l3_hypos_netgen
4846 def SetNbSegPerEdge(self, theVal):
4847 self.Parameters().SetNbSegPerEdge(theVal)
4849 ## Sets NbSegPerRadius
4850 # Parameter of FULL_NETGEN
4851 # @ingroup l3_hypos_netgen
4852 def SetNbSegPerRadius(self, theVal):
4853 self.Parameters().SetNbSegPerRadius(theVal)
4855 ## Sets number of segments overriding value set by SetLocalLength()
4856 # Only for algoType == NETGEN_FULL
4857 # @ingroup l3_hypos_netgen
4858 def SetNumberOfSegments(self, theVal):
4859 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4861 ## Sets number of segments overriding value set by SetNumberOfSegments()
4862 # Only for algoType == NETGEN_FULL
4863 # @ingroup l3_hypos_netgen
4864 def SetLocalLength(self, theVal):
4865 self.Parameters(SIMPLE).SetLocalLength(theVal)
4867 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4868 # Overrides value set by LengthFromEdges()
4869 # Only for algoType == NETGEN_FULL
4870 # @ingroup l3_hypos_netgen
4871 def MaxElementArea(self, area):
4872 self.Parameters(SIMPLE).SetMaxElementArea(area)
4874 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4875 # Overrides value set by MaxElementArea()
4876 # Only for algoType == NETGEN_FULL
4877 # @ingroup l3_hypos_netgen
4878 def LengthFromEdges(self):
4879 self.Parameters(SIMPLE).LengthFromEdges()
4881 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4882 # Overrides value set by MaxElementVolume()
4883 # Only for algoType == NETGEN_FULL
4884 # @ingroup l3_hypos_netgen
4885 def LengthFromFaces(self):
4886 self.Parameters(SIMPLE).LengthFromFaces()
4888 ## To mesh "holes" in a solid or not. Default is to mesh.
4889 # @ingroup l3_hypos_ghs3dh
4890 def SetToMeshHoles(self, toMesh):
4891 # Parameter of GHS3D
4892 self.Parameters().SetToMeshHoles(toMesh)
4894 ## Set Optimization level:
4895 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
4896 # Strong_Optimization.
4897 # Default is Standard_Optimization
4898 # @ingroup l3_hypos_ghs3dh
4899 def SetOptimizationLevel(self, level):
4900 # Parameter of GHS3D
4901 self.Parameters().SetOptimizationLevel(level)
4903 ## Maximal size of memory to be used by the algorithm (in Megabytes).
4904 # @ingroup l3_hypos_ghs3dh
4905 def SetMaximumMemory(self, MB):
4906 # Advanced parameter of GHS3D
4907 self.Parameters().SetMaximumMemory(MB)
4909 ## Initial size of memory to be used by the algorithm (in Megabytes) in
4910 # automatic memory adjustment mode.
4911 # @ingroup l3_hypos_ghs3dh
4912 def SetInitialMemory(self, MB):
4913 # Advanced parameter of GHS3D
4914 self.Parameters().SetInitialMemory(MB)
4916 ## Path to working directory.
4917 # @ingroup l3_hypos_ghs3dh
4918 def SetWorkingDirectory(self, path):
4919 # Advanced parameter of GHS3D
4920 self.Parameters().SetWorkingDirectory(path)
4922 ## To keep working files or remove them. Log file remains in case of errors anyway.
4923 # @ingroup l3_hypos_ghs3dh
4924 def SetKeepFiles(self, toKeep):
4925 # Advanced parameter of GHS3D and GHS3DPRL
4926 self.Parameters().SetKeepFiles(toKeep)
4928 ## To set verbose level [0-10]. <ul>
4929 #<li> 0 - no standard output,
4930 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4931 # indicates when the final mesh is being saved. In addition the software
4932 # gives indication regarding the CPU time.
4933 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4934 # histogram of the skin mesh, quality statistics histogram together with
4935 # the characteristics of the final mesh.</ul>
4936 # @ingroup l3_hypos_ghs3dh
4937 def SetVerboseLevel(self, level):
4938 # Advanced parameter of GHS3D
4939 self.Parameters().SetVerboseLevel(level)
4941 ## To create new nodes.
4942 # @ingroup l3_hypos_ghs3dh
4943 def SetToCreateNewNodes(self, toCreate):
4944 # Advanced parameter of GHS3D
4945 self.Parameters().SetToCreateNewNodes(toCreate)
4947 ## To use boundary recovery version which tries to create mesh on a very poor
4948 # quality surface mesh.
4949 # @ingroup l3_hypos_ghs3dh
4950 def SetToUseBoundaryRecoveryVersion(self, toUse):
4951 # Advanced parameter of GHS3D
4952 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4954 ## Sets command line option as text.
4955 # @ingroup l3_hypos_ghs3dh
4956 def SetTextOption(self, option):
4957 # Advanced parameter of GHS3D
4958 self.Parameters().SetTextOption(option)
4960 ## Sets MED files name and path.
4961 def SetMEDName(self, value):
4962 self.Parameters().SetMEDName(value)
4964 ## Sets the number of partition of the initial mesh
4965 def SetNbPart(self, value):
4966 self.Parameters().SetNbPart(value)
4968 ## When big mesh, start tepal in background
4969 def SetBackground(self, value):
4970 self.Parameters().SetBackground(value)
4972 # Public class: Mesh_Hexahedron
4973 # ------------------------------
4975 ## Defines a hexahedron 3D algorithm
4977 # @ingroup l3_algos_basic
4978 class Mesh_Hexahedron(Mesh_Algorithm):
4983 ## Private constructor.
4984 def __init__(self, mesh, algoType=Hexa, geom=0):
4985 Mesh_Algorithm.__init__(self)
4987 self.algoType = algoType
4989 if algoType == Hexa:
4990 self.Create(mesh, geom, "Hexa_3D")
4993 elif algoType == Hexotic:
4994 CheckPlugin(Hexotic)
4995 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
4998 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
4999 # @ingroup l3_hypos_hexotic
5000 def MinMaxQuad(self, min=3, max=8, quad=True):
5001 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
5003 self.params.SetHexesMinLevel(min)
5004 self.params.SetHexesMaxLevel(max)
5005 self.params.SetHexoticQuadrangles(quad)
5008 # Deprecated, only for compatibility!
5009 # Public class: Mesh_Netgen
5010 # ------------------------------
5012 ## Defines a NETGEN-based 2D or 3D algorithm
5013 # that needs no discrete boundary (i.e. independent)
5015 # This class is deprecated, only for compatibility!
5018 # @ingroup l3_algos_basic
5019 class Mesh_Netgen(Mesh_Algorithm):
5023 ## Private constructor.
5024 def __init__(self, mesh, is3D, geom=0):
5025 Mesh_Algorithm.__init__(self)
5031 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5035 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
5038 ## Defines the hypothesis containing parameters of the algorithm
5039 def Parameters(self):
5041 hyp = self.Hypothesis("NETGEN_Parameters", [],
5042 "libNETGENEngine.so", UseExisting=0)
5044 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
5045 "libNETGENEngine.so", UseExisting=0)
5048 # Public class: Mesh_Projection1D
5049 # ------------------------------
5051 ## Defines a projection 1D algorithm
5052 # @ingroup l3_algos_proj
5054 class Mesh_Projection1D(Mesh_Algorithm):
5056 ## Private constructor.
5057 def __init__(self, mesh, geom=0):
5058 Mesh_Algorithm.__init__(self)
5059 self.Create(mesh, geom, "Projection_1D")
5061 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
5062 # a mesh pattern is taken, and, optionally, the association of vertices
5063 # between the source edge and a target edge (to which a hypothesis is assigned)
5064 # @param edge from which nodes distribution is taken
5065 # @param mesh from which nodes distribution is taken (optional)
5066 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
5067 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
5068 # to associate with \a srcV (optional)
5069 # @param UseExisting if ==true - searches for the existing hypothesis created with
5070 # the same parameters, else (default) - creates a new one
5071 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
5072 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
5074 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
5075 hyp.SetSourceEdge( edge )
5076 if not mesh is None and isinstance(mesh, Mesh):
5077 mesh = mesh.GetMesh()
5078 hyp.SetSourceMesh( mesh )
5079 hyp.SetVertexAssociation( srcV, tgtV )
5082 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
5083 #def CompareSourceEdge(self, hyp, args):
5084 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
5088 # Public class: Mesh_Projection2D
5089 # ------------------------------
5091 ## Defines a projection 2D algorithm
5092 # @ingroup l3_algos_proj
5094 class Mesh_Projection2D(Mesh_Algorithm):
5096 ## Private constructor.
5097 def __init__(self, mesh, geom=0):
5098 Mesh_Algorithm.__init__(self)
5099 self.Create(mesh, geom, "Projection_2D")
5101 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
5102 # a mesh pattern is taken, and, optionally, the association of vertices
5103 # between the source face and the target face (to which a hypothesis is assigned)
5104 # @param face from which the mesh pattern is taken
5105 # @param mesh from which the mesh pattern is taken (optional)
5106 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
5107 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
5108 # to associate with \a srcV1 (optional)
5109 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
5110 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
5111 # to associate with \a srcV2 (optional)
5112 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
5113 # the same parameters, else (default) - forces the creation a new one
5115 # Note: all association vertices must belong to one edge of a face
5116 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
5117 srcV2=None, tgtV2=None, UseExisting=0):
5118 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
5120 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
5121 hyp.SetSourceFace( face )
5122 if not mesh is None and isinstance(mesh, Mesh):
5123 mesh = mesh.GetMesh()
5124 hyp.SetSourceMesh( mesh )
5125 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5128 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
5129 #def CompareSourceFace(self, hyp, args):
5130 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
5133 # Public class: Mesh_Projection3D
5134 # ------------------------------
5136 ## Defines a projection 3D algorithm
5137 # @ingroup l3_algos_proj
5139 class Mesh_Projection3D(Mesh_Algorithm):
5141 ## Private constructor.
5142 def __init__(self, mesh, geom=0):
5143 Mesh_Algorithm.__init__(self)
5144 self.Create(mesh, geom, "Projection_3D")
5146 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
5147 # the mesh pattern is taken, and, optionally, the association of vertices
5148 # between the source and the target solid (to which a hipothesis is assigned)
5149 # @param solid from where the mesh pattern is taken
5150 # @param mesh from where the mesh pattern is taken (optional)
5151 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
5152 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
5153 # to associate with \a srcV1 (optional)
5154 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
5155 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
5156 # to associate with \a srcV2 (optional)
5157 # @param UseExisting - if ==true - searches for the existing hypothesis created with
5158 # the same parameters, else (default) - creates a new one
5160 # Note: association vertices must belong to one edge of a solid
5161 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
5162 srcV2=0, tgtV2=0, UseExisting=0):
5163 hyp = self.Hypothesis("ProjectionSource3D",
5164 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
5166 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
5167 hyp.SetSource3DShape( solid )
5168 if not mesh is None and isinstance(mesh, Mesh):
5169 mesh = mesh.GetMesh()
5170 hyp.SetSourceMesh( mesh )
5171 if srcV1 and srcV2 and tgtV1 and tgtV2:
5172 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5173 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
5176 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
5177 #def CompareSourceShape3D(self, hyp, args):
5178 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
5182 # Public class: Mesh_Prism
5183 # ------------------------
5185 ## Defines a 3D extrusion algorithm
5186 # @ingroup l3_algos_3dextr
5188 class Mesh_Prism3D(Mesh_Algorithm):
5190 ## Private constructor.
5191 def __init__(self, mesh, geom=0):
5192 Mesh_Algorithm.__init__(self)
5193 self.Create(mesh, geom, "Prism_3D")
5195 # Public class: Mesh_RadialPrism
5196 # -------------------------------
5198 ## Defines a Radial Prism 3D algorithm
5199 # @ingroup l3_algos_radialp
5201 class Mesh_RadialPrism3D(Mesh_Algorithm):
5203 ## Private constructor.
5204 def __init__(self, mesh, geom=0):
5205 Mesh_Algorithm.__init__(self)
5206 self.Create(mesh, geom, "RadialPrism_3D")
5208 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
5209 self.nbLayers = None
5211 ## Return 3D hypothesis holding the 1D one
5212 def Get3DHypothesis(self):
5213 return self.distribHyp
5215 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5216 # hypothesis. Returns the created hypothesis
5217 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5218 #print "OwnHypothesis",hypType
5219 if not self.nbLayers is None:
5220 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5221 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5222 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5223 self.mesh.smeshpyD.SetCurrentStudy( None )
5224 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5225 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5226 self.distribHyp.SetLayerDistribution( hyp )
5229 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
5230 # prisms to build between the inner and outer shells
5231 # @param n number of layers
5232 # @param UseExisting if ==true - searches for the existing hypothesis created with
5233 # the same parameters, else (default) - creates a new one
5234 def NumberOfLayers(self, n, UseExisting=0):
5235 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5236 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
5237 CompareMethod=self.CompareNumberOfLayers)
5238 self.nbLayers.SetNumberOfLayers( n )
5239 return self.nbLayers
5241 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5242 def CompareNumberOfLayers(self, hyp, args):
5243 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5245 ## Defines "LocalLength" hypothesis, specifying the segment length
5246 # to build between the inner and the outer shells
5247 # @param l the length of segments
5248 # @param p the precision of rounding
5249 def LocalLength(self, l, p=1e-07):
5250 hyp = self.OwnHypothesis("LocalLength", [l,p])
5255 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
5256 # prisms to build between the inner and the outer shells.
5257 # @param n the number of layers
5258 # @param s the scale factor (optional)
5259 def NumberOfSegments(self, n, s=[]):
5261 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5263 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5264 hyp.SetDistrType( 1 )
5265 hyp.SetScaleFactor(s)
5266 hyp.SetNumberOfSegments(n)
5269 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5270 # to build between the inner and the outer shells with a length that changes in arithmetic progression
5271 # @param start the length of the first segment
5272 # @param end the length of the last segment
5273 def Arithmetic1D(self, start, end ):
5274 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5275 hyp.SetLength(start, 1)
5276 hyp.SetLength(end , 0)
5279 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5280 # to build between the inner and the outer shells as geometric length increasing
5281 # @param start for the length of the first segment
5282 # @param end for the length of the last segment
5283 def StartEndLength(self, start, end):
5284 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5285 hyp.SetLength(start, 1)
5286 hyp.SetLength(end , 0)
5289 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5290 # to build between the inner and outer shells
5291 # @param fineness defines the quality of the mesh within the range [0-1]
5292 def AutomaticLength(self, fineness=0):
5293 hyp = self.OwnHypothesis("AutomaticLength")
5294 hyp.SetFineness( fineness )
5297 # Public class: Mesh_RadialQuadrangle1D2D
5298 # -------------------------------
5300 ## Defines a Radial Quadrangle 1D2D algorithm
5301 # @ingroup l2_algos_radialq
5303 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
5305 ## Private constructor.
5306 def __init__(self, mesh, geom=0):
5307 Mesh_Algorithm.__init__(self)
5308 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5310 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
5311 self.nbLayers = None
5313 ## Return 2D hypothesis holding the 1D one
5314 def Get2DHypothesis(self):
5315 return self.distribHyp
5317 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5318 # hypothesis. Returns the created hypothesis
5319 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5320 #print "OwnHypothesis",hypType
5322 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5323 if self.distribHyp is None:
5324 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5326 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5327 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5328 self.mesh.smeshpyD.SetCurrentStudy( None )
5329 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5330 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5331 self.distribHyp.SetLayerDistribution( hyp )
5334 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
5335 # @param n number of layers
5336 # @param UseExisting if ==true - searches for the existing hypothesis created with
5337 # the same parameters, else (default) - creates a new one
5338 def NumberOfLayers(self, n, UseExisting=0):
5340 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5341 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5342 CompareMethod=self.CompareNumberOfLayers)
5343 self.nbLayers.SetNumberOfLayers( n )
5344 return self.nbLayers
5346 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5347 def CompareNumberOfLayers(self, hyp, args):
5348 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5350 ## Defines "LocalLength" hypothesis, specifying the segment length
5351 # @param l the length of segments
5352 # @param p the precision of rounding
5353 def LocalLength(self, l, p=1e-07):
5354 hyp = self.OwnHypothesis("LocalLength", [l,p])
5359 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5360 # @param n the number of layers
5361 # @param s the scale factor (optional)
5362 def NumberOfSegments(self, n, s=[]):
5364 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5366 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5367 hyp.SetDistrType( 1 )
5368 hyp.SetScaleFactor(s)
5369 hyp.SetNumberOfSegments(n)
5372 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5373 # with a length that changes in arithmetic progression
5374 # @param start the length of the first segment
5375 # @param end the length of the last segment
5376 def Arithmetic1D(self, start, end ):
5377 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5378 hyp.SetLength(start, 1)
5379 hyp.SetLength(end , 0)
5382 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5383 # as geometric length increasing
5384 # @param start for the length of the first segment
5385 # @param end for the length of the last segment
5386 def StartEndLength(self, start, end):
5387 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5388 hyp.SetLength(start, 1)
5389 hyp.SetLength(end , 0)
5392 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5393 # @param fineness defines the quality of the mesh within the range [0-1]
5394 def AutomaticLength(self, fineness=0):
5395 hyp = self.OwnHypothesis("AutomaticLength")
5396 hyp.SetFineness( fineness )
5400 # Private class: Mesh_UseExisting
5401 # -------------------------------
5402 class Mesh_UseExisting(Mesh_Algorithm):
5404 def __init__(self, dim, mesh, geom=0):
5406 self.Create(mesh, geom, "UseExisting_1D")
5408 self.Create(mesh, geom, "UseExisting_2D")
5411 import salome_notebook
5412 notebook = salome_notebook.notebook
5414 ##Return values of the notebook variables
5415 def ParseParameters(last, nbParams,nbParam, value):
5419 listSize = len(last)
5420 for n in range(0,nbParams):
5422 if counter < listSize:
5423 strResult = strResult + last[counter]
5425 strResult = strResult + ""
5427 if isinstance(value, str):
5428 if notebook.isVariable(value):
5429 result = notebook.get(value)
5430 strResult=strResult+value
5432 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
5434 strResult=strResult+str(value)
5436 if nbParams - 1 != counter:
5437 strResult=strResult+var_separator #":"
5439 return result, strResult
5441 #Wrapper class for StdMeshers_LocalLength hypothesis
5442 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5444 ## Set Length parameter value
5445 # @param length numerical value or name of variable from notebook
5446 def SetLength(self, length):
5447 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
5448 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5449 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
5451 ## Set Precision parameter value
5452 # @param precision numerical value or name of variable from notebook
5453 def SetPrecision(self, precision):
5454 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
5455 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5456 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5458 #Registering the new proxy for LocalLength
5459 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5462 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5463 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5465 def SetLayerDistribution(self, hypo):
5466 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
5467 hypo.ClearParameters();
5468 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5470 #Registering the new proxy for LayerDistribution
5471 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5473 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5474 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5476 ## Set Length parameter value
5477 # @param length numerical value or name of variable from notebook
5478 def SetLength(self, length):
5479 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
5480 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
5481 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5483 #Registering the new proxy for SegmentLengthAroundVertex
5484 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5487 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5488 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5490 ## Set Length parameter value
5491 # @param length numerical value or name of variable from notebook
5492 # @param isStart true is length is Start Length, otherwise false
5493 def SetLength(self, length, isStart):
5497 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
5498 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
5499 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
5501 #Registering the new proxy for Arithmetic1D
5502 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
5504 #Wrapper class for StdMeshers_Deflection1D hypothesis
5505 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
5507 ## Set Deflection parameter value
5508 # @param deflection numerical value or name of variable from notebook
5509 def SetDeflection(self, deflection):
5510 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
5511 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
5512 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
5514 #Registering the new proxy for Deflection1D
5515 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
5517 #Wrapper class for StdMeshers_StartEndLength hypothesis
5518 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
5520 ## Set Length parameter value
5521 # @param length numerical value or name of variable from notebook
5522 # @param isStart true is length is Start Length, otherwise false
5523 def SetLength(self, length, isStart):
5527 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
5528 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
5529 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
5531 #Registering the new proxy for StartEndLength
5532 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
5534 #Wrapper class for StdMeshers_MaxElementArea hypothesis
5535 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
5537 ## Set Max Element Area parameter value
5538 # @param area numerical value or name of variable from notebook
5539 def SetMaxElementArea(self, area):
5540 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
5541 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
5542 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
5544 #Registering the new proxy for MaxElementArea
5545 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
5548 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
5549 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
5551 ## Set Max Element Volume parameter value
5552 # @param volume numerical value or name of variable from notebook
5553 def SetMaxElementVolume(self, volume):
5554 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
5555 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
5556 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
5558 #Registering the new proxy for MaxElementVolume
5559 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
5562 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
5563 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
5565 ## Set Number Of Layers parameter value
5566 # @param nbLayers numerical value or name of variable from notebook
5567 def SetNumberOfLayers(self, nbLayers):
5568 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
5569 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
5570 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
5572 #Registering the new proxy for NumberOfLayers
5573 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
5575 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
5576 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
5578 ## Set Number Of Segments parameter value
5579 # @param nbSeg numerical value or name of variable from notebook
5580 def SetNumberOfSegments(self, nbSeg):
5581 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
5582 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
5583 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5584 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
5586 ## Set Scale Factor parameter value
5587 # @param factor numerical value or name of variable from notebook
5588 def SetScaleFactor(self, factor):
5589 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
5590 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5591 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
5593 #Registering the new proxy for NumberOfSegments
5594 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
5596 if not noNETGENPlugin:
5597 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
5598 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
5600 ## Set Max Size parameter value
5601 # @param maxsize numerical value or name of variable from notebook
5602 def SetMaxSize(self, maxsize):
5603 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5604 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
5605 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5606 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
5608 ## Set Growth Rate parameter value
5609 # @param value numerical value or name of variable from notebook
5610 def SetGrowthRate(self, value):
5611 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5612 value, parameters = ParseParameters(lastParameters,4,2,value)
5613 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5614 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
5616 ## Set Number of Segments per Edge parameter value
5617 # @param value numerical value or name of variable from notebook
5618 def SetNbSegPerEdge(self, value):
5619 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5620 value, parameters = ParseParameters(lastParameters,4,3,value)
5621 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5622 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
5624 ## Set Number of Segments per Radius parameter value
5625 # @param value numerical value or name of variable from notebook
5626 def SetNbSegPerRadius(self, value):
5627 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5628 value, parameters = ParseParameters(lastParameters,4,4,value)
5629 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5630 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
5632 #Registering the new proxy for NETGENPlugin_Hypothesis
5633 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5636 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5637 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5640 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5641 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5643 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5644 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5646 ## Set Number of Segments parameter value
5647 # @param nbSeg numerical value or name of variable from notebook
5648 def SetNumberOfSegments(self, nbSeg):
5649 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5650 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5651 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5652 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5654 ## Set Local Length parameter value
5655 # @param length numerical value or name of variable from notebook
5656 def SetLocalLength(self, length):
5657 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5658 length, parameters = ParseParameters(lastParameters,2,1,length)
5659 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5660 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
5662 ## Set Max Element Area parameter value
5663 # @param area numerical value or name of variable from notebook
5664 def SetMaxElementArea(self, area):
5665 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5666 area, parameters = ParseParameters(lastParameters,2,2,area)
5667 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5668 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
5670 def LengthFromEdges(self):
5671 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5673 value, parameters = ParseParameters(lastParameters,2,2,value)
5674 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5675 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
5677 #Registering the new proxy for NETGEN_SimpleParameters_2D
5678 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
5681 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
5682 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
5683 ## Set Max Element Volume parameter value
5684 # @param volume numerical value or name of variable from notebook
5685 def SetMaxElementVolume(self, volume):
5686 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5687 volume, parameters = ParseParameters(lastParameters,3,3,volume)
5688 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5689 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5691 def LengthFromFaces(self):
5692 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5694 value, parameters = ParseParameters(lastParameters,3,3,value)
5695 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5696 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5698 #Registering the new proxy for NETGEN_SimpleParameters_3D
5699 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5701 pass # if not noNETGENPlugin:
5703 class Pattern(SMESH._objref_SMESH_Pattern):
5705 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5707 if isinstance(theNodeIndexOnKeyPoint1,str):
5709 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5711 theNodeIndexOnKeyPoint1 -= 1
5712 theMesh.SetParameters(Parameters)
5713 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5715 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5718 if isinstance(theNode000Index,str):
5720 if isinstance(theNode001Index,str):
5722 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5724 theNode000Index -= 1
5726 theNode001Index -= 1
5727 theMesh.SetParameters(Parameters)
5728 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5730 #Registering the new proxy for Pattern
5731 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)