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 elements = self.editor.MakeIDSource(elements, SMESH.ALL)
2819 return self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName,
2820 toCopyElements,toCopyExistingBondary)
2822 ## Renumber mesh nodes
2823 # @ingroup l2_modif_renumber
2824 def RenumberNodes(self):
2825 self.editor.RenumberNodes()
2827 ## Renumber mesh elements
2828 # @ingroup l2_modif_renumber
2829 def RenumberElements(self):
2830 self.editor.RenumberElements()
2832 ## Generates new elements by rotation of the elements around the axis
2833 # @param IDsOfElements the list of ids of elements to sweep
2834 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2835 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2836 # @param NbOfSteps the number of steps
2837 # @param Tolerance tolerance
2838 # @param MakeGroups forces the generation of new groups from existing ones
2839 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2840 # of all steps, else - size of each step
2841 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2842 # @ingroup l2_modif_extrurev
2843 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2844 MakeGroups=False, TotalAngle=False):
2846 if isinstance(AngleInRadians,str):
2848 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2850 AngleInRadians = DegreesToRadians(AngleInRadians)
2851 if IDsOfElements == []:
2852 IDsOfElements = self.GetElementsId()
2853 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2854 Axis = self.smeshpyD.GetAxisStruct(Axis)
2855 Axis,AxisParameters = ParseAxisStruct(Axis)
2856 if TotalAngle and NbOfSteps:
2857 AngleInRadians /= NbOfSteps
2858 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2859 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2860 self.mesh.SetParameters(Parameters)
2862 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2863 AngleInRadians, NbOfSteps, Tolerance)
2864 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2867 ## Generates new elements by rotation of the elements of object around the axis
2868 # @param theObject object which elements should be sweeped
2869 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2870 # @param AngleInRadians the angle of Rotation
2871 # @param NbOfSteps number of steps
2872 # @param Tolerance tolerance
2873 # @param MakeGroups forces the generation of new groups from existing ones
2874 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2875 # of all steps, else - size of each step
2876 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2877 # @ingroup l2_modif_extrurev
2878 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2879 MakeGroups=False, TotalAngle=False):
2881 if isinstance(AngleInRadians,str):
2883 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2885 AngleInRadians = DegreesToRadians(AngleInRadians)
2886 if ( isinstance( theObject, Mesh )):
2887 theObject = theObject.GetMesh()
2888 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2889 Axis = self.smeshpyD.GetAxisStruct(Axis)
2890 Axis,AxisParameters = ParseAxisStruct(Axis)
2891 if TotalAngle and NbOfSteps:
2892 AngleInRadians /= NbOfSteps
2893 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2894 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2895 self.mesh.SetParameters(Parameters)
2897 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2898 NbOfSteps, Tolerance)
2899 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2902 ## Generates new elements by rotation of the elements of object around the axis
2903 # @param theObject object which elements should be sweeped
2904 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2905 # @param AngleInRadians the angle of Rotation
2906 # @param NbOfSteps number of steps
2907 # @param Tolerance tolerance
2908 # @param MakeGroups forces the generation of new groups from existing ones
2909 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2910 # of all steps, else - size of each step
2911 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2912 # @ingroup l2_modif_extrurev
2913 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2914 MakeGroups=False, TotalAngle=False):
2916 if isinstance(AngleInRadians,str):
2918 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2920 AngleInRadians = DegreesToRadians(AngleInRadians)
2921 if ( isinstance( theObject, Mesh )):
2922 theObject = theObject.GetMesh()
2923 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2924 Axis = self.smeshpyD.GetAxisStruct(Axis)
2925 Axis,AxisParameters = ParseAxisStruct(Axis)
2926 if TotalAngle and NbOfSteps:
2927 AngleInRadians /= NbOfSteps
2928 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2929 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2930 self.mesh.SetParameters(Parameters)
2932 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2933 NbOfSteps, Tolerance)
2934 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2937 ## Generates new elements by rotation of the elements of object around the axis
2938 # @param theObject object which elements should be sweeped
2939 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2940 # @param AngleInRadians the angle of Rotation
2941 # @param NbOfSteps number of steps
2942 # @param Tolerance tolerance
2943 # @param MakeGroups forces the generation of new groups from existing ones
2944 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2945 # of all steps, else - size of each step
2946 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2947 # @ingroup l2_modif_extrurev
2948 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2949 MakeGroups=False, TotalAngle=False):
2951 if isinstance(AngleInRadians,str):
2953 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2955 AngleInRadians = DegreesToRadians(AngleInRadians)
2956 if ( isinstance( theObject, Mesh )):
2957 theObject = theObject.GetMesh()
2958 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2959 Axis = self.smeshpyD.GetAxisStruct(Axis)
2960 Axis,AxisParameters = ParseAxisStruct(Axis)
2961 if TotalAngle and NbOfSteps:
2962 AngleInRadians /= NbOfSteps
2963 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2964 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2965 self.mesh.SetParameters(Parameters)
2967 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2968 NbOfSteps, Tolerance)
2969 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2972 ## Generates new elements by extrusion of the elements with given ids
2973 # @param IDsOfElements the list of elements ids for extrusion
2974 # @param StepVector vector, defining the direction and value of extrusion
2975 # @param NbOfSteps the number of steps
2976 # @param MakeGroups forces the generation of new groups from existing ones
2977 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2978 # @ingroup l2_modif_extrurev
2979 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2980 if IDsOfElements == []:
2981 IDsOfElements = self.GetElementsId()
2982 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2983 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2984 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2985 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2986 Parameters = StepVectorParameters + var_separator + Parameters
2987 self.mesh.SetParameters(Parameters)
2989 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2990 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2993 ## Generates new elements by extrusion of the elements with given ids
2994 # @param IDsOfElements is ids of elements
2995 # @param StepVector vector, defining the direction and value of extrusion
2996 # @param NbOfSteps the number of steps
2997 # @param ExtrFlags sets flags for extrusion
2998 # @param SewTolerance uses for comparing locations of nodes if flag
2999 # EXTRUSION_FLAG_SEW is set
3000 # @param MakeGroups forces the generation of new groups from existing ones
3001 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3002 # @ingroup l2_modif_extrurev
3003 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
3004 ExtrFlags, SewTolerance, MakeGroups=False):
3005 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3006 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3008 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
3009 ExtrFlags, SewTolerance)
3010 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
3011 ExtrFlags, SewTolerance)
3014 ## Generates new elements by extrusion of the elements which belong to the object
3015 # @param theObject the object which elements should be processed
3016 # @param StepVector vector, defining the direction and value of extrusion
3017 # @param NbOfSteps the number of steps
3018 # @param MakeGroups forces the generation of new groups from existing ones
3019 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3020 # @ingroup l2_modif_extrurev
3021 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3022 if ( isinstance( theObject, Mesh )):
3023 theObject = theObject.GetMesh()
3024 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3025 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3026 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3027 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3028 Parameters = StepVectorParameters + var_separator + Parameters
3029 self.mesh.SetParameters(Parameters)
3031 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3032 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
3035 ## Generates new elements by extrusion of the elements which belong to the object
3036 # @param theObject object which elements should be processed
3037 # @param StepVector vector, defining the direction and value of extrusion
3038 # @param NbOfSteps the number of steps
3039 # @param MakeGroups to generate new groups from existing ones
3040 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3041 # @ingroup l2_modif_extrurev
3042 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3043 if ( isinstance( theObject, Mesh )):
3044 theObject = theObject.GetMesh()
3045 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3046 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3047 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3048 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3049 Parameters = StepVectorParameters + var_separator + Parameters
3050 self.mesh.SetParameters(Parameters)
3052 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3053 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3056 ## Generates new elements by extrusion of the elements which belong to the object
3057 # @param theObject object which elements should be processed
3058 # @param StepVector vector, defining the direction and value of extrusion
3059 # @param NbOfSteps the number of steps
3060 # @param MakeGroups forces the generation of new groups from existing ones
3061 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3062 # @ingroup l2_modif_extrurev
3063 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3064 if ( isinstance( theObject, Mesh )):
3065 theObject = theObject.GetMesh()
3066 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3067 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3068 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3069 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3070 Parameters = StepVectorParameters + var_separator + Parameters
3071 self.mesh.SetParameters(Parameters)
3073 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3074 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3079 ## Generates new elements by extrusion of the given elements
3080 # The path of extrusion must be a meshed edge.
3081 # @param Base mesh or list of ids of elements for extrusion
3082 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3083 # @param NodeStart the start node from Path. Defines the direction of extrusion
3084 # @param HasAngles allows the shape to be rotated around the path
3085 # to get the resulting mesh in a helical fashion
3086 # @param Angles list of angles in radians
3087 # @param LinearVariation forces the computation of rotation angles as linear
3088 # variation of the given Angles along path steps
3089 # @param HasRefPoint allows using the reference point
3090 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3091 # The User can specify any point as the Reference Point.
3092 # @param MakeGroups forces the generation of new groups from existing ones
3093 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3094 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3095 # only SMESH::Extrusion_Error otherwise
3096 # @ingroup l2_modif_extrurev
3097 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3098 HasAngles, Angles, LinearVariation,
3099 HasRefPoint, RefPoint, MakeGroups, ElemType):
3100 Angles,AnglesParameters = ParseAngles(Angles)
3101 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3102 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3103 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3105 Parameters = AnglesParameters + var_separator + RefPointParameters
3106 self.mesh.SetParameters(Parameters)
3108 if isinstance(Base,list):
3110 if Base == []: IDsOfElements = self.GetElementsId()
3111 else: IDsOfElements = Base
3112 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3113 HasAngles, Angles, LinearVariation,
3114 HasRefPoint, RefPoint, MakeGroups, ElemType)
3116 if isinstance(Base,Mesh):
3117 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3118 HasAngles, Angles, LinearVariation,
3119 HasRefPoint, RefPoint, MakeGroups, ElemType)
3121 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3124 ## Generates new elements by extrusion of the given elements
3125 # The path of extrusion must be a meshed edge.
3126 # @param IDsOfElements ids of elements
3127 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3128 # @param PathShape shape(edge) defines the sub-mesh for the path
3129 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3130 # @param HasAngles allows the shape to be rotated around the path
3131 # to get the resulting mesh in a helical fashion
3132 # @param Angles list of angles in radians
3133 # @param HasRefPoint allows using the reference point
3134 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3135 # The User can specify any point as the Reference Point.
3136 # @param MakeGroups forces the generation of new groups from existing ones
3137 # @param LinearVariation forces the computation of rotation angles as linear
3138 # variation of the given Angles along path steps
3139 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3140 # only SMESH::Extrusion_Error otherwise
3141 # @ingroup l2_modif_extrurev
3142 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3143 HasAngles, Angles, HasRefPoint, RefPoint,
3144 MakeGroups=False, LinearVariation=False):
3145 Angles,AnglesParameters = ParseAngles(Angles)
3146 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3147 if IDsOfElements == []:
3148 IDsOfElements = self.GetElementsId()
3149 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3150 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3152 if ( isinstance( PathMesh, Mesh )):
3153 PathMesh = PathMesh.GetMesh()
3154 if HasAngles and Angles and LinearVariation:
3155 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3157 Parameters = AnglesParameters + var_separator + RefPointParameters
3158 self.mesh.SetParameters(Parameters)
3160 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3161 PathShape, NodeStart, HasAngles,
3162 Angles, HasRefPoint, RefPoint)
3163 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3164 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3166 ## Generates new elements by extrusion of the elements which belong to the object
3167 # The path of extrusion must be a meshed edge.
3168 # @param theObject the object which elements should be processed
3169 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3170 # @param PathShape shape(edge) defines the sub-mesh for the path
3171 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3172 # @param HasAngles allows the shape to be rotated around the path
3173 # to get the resulting mesh in a helical fashion
3174 # @param Angles list of angles
3175 # @param HasRefPoint allows using the reference point
3176 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3177 # The User can specify any point as the Reference Point.
3178 # @param MakeGroups forces the generation of new groups from existing ones
3179 # @param LinearVariation forces the computation of rotation angles as linear
3180 # variation of the given Angles along path steps
3181 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3182 # only SMESH::Extrusion_Error otherwise
3183 # @ingroup l2_modif_extrurev
3184 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3185 HasAngles, Angles, HasRefPoint, RefPoint,
3186 MakeGroups=False, LinearVariation=False):
3187 Angles,AnglesParameters = ParseAngles(Angles)
3188 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3189 if ( isinstance( theObject, Mesh )):
3190 theObject = theObject.GetMesh()
3191 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3192 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3193 if ( isinstance( PathMesh, Mesh )):
3194 PathMesh = PathMesh.GetMesh()
3195 if HasAngles and Angles and LinearVariation:
3196 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3198 Parameters = AnglesParameters + var_separator + RefPointParameters
3199 self.mesh.SetParameters(Parameters)
3201 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3202 PathShape, NodeStart, HasAngles,
3203 Angles, HasRefPoint, RefPoint)
3204 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3205 NodeStart, HasAngles, Angles, HasRefPoint,
3208 ## Generates new elements by extrusion of the elements which belong to the object
3209 # The path of extrusion must be a meshed edge.
3210 # @param theObject the object which elements should be processed
3211 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3212 # @param PathShape shape(edge) defines the sub-mesh for the path
3213 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3214 # @param HasAngles allows the shape to be rotated around the path
3215 # to get the resulting mesh in a helical fashion
3216 # @param Angles list of angles
3217 # @param HasRefPoint allows using the reference point
3218 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3219 # The User can specify any point as the Reference Point.
3220 # @param MakeGroups forces the generation of new groups from existing ones
3221 # @param LinearVariation forces the computation of rotation angles as linear
3222 # variation of the given Angles along path steps
3223 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3224 # only SMESH::Extrusion_Error otherwise
3225 # @ingroup l2_modif_extrurev
3226 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3227 HasAngles, Angles, HasRefPoint, RefPoint,
3228 MakeGroups=False, LinearVariation=False):
3229 Angles,AnglesParameters = ParseAngles(Angles)
3230 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3231 if ( isinstance( theObject, Mesh )):
3232 theObject = theObject.GetMesh()
3233 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3234 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3235 if ( isinstance( PathMesh, Mesh )):
3236 PathMesh = PathMesh.GetMesh()
3237 if HasAngles and Angles and LinearVariation:
3238 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3240 Parameters = AnglesParameters + var_separator + RefPointParameters
3241 self.mesh.SetParameters(Parameters)
3243 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3244 PathShape, NodeStart, HasAngles,
3245 Angles, HasRefPoint, RefPoint)
3246 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3247 NodeStart, HasAngles, Angles, HasRefPoint,
3250 ## Generates new elements by extrusion of the elements which belong to the object
3251 # The path of extrusion must be a meshed edge.
3252 # @param theObject the object which elements should be processed
3253 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3254 # @param PathShape shape(edge) defines the sub-mesh for the path
3255 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3256 # @param HasAngles allows the shape to be rotated around the path
3257 # to get the resulting mesh in a helical fashion
3258 # @param Angles list of angles
3259 # @param HasRefPoint allows using the reference point
3260 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3261 # The User can specify any point as the Reference Point.
3262 # @param MakeGroups forces the generation of new groups from existing ones
3263 # @param LinearVariation forces the computation of rotation angles as linear
3264 # variation of the given Angles along path steps
3265 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3266 # only SMESH::Extrusion_Error otherwise
3267 # @ingroup l2_modif_extrurev
3268 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3269 HasAngles, Angles, HasRefPoint, RefPoint,
3270 MakeGroups=False, LinearVariation=False):
3271 Angles,AnglesParameters = ParseAngles(Angles)
3272 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3273 if ( isinstance( theObject, Mesh )):
3274 theObject = theObject.GetMesh()
3275 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3276 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3277 if ( isinstance( PathMesh, Mesh )):
3278 PathMesh = PathMesh.GetMesh()
3279 if HasAngles and Angles and LinearVariation:
3280 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3282 Parameters = AnglesParameters + var_separator + RefPointParameters
3283 self.mesh.SetParameters(Parameters)
3285 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3286 PathShape, NodeStart, HasAngles,
3287 Angles, HasRefPoint, RefPoint)
3288 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3289 NodeStart, HasAngles, Angles, HasRefPoint,
3292 ## Creates a symmetrical copy of mesh elements
3293 # @param IDsOfElements list of elements ids
3294 # @param Mirror is AxisStruct or geom object(point, line, plane)
3295 # @param theMirrorType is POINT, AXIS or PLANE
3296 # If the Mirror is a geom object this parameter is unnecessary
3297 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3298 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3299 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3300 # @ingroup l2_modif_trsf
3301 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3302 if IDsOfElements == []:
3303 IDsOfElements = self.GetElementsId()
3304 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3305 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3306 Mirror,Parameters = ParseAxisStruct(Mirror)
3307 self.mesh.SetParameters(Parameters)
3308 if Copy and MakeGroups:
3309 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3310 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3313 ## Creates a new mesh by a symmetrical copy of mesh elements
3314 # @param IDsOfElements the list of elements ids
3315 # @param Mirror is AxisStruct or geom object (point, line, plane)
3316 # @param theMirrorType is POINT, AXIS or PLANE
3317 # If the Mirror is a geom object this parameter is unnecessary
3318 # @param MakeGroups to generate new groups from existing ones
3319 # @param NewMeshName a name of the new mesh to create
3320 # @return instance of Mesh class
3321 # @ingroup l2_modif_trsf
3322 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3323 if IDsOfElements == []:
3324 IDsOfElements = self.GetElementsId()
3325 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3326 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3327 Mirror,Parameters = ParseAxisStruct(Mirror)
3328 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3329 MakeGroups, NewMeshName)
3330 mesh.SetParameters(Parameters)
3331 return Mesh(self.smeshpyD,self.geompyD,mesh)
3333 ## Creates a symmetrical copy of the object
3334 # @param theObject mesh, submesh or group
3335 # @param Mirror AxisStruct or geom object (point, line, plane)
3336 # @param theMirrorType is POINT, AXIS or PLANE
3337 # If the Mirror is a geom object this parameter is unnecessary
3338 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3339 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3340 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3341 # @ingroup l2_modif_trsf
3342 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3343 if ( isinstance( theObject, Mesh )):
3344 theObject = theObject.GetMesh()
3345 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3346 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3347 Mirror,Parameters = ParseAxisStruct(Mirror)
3348 self.mesh.SetParameters(Parameters)
3349 if Copy and MakeGroups:
3350 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3351 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3354 ## Creates a new mesh by a symmetrical copy of the object
3355 # @param theObject mesh, submesh or group
3356 # @param Mirror AxisStruct or geom object (point, line, plane)
3357 # @param theMirrorType POINT, AXIS or PLANE
3358 # If the Mirror is a geom object this parameter is unnecessary
3359 # @param MakeGroups forces the generation of new groups from existing ones
3360 # @param NewMeshName the name of the new mesh to create
3361 # @return instance of Mesh class
3362 # @ingroup l2_modif_trsf
3363 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3364 if ( isinstance( theObject, Mesh )):
3365 theObject = theObject.GetMesh()
3366 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3367 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3368 Mirror,Parameters = ParseAxisStruct(Mirror)
3369 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3370 MakeGroups, NewMeshName)
3371 mesh.SetParameters(Parameters)
3372 return Mesh( self.smeshpyD,self.geompyD,mesh )
3374 ## Translates the elements
3375 # @param IDsOfElements list of elements ids
3376 # @param Vector the direction of translation (DirStruct or vector)
3377 # @param Copy allows copying the translated elements
3378 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3379 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3380 # @ingroup l2_modif_trsf
3381 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3382 if IDsOfElements == []:
3383 IDsOfElements = self.GetElementsId()
3384 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3385 Vector = self.smeshpyD.GetDirStruct(Vector)
3386 Vector,Parameters = ParseDirStruct(Vector)
3387 self.mesh.SetParameters(Parameters)
3388 if Copy and MakeGroups:
3389 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3390 self.editor.Translate(IDsOfElements, Vector, Copy)
3393 ## Creates a new mesh of translated elements
3394 # @param IDsOfElements list of elements ids
3395 # @param Vector the direction of translation (DirStruct or vector)
3396 # @param MakeGroups forces the generation of new groups from existing ones
3397 # @param NewMeshName the name of the newly created mesh
3398 # @return instance of Mesh class
3399 # @ingroup l2_modif_trsf
3400 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3401 if IDsOfElements == []:
3402 IDsOfElements = self.GetElementsId()
3403 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3404 Vector = self.smeshpyD.GetDirStruct(Vector)
3405 Vector,Parameters = ParseDirStruct(Vector)
3406 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3407 mesh.SetParameters(Parameters)
3408 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3410 ## Translates the object
3411 # @param theObject the object to translate (mesh, submesh, or group)
3412 # @param Vector direction of translation (DirStruct or geom vector)
3413 # @param Copy allows copying the translated elements
3414 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3415 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3416 # @ingroup l2_modif_trsf
3417 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3418 if ( isinstance( theObject, Mesh )):
3419 theObject = theObject.GetMesh()
3420 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3421 Vector = self.smeshpyD.GetDirStruct(Vector)
3422 Vector,Parameters = ParseDirStruct(Vector)
3423 self.mesh.SetParameters(Parameters)
3424 if Copy and MakeGroups:
3425 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3426 self.editor.TranslateObject(theObject, Vector, Copy)
3429 ## Creates a new mesh from the translated object
3430 # @param theObject the object to translate (mesh, submesh, or group)
3431 # @param Vector the direction of translation (DirStruct or geom vector)
3432 # @param MakeGroups forces the generation of new groups from existing ones
3433 # @param NewMeshName the name of the newly created mesh
3434 # @return instance of Mesh class
3435 # @ingroup l2_modif_trsf
3436 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3437 if (isinstance(theObject, Mesh)):
3438 theObject = theObject.GetMesh()
3439 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3440 Vector = self.smeshpyD.GetDirStruct(Vector)
3441 Vector,Parameters = ParseDirStruct(Vector)
3442 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3443 mesh.SetParameters(Parameters)
3444 return Mesh( self.smeshpyD, self.geompyD, mesh )
3448 ## Scales the object
3449 # @param theObject - the object to translate (mesh, submesh, or group)
3450 # @param thePoint - base point for scale
3451 # @param theScaleFact - list of 1-3 scale factors for axises
3452 # @param Copy - allows copying the translated elements
3453 # @param MakeGroups - forces the generation of new groups from existing
3455 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3456 # empty list otherwise
3457 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3458 if ( isinstance( theObject, Mesh )):
3459 theObject = theObject.GetMesh()
3460 if ( isinstance( theObject, list )):
3461 theObject = self.editor.MakeIDSource(theObject, SMESH.ALL)
3463 thePoint, Parameters = ParsePointStruct(thePoint)
3464 self.mesh.SetParameters(Parameters)
3466 if Copy and MakeGroups:
3467 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3468 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3471 ## Creates a new mesh from the translated object
3472 # @param theObject - the object to translate (mesh, submesh, or group)
3473 # @param thePoint - base point for scale
3474 # @param theScaleFact - list of 1-3 scale factors for axises
3475 # @param MakeGroups - forces the generation of new groups from existing ones
3476 # @param NewMeshName - the name of the newly created mesh
3477 # @return instance of Mesh class
3478 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3479 if (isinstance(theObject, Mesh)):
3480 theObject = theObject.GetMesh()
3481 if ( isinstance( theObject, list )):
3482 theObject = self.editor.MakeIDSource(theObject,SMESH.ALL)
3484 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3485 MakeGroups, NewMeshName)
3486 #mesh.SetParameters(Parameters)
3487 return Mesh( self.smeshpyD, self.geompyD, mesh )
3491 ## Rotates the elements
3492 # @param IDsOfElements list of elements ids
3493 # @param Axis the axis of rotation (AxisStruct or geom line)
3494 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3495 # @param Copy allows copying the rotated elements
3496 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3497 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3498 # @ingroup l2_modif_trsf
3499 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3501 if isinstance(AngleInRadians,str):
3503 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3505 AngleInRadians = DegreesToRadians(AngleInRadians)
3506 if IDsOfElements == []:
3507 IDsOfElements = self.GetElementsId()
3508 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3509 Axis = self.smeshpyD.GetAxisStruct(Axis)
3510 Axis,AxisParameters = ParseAxisStruct(Axis)
3511 Parameters = AxisParameters + var_separator + Parameters
3512 self.mesh.SetParameters(Parameters)
3513 if Copy and MakeGroups:
3514 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3515 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3518 ## Creates a new mesh of rotated elements
3519 # @param IDsOfElements list of element ids
3520 # @param Axis the axis of rotation (AxisStruct or geom line)
3521 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3522 # @param MakeGroups forces the generation of new groups from existing ones
3523 # @param NewMeshName the name of the newly created mesh
3524 # @return instance of Mesh class
3525 # @ingroup l2_modif_trsf
3526 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3528 if isinstance(AngleInRadians,str):
3530 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3532 AngleInRadians = DegreesToRadians(AngleInRadians)
3533 if IDsOfElements == []:
3534 IDsOfElements = self.GetElementsId()
3535 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3536 Axis = self.smeshpyD.GetAxisStruct(Axis)
3537 Axis,AxisParameters = ParseAxisStruct(Axis)
3538 Parameters = AxisParameters + var_separator + Parameters
3539 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3540 MakeGroups, NewMeshName)
3541 mesh.SetParameters(Parameters)
3542 return Mesh( self.smeshpyD, self.geompyD, mesh )
3544 ## Rotates the object
3545 # @param theObject the object to rotate( mesh, submesh, or group)
3546 # @param Axis the axis of rotation (AxisStruct or geom line)
3547 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3548 # @param Copy allows copying the rotated elements
3549 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3550 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3551 # @ingroup l2_modif_trsf
3552 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3554 if isinstance(AngleInRadians,str):
3556 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3558 AngleInRadians = DegreesToRadians(AngleInRadians)
3559 if (isinstance(theObject, Mesh)):
3560 theObject = theObject.GetMesh()
3561 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3562 Axis = self.smeshpyD.GetAxisStruct(Axis)
3563 Axis,AxisParameters = ParseAxisStruct(Axis)
3564 Parameters = AxisParameters + ":" + Parameters
3565 self.mesh.SetParameters(Parameters)
3566 if Copy and MakeGroups:
3567 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3568 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3571 ## Creates a new mesh from the rotated object
3572 # @param theObject the object to rotate (mesh, submesh, or group)
3573 # @param Axis the axis of rotation (AxisStruct or geom line)
3574 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3575 # @param MakeGroups forces the generation of new groups from existing ones
3576 # @param NewMeshName the name of the newly created mesh
3577 # @return instance of Mesh class
3578 # @ingroup l2_modif_trsf
3579 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3581 if isinstance(AngleInRadians,str):
3583 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3585 AngleInRadians = DegreesToRadians(AngleInRadians)
3586 if (isinstance( theObject, Mesh )):
3587 theObject = theObject.GetMesh()
3588 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3589 Axis = self.smeshpyD.GetAxisStruct(Axis)
3590 Axis,AxisParameters = ParseAxisStruct(Axis)
3591 Parameters = AxisParameters + ":" + Parameters
3592 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3593 MakeGroups, NewMeshName)
3594 mesh.SetParameters(Parameters)
3595 return Mesh( self.smeshpyD, self.geompyD, mesh )
3597 ## Finds groups of ajacent nodes within Tolerance.
3598 # @param Tolerance the value of tolerance
3599 # @return the list of groups of nodes
3600 # @ingroup l2_modif_trsf
3601 def FindCoincidentNodes (self, Tolerance):
3602 return self.editor.FindCoincidentNodes(Tolerance)
3604 ## Finds groups of ajacent nodes within Tolerance.
3605 # @param Tolerance the value of tolerance
3606 # @param SubMeshOrGroup SubMesh or Group
3607 # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
3608 # @return the list of groups of nodes
3609 # @ingroup l2_modif_trsf
3610 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
3611 if (isinstance( SubMeshOrGroup, Mesh )):
3612 SubMeshOrGroup = SubMeshOrGroup.GetMesh()
3613 if not isinstance( ExceptSubMeshOrGroups, list):
3614 ExceptSubMeshOrGroups = [ ExceptSubMeshOrGroups ]
3615 if ExceptSubMeshOrGroups and isinstance( ExceptSubMeshOrGroups[0], int):
3616 ExceptSubMeshOrGroups = [ self.editor.MakeIDSource( ExceptSubMeshOrGroups, SMESH.NODE)]
3617 return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,ExceptSubMeshOrGroups)
3620 # @param GroupsOfNodes the list of groups of nodes
3621 # @ingroup l2_modif_trsf
3622 def MergeNodes (self, GroupsOfNodes):
3623 self.editor.MergeNodes(GroupsOfNodes)
3625 ## Finds the elements built on the same nodes.
3626 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3627 # @return a list of groups of equal elements
3628 # @ingroup l2_modif_trsf
3629 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3630 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3631 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3632 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3634 ## Merges elements in each given group.
3635 # @param GroupsOfElementsID groups of elements for merging
3636 # @ingroup l2_modif_trsf
3637 def MergeElements(self, GroupsOfElementsID):
3638 self.editor.MergeElements(GroupsOfElementsID)
3640 ## Leaves one element and removes all other elements built on the same nodes.
3641 # @ingroup l2_modif_trsf
3642 def MergeEqualElements(self):
3643 self.editor.MergeEqualElements()
3645 ## Sews free borders
3646 # @return SMESH::Sew_Error
3647 # @ingroup l2_modif_trsf
3648 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3649 FirstNodeID2, SecondNodeID2, LastNodeID2,
3650 CreatePolygons, CreatePolyedrs):
3651 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3652 FirstNodeID2, SecondNodeID2, LastNodeID2,
3653 CreatePolygons, CreatePolyedrs)
3655 ## Sews conform free borders
3656 # @return SMESH::Sew_Error
3657 # @ingroup l2_modif_trsf
3658 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3659 FirstNodeID2, SecondNodeID2):
3660 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3661 FirstNodeID2, SecondNodeID2)
3663 ## Sews border to side
3664 # @return SMESH::Sew_Error
3665 # @ingroup l2_modif_trsf
3666 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3667 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3668 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3669 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3671 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3672 # merged with the nodes of elements of Side2.
3673 # The number of elements in theSide1 and in theSide2 must be
3674 # equal and they should have similar nodal connectivity.
3675 # The nodes to merge should belong to side borders and
3676 # the first node should be linked to the second.
3677 # @return SMESH::Sew_Error
3678 # @ingroup l2_modif_trsf
3679 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3680 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3681 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3682 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3683 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3684 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3686 ## Sets new nodes for the given element.
3687 # @param ide the element id
3688 # @param newIDs nodes ids
3689 # @return If the number of nodes does not correspond to the type of element - returns false
3690 # @ingroup l2_modif_edit
3691 def ChangeElemNodes(self, ide, newIDs):
3692 return self.editor.ChangeElemNodes(ide, newIDs)
3694 ## If during the last operation of MeshEditor some nodes were
3695 # created, this method returns the list of their IDs, \n
3696 # if new nodes were not created - returns empty list
3697 # @return the list of integer values (can be empty)
3698 # @ingroup l1_auxiliary
3699 def GetLastCreatedNodes(self):
3700 return self.editor.GetLastCreatedNodes()
3702 ## If during the last operation of MeshEditor some elements were
3703 # created this method returns the list of their IDs, \n
3704 # if new elements were not created - returns empty list
3705 # @return the list of integer values (can be empty)
3706 # @ingroup l1_auxiliary
3707 def GetLastCreatedElems(self):
3708 return self.editor.GetLastCreatedElems()
3710 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3711 # @param theNodes identifiers of nodes to be doubled
3712 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
3713 # nodes. If list of element identifiers is empty then nodes are doubled but
3714 # they not assigned to elements
3715 # @return TRUE if operation has been completed successfully, FALSE otherwise
3716 # @ingroup l2_modif_edit
3717 def DoubleNodes(self, theNodes, theModifiedElems):
3718 return self.editor.DoubleNodes(theNodes, theModifiedElems)
3720 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3721 # This method provided for convenience works as DoubleNodes() described above.
3722 # @param theNodeId identifiers of node to be doubled
3723 # @param theModifiedElems identifiers of elements to be updated
3724 # @return TRUE if operation has been completed successfully, FALSE otherwise
3725 # @ingroup l2_modif_edit
3726 def DoubleNode(self, theNodeId, theModifiedElems):
3727 return self.editor.DoubleNode(theNodeId, theModifiedElems)
3729 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3730 # This method provided for convenience works as DoubleNodes() described above.
3731 # @param theNodes group of nodes to be doubled
3732 # @param theModifiedElems group of elements to be updated.
3733 # @param theMakeGroup forces the generation of a group containing new nodes.
3734 # @return TRUE or a created group if operation has been completed successfully,
3735 # FALSE or None otherwise
3736 # @ingroup l2_modif_edit
3737 def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
3739 return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
3740 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3742 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3743 # This method provided for convenience works as DoubleNodes() described above.
3744 # @param theNodes list of groups of nodes to be doubled
3745 # @param theModifiedElems list of groups of elements to be updated.
3746 # @return TRUE if operation has been completed successfully, FALSE otherwise
3747 # @ingroup l2_modif_edit
3748 def DoubleNodeGroups(self, theNodes, theModifiedElems):
3749 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3751 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3752 # @param theElems - the list of elements (edges or faces) to be replicated
3753 # The nodes for duplication could be found from these elements
3754 # @param theNodesNot - list of nodes to NOT replicate
3755 # @param theAffectedElems - the list of elements (cells and edges) to which the
3756 # replicated nodes should be associated to.
3757 # @return TRUE if operation has been completed successfully, FALSE otherwise
3758 # @ingroup l2_modif_edit
3759 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
3760 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
3762 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3763 # @param theElems - the list of elements (edges or faces) to be replicated
3764 # The nodes for duplication could be found from these elements
3765 # @param theNodesNot - list of nodes to NOT replicate
3766 # @param theShape - shape to detect affected elements (element which geometric center
3767 # located on or inside shape).
3768 # The replicated nodes should be associated to affected elements.
3769 # @return TRUE if operation has been completed successfully, FALSE otherwise
3770 # @ingroup l2_modif_edit
3771 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
3772 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
3774 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3775 # This method provided for convenience works as DoubleNodes() described above.
3776 # @param theElems - group of of elements (edges or faces) to be replicated
3777 # @param theNodesNot - group of nodes not to replicated
3778 # @param theAffectedElems - group of elements to which the replicated nodes
3779 # should be associated to.
3780 # @param theMakeGroup forces the generation of a group containing new elements.
3781 # @ingroup l2_modif_edit
3782 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
3784 return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
3785 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
3787 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3788 # This method provided for convenience works as DoubleNodes() described above.
3789 # @param theElems - group of of elements (edges or faces) to be replicated
3790 # @param theNodesNot - group of nodes not to replicated
3791 # @param theShape - shape to detect affected elements (element which geometric center
3792 # located on or inside shape).
3793 # The replicated nodes should be associated to affected elements.
3794 # @ingroup l2_modif_edit
3795 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
3796 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
3798 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3799 # This method provided for convenience works as DoubleNodes() described above.
3800 # @param theElems - list of groups of elements (edges or faces) to be replicated
3801 # @param theNodesNot - list of groups of nodes not to replicated
3802 # @param theAffectedElems - group of elements to which the replicated nodes
3803 # should be associated to.
3804 # @return TRUE if operation has been completed successfully, FALSE otherwise
3805 # @ingroup l2_modif_edit
3806 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems):
3807 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
3809 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3810 # This method provided for convenience works as DoubleNodes() described above.
3811 # @param theElems - list of groups of elements (edges or faces) to be replicated
3812 # @param theNodesNot - list of groups of nodes not to replicated
3813 # @param theShape - shape to detect affected elements (element which geometric center
3814 # located on or inside shape).
3815 # The replicated nodes should be associated to affected elements.
3816 # @return TRUE if operation has been completed successfully, FALSE otherwise
3817 # @ingroup l2_modif_edit
3818 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
3819 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
3821 ## The mother class to define algorithm, it is not recommended to use it directly.
3824 # @ingroup l2_algorithms
3825 class Mesh_Algorithm:
3826 # @class Mesh_Algorithm
3827 # @brief Class Mesh_Algorithm
3829 #def __init__(self,smesh):
3837 ## Finds a hypothesis in the study by its type name and parameters.
3838 # Finds only the hypotheses created in smeshpyD engine.
3839 # @return SMESH.SMESH_Hypothesis
3840 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3841 study = smeshpyD.GetCurrentStudy()
3842 #to do: find component by smeshpyD object, not by its data type
3843 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3844 if scomp is not None:
3845 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3846 # Check if the root label of the hypotheses exists
3847 if res and hypRoot is not None:
3848 iter = study.NewChildIterator(hypRoot)
3849 # Check all published hypotheses
3851 hypo_so_i = iter.Value()
3852 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3853 if attr is not None:
3854 anIOR = attr.Value()
3855 hypo_o_i = salome.orb.string_to_object(anIOR)
3856 if hypo_o_i is not None:
3857 # Check if this is a hypothesis
3858 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3859 if hypo_i is not None:
3860 # Check if the hypothesis belongs to current engine
3861 if smeshpyD.GetObjectId(hypo_i) > 0:
3862 # Check if this is the required hypothesis
3863 if hypo_i.GetName() == hypname:
3865 if CompareMethod(hypo_i, args):
3879 ## Finds the algorithm in the study by its type name.
3880 # Finds only the algorithms, which have been created in smeshpyD engine.
3881 # @return SMESH.SMESH_Algo
3882 def FindAlgorithm (self, algoname, smeshpyD):
3883 study = smeshpyD.GetCurrentStudy()
3884 #to do: find component by smeshpyD object, not by its data type
3885 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3886 if scomp is not None:
3887 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3888 # Check if the root label of the algorithms exists
3889 if res and hypRoot is not None:
3890 iter = study.NewChildIterator(hypRoot)
3891 # Check all published algorithms
3893 algo_so_i = iter.Value()
3894 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3895 if attr is not None:
3896 anIOR = attr.Value()
3897 algo_o_i = salome.orb.string_to_object(anIOR)
3898 if algo_o_i is not None:
3899 # Check if this is an algorithm
3900 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3901 if algo_i is not None:
3902 # Checks if the algorithm belongs to the current engine
3903 if smeshpyD.GetObjectId(algo_i) > 0:
3904 # Check if this is the required algorithm
3905 if algo_i.GetName() == algoname:
3918 ## If the algorithm is global, returns 0; \n
3919 # else returns the submesh associated to this algorithm.
3920 def GetSubMesh(self):
3923 ## Returns the wrapped mesher.
3924 def GetAlgorithm(self):
3927 ## Gets the list of hypothesis that can be used with this algorithm
3928 def GetCompatibleHypothesis(self):
3931 mylist = self.algo.GetCompatibleHypothesis()
3934 ## Gets the name of the algorithm
3938 ## Sets the name to the algorithm
3939 def SetName(self, name):
3940 self.mesh.smeshpyD.SetName(self.algo, name)
3942 ## Gets the id of the algorithm
3944 return self.algo.GetId()
3947 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3949 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3950 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3952 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3954 self.Assign(algo, mesh, geom)
3958 def Assign(self, algo, mesh, geom):
3960 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3969 name = GetName(geom)
3972 name = mesh.geompyD.SubShapeName(geom, piece)
3973 mesh.geompyD.addToStudyInFather(piece, geom, name)
3975 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3978 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3979 TreatHypoStatus( status, algo.GetName(), name, True )
3981 def CompareHyp (self, hyp, args):
3982 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3985 def CompareEqualHyp (self, hyp, args):
3989 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3990 UseExisting=0, CompareMethod=""):
3993 if CompareMethod == "": CompareMethod = self.CompareHyp
3994 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3997 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
4003 a = a + s + str(args[i])
4007 self.mesh.smeshpyD.SetName(hypo, hyp + a)
4009 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
4010 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
4013 ## Returns entry of the shape to mesh in the study
4014 def MainShapeEntry(self):
4016 if not self.mesh or not self.mesh.GetMesh(): return entry
4017 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
4018 study = self.mesh.smeshpyD.GetCurrentStudy()
4019 ior = salome.orb.object_to_string( self.mesh.GetShape() )
4020 sobj = study.FindObjectIOR(ior)
4021 if sobj: entry = sobj.GetID()
4022 if not entry: return ""
4025 # Public class: Mesh_Segment
4026 # --------------------------
4028 ## Class to define a segment 1D algorithm for discretization
4031 # @ingroup l3_algos_basic
4032 class Mesh_Segment(Mesh_Algorithm):
4034 ## Private constructor.
4035 def __init__(self, mesh, geom=0):
4036 Mesh_Algorithm.__init__(self)
4037 self.Create(mesh, geom, "Regular_1D")
4039 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
4040 # @param l for the length of segments that cut an edge
4041 # @param UseExisting if ==true - searches for an existing hypothesis created with
4042 # the same parameters, else (default) - creates a new one
4043 # @param p precision, used for calculation of the number of segments.
4044 # The precision should be a positive, meaningful value within the range [0,1].
4045 # In general, the number of segments is calculated with the formula:
4046 # nb = ceil((edge_length / l) - p)
4047 # Function ceil rounds its argument to the higher integer.
4048 # So, p=0 means rounding of (edge_length / l) to the higher integer,
4049 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
4050 # p=1 means rounding of (edge_length / l) to the lower integer.
4051 # Default value is 1e-07.
4052 # @return an instance of StdMeshers_LocalLength hypothesis
4053 # @ingroup l3_hypos_1dhyps
4054 def LocalLength(self, l, UseExisting=0, p=1e-07):
4055 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
4056 CompareMethod=self.CompareLocalLength)
4062 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
4063 def CompareLocalLength(self, hyp, args):
4064 if IsEqual(hyp.GetLength(), args[0]):
4065 return IsEqual(hyp.GetPrecision(), args[1])
4068 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
4069 # @param length is optional maximal allowed length of segment, if it is omitted
4070 # the preestimated length is used that depends on geometry size
4071 # @param UseExisting if ==true - searches for an existing hypothesis created with
4072 # the same parameters, else (default) - create a new one
4073 # @return an instance of StdMeshers_MaxLength hypothesis
4074 # @ingroup l3_hypos_1dhyps
4075 def MaxSize(self, length=0.0, UseExisting=0):
4076 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
4079 hyp.SetLength(length)
4081 # set preestimated length
4082 gen = self.mesh.smeshpyD
4083 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
4084 self.mesh.GetMesh(), self.mesh.GetShape(),
4086 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
4088 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
4091 hyp.SetUsePreestimatedLength( length == 0.0 )
4094 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
4095 # @param n for the number of segments that cut an edge
4096 # @param s for the scale factor (optional)
4097 # @param reversedEdges is a list of edges to mesh using reversed orientation
4098 # @param UseExisting if ==true - searches for an existing hypothesis created with
4099 # the same parameters, else (default) - create a new one
4100 # @return an instance of StdMeshers_NumberOfSegments hypothesis
4101 # @ingroup l3_hypos_1dhyps
4102 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4103 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4104 reversedEdges, UseExisting = [], reversedEdges
4105 entry = self.MainShapeEntry()
4107 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
4108 UseExisting=UseExisting,
4109 CompareMethod=self.CompareNumberOfSegments)
4111 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
4112 UseExisting=UseExisting,
4113 CompareMethod=self.CompareNumberOfSegments)
4114 hyp.SetDistrType( 1 )
4115 hyp.SetScaleFactor(s)
4116 hyp.SetNumberOfSegments(n)
4117 hyp.SetReversedEdges( reversedEdges )
4118 hyp.SetObjectEntry( entry )
4122 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4123 def CompareNumberOfSegments(self, hyp, args):
4124 if hyp.GetNumberOfSegments() == args[0]:
4126 if hyp.GetReversedEdges() == args[1]:
4127 if not args[1] or hyp.GetObjectEntry() == args[2]:
4130 if hyp.GetReversedEdges() == args[2]:
4131 if not args[2] or hyp.GetObjectEntry() == args[3]:
4132 if hyp.GetDistrType() == 1:
4133 if IsEqual(hyp.GetScaleFactor(), args[1]):
4137 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4138 # @param start defines the length of the first segment
4139 # @param end defines the length of the last segment
4140 # @param reversedEdges is a list of edges to mesh using reversed orientation
4141 # @param UseExisting if ==true - searches for an existing hypothesis created with
4142 # the same parameters, else (default) - creates a new one
4143 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4144 # @ingroup l3_hypos_1dhyps
4145 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4146 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4147 reversedEdges, UseExisting = [], reversedEdges
4148 entry = self.MainShapeEntry()
4149 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
4150 UseExisting=UseExisting,
4151 CompareMethod=self.CompareArithmetic1D)
4152 hyp.SetStartLength(start)
4153 hyp.SetEndLength(end)
4154 hyp.SetReversedEdges( reversedEdges )
4155 hyp.SetObjectEntry( entry )
4159 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4160 def CompareArithmetic1D(self, hyp, args):
4161 if IsEqual(hyp.GetLength(1), args[0]):
4162 if IsEqual(hyp.GetLength(0), args[1]):
4163 if hyp.GetReversedEdges() == args[2]:
4164 if not args[2] or hyp.GetObjectEntry() == args[3]:
4169 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4170 # on curve from 0 to 1 (additionally it is neecessary to check
4171 # orientation of edges and create list of reversed edges if it is
4172 # needed) and sets numbers of segments between given points (default
4173 # values are equals 1
4174 # @param points defines the list of parameters on curve
4175 # @param nbSegs defines the list of numbers of segments
4176 # @param reversedEdges is a list of edges to mesh using reversed orientation
4177 # @param UseExisting if ==true - searches for an existing hypothesis created with
4178 # the same parameters, else (default) - creates a new one
4179 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4180 # @ingroup l3_hypos_1dhyps
4181 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4182 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4183 reversedEdges, UseExisting = [], reversedEdges
4184 if reversedEdges and isinstance( reversedEdges[0], geompyDC.GEOM._objref_GEOM_Object ):
4185 for i in range( len( reversedEdges )):
4186 reversedEdges[i] = self.mesh.geompyD.GetSubShapeID(self.mesh.geom, reversedEdges[i] )
4187 entry = self.MainShapeEntry()
4188 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
4189 UseExisting=UseExisting,
4190 CompareMethod=self.CompareFixedPoints1D)
4191 hyp.SetPoints(points)
4192 hyp.SetNbSegments(nbSegs)
4193 hyp.SetReversedEdges(reversedEdges)
4194 hyp.SetObjectEntry(entry)
4198 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4199 ## as the given arguments
4200 def CompareFixedPoints1D(self, hyp, args):
4201 if hyp.GetPoints() == args[0]:
4202 if hyp.GetNbSegments() == args[1]:
4203 if hyp.GetReversedEdges() == args[2]:
4204 if not args[2] or hyp.GetObjectEntry() == args[3]:
4210 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4211 # @param start defines the length of the first segment
4212 # @param end defines the length of the last segment
4213 # @param reversedEdges is a list of edges to mesh using reversed orientation
4214 # @param UseExisting if ==true - searches for an existing hypothesis created with
4215 # the same parameters, else (default) - creates a new one
4216 # @return an instance of StdMeshers_StartEndLength hypothesis
4217 # @ingroup l3_hypos_1dhyps
4218 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4219 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4220 reversedEdges, UseExisting = [], reversedEdges
4221 entry = self.MainShapeEntry()
4222 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
4223 UseExisting=UseExisting,
4224 CompareMethod=self.CompareStartEndLength)
4225 hyp.SetStartLength(start)
4226 hyp.SetEndLength(end)
4227 hyp.SetReversedEdges( reversedEdges )
4228 hyp.SetObjectEntry( entry )
4231 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4232 def CompareStartEndLength(self, hyp, args):
4233 if IsEqual(hyp.GetLength(1), args[0]):
4234 if IsEqual(hyp.GetLength(0), args[1]):
4235 if hyp.GetReversedEdges() == args[2]:
4236 if not args[2] or hyp.GetObjectEntry() == args[3]:
4240 ## Defines "Deflection1D" hypothesis
4241 # @param d for the deflection
4242 # @param UseExisting if ==true - searches for an existing hypothesis created with
4243 # the same parameters, else (default) - create a new one
4244 # @ingroup l3_hypos_1dhyps
4245 def Deflection1D(self, d, UseExisting=0):
4246 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4247 CompareMethod=self.CompareDeflection1D)
4248 hyp.SetDeflection(d)
4251 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4252 def CompareDeflection1D(self, hyp, args):
4253 return IsEqual(hyp.GetDeflection(), args[0])
4255 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4256 # the opposite side in case of quadrangular faces
4257 # @ingroup l3_hypos_additi
4258 def Propagation(self):
4259 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4261 ## Defines "AutomaticLength" hypothesis
4262 # @param fineness for the fineness [0-1]
4263 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4264 # same parameters, else (default) - create a new one
4265 # @ingroup l3_hypos_1dhyps
4266 def AutomaticLength(self, fineness=0, UseExisting=0):
4267 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4268 CompareMethod=self.CompareAutomaticLength)
4269 hyp.SetFineness( fineness )
4272 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4273 def CompareAutomaticLength(self, hyp, args):
4274 return IsEqual(hyp.GetFineness(), args[0])
4276 ## Defines "SegmentLengthAroundVertex" hypothesis
4277 # @param length for the segment length
4278 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4279 # Any other integer value means that the hypothesis will be set on the
4280 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4281 # @param UseExisting if ==true - searches for an existing hypothesis created with
4282 # the same parameters, else (default) - creates a new one
4283 # @ingroup l3_algos_segmarv
4284 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4286 store_geom = self.geom
4287 if type(vertex) is types.IntType:
4288 if vertex == 0 or vertex == 1:
4289 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
4297 if self.geom is None:
4298 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4300 name = GetName(self.geom)
4303 piece = self.mesh.geom
4304 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
4305 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
4307 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4309 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4311 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4312 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4314 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4315 CompareMethod=self.CompareLengthNearVertex)
4316 self.geom = store_geom
4317 hyp.SetLength( length )
4320 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4321 # @ingroup l3_algos_segmarv
4322 def CompareLengthNearVertex(self, hyp, args):
4323 return IsEqual(hyp.GetLength(), args[0])
4325 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4326 # If the 2D mesher sees that all boundary edges are quadratic,
4327 # it generates quadratic faces, else it generates linear faces using
4328 # medium nodes as if they are vertices.
4329 # The 3D mesher generates quadratic volumes only if all boundary faces
4330 # are quadratic, else it fails.
4332 # @ingroup l3_hypos_additi
4333 def QuadraticMesh(self):
4334 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4337 # Public class: Mesh_CompositeSegment
4338 # --------------------------
4340 ## Defines a segment 1D algorithm for discretization
4342 # @ingroup l3_algos_basic
4343 class Mesh_CompositeSegment(Mesh_Segment):
4345 ## Private constructor.
4346 def __init__(self, mesh, geom=0):
4347 self.Create(mesh, geom, "CompositeSegment_1D")
4350 # Public class: Mesh_Segment_Python
4351 # ---------------------------------
4353 ## Defines a segment 1D algorithm for discretization with python function
4355 # @ingroup l3_algos_basic
4356 class Mesh_Segment_Python(Mesh_Segment):
4358 ## Private constructor.
4359 def __init__(self, mesh, geom=0):
4360 import Python1dPlugin
4361 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4363 ## Defines "PythonSplit1D" hypothesis
4364 # @param n for the number of segments that cut an edge
4365 # @param func for the python function that calculates the length of all segments
4366 # @param UseExisting if ==true - searches for the existing hypothesis created with
4367 # the same parameters, else (default) - creates a new one
4368 # @ingroup l3_hypos_1dhyps
4369 def PythonSplit1D(self, n, func, UseExisting=0):
4370 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4371 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4372 hyp.SetNumberOfSegments(n)
4373 hyp.SetPythonLog10RatioFunction(func)
4376 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4377 def ComparePythonSplit1D(self, hyp, args):
4378 #if hyp.GetNumberOfSegments() == args[0]:
4379 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4383 # Public class: Mesh_Triangle
4384 # ---------------------------
4386 ## Defines a triangle 2D algorithm
4388 # @ingroup l3_algos_basic
4389 class Mesh_Triangle(Mesh_Algorithm):
4398 ## Private constructor.
4399 def __init__(self, mesh, algoType, geom=0):
4400 Mesh_Algorithm.__init__(self)
4402 self.algoType = algoType
4403 if algoType == MEFISTO:
4404 self.Create(mesh, geom, "MEFISTO_2D")
4406 elif algoType == BLSURF:
4408 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4409 #self.SetPhysicalMesh() - PAL19680
4410 elif algoType == NETGEN:
4412 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4414 elif algoType == NETGEN_2D:
4416 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4419 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4420 # @param area for the maximum area of each triangle
4421 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4422 # same parameters, else (default) - creates a new one
4424 # Only for algoType == MEFISTO || NETGEN_2D
4425 # @ingroup l3_hypos_2dhyps
4426 def MaxElementArea(self, area, UseExisting=0):
4427 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4428 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4429 CompareMethod=self.CompareMaxElementArea)
4430 elif self.algoType == NETGEN:
4431 hyp = self.Parameters(SIMPLE)
4432 hyp.SetMaxElementArea(area)
4435 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4436 def CompareMaxElementArea(self, hyp, args):
4437 return IsEqual(hyp.GetMaxElementArea(), args[0])
4439 ## Defines "LengthFromEdges" hypothesis to build triangles
4440 # based on the length of the edges taken from the wire
4442 # Only for algoType == MEFISTO || NETGEN_2D
4443 # @ingroup l3_hypos_2dhyps
4444 def LengthFromEdges(self):
4445 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4446 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4448 elif self.algoType == NETGEN:
4449 hyp = self.Parameters(SIMPLE)
4450 hyp.LengthFromEdges()
4453 ## Sets a way to define size of mesh elements to generate.
4454 # @param thePhysicalMesh is: DefaultSize or Custom.
4455 # @ingroup l3_hypos_blsurf
4456 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4457 # Parameter of BLSURF algo
4458 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4460 ## Sets size of mesh elements to generate.
4461 # @ingroup l3_hypos_blsurf
4462 def SetPhySize(self, theVal):
4463 # Parameter of BLSURF algo
4464 self.SetPhysicalMesh(1) #Custom - else why to set the size?
4465 self.Parameters().SetPhySize(theVal)
4467 ## Sets lower boundary of mesh element size (PhySize).
4468 # @ingroup l3_hypos_blsurf
4469 def SetPhyMin(self, theVal=-1):
4470 # Parameter of BLSURF algo
4471 self.Parameters().SetPhyMin(theVal)
4473 ## Sets upper boundary of mesh element size (PhySize).
4474 # @ingroup l3_hypos_blsurf
4475 def SetPhyMax(self, theVal=-1):
4476 # Parameter of BLSURF algo
4477 self.Parameters().SetPhyMax(theVal)
4479 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4480 # @param theGeometricMesh is: 0 (None) or 1 (Custom)
4481 # @ingroup l3_hypos_blsurf
4482 def SetGeometricMesh(self, theGeometricMesh=0):
4483 # Parameter of BLSURF algo
4484 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4485 self.params.SetGeometricMesh(theGeometricMesh)
4487 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4488 # @ingroup l3_hypos_blsurf
4489 def SetAngleMeshS(self, theVal=_angleMeshS):
4490 # Parameter of BLSURF algo
4491 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4492 self.params.SetAngleMeshS(theVal)
4494 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4495 # @ingroup l3_hypos_blsurf
4496 def SetAngleMeshC(self, theVal=_angleMeshS):
4497 # Parameter of BLSURF algo
4498 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4499 self.params.SetAngleMeshC(theVal)
4501 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4502 # @ingroup l3_hypos_blsurf
4503 def SetGeoMin(self, theVal=-1):
4504 # Parameter of BLSURF algo
4505 self.Parameters().SetGeoMin(theVal)
4507 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4508 # @ingroup l3_hypos_blsurf
4509 def SetGeoMax(self, theVal=-1):
4510 # Parameter of BLSURF algo
4511 self.Parameters().SetGeoMax(theVal)
4513 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4514 # @ingroup l3_hypos_blsurf
4515 def SetGradation(self, theVal=_gradation):
4516 # Parameter of BLSURF algo
4517 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4518 self.params.SetGradation(theVal)
4520 ## Sets topology usage way.
4521 # @param way defines how mesh conformity is assured <ul>
4522 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4523 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4524 # @ingroup l3_hypos_blsurf
4525 def SetTopology(self, way):
4526 # Parameter of BLSURF algo
4527 self.Parameters().SetTopology(way)
4529 ## To respect geometrical edges or not.
4530 # @ingroup l3_hypos_blsurf
4531 def SetDecimesh(self, toIgnoreEdges=False):
4532 # Parameter of BLSURF algo
4533 self.Parameters().SetDecimesh(toIgnoreEdges)
4535 ## Sets verbosity level in the range 0 to 100.
4536 # @ingroup l3_hypos_blsurf
4537 def SetVerbosity(self, level):
4538 # Parameter of BLSURF algo
4539 self.Parameters().SetVerbosity(level)
4541 ## Sets advanced option value.
4542 # @ingroup l3_hypos_blsurf
4543 def SetOptionValue(self, optionName, level):
4544 # Parameter of BLSURF algo
4545 self.Parameters().SetOptionValue(optionName,level)
4547 ## Sets QuadAllowed flag.
4548 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
4549 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4550 def SetQuadAllowed(self, toAllow=True):
4551 if self.algoType == NETGEN_2D:
4552 if toAllow: # add QuadranglePreference
4553 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4554 else: # remove QuadranglePreference
4555 for hyp in self.mesh.GetHypothesisList( self.geom ):
4556 if hyp.GetName() == "QuadranglePreference":
4557 self.mesh.RemoveHypothesis( self.geom, hyp )
4562 if self.Parameters():
4563 self.params.SetQuadAllowed(toAllow)
4566 ## Defines hypothesis having several parameters
4568 # @ingroup l3_hypos_netgen
4569 def Parameters(self, which=SOLE):
4572 if self.algoType == NETGEN:
4574 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4575 "libNETGENEngine.so", UseExisting=0)
4577 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4578 "libNETGENEngine.so", UseExisting=0)
4580 elif self.algoType == MEFISTO:
4581 print "Mefisto algo support no multi-parameter hypothesis"
4583 elif self.algoType == NETGEN_2D:
4584 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4585 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4587 elif self.algoType == BLSURF:
4588 self.params = self.Hypothesis("BLSURF_Parameters", [],
4589 "libBLSURFEngine.so", UseExisting=0)
4592 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4597 # Only for algoType == NETGEN
4598 # @ingroup l3_hypos_netgen
4599 def SetMaxSize(self, theSize):
4600 if self.Parameters():
4601 self.params.SetMaxSize(theSize)
4603 ## Sets SecondOrder flag
4605 # Only for algoType == NETGEN
4606 # @ingroup l3_hypos_netgen
4607 def SetSecondOrder(self, theVal):
4608 if self.Parameters():
4609 self.params.SetSecondOrder(theVal)
4611 ## Sets Optimize flag
4613 # Only for algoType == NETGEN
4614 # @ingroup l3_hypos_netgen
4615 def SetOptimize(self, theVal):
4616 if self.Parameters():
4617 self.params.SetOptimize(theVal)
4620 # @param theFineness is:
4621 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4623 # Only for algoType == NETGEN
4624 # @ingroup l3_hypos_netgen
4625 def SetFineness(self, theFineness):
4626 if self.Parameters():
4627 self.params.SetFineness(theFineness)
4631 # Only for algoType == NETGEN
4632 # @ingroup l3_hypos_netgen
4633 def SetGrowthRate(self, theRate):
4634 if self.Parameters():
4635 self.params.SetGrowthRate(theRate)
4637 ## Sets NbSegPerEdge
4639 # Only for algoType == NETGEN
4640 # @ingroup l3_hypos_netgen
4641 def SetNbSegPerEdge(self, theVal):
4642 if self.Parameters():
4643 self.params.SetNbSegPerEdge(theVal)
4645 ## Sets NbSegPerRadius
4647 # Only for algoType == NETGEN
4648 # @ingroup l3_hypos_netgen
4649 def SetNbSegPerRadius(self, theVal):
4650 if self.Parameters():
4651 self.params.SetNbSegPerRadius(theVal)
4653 ## Sets number of segments overriding value set by SetLocalLength()
4655 # Only for algoType == NETGEN
4656 # @ingroup l3_hypos_netgen
4657 def SetNumberOfSegments(self, theVal):
4658 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4660 ## Sets number of segments overriding value set by SetNumberOfSegments()
4662 # Only for algoType == NETGEN
4663 # @ingroup l3_hypos_netgen
4664 def SetLocalLength(self, theVal):
4665 self.Parameters(SIMPLE).SetLocalLength(theVal)
4670 # Public class: Mesh_Quadrangle
4671 # -----------------------------
4673 ## Defines a quadrangle 2D algorithm
4675 # @ingroup l3_algos_basic
4676 class Mesh_Quadrangle(Mesh_Algorithm):
4678 ## Private constructor.
4679 def __init__(self, mesh, geom=0):
4680 Mesh_Algorithm.__init__(self)
4681 self.Create(mesh, geom, "Quadrangle_2D")
4683 ## Defines "QuadranglePreference" hypothesis, forcing construction
4684 # of quadrangles if the number of nodes on the opposite edges is not the same
4685 # while the total number of nodes on edges is even
4687 # @ingroup l3_hypos_additi
4688 def QuadranglePreference(self):
4689 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4690 CompareMethod=self.CompareEqualHyp)
4693 ## Defines "TrianglePreference" hypothesis, forcing construction
4694 # of triangles in the refinement area if the number of nodes
4695 # on the opposite edges is not the same
4697 # @ingroup l3_hypos_additi
4698 def TrianglePreference(self):
4699 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4700 CompareMethod=self.CompareEqualHyp)
4703 ## Defines "QuadrangleParams" hypothesis
4704 # @param vertex: vertex of a trilateral geometrical face, around which triangles
4705 # will be created while other elements will be quadrangles.
4706 # Vertex can be either a GEOM_Object or a vertex ID within the
4708 # @param UseExisting: if ==true - searches for the existing hypothesis created with
4709 # the same parameters, else (default) - creates a new one
4711 # @ingroup l3_hypos_additi
4712 def TriangleVertex(self, vertex, UseExisting=0):
4714 if isinstance( vertexID, geompyDC.GEOM._objref_GEOM_Object ):
4715 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, vertex )
4716 hyp = self.Hypothesis("QuadrangleParams", [vertexID], UseExisting = UseExisting,
4717 CompareMethod=lambda hyp,args: hyp.GetTriaVertex()==args[0])
4718 hyp.SetTriaVertex( vertexID )
4722 # Public class: Mesh_Tetrahedron
4723 # ------------------------------
4725 ## Defines a tetrahedron 3D algorithm
4727 # @ingroup l3_algos_basic
4728 class Mesh_Tetrahedron(Mesh_Algorithm):
4733 ## Private constructor.
4734 def __init__(self, mesh, algoType, geom=0):
4735 Mesh_Algorithm.__init__(self)
4737 if algoType == NETGEN:
4739 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4742 elif algoType == FULL_NETGEN:
4744 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4747 elif algoType == GHS3D:
4749 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4752 elif algoType == GHS3DPRL:
4753 CheckPlugin(GHS3DPRL)
4754 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4757 self.algoType = algoType
4759 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4760 # @param vol for the maximum volume of each tetrahedron
4761 # @param UseExisting if ==true - searches for the existing hypothesis created with
4762 # the same parameters, else (default) - creates a new one
4763 # @ingroup l3_hypos_maxvol
4764 def MaxElementVolume(self, vol, UseExisting=0):
4765 if self.algoType == NETGEN:
4766 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4767 CompareMethod=self.CompareMaxElementVolume)
4768 hyp.SetMaxElementVolume(vol)
4770 elif self.algoType == FULL_NETGEN:
4771 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4774 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4775 def CompareMaxElementVolume(self, hyp, args):
4776 return IsEqual(hyp.GetMaxElementVolume(), args[0])
4778 ## Defines hypothesis having several parameters
4780 # @ingroup l3_hypos_netgen
4781 def Parameters(self, which=SOLE):
4785 if self.algoType == FULL_NETGEN:
4787 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4788 "libNETGENEngine.so", UseExisting=0)
4790 self.params = self.Hypothesis("NETGEN_Parameters", [],
4791 "libNETGENEngine.so", UseExisting=0)
4794 if self.algoType == GHS3D:
4795 self.params = self.Hypothesis("GHS3D_Parameters", [],
4796 "libGHS3DEngine.so", UseExisting=0)
4799 if self.algoType == GHS3DPRL:
4800 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4801 "libGHS3DPRLEngine.so", UseExisting=0)
4804 print "Algo supports no multi-parameter hypothesis"
4808 # Parameter of FULL_NETGEN
4809 # @ingroup l3_hypos_netgen
4810 def SetMaxSize(self, theSize):
4811 self.Parameters().SetMaxSize(theSize)
4813 ## Sets SecondOrder flag
4814 # Parameter of FULL_NETGEN
4815 # @ingroup l3_hypos_netgen
4816 def SetSecondOrder(self, theVal):
4817 self.Parameters().SetSecondOrder(theVal)
4819 ## Sets Optimize flag
4820 # Parameter of FULL_NETGEN
4821 # @ingroup l3_hypos_netgen
4822 def SetOptimize(self, theVal):
4823 self.Parameters().SetOptimize(theVal)
4826 # @param theFineness is:
4827 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4828 # Parameter of FULL_NETGEN
4829 # @ingroup l3_hypos_netgen
4830 def SetFineness(self, theFineness):
4831 self.Parameters().SetFineness(theFineness)
4834 # Parameter of FULL_NETGEN
4835 # @ingroup l3_hypos_netgen
4836 def SetGrowthRate(self, theRate):
4837 self.Parameters().SetGrowthRate(theRate)
4839 ## Sets NbSegPerEdge
4840 # Parameter of FULL_NETGEN
4841 # @ingroup l3_hypos_netgen
4842 def SetNbSegPerEdge(self, theVal):
4843 self.Parameters().SetNbSegPerEdge(theVal)
4845 ## Sets NbSegPerRadius
4846 # Parameter of FULL_NETGEN
4847 # @ingroup l3_hypos_netgen
4848 def SetNbSegPerRadius(self, theVal):
4849 self.Parameters().SetNbSegPerRadius(theVal)
4851 ## Sets number of segments overriding value set by SetLocalLength()
4852 # Only for algoType == NETGEN_FULL
4853 # @ingroup l3_hypos_netgen
4854 def SetNumberOfSegments(self, theVal):
4855 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4857 ## Sets number of segments overriding value set by SetNumberOfSegments()
4858 # Only for algoType == NETGEN_FULL
4859 # @ingroup l3_hypos_netgen
4860 def SetLocalLength(self, theVal):
4861 self.Parameters(SIMPLE).SetLocalLength(theVal)
4863 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4864 # Overrides value set by LengthFromEdges()
4865 # Only for algoType == NETGEN_FULL
4866 # @ingroup l3_hypos_netgen
4867 def MaxElementArea(self, area):
4868 self.Parameters(SIMPLE).SetMaxElementArea(area)
4870 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4871 # Overrides value set by MaxElementArea()
4872 # Only for algoType == NETGEN_FULL
4873 # @ingroup l3_hypos_netgen
4874 def LengthFromEdges(self):
4875 self.Parameters(SIMPLE).LengthFromEdges()
4877 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4878 # Overrides value set by MaxElementVolume()
4879 # Only for algoType == NETGEN_FULL
4880 # @ingroup l3_hypos_netgen
4881 def LengthFromFaces(self):
4882 self.Parameters(SIMPLE).LengthFromFaces()
4884 ## To mesh "holes" in a solid or not. Default is to mesh.
4885 # @ingroup l3_hypos_ghs3dh
4886 def SetToMeshHoles(self, toMesh):
4887 # Parameter of GHS3D
4888 self.Parameters().SetToMeshHoles(toMesh)
4890 ## Set Optimization level:
4891 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
4892 # Strong_Optimization.
4893 # Default is Standard_Optimization
4894 # @ingroup l3_hypos_ghs3dh
4895 def SetOptimizationLevel(self, level):
4896 # Parameter of GHS3D
4897 self.Parameters().SetOptimizationLevel(level)
4899 ## Maximal size of memory to be used by the algorithm (in Megabytes).
4900 # @ingroup l3_hypos_ghs3dh
4901 def SetMaximumMemory(self, MB):
4902 # Advanced parameter of GHS3D
4903 self.Parameters().SetMaximumMemory(MB)
4905 ## Initial size of memory to be used by the algorithm (in Megabytes) in
4906 # automatic memory adjustment mode.
4907 # @ingroup l3_hypos_ghs3dh
4908 def SetInitialMemory(self, MB):
4909 # Advanced parameter of GHS3D
4910 self.Parameters().SetInitialMemory(MB)
4912 ## Path to working directory.
4913 # @ingroup l3_hypos_ghs3dh
4914 def SetWorkingDirectory(self, path):
4915 # Advanced parameter of GHS3D
4916 self.Parameters().SetWorkingDirectory(path)
4918 ## To keep working files or remove them. Log file remains in case of errors anyway.
4919 # @ingroup l3_hypos_ghs3dh
4920 def SetKeepFiles(self, toKeep):
4921 # Advanced parameter of GHS3D and GHS3DPRL
4922 self.Parameters().SetKeepFiles(toKeep)
4924 ## To set verbose level [0-10]. <ul>
4925 #<li> 0 - no standard output,
4926 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4927 # indicates when the final mesh is being saved. In addition the software
4928 # gives indication regarding the CPU time.
4929 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4930 # histogram of the skin mesh, quality statistics histogram together with
4931 # the characteristics of the final mesh.</ul>
4932 # @ingroup l3_hypos_ghs3dh
4933 def SetVerboseLevel(self, level):
4934 # Advanced parameter of GHS3D
4935 self.Parameters().SetVerboseLevel(level)
4937 ## To create new nodes.
4938 # @ingroup l3_hypos_ghs3dh
4939 def SetToCreateNewNodes(self, toCreate):
4940 # Advanced parameter of GHS3D
4941 self.Parameters().SetToCreateNewNodes(toCreate)
4943 ## To use boundary recovery version which tries to create mesh on a very poor
4944 # quality surface mesh.
4945 # @ingroup l3_hypos_ghs3dh
4946 def SetToUseBoundaryRecoveryVersion(self, toUse):
4947 # Advanced parameter of GHS3D
4948 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4950 ## Sets command line option as text.
4951 # @ingroup l3_hypos_ghs3dh
4952 def SetTextOption(self, option):
4953 # Advanced parameter of GHS3D
4954 self.Parameters().SetTextOption(option)
4956 ## Sets MED files name and path.
4957 def SetMEDName(self, value):
4958 self.Parameters().SetMEDName(value)
4960 ## Sets the number of partition of the initial mesh
4961 def SetNbPart(self, value):
4962 self.Parameters().SetNbPart(value)
4964 ## When big mesh, start tepal in background
4965 def SetBackground(self, value):
4966 self.Parameters().SetBackground(value)
4968 # Public class: Mesh_Hexahedron
4969 # ------------------------------
4971 ## Defines a hexahedron 3D algorithm
4973 # @ingroup l3_algos_basic
4974 class Mesh_Hexahedron(Mesh_Algorithm):
4979 ## Private constructor.
4980 def __init__(self, mesh, algoType=Hexa, geom=0):
4981 Mesh_Algorithm.__init__(self)
4983 self.algoType = algoType
4985 if algoType == Hexa:
4986 self.Create(mesh, geom, "Hexa_3D")
4989 elif algoType == Hexotic:
4990 CheckPlugin(Hexotic)
4991 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
4994 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
4995 # @ingroup l3_hypos_hexotic
4996 def MinMaxQuad(self, min=3, max=8, quad=True):
4997 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
4999 self.params.SetHexesMinLevel(min)
5000 self.params.SetHexesMaxLevel(max)
5001 self.params.SetHexoticQuadrangles(quad)
5004 # Deprecated, only for compatibility!
5005 # Public class: Mesh_Netgen
5006 # ------------------------------
5008 ## Defines a NETGEN-based 2D or 3D algorithm
5009 # that needs no discrete boundary (i.e. independent)
5011 # This class is deprecated, only for compatibility!
5014 # @ingroup l3_algos_basic
5015 class Mesh_Netgen(Mesh_Algorithm):
5019 ## Private constructor.
5020 def __init__(self, mesh, is3D, geom=0):
5021 Mesh_Algorithm.__init__(self)
5027 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5031 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
5034 ## Defines the hypothesis containing parameters of the algorithm
5035 def Parameters(self):
5037 hyp = self.Hypothesis("NETGEN_Parameters", [],
5038 "libNETGENEngine.so", UseExisting=0)
5040 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
5041 "libNETGENEngine.so", UseExisting=0)
5044 # Public class: Mesh_Projection1D
5045 # ------------------------------
5047 ## Defines a projection 1D algorithm
5048 # @ingroup l3_algos_proj
5050 class Mesh_Projection1D(Mesh_Algorithm):
5052 ## Private constructor.
5053 def __init__(self, mesh, geom=0):
5054 Mesh_Algorithm.__init__(self)
5055 self.Create(mesh, geom, "Projection_1D")
5057 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
5058 # a mesh pattern is taken, and, optionally, the association of vertices
5059 # between the source edge and a target edge (to which a hypothesis is assigned)
5060 # @param edge from which nodes distribution is taken
5061 # @param mesh from which nodes distribution is taken (optional)
5062 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
5063 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
5064 # to associate with \a srcV (optional)
5065 # @param UseExisting if ==true - searches for the existing hypothesis created with
5066 # the same parameters, else (default) - creates a new one
5067 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
5068 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
5070 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
5071 hyp.SetSourceEdge( edge )
5072 if not mesh is None and isinstance(mesh, Mesh):
5073 mesh = mesh.GetMesh()
5074 hyp.SetSourceMesh( mesh )
5075 hyp.SetVertexAssociation( srcV, tgtV )
5078 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
5079 #def CompareSourceEdge(self, hyp, args):
5080 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
5084 # Public class: Mesh_Projection2D
5085 # ------------------------------
5087 ## Defines a projection 2D algorithm
5088 # @ingroup l3_algos_proj
5090 class Mesh_Projection2D(Mesh_Algorithm):
5092 ## Private constructor.
5093 def __init__(self, mesh, geom=0):
5094 Mesh_Algorithm.__init__(self)
5095 self.Create(mesh, geom, "Projection_2D")
5097 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
5098 # a mesh pattern is taken, and, optionally, the association of vertices
5099 # between the source face and the target face (to which a hypothesis is assigned)
5100 # @param face from which the mesh pattern is taken
5101 # @param mesh from which the mesh pattern is taken (optional)
5102 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
5103 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
5104 # to associate with \a srcV1 (optional)
5105 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
5106 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
5107 # to associate with \a srcV2 (optional)
5108 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
5109 # the same parameters, else (default) - forces the creation a new one
5111 # Note: all association vertices must belong to one edge of a face
5112 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
5113 srcV2=None, tgtV2=None, UseExisting=0):
5114 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
5116 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
5117 hyp.SetSourceFace( face )
5118 if not mesh is None and isinstance(mesh, Mesh):
5119 mesh = mesh.GetMesh()
5120 hyp.SetSourceMesh( mesh )
5121 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5124 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
5125 #def CompareSourceFace(self, hyp, args):
5126 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
5129 # Public class: Mesh_Projection3D
5130 # ------------------------------
5132 ## Defines a projection 3D algorithm
5133 # @ingroup l3_algos_proj
5135 class Mesh_Projection3D(Mesh_Algorithm):
5137 ## Private constructor.
5138 def __init__(self, mesh, geom=0):
5139 Mesh_Algorithm.__init__(self)
5140 self.Create(mesh, geom, "Projection_3D")
5142 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
5143 # the mesh pattern is taken, and, optionally, the association of vertices
5144 # between the source and the target solid (to which a hipothesis is assigned)
5145 # @param solid from where the mesh pattern is taken
5146 # @param mesh from where the mesh pattern is taken (optional)
5147 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
5148 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
5149 # to associate with \a srcV1 (optional)
5150 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
5151 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
5152 # to associate with \a srcV2 (optional)
5153 # @param UseExisting - if ==true - searches for the existing hypothesis created with
5154 # the same parameters, else (default) - creates a new one
5156 # Note: association vertices must belong to one edge of a solid
5157 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
5158 srcV2=0, tgtV2=0, UseExisting=0):
5159 hyp = self.Hypothesis("ProjectionSource3D",
5160 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
5162 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
5163 hyp.SetSource3DShape( solid )
5164 if not mesh is None and isinstance(mesh, Mesh):
5165 mesh = mesh.GetMesh()
5166 hyp.SetSourceMesh( mesh )
5167 if srcV1 and srcV2 and tgtV1 and tgtV2:
5168 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5169 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
5172 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
5173 #def CompareSourceShape3D(self, hyp, args):
5174 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
5178 # Public class: Mesh_Prism
5179 # ------------------------
5181 ## Defines a 3D extrusion algorithm
5182 # @ingroup l3_algos_3dextr
5184 class Mesh_Prism3D(Mesh_Algorithm):
5186 ## Private constructor.
5187 def __init__(self, mesh, geom=0):
5188 Mesh_Algorithm.__init__(self)
5189 self.Create(mesh, geom, "Prism_3D")
5191 # Public class: Mesh_RadialPrism
5192 # -------------------------------
5194 ## Defines a Radial Prism 3D algorithm
5195 # @ingroup l3_algos_radialp
5197 class Mesh_RadialPrism3D(Mesh_Algorithm):
5199 ## Private constructor.
5200 def __init__(self, mesh, geom=0):
5201 Mesh_Algorithm.__init__(self)
5202 self.Create(mesh, geom, "RadialPrism_3D")
5204 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
5205 self.nbLayers = None
5207 ## Return 3D hypothesis holding the 1D one
5208 def Get3DHypothesis(self):
5209 return self.distribHyp
5211 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5212 # hypothesis. Returns the created hypothesis
5213 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5214 #print "OwnHypothesis",hypType
5215 if not self.nbLayers is None:
5216 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5217 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5218 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5219 self.mesh.smeshpyD.SetCurrentStudy( None )
5220 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5221 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5222 self.distribHyp.SetLayerDistribution( hyp )
5225 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
5226 # prisms to build between the inner and outer shells
5227 # @param n number of layers
5228 # @param UseExisting if ==true - searches for the existing hypothesis created with
5229 # the same parameters, else (default) - creates a new one
5230 def NumberOfLayers(self, n, UseExisting=0):
5231 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5232 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
5233 CompareMethod=self.CompareNumberOfLayers)
5234 self.nbLayers.SetNumberOfLayers( n )
5235 return self.nbLayers
5237 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5238 def CompareNumberOfLayers(self, hyp, args):
5239 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5241 ## Defines "LocalLength" hypothesis, specifying the segment length
5242 # to build between the inner and the outer shells
5243 # @param l the length of segments
5244 # @param p the precision of rounding
5245 def LocalLength(self, l, p=1e-07):
5246 hyp = self.OwnHypothesis("LocalLength", [l,p])
5251 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
5252 # prisms to build between the inner and the outer shells.
5253 # @param n the number of layers
5254 # @param s the scale factor (optional)
5255 def NumberOfSegments(self, n, s=[]):
5257 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5259 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5260 hyp.SetDistrType( 1 )
5261 hyp.SetScaleFactor(s)
5262 hyp.SetNumberOfSegments(n)
5265 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5266 # to build between the inner and the outer shells with a length that changes in arithmetic progression
5267 # @param start the length of the first segment
5268 # @param end the length of the last segment
5269 def Arithmetic1D(self, start, end ):
5270 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5271 hyp.SetLength(start, 1)
5272 hyp.SetLength(end , 0)
5275 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5276 # to build between the inner and the outer shells as geometric length increasing
5277 # @param start for the length of the first segment
5278 # @param end for the length of the last segment
5279 def StartEndLength(self, start, end):
5280 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5281 hyp.SetLength(start, 1)
5282 hyp.SetLength(end , 0)
5285 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5286 # to build between the inner and outer shells
5287 # @param fineness defines the quality of the mesh within the range [0-1]
5288 def AutomaticLength(self, fineness=0):
5289 hyp = self.OwnHypothesis("AutomaticLength")
5290 hyp.SetFineness( fineness )
5293 # Public class: Mesh_RadialQuadrangle1D2D
5294 # -------------------------------
5296 ## Defines a Radial Quadrangle 1D2D algorithm
5297 # @ingroup l2_algos_radialq
5299 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
5301 ## Private constructor.
5302 def __init__(self, mesh, geom=0):
5303 Mesh_Algorithm.__init__(self)
5304 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5306 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
5307 self.nbLayers = None
5309 ## Return 2D hypothesis holding the 1D one
5310 def Get2DHypothesis(self):
5311 return self.distribHyp
5313 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5314 # hypothesis. Returns the created hypothesis
5315 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5316 #print "OwnHypothesis",hypType
5318 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5319 if self.distribHyp is None:
5320 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5322 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5323 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5324 self.mesh.smeshpyD.SetCurrentStudy( None )
5325 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5326 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5327 self.distribHyp.SetLayerDistribution( hyp )
5330 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
5331 # @param n number of layers
5332 # @param UseExisting if ==true - searches for the existing hypothesis created with
5333 # the same parameters, else (default) - creates a new one
5334 def NumberOfLayers(self, n, UseExisting=0):
5336 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5337 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5338 CompareMethod=self.CompareNumberOfLayers)
5339 self.nbLayers.SetNumberOfLayers( n )
5340 return self.nbLayers
5342 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5343 def CompareNumberOfLayers(self, hyp, args):
5344 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5346 ## Defines "LocalLength" hypothesis, specifying the segment length
5347 # @param l the length of segments
5348 # @param p the precision of rounding
5349 def LocalLength(self, l, p=1e-07):
5350 hyp = self.OwnHypothesis("LocalLength", [l,p])
5355 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5356 # @param n the number of layers
5357 # @param s the scale factor (optional)
5358 def NumberOfSegments(self, n, s=[]):
5360 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5362 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5363 hyp.SetDistrType( 1 )
5364 hyp.SetScaleFactor(s)
5365 hyp.SetNumberOfSegments(n)
5368 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5369 # with a length that changes in arithmetic progression
5370 # @param start the length of the first segment
5371 # @param end the length of the last segment
5372 def Arithmetic1D(self, start, end ):
5373 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5374 hyp.SetLength(start, 1)
5375 hyp.SetLength(end , 0)
5378 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5379 # as geometric length increasing
5380 # @param start for the length of the first segment
5381 # @param end for the length of the last segment
5382 def StartEndLength(self, start, end):
5383 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5384 hyp.SetLength(start, 1)
5385 hyp.SetLength(end , 0)
5388 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5389 # @param fineness defines the quality of the mesh within the range [0-1]
5390 def AutomaticLength(self, fineness=0):
5391 hyp = self.OwnHypothesis("AutomaticLength")
5392 hyp.SetFineness( fineness )
5396 # Private class: Mesh_UseExisting
5397 # -------------------------------
5398 class Mesh_UseExisting(Mesh_Algorithm):
5400 def __init__(self, dim, mesh, geom=0):
5402 self.Create(mesh, geom, "UseExisting_1D")
5404 self.Create(mesh, geom, "UseExisting_2D")
5407 import salome_notebook
5408 notebook = salome_notebook.notebook
5410 ##Return values of the notebook variables
5411 def ParseParameters(last, nbParams,nbParam, value):
5415 listSize = len(last)
5416 for n in range(0,nbParams):
5418 if counter < listSize:
5419 strResult = strResult + last[counter]
5421 strResult = strResult + ""
5423 if isinstance(value, str):
5424 if notebook.isVariable(value):
5425 result = notebook.get(value)
5426 strResult=strResult+value
5428 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
5430 strResult=strResult+str(value)
5432 if nbParams - 1 != counter:
5433 strResult=strResult+var_separator #":"
5435 return result, strResult
5437 #Wrapper class for StdMeshers_LocalLength hypothesis
5438 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5440 ## Set Length parameter value
5441 # @param length numerical value or name of variable from notebook
5442 def SetLength(self, length):
5443 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
5444 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5445 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
5447 ## Set Precision parameter value
5448 # @param precision numerical value or name of variable from notebook
5449 def SetPrecision(self, precision):
5450 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
5451 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5452 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5454 #Registering the new proxy for LocalLength
5455 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5458 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5459 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5461 def SetLayerDistribution(self, hypo):
5462 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
5463 hypo.ClearParameters();
5464 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5466 #Registering the new proxy for LayerDistribution
5467 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5469 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5470 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5472 ## Set Length parameter value
5473 # @param length numerical value or name of variable from notebook
5474 def SetLength(self, length):
5475 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
5476 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
5477 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5479 #Registering the new proxy for SegmentLengthAroundVertex
5480 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5483 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5484 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5486 ## Set Length parameter value
5487 # @param length numerical value or name of variable from notebook
5488 # @param isStart true is length is Start Length, otherwise false
5489 def SetLength(self, length, isStart):
5493 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
5494 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
5495 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
5497 #Registering the new proxy for Arithmetic1D
5498 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
5500 #Wrapper class for StdMeshers_Deflection1D hypothesis
5501 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
5503 ## Set Deflection parameter value
5504 # @param deflection numerical value or name of variable from notebook
5505 def SetDeflection(self, deflection):
5506 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
5507 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
5508 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
5510 #Registering the new proxy for Deflection1D
5511 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
5513 #Wrapper class for StdMeshers_StartEndLength hypothesis
5514 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
5516 ## Set Length parameter value
5517 # @param length numerical value or name of variable from notebook
5518 # @param isStart true is length is Start Length, otherwise false
5519 def SetLength(self, length, isStart):
5523 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
5524 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
5525 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
5527 #Registering the new proxy for StartEndLength
5528 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
5530 #Wrapper class for StdMeshers_MaxElementArea hypothesis
5531 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
5533 ## Set Max Element Area parameter value
5534 # @param area numerical value or name of variable from notebook
5535 def SetMaxElementArea(self, area):
5536 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
5537 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
5538 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
5540 #Registering the new proxy for MaxElementArea
5541 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
5544 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
5545 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
5547 ## Set Max Element Volume parameter value
5548 # @param volume numerical value or name of variable from notebook
5549 def SetMaxElementVolume(self, volume):
5550 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
5551 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
5552 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
5554 #Registering the new proxy for MaxElementVolume
5555 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
5558 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
5559 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
5561 ## Set Number Of Layers parameter value
5562 # @param nbLayers numerical value or name of variable from notebook
5563 def SetNumberOfLayers(self, nbLayers):
5564 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
5565 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
5566 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
5568 #Registering the new proxy for NumberOfLayers
5569 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
5571 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
5572 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
5574 ## Set Number Of Segments parameter value
5575 # @param nbSeg numerical value or name of variable from notebook
5576 def SetNumberOfSegments(self, nbSeg):
5577 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
5578 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
5579 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5580 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
5582 ## Set Scale Factor parameter value
5583 # @param factor numerical value or name of variable from notebook
5584 def SetScaleFactor(self, factor):
5585 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
5586 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5587 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
5589 #Registering the new proxy for NumberOfSegments
5590 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
5592 if not noNETGENPlugin:
5593 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
5594 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
5596 ## Set Max Size parameter value
5597 # @param maxsize numerical value or name of variable from notebook
5598 def SetMaxSize(self, maxsize):
5599 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5600 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
5601 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5602 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
5604 ## Set Growth Rate parameter value
5605 # @param value numerical value or name of variable from notebook
5606 def SetGrowthRate(self, value):
5607 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5608 value, parameters = ParseParameters(lastParameters,4,2,value)
5609 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5610 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
5612 ## Set Number of Segments per Edge parameter value
5613 # @param value numerical value or name of variable from notebook
5614 def SetNbSegPerEdge(self, value):
5615 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5616 value, parameters = ParseParameters(lastParameters,4,3,value)
5617 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5618 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
5620 ## Set Number of Segments per Radius parameter value
5621 # @param value numerical value or name of variable from notebook
5622 def SetNbSegPerRadius(self, value):
5623 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5624 value, parameters = ParseParameters(lastParameters,4,4,value)
5625 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5626 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
5628 #Registering the new proxy for NETGENPlugin_Hypothesis
5629 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5632 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5633 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5636 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5637 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5639 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5640 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5642 ## Set Number of Segments parameter value
5643 # @param nbSeg numerical value or name of variable from notebook
5644 def SetNumberOfSegments(self, nbSeg):
5645 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5646 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5647 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5648 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5650 ## Set Local Length parameter value
5651 # @param length numerical value or name of variable from notebook
5652 def SetLocalLength(self, length):
5653 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5654 length, parameters = ParseParameters(lastParameters,2,1,length)
5655 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5656 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
5658 ## Set Max Element Area parameter value
5659 # @param area numerical value or name of variable from notebook
5660 def SetMaxElementArea(self, area):
5661 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5662 area, parameters = ParseParameters(lastParameters,2,2,area)
5663 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5664 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
5666 def LengthFromEdges(self):
5667 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5669 value, parameters = ParseParameters(lastParameters,2,2,value)
5670 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5671 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
5673 #Registering the new proxy for NETGEN_SimpleParameters_2D
5674 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
5677 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
5678 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
5679 ## Set Max Element Volume parameter value
5680 # @param volume numerical value or name of variable from notebook
5681 def SetMaxElementVolume(self, volume):
5682 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5683 volume, parameters = ParseParameters(lastParameters,3,3,volume)
5684 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5685 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5687 def LengthFromFaces(self):
5688 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5690 value, parameters = ParseParameters(lastParameters,3,3,value)
5691 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5692 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5694 #Registering the new proxy for NETGEN_SimpleParameters_3D
5695 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5697 pass # if not noNETGENPlugin:
5699 class Pattern(SMESH._objref_SMESH_Pattern):
5701 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5703 if isinstance(theNodeIndexOnKeyPoint1,str):
5705 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5707 theNodeIndexOnKeyPoint1 -= 1
5708 theMesh.SetParameters(Parameters)
5709 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5711 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5714 if isinstance(theNode000Index,str):
5716 if isinstance(theNode001Index,str):
5718 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5720 theNode000Index -= 1
5722 theNode001Index -= 1
5723 theMesh.SetParameters(Parameters)
5724 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5726 #Registering the new proxy for Pattern
5727 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)